]> git.sur5r.net Git - contagged/commitdiff
PHP5 compatibility and code cleanup
authorPaul Howarth <paul@city-fan.org>
Thu, 27 Apr 2006 11:17:04 +0000 (13:17 +0200)
committerPaul Howarth <paul@city-fan.org>
Thu, 27 Apr 2006 11:17:04 +0000 (13:17 +0200)
The first (quotefix) patch just quotes string constants when used as
indexes to arrays. This gets rid of many warning messages from PHP and
also fixes at least one case where one of the strings is a reserved word
("private") in PHP5.

The second (cleanup) patch probably needs more looking at as my lack of
understanding of PHP may mean that I've not done things properly.

1. It adds an alternative way of specifying the LDAP server, by URL
instead of hostname and port.

2. It casts the arguments of array_merge() to array types everywhere
(not sure if all of these are necessary).

3. It makes $_SESSION['ldapab']['username'] and
$_SESSION['ldapab']['binddn'] null strings if they are not set.

4. It removes the reference to the unused variable $dfexample

With these fixes, ConTagged seems to run OK on PHP 5

darcs-hash:20060427111704-df059-55357a0b7161d967d7119368d08eaa2576331acd.gz

14 files changed:
ajax.php
config.php
entry.php
functions.php
img.php
import.php
importVCF.php
index.php
init.php
lang/de.php
lang/en.php
login.php
tags.php
template.php

index fafe45a8a5fc39fa06931f350943dae5ee881fb7..564e59d36e1e427174b3c5ab94ebb9943781e104 100644 (file)
--- a/ajax.php
+++ b/ajax.php
@@ -41,7 +41,7 @@ function ajax_addnote($dn,$note){
 function ajax_settags($dn,$tags){
   global $conf;
   global $LDAP_CON;
-  if(!$conf[extended]) return;
+  if(!$conf['extended']) return;
 
   $tags = explode(',',$tags);
   $tags = array_map('trim',$tags);
@@ -67,7 +67,7 @@ function ajax_settags($dn,$tags){
 function ajax_taglookup($tag){
   global $conf;
   global $LDAP_CON;
-  if(!$conf[extended]) return;
+  if(!$conf['extended']) return;
 
   $search = ldap_filterescape($tag);
   $filter = "(&(objectClass=contactPerson)(marker=$search*))";
index 8de50798f2cc2dda7b7bf5e4dec04377d6e69f77..84cd10d465f97a3b1861e950d005d6c07fa9d356 100644 (file)
@@ -1,50 +1,53 @@
 <?
 
+  // LDAP URL; if set, takes precedence over ldapserver and ldapport
+  #$conf['ldapurl']     = 'ldaps://ldap.example.com/';
+
   // Which LDAP Server to use?
-  $conf[ldapserver]  = 'ldap';
+  $conf['ldapserver']  = 'ldap';
 
   // Which LDAP Port Server to use? (389 is standard, 636 for ssl)
-  $conf[ldapport]    = 389;
+  $conf['ldapport']    = 389;
 
   // What is the root dn on this Server?
-  $conf[ldaprootdn]  = 'o=cosmocode, c=de';
+  $conf['ldaprootdn']  = 'o=cosmocode, c=de';
 
   // Where are the user Accounts stored?
-  $conf[usertree]    = 'ou=people, '.$conf[ldaprootdn];
+  $conf['usertree']    = 'ou=people, '.$conf['ldaprootdn'];
 
   // How to match users? %u is replaced by the given login
-  $conf[userfilter]  = '(&(uid=%u)(objectClass=posixAccount))';
+  $conf['userfilter']  = '(&(uid=%u)(objectClass=posixAccount))';
 
   // Use these values to bind to the ldap directory when not logged in (leave blank for anonymous bind)
-  $conf[anonbinddn]  = '';
-  $conf[anonbindpw]  = '';
+  $conf['anonbinddn']  = '';
+  $conf['anonbindpw']  = '';
 
   // Which language to use (see lang directory)
-  $conf[lang]        = 'en';
+  $conf['lang']        = 'en';
 
   // Where to store public contacts?
-  $conf[publicbook]  = 'ou=contacts, '.$conf[ldaprootdn];
+  $conf['publicbook']  = 'ou=contacts, '.$conf['ldaprootdn'];
 
-  // Where to store private contacts (relative to $conf[usertree])
-  $conf[privatebook] = 'ou=contacts';
+  // Where to store private contacts (relative to $conf['usertree'])
+  $conf['privatebook'] = 'ou=contacts';
 
   // Should the additional schema ldapab.schema be used? (0|1)
   // Note: openxchange and extended are currently exclusive, do not use both at the same time!
-  $conf[extended]    = 1;
+  $conf['extended']    = 1;
   
   // Should we use some parts of the openxchange.schema? (0|1)
   // Note: openxchange and extended are currently exclusive, do not use both at the same time!
-  $conf[openxchange] = 0;
+  $conf['openxchange'] = 0;
  
   // Should we try to login using the username and password provided by httpd? (0|1)
-  $conf[httpd_auth]  = 0;
+  $conf['httpd_auth']  = 0;
  
   // Dateformat for birthdays when using extended schema
   // see http://www.php.net/manual/en/function.strftime.php
-  #$conf[dateformat]  = '%Y/%m/%d';
-  $conf[dateformat]  = '%d.%m.%Y';
+  #$conf['dateformat']  = '%Y/%m/%d';
+  $conf['dateformat']  = '%d.%m.%Y';
 
   // Force recompilation of smarty templates?
-  $conf[smartycompile] = 0;
+  $conf['smartycompile'] = 0;
 
 ?>
index 00fa82c616bae39f442986118aceb28b19d695ed..c081da428596df7191effc51549e4a48efda1264 100644 (file)
--- a/entry.php
+++ b/entry.php
@@ -5,20 +5,20 @@
   $users = get_users();
 
   //select template to use
-  if( $_SESSION[ldapab][username] &&
-     ($_REQUEST[mode]=='edit' || $_REQUEST[mode]=='copy')){
+  if( $_SESSION['ldapab']['username'] &&
+     ($_REQUEST['mode']=='edit' || $_REQUEST['mode']=='copy')){
     $template='entry_edit.tpl';
-  }elseif($_REQUEST[mode]=='vcf'){
+  }elseif($_REQUEST['mode']=='vcf'){
     $template='entry_vcf.tpl';
   }else{
     $template='entry_show.tpl';
   }
 
-  $dn = $_REQUEST[dn];
+  $dn = $_REQUEST['dn'];
   #$dn = 'cn=bar foo, ou=contacts, o=cosmocode, c=de';
 
   //save data if asked for
-  if($_SESSION[ldapab][username] && $_REQUEST[save]){
+  if($_SESSION['ldapab']['username'] && $_REQUEST['save']){
     // prepare special data
     $_REQUEST['entry']['jpegPhoto'][]=_getUploadData();
     $_REQUEST['entry']['marker'] = explode(',',$_REQUEST['entry']['markers']);
   }
 
   if(empty($dn)){
-    if(!$_REQUEST[mode]=='edit'){
+    if(!$_REQUEST['mode']=='edit'){
       $smarty->assign('error','No dn was given');
       $template = 'error.tpl';
     }
-  }elseif($_REQUEST[del]){
+  }elseif($_REQUEST['del']){
     _delEntry($dn);
   }elseif(!_fetchData($dn)){
     $smarty->assign('error',"The requested entry '$dn' was not found");
@@ -58,9 +58,9 @@
   tpl_timezone();
   tpl_country();
   //display templates
-  if($_REQUEST[mode]=='vcf'){
+  if($_REQUEST['mode']=='vcf'){
     $entry = $smarty->get_template_vars('entry');
-    $filename = $entry[givenname].'_'.$entry[name].'.vcf';
+    $filename = $entry['givenname'].'_'.$entry['name'].'.vcf';
     header("Content-Disposition: attachment; filename=\"$filename\"");
     header("Content-type: text/x-vcard; name=\"$filename\"; charset=utf-8");
     $smarty->display($template);
@@ -89,8 +89,8 @@
     $entry  = $result[0];
 
     //remove dn from entry when copy
-    if($_REQUEST[mode] == 'copy'){
-      $entry[dn]='';
+    if($_REQUEST['mode'] == 'copy'){
+      $entry['dn']='';
     }
 
     //assign entry to template:
@@ -101,12 +101,12 @@ print_r($entry);
 print '</pre>';*/
 
     // make username from dn for manager:
-    $smarty->assign('managername',$users[$entry[manager][0]]);
+    $smarty->assign('managername',$users[$entry['manager'][0]]);
     return true;
   }
 
   /**
-   * saves the data from $_REQUEST[entry] to the LDAP directory
+   * saves the data from $_REQUEST['entry'] to the LDAP directory
    *
    * returns given or constructed dn
    */
@@ -115,21 +115,21 @@ print '</pre>';*/
     global $conf;
     $entries = namedentries();
     $entries['mail']='mail';  //special field mail isn't in entries so we add it here
-    if($conf[extended]){
+    if($conf['extended']){
       $entries['marker']='marker'; //same for marker inextended schema
     }
 
-    $entry = $_REQUEST[entry];
-    $dn    = $_REQUEST[dn];
+    $entry = $_REQUEST['entry'];
+    $dn    = $_REQUEST['dn'];
     //construct new dn
     $now    = time();
     $newdn  = 'uid='.$now;
-    if($_REQUEST[type] == 'private'){
-      $newdn .= ', '.$conf[privatebook].', '.$_SESSION[ldapab][binddn];
+    if($_REQUEST['type'] == 'private'){
+      $newdn .= ', '.$conf['privatebook'].', '.$_SESSION['ldapab']['binddn'];
     }else{
-      $newdn .= ', '.$conf[publicbook];
+      $newdn .= ', '.$conf['publicbook'];
     }
-    $entry[cn]          = $entry[givenname].' '.$entry[name];;
+    $entry['cn']          = $entry['givenname'].' '.$entry['name'];;
     $entry = prepare_ldap_entry($entry);
 
 /*
@@ -140,17 +140,17 @@ print '</pre>';
 
     if(empty($dn)){
       //new entry
-      $entry[uid][] = $now;
+      $entry['uid'][] = $now;
       $r = ldap_add($LDAP_CON,$newdn,$entry);
       tpl_ldaperror();
       return $newdn;
     }else{
       // in extended mode we have to make sure the right classes are set
-      if($conf[extended]){
+      if($conf['extended']){
         ldap_store_objectclasses($dn,array('inetOrgPerson','contactPerson'));
       }
       // in openxchange mode we have to make sure the right classes are set
-      if ($conf[openxchange]){
+      if ($conf['openxchange']){
         ldap_store_objectclasses($dn,array('inetOrgPerson','OXUserObject'));
       }
       //modify entry (touches only our attributes)
@@ -191,14 +191,14 @@ print '</pre>';
    * gets the binary data from an uploaded file
    */
   function _getUploadData(){
-    $file = $_FILES[photoupload];
+    $file = $_FILES['photoupload'];
 
-    if (is_uploaded_file($file[tmp_name])) {
-      if(preg_match('=image/p?jpe?g=',$file[type])){
-        $fh = fopen($file[tmp_name],'r');
-        $data = fread($fh,$file[size]);
+    if (is_uploaded_file($file['tmp_name'])) {
+      if(preg_match('=image/p?jpe?g=',$file['type'])){
+        $fh = fopen($file['tmp_name'],'r');
+        $data = fread($fh,$file['size']);
         fclose($fh);
-        unlink($file[tmp_name]);
+        unlink($file['tmp_name']);
         return $data;
       }
     }
index 74170a07a7e9be99d149ec2a72b519cc03da6bf4..5250b844f558b1dd55f480a575c60a8c368d20af 100644 (file)
@@ -5,7 +5,7 @@
  */
 function smarty_std(){
   global $smarty;
-  $smarty->assign('USER',$_SESSION[ldapab][username]);
+  $smarty->assign('USER',$_SESSION['ldapab']['username']);
 }
 
 /**
@@ -49,9 +49,13 @@ function do_ldap_bind($user,$pass,$dn=""){
   global $conf;
   global $LDAP_CON;
   
-  //create global connection to LDAP if nessessary
+  //create global connection to LDAP if necessary
   if(!$LDAP_CON){
-    $LDAP_CON = ldap_connect($conf[ldapserver],$conf[ldapport]);
+    if (!empty($conf['ldapurl'])){
+      $LDAP_CON = ldap_connect($conf['ldapurl']);
+    }else{
+      $LDAP_CON = ldap_connect($conf['ldapserver'],$conf['ldapport']);
+    }
     if(!$LDAP_CON){
       die("couldn't connect to LDAP server");
     }
@@ -60,7 +64,7 @@ function do_ldap_bind($user,$pass,$dn=""){
   if(empty($dn)){
     //anonymous bind to lookup users
     //blank binddn or blank bindpw will result in anonymous bind
-    if(!ldap_bind($LDAP_CON,$conf[anonbinddn],$conf[anonbindpw])){
+    if(!ldap_bind($LDAP_CON,$conf['anonbinddn'],$conf['anonbindpw'])){
       die("can not bind for user lookup");
     }
   
@@ -71,8 +75,8 @@ function do_ldap_bind($user,$pass,$dn=""){
     }
 
     //get dn for given user
-    $filter = str_replace('%u',$user,$conf[userfilter]);
-    $sr = ldap_search($LDAP_CON, $conf[usertree], $filter);;
+    $filter = str_replace('%u',$user,$conf['userfilter']);
+    $sr = ldap_search($LDAP_CON, $conf['usertree'], $filter);;
     $result = ldap_get_entries($LDAP_CON, $sr);
     if($result['count'] != 1){
       set_session('','','');
@@ -121,10 +125,10 @@ function set_session($user,$pass,$dn){
   global $conf;
 
   $rand = rand();
-  $_SESSION[ldapab][username]  = $user;
-  $_SESSION[ldapab][binddn]    = $dn;
-  $_SESSION[ldapab][password]  = $pass;
-  $_SESSION[ldapab][browserid] = auth_browseruid();
+  $_SESSION['ldapab']['username']  = $user;
+  $_SESSION['ldapab']['binddn']    = $dn;
+  $_SESSION['ldapab']['password']  = $pass;
+  $_SESSION['ldapab']['browserid'] = auth_browseruid();
 
   // (re)set the persistant auth cookie
   if($user == ''){
@@ -192,40 +196,40 @@ function ldap_get_binentries($conn,$srchRslt){
 function namedentries($flip=false){
   global $conf;
 
-  $entries[dn]                         = 'dn';
-  $entries[sn]                         = 'name';
-  $entries[givenName]                  = 'givenname';
-  $entries[title]                      = 'title';
-  $entries[o]                          = 'organization';
-  $entries[physicalDeliveryOfficeName] = 'office';
-  $entries[postalAddress]              = 'street';
-  $entries[postalCode]                 = 'zip';
-  $entries[l]                          = 'location';
-  $entries[telephoneNumber]            = 'phone';
-  $entries[facsimileTelephoneNumber]   = 'fax';
-  $entries[mobile]                     = 'mobile';
-  $entries[pager]                      = 'pager';
-  $entries[homePhone]                  = 'homephone';
-  $entries[homePostalAddress]          = 'homestreet';
-  $entries[jpegPhoto]                  = 'photo';
-  $entries[labeledURI]                 = 'url';
-  $entries[description]                = 'note';
-  $entries[manager]                    = 'manager';
-  $entries[cn]                         = 'displayname';
-
-  if($conf[extended]){
-    $entries[anniversary]              = 'anniversary';
+  $entries['dn']                         = 'dn';
+  $entries['sn']                         = 'name';
+  $entries['givenName']                  = 'givenname';
+  $entries['title']                      = 'title';
+  $entries['o']                          = 'organization';
+  $entries['physicalDeliveryOfficeName'] = 'office';
+  $entries['postalAddress']              = 'street';
+  $entries['postalCode']                 = 'zip';
+  $entries['l']                          = 'location';
+  $entries['telephoneNumber']            = 'phone';
+  $entries['facsimileTelephoneNumber']   = 'fax';
+  $entries['mobile']                     = 'mobile';
+  $entries['pager']                      = 'pager';
+  $entries['homePhone']                  = 'homephone';
+  $entries['homePostalAddress']          = 'homestreet';
+  $entries['jpegPhoto']                  = 'photo';
+  $entries['labeledURI']                 = 'url';
+  $entries['description']                = 'note';
+  $entries['manager']                    = 'manager';
+  $entries['cn']                         = 'displayname';
+
+  if($conf['extended']){
+    $entries['anniversary']              = 'anniversary';
   }
-  if($conf[openxchange]){
-    $entries[mailDomain]               = 'domain';
-    $entries[userCountry]              = 'country';
-    $entries[birthDay]                 = 'birthday';
-    $entries[IPPhone]                  = 'ipphone';
-    $entries[OXUserCategories]         = 'categories';
-    $entries[OXUserInstantMessenger]   = 'instantmessenger';
-    $entries[OXTimeZone]               = 'timezone';
-    $entries[OXUserPosition]           = 'position';
-    $entries[relClientCert]            = 'certificate';
+  if($conf['openxchange']){
+    $entries['mailDomain']               = 'domain';
+    $entries['userCountry']              = 'country';
+    $entries['birthDay']                 = 'birthday';
+    $entries['IPPhone']                  = 'ipphone';
+    $entries['OXUserCategories']         = 'categories';
+    $entries['OXUserInstantMessenger']   = 'instantmessenger';
+    $entries['OXTimeZone']               = 'timezone';
+    $entries['OXUserPosition']           = 'position';
+    $entries['relClientCert']            = 'certificate';
   }
 
   if($flip){
@@ -242,8 +246,8 @@ function prepare_ldap_entry($in){
   global $conf;
 
   //check dateformat
-  if(!preg_match('/\d\d\d\d-\d\d-\d\d/',$in[anniversary])){
-    $in[anniversary]='';
+  if(!preg_match('/\d\d\d\d-\d\d-\d\d/',$in['anniversary'])){
+    $in['anniversary']='';
   }
 
   $entries = namedentries(true);
@@ -261,12 +265,12 @@ function prepare_ldap_entry($in){
   }
 
   //standard Objectclass
-  $out[objectclass][] = 'inetOrgPerson';
-  if($conf[extended]){
-    $out[objectclass][] = 'contactPerson';
+  $out['objectclass'][] = 'inetOrgPerson';
+  if($conf['extended']){
+    $out['objectclass'][] = 'contactPerson';
   }
-  if($conf[openxchange]){
-    $out[objectclass][] = 'OXUserObject';
+  if($conf['openxchange']){
+    $out['objectclass'][] = 'OXUserObject';
   }
 
   return clear_array($out);
@@ -330,12 +334,12 @@ function get_users(){
   global $conf;
   global $LDAP_CON;
 
-  $sr = ldap_list($LDAP_CON,$conf[usertree],"ObjectClass=inetOrgPerson");
+  $sr = ldap_list($LDAP_CON,$conf['usertree'],"ObjectClass=inetOrgPerson");
   $result = ldap_get_binentries($LDAP_CON, $sr);
   if(count($result)){
     foreach ($result as $entry){
-      if(!empty($entry[sn][0])){
-        $users[$entry[dn]] = $entry[givenName][0]." ".$entry[sn][0];
+      if(!empty($entry['sn'][0])){
+        $users[$entry['dn']] = $entry['givenName'][0]." ".$entry['sn'][0];
       }
     }
   }
@@ -361,9 +365,9 @@ function ldap_store_objectclasses($dn,$classes){
 
   $sr     = ldap_search($LDAP_CON,$dn,"objectClass=*",array('objectClass'));
   $result = ldap_get_binentries($LDAP_CON, $sr);
-  $set    = $result[0][objectClass];
-  $set    = array_unique_renumber(array_merge($set,$classes));
-  $add[objectClass] = $set;
+  $set    = $result[0]['objectClass'];
+  $set    = array_unique_renumber(array_merge((array)$set,(array)$classes));
+  $add['objectClass'] = $set;
 
   $r = @ldap_mod_replace($LDAP_CON,$dn,$add);
   tpl_ldaperror();
@@ -416,7 +420,7 @@ function ldap_queryabooks($filter,$types){
   }
 
   // return merged results
-  return array_merge($result1,$result2);
+  return array_merge((array)$result1,(array)$result2);
 }
 
 /**
diff --git a/img.php b/img.php
index 993a4fcabab6bb785c7540154d14d1a1a4bf872f..eeb44713e46bf1b984a66d686a8fcb8ef4c95e5c 100644 (file)
--- a/img.php
+++ b/img.php
@@ -2,7 +2,7 @@
   require_once('init.php');
   ldap_login();
 
-  $dn = $_REQUEST[dn];
+  $dn = $_REQUEST['dn'];
 
   $sr = ldap_search($LDAP_CON,$dn,'(objectClass=inetOrgPerson)',array('jpegPhoto'));
   if(!ldap_count_entries($LDAP_CON,$sr)){
index d1753cf83ec7ea9a7fd2c560db87868ca94e3b76..2f880f16d77b2b1117079839dd8be1bc4054d25e 100644 (file)
@@ -4,7 +4,7 @@
   require_once('xml.php');
   ldap_login();
 
-  if(! $_SESSION[ldapab][username] ){
+  if(! $_SESSION['ldapab']['username'] ){
     header("Location: login.php");
     exit;
   }
index bc9ea6584ee2dd17d97ab7d4346fc415b28b3447..1138b996cf0bb5c6249531ae1b1516bc8151c531 100644 (file)
@@ -3,7 +3,7 @@
   require_once('Contact_Vcard_Parse.php');
   ldap_login();
 
-  if(! $_SESSION[ldapab][username] ){
+  if(! $_SESSION['ldapab']['username'] ){
     header("Location: login.php");
     exit;
   }
index 04ab99662fb6fc638eee1ce6bb572fbc9a5b9ebe..128bd3dd4d93a2d5631ea5ec2106e816336d238f 100644 (file)
--- a/index.php
+++ b/index.php
@@ -6,17 +6,17 @@
   $ldapfilter = _makeldapfilter();
 
   //check public addressbook
-  $sr = ldap_list($LDAP_CON,$conf[publicbook],$ldapfilter);
+  $sr = ldap_list($LDAP_CON,$conf['publicbook'],$ldapfilter);
   $result1 = ldap_get_binentries($LDAP_CON, $sr);
   //check users private addressbook
-  if(!empty($_SESSION[ldapab][binddn])){
+  if(!empty($_SESSION['ldapab']['binddn'])){
     $sr = @ldap_list($LDAP_CON,
-                    $conf[privatebook].','.$_SESSION[ldapab][binddn],
+                    $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
                     $ldapfilter);
     $result2 = ldap_get_binentries($LDAP_CON, $sr);
   }
   
-  $result = array_merge($result1,$result2);
+  $result = array_merge((array)$result1,(array)$result2);
 
   // select entry template
   if($_REQUEST['export'] == 'csv'){
@@ -26,9 +26,9 @@
   }
 
   $list = '';
-  if(count($result)==1 && $_REQUEST[search]){
+  if(count($result)==1 && $_REQUEST['search']){
     //only one result on a search -> display page
-    header("Location: entry.php?dn=".$result[0][dn]);
+    header("Location: entry.php?dn=".$result[0]['dn']);
     exit;
   }elseif(count($result)){
     $keys = array_keys($result);
@@ -56,7 +56,7 @@
     $smarty->display('export_list_csv.tpl');
   }else{
     //save location in session
-    $_SESSION[ldapab][lastlocation]=$_SERVER["REQUEST_URI"];
+    $_SESSION['ldapab']['lastlocation']=$_SERVER["REQUEST_URI"];
 
     header('Content-Type: text/html; charset=utf-8');
     $smarty->display('list.tpl');
@@ -70,8 +70,8 @@
    */
   function _namesort($a,$b){
     global $result;
-    $x = $result[$a][sn][0].$result[$a][givenName][0];
-    $y = $result[$b][sn][0].$result[$b][givenName][0];
+    $x = $result[$a]['sn'][0].$result[$a]['givenName'][0];
+    $y = $result[$b]['sn'][0].$result[$b]['givenName'][0];
     return(strcasecmp($x,$y));
   }
 
@@ -87,7 +87,7 @@
     $org    = ldap_filterescape($_REQUEST['org']);
     $marker = ldap_filterescape($_REQUEST['marker']);
     $categories = ldap_filterescape($_REQUEST['categories']);
-    $_SESSION[ldapab][filter] = $_REQUEST['filter'];
+    $_SESSION['ldapab']['filter'] = $_REQUEST['filter'];
     if(empty($filter)) $filter='a';
 
     if(!empty($marker)){
index 14bd24fdd85058adce9de5ff126a43db133b5e08..b46c6dca9cae1d1deb159a13a8de9c8d6746b0bb 100644 (file)
--- a/init.php
+++ b/init.php
@@ -1,6 +1,6 @@
 <?
   require_once('config.php');
-  require_once('lang/'.$conf[lang].'.php');
+  require_once('lang/'.$conf['lang'].'.php');
   require_once('functions.php');
   require_once('template.php');
   require_once('smarty/Smarty.class.php');
@@ -35,5 +35,5 @@
   $smarty->compile_dir   = './cache';
   $smarty->use_sub_dirs  = 0;
   $smarty->template_dir  = './templates';
-  $smarty->force_compile = $conf[smartycompile];
+  $smarty->force_compile = $conf['smartycompile'];
 ?>
index 21fa105da8c739b4c2f3b32eaa0d3b5b8fa6b8cb..1f97dd81050f5c6587b915547ce29da9e65f6d61 100644 (file)
@@ -1,73 +1,73 @@
 <?
 
-$lang[ldapab]         = 'Das LDAP Adressbuch';
+$lang['ldapab']         = 'Das LDAP Adressbuch';
 
-$lang[name]           = 'Name';
-$lang[givenname]      = 'Vorname';
-$lang[title]          = 'Titel';
-$lang[organization]   = 'Firma';
-$lang[office]         = 'Abteilung';
-$lang[street]         = 'Straße, Nr.';
-$lang[zip]            = 'Postleitzahl';
-$lang[location]       = 'Ort';
-$lang[phone]          = 'Telefon';
-$lang[fax]            = 'FAX';
-$lang[mobile]         = 'Handy';
-$lang[pager]          = 'Pieper';
-$lang[homephone]      = 'Telefon (priv.)';
-$lang[homestreet]     = 'Adresse (priv.)';
-$lang[photo]          = 'Foto';
-$lang[url]            = 'Webseite';
-$lang[note]           = 'Notizen';
-$lang[mail]           = 'E-Mail';
-$lang[manager]        = 'Key Account';
+$lang['name']           = 'Name';
+$lang['givenname']      = 'Vorname';
+$lang['title']          = 'Titel';
+$lang['organization']   = 'Firma';
+$lang['office']         = 'Abteilung';
+$lang['street']         = 'Straße, Nr.';
+$lang['zip']            = 'Postleitzahl';
+$lang['location']       = 'Ort';
+$lang['phone']          = 'Telefon';
+$lang['fax']            = 'FAX';
+$lang['mobile']         = 'Handy';
+$lang['pager']          = 'Pieper';
+$lang['homephone']      = 'Telefon (priv.)';
+$lang['homestreet']     = 'Adresse (priv.)';
+$lang['photo']          = 'Foto';
+$lang['url']            = 'Webseite';
+$lang['note']           = 'Notizen';
+$lang['mail']           = 'E-Mail';
+$lang['manager']        = 'Key Account';
 
-$lang[anniversary]    = 'Geburtstag';
-$lang[marker]         = 'Tags';
-$lang[tagcloud]       = 'Alle verwendeten Tags, alphabetisch sortiert. Häufig verwendete Tags werden größer dargestellt.';
+$lang['anniversary']    = 'Geburtstag';
+$lang['marker']         = 'Tags';
+$lang['tagcloud']       = 'Alle verwendeten Tags, alphabetisch sortiert. Häufig verwendete Tags werden größer dargestellt.';
 
-$lang[business]       = 'Geschäftlich';
-$lang[private]        = 'Privat';
-$lang[extended]       = 'Zusätzliche Infos';
+$lang['business']       = 'Geschäftlich';
+$lang['private']        = 'Privat';
+$lang['extended']       = 'Zusätzliche Infos';
 
-$lang[delphoto]       = 'Vorhandenes Foto löschen';
+$lang['delphoto']       = 'Vorhandenes Foto löschen';
 
-$lang[notloggedin]    = 'Nicht angemeldet';
-$lang[loggedinas]     = 'Angemeldet als';
-$lang[login]          = 'Anmelden';
-$lang[logout]         = 'Abmelden';
-$lang[edit]           = 'Bearbeiten';
-$lang[show]           = 'Anzeigen';
-$lang['new']          = 'Neu';
-$lang['delete']       = 'Löschen';
-$lang['copy']         = 'Kopieren';
-$lang[csvexport]      = 'CSV';
-$lang[vcfexport]      = 'VCard';
-$lang[vcfimport]                       = 'Import';
-$lang[search]         = 'Suchen';
-$lang[submit]         = 'Absenden';
-$lang[help]           = 'Hilfe';
-$lang[select]         = 'Auswählen';
-$lang[orgs]           = 'Firmen';
-$lang[upload]         = 'Hochladen';
+$lang['notloggedin']    = 'Nicht angemeldet';
+$lang['loggedinas']     = 'Angemeldet als';
+$lang['login']          = 'Anmelden';
+$lang['logout']         = 'Abmelden';
+$lang['edit']           = 'Bearbeiten';
+$lang['show']           = 'Anzeigen';
+$lang['new']            = 'Neu';
+$lang['delete']         = 'Löschen';
+$lang['copy']           = 'Kopieren';
+$lang['csvexport']      = 'CSV';
+$lang['vcfexport']      = 'VCard';
+$lang['vcfimport']                     = 'Import';
+$lang['search']         = 'Suchen';
+$lang['submit']         = 'Absenden';
+$lang['help']           = 'Hilfe';
+$lang['select']         = 'Auswählen';
+$lang['orgs']           = 'Firmen';
+$lang['upload']         = 'Hochladen';
 
-$lang[publicbook]     = 'Öffentliches Adressbuch';
-$lang[privatebook]    = 'Privates Adressbuch';
+$lang['publicbook']     = 'Öffentliches Adressbuch';
+$lang['privatebook']    = 'Privates Adressbuch';
 
 
-$lang[username]       = 'Benutzername';
-$lang[password]       = 'Passwort';
-$lang[remember]       = 'Auf diesem Computer angemeldet bleiben';
+$lang['username']       = 'Benutzername';
+$lang['password']       = 'Passwort';
+$lang['remember']       = 'Auf diesem Computer angemeldet bleiben';
 
-$lang[msg_login]      = 'Bitte melden sie sich an!';
-$lang[msg_loginfail]  = 'Anmeldung fehlgeschlagen!';
-$lang[msg_reallydel]  = 'Eintrag wirklich löschen?';
-$lang[msg_addto]      = 'Zu welchem Adressbuch soll der Eintrag hinzugefügt werden?';
-$lang[msg_jpegonly]   = 'Nur JPEG';
-$lang[msg_dateformat] = 'JJJJ-MM-TT';
-$lang[msg_uploadvcf]  = 'Upload VCard File';
-$lang[msg_tagsep]     = 'Durch Komma getrennt';
+$lang['msg_login']      = 'Bitte melden sie sich an!';
+$lang['msg_loginfail']  = 'Anmeldung fehlgeschlagen!';
+$lang['msg_reallydel']  = 'Eintrag wirklich löschen?';
+$lang['msg_addto']      = 'Zu welchem Adressbuch soll der Eintrag hinzugefügt werden?';
+$lang['msg_jpegonly']   = 'Nur JPEG';
+$lang['msg_dateformat'] = 'JJJJ-MM-TT';
+$lang['msg_uploadvcf']  = 'Upload VCard File';
+$lang['msg_tagsep']     = 'Durch Komma getrennt';
 
-$lang[err_noentries]  = 'Keine Einträge';
-$lang[err_ldap]       = 'Der LDAP Server lieferte folgende Fehlermeldungen';
+$lang['err_noentries']  = 'Keine Einträge';
+$lang['err_ldap']       = 'Der LDAP Server lieferte folgende Fehlermeldungen';
 ?>
index cca3902ef0fad0e8809232086ffa13f7e943e500..6e28ec662a25df88334bdd0926a6ef0e318b3f4e 100644 (file)
@@ -1,84 +1,84 @@
 <?
 
-$lang[ldapab]         = 'The LDAP address book';
+$lang['ldapab']           = 'The LDAP address book';
 
-$lang[name]           = 'Last Name';
-$lang[givenname]      = 'First Name';
-$lang[title]          = 'Title';
-$lang[organization]   = 'Company';
-$lang[office]         = 'Office';
-$lang[street]         = 'Street No.';
-$lang[zip]            = 'Postal Code';
-$lang[location]       = 'City';
-$lang[phone]          = 'Phone';
-$lang[fax]            = 'FAX';
-$lang[mobile]         = 'Mobile';
-$lang[pager]          = 'Pager';
-$lang[homephone]      = 'Phone (priv.)';
-$lang[homestreet]     = 'Address (priv.)';
-$lang[photo]          = 'Picture';
-$lang[url]            = 'Website';
-$lang[note]           = 'Notes';
-$lang[mail]           = 'E-Mail';
-$lang[manager]        = 'Key Account';
+$lang['name']             = 'Last Name';
+$lang['givenname']        = 'First Name';
+$lang['title']            = 'Title';
+$lang['organization']     = 'Company';
+$lang['office']           = 'Office';
+$lang['street']           = 'Street No.';
+$lang['zip']              = 'Postal Code';
+$lang['location']         = 'City';
+$lang['phone']            = 'Phone';
+$lang['fax']              = 'FAX';
+$lang['mobile']           = 'Mobile';
+$lang['pager']            = 'Pager';
+$lang['homephone']        = 'Phone (priv.)';
+$lang['homestreet']       = 'Address (priv.)';
+$lang['photo']            = 'Picture';
+$lang['url']              = 'Website';
+$lang['note']             = 'Notes';
+$lang['mail']             = 'E-Mail';
+$lang['manager']          = 'Key Account';
 
-$lang[anniversary]    = 'Birthday';
-$lang[marker]         = 'Tags';
-$lang[tagcloud]       = 'All used tags, sorted alphabetically. Frequently used tags are shown bigger.';
+$lang['anniversary']      = 'Birthday';
+$lang['marker']           = 'Tags';
+$lang['tagcloud']         = 'All used tags, sorted alphabetically. Frequently used tags are shown bigger.';
 
-$lang[business]       = 'Business';
-$lang[private]        = 'Private';
-$lang[extended]       = 'Additional Information';
+$lang['business']         = 'Business';
+$lang['private']          = 'Private';
+$lang['extended']         = 'Additional Information';
 
-$lang[delphoto]       = 'Delete existing photo';
+$lang['delphoto']         = 'Delete existing photo';
 
-$lang[notloggedin]    = 'Not logged in';
-$lang[loggedinas]     = 'Logged in as';
-$lang[login]          = 'Log in';
-$lang[logout]         = 'Log out';
-$lang[edit]           = 'Edit';
-$lang[show]           = 'Show';
-$lang['new']          = 'New';
-$lang['delete']       = 'Delete';
-$lang['copy']         = 'Copy';
-$lang[csvexport]      = 'CSV';
-$lang[vcfexport]      = 'VCard';
-$lang[vcfimport]                       = 'Import';
-$lang[search]         = 'Search';
-$lang[submit]         = 'Send';
-$lang[help]           = 'Help';
-$lang[select]         = 'Select';
-$lang[orgs]           = 'Companies';
-$lang[upload]         = 'Upload';
+$lang['notloggedin']      = 'Not logged in';
+$lang['loggedinas']       = 'Logged in as';
+$lang['login']            = 'Log in';
+$lang['logout']           = 'Log out';
+$lang['edit']             = 'Edit';
+$lang['show']             = 'Show';
+$lang['new']              = 'New';
+$lang['delete']           = 'Delete';
+$lang['copy']             = 'Copy';
+$lang['csvexport']        = 'CSV';
+$lang['vcfexport']        = 'VCard';
+$lang['vcfimport']        = 'Import';
+$lang['search']           = 'Search';
+$lang['submit']           = 'Send';
+$lang['help']             = 'Help';
+$lang['select']           = 'Select';
+$lang['orgs']             = 'Companies';
+$lang['upload']           = 'Upload';
 
-$lang[publicbook]     = 'Public Addressbook';
-$lang[privatebook]    = 'Private Addressbook';
+$lang['publicbook']       = 'Public Addressbook';
+$lang['privatebook']      = 'Private Addressbook';
 
-$lang[username]       = 'Username';
-$lang[password]       = 'Password';
-$lang[remember]       = 'Stay logged in on this computer';
+$lang['username']         = 'Username';
+$lang['password']         = 'Password';
+$lang['remember']         = 'Stay logged in on this computer';
 
-$lang[msg_login]      = 'Please log in!';
-$lang[msg_loginfail]  = 'Log in failed!';
-$lang[msg_reallydel]  = 'Really delete entry?';
-$lang[msg_addto]      = 'Select address book to which the entry should be added:';
-$lang[msg_jpegonly]   = 'JPEG only';
-$lang[msg_dateformat] = 'YYYY-MM-DD';
-$lang[msg_uploadvcf]  = 'Upload VCard File';
-$lang[msg_tagsep]     = 'Comma separated';
+$lang['msg_login']        = 'Please log in!';
+$lang['msg_loginfail']    = 'Log in failed!';
+$lang['msg_reallydel']    = 'Really delete entry?';
+$lang['msg_addto']        = 'Select address book to which the entry should be added:';
+$lang['msg_jpegonly']     = 'JPEG only';
+$lang['msg_dateformat']   = 'YYYY-MM-DD';
+$lang['msg_uploadvcf']    = 'Upload VCard File';
+$lang['msg_tagsep']       = 'Comma separated';
 
-$lang[err_noentries]  = 'No entries';
-$lang[err_ldap]       = 'The LDAP server returned the following errors';
+$lang['err_noentries']    = 'No entries';
+$lang['err_ldap']         = 'The LDAP server returned the following errors';
 
-$lang[openxchange]    = 'Xchange Information';
-$lang[moreopenxchange]    = 'Xchange Information Cont\'d';
-$lang[instantmessenger] = 'Inst Msg';
-$lang[categories]     = 'Categories';
-$lang[birthday]       = 'Birthday';
-$lang[domain]         = 'Mail Domain';
-$lang[country]        = 'Country';
-$lang[certificate]    = 'x.509 Cert';
-$lang[timezone]       = 'Time Zone';
-$lang[position]       = 'Position';
-$lang[ipphone]        = 'IP Phone';
+$lang['openxchange']      = 'Xchange Information';
+$lang['moreopenxchange']  = 'Xchange Information Cont\'d';
+$lang['instantmessenger'] = 'Inst Msg';
+$lang['categories']       = 'Categories';
+$lang['birthday']         = 'Birthday';
+$lang['domain']           = 'Mail Domain';
+$lang['country']          = 'Country';
+$lang['certificate']      = 'x.509 Cert';
+$lang['timezone']         = 'Time Zone';
+$lang['position']         = 'Position';
+$lang['ipphone']          = 'IP Phone';
 ?>
index 2bf41bcceaf89a7ca24f0b11ac5e8616c9abe149..96ba2368200c1f23879cddbe14c05271483c9aa8 100644 (file)
--- a/login.php
+++ b/login.php
@@ -1,18 +1,18 @@
 <?
   require_once('init.php');
 
-  $msg = $lang[msg_login];
-  if(isset($_REQUEST[username])){
-    if (do_ldap_bind($_REQUEST[username],$_REQUEST[password])){
+  $msg = $lang['msg_login'];
+  if(isset($_REQUEST['username'])){
+    if (do_ldap_bind($_REQUEST['username'],$_REQUEST['password'])){
       //forward to next page
-      if(!empty($_SESSION[ldapab][lastlocation])){
-        header('Location: '.$_SESSION[ldapab][lastlocation]);
+      if(!empty($_SESSION['ldapab']['lastlocation'])){
+        header('Location: '.$_SESSION['ldapab']['lastlocation']);
       }else{
         header('Location: index.php');
       }
       exit;
     }else{
-      $msg = $lang[msg_loginfail];;
+      $msg = $lang['msg_loginfail'];;
     }
   }
 
index 4a3019ad1d30ccf2b0e93cc6079333e12ec5b720..740c0aae6b91a755ff3f4caeb5c96bc1e0a752e2 100644 (file)
--- a/tags.php
+++ b/tags.php
@@ -12,7 +12,7 @@
   function tag_cloud(){
     global $conf;
     global $LDAP_CON;
-    if(!$conf[extended]) return;
+    if(!$conf['extended']) return;
     
     $result = ldap_queryabooks('(objectClass=contactPerson)','marker');
 
index 06fe3d0cebdeacbc4482d4e47cfda46c5dfeb3e4..e5731666ca7dc5b898bf785ddec912417cdad13d 100644 (file)
@@ -8,16 +8,23 @@ function tpl_std(){
   global $lang;
   global $conf;
 
-  $smarty->assign('user',$_SESSION[ldapab][username]);
-  $smarty->assign('binddn',$_SESSION[ldapab][binddn]);
-  if(!empty($_SESSION[ldapab][lastlocation])){
-    $smarty->assign('home',$_SESSION[ldapab][lastlocation]);
+  if(empty($_SESSION['ldapab']['username'])){
+    $_SESSION['ldapab']['username'] = '';
+  }
+  if(empty($_SESSION['ldapab']['binddn'])){
+    $_SESSION['ldapab']['binddn'] = '';
+  }
+
+  $smarty->assign('user',$_SESSION['ldapab']['username']);
+  $smarty->assign('binddn',$_SESSION['ldapab']['binddn']);
+  if(!empty($_SESSION['ldapab']['lastlocation'])){
+    $smarty->assign('home',$_SESSION['ldapab']['lastlocation']);
   }else{
      $smarty->assign('home','index.php');
   }
   $smarty->assign('conf',$conf);
   $smarty->assign('lang',$lang);
-  $smarty->assign('dfexample',$dfexample);
+  //$smarty->assign('dfexample',$dfexample);
 }
 
 /**
@@ -43,23 +50,23 @@ function tpl_entry($in){
 
   //set the type
   $out['dn']        = normalize_dn($out['dn']);
-  $conf[publicbook] = normalize_dn($conf[publicbook]);
+  $conf['publicbook'] = normalize_dn($conf['publicbook']);
   if($out['dn']){
-    if(strstr($out['dn'],$conf[publicbook])){
-      $out[type] = 'public';
+    if(strstr($out['dn'],$conf['publicbook'])){
+      $out['type'] = 'public';
     }else{
-      $out[type] = 'private';
+      $out['type'] = 'private';
     }
   }
 
   //mail entries are handled special
   $out['mail'] = $in['mail'];
-  if ($conf[extended]){
+  if ($conf['extended']){
     //handle marker special in extended mode
     $out['marker'] = $in['marker'];
     if(is_array($in['marker'])) $out['markers'] = join(', ',$in['marker']);
   }
-  if ($conf[openxchange]){
+  if ($conf['openxchange']){
     //handle categories special in openxchange mode
     $out['categories'] = $in['OXUserCategories'];
   }
@@ -97,20 +104,20 @@ function tpl_markers(){
   global $LDAP_CON;
   global $smarty;
 
-  if(!$conf[extended]) return;
+  if(!$conf['extended']) return;
 
   $markers = array();
 
-  $sr = ldap_list($LDAP_CON,$conf[publicbook],"ObjectClass=inetOrgPerson",array("marker"));
+  $sr = ldap_list($LDAP_CON,$conf['publicbook'],"ObjectClass=inetOrgPerson",array("marker"));
   $result1 = ldap_get_binentries($LDAP_CON, $sr);
   //check users private addressbook
-  if(!empty($_SESSION[ldapab][binddn])){
+  if(!empty($_SESSION['ldapab']['binddn'])){
     $sr = @ldap_list($LDAP_CON,
-                    $conf[privatebook].','.$_SESSION[ldapab][binddn],
+                    $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
                     "ObjectClass=inetOrgPerson",array("marker"));
     $result2 = ldap_get_binentries($LDAP_CON, $sr);
   }
-  $result = array_merge($result1,$result2);
+  $result = array_merge((array)$result1,(array)$result2);
 
   if(count($result)){
     foreach ($result as $entry){
@@ -137,21 +144,21 @@ function tpl_orgs(){
 
   $orgs = array();
 
-  $sr = ldap_list($LDAP_CON,$conf[publicbook],"ObjectClass=inetOrgPerson",array("o"));
+  $sr = ldap_list($LDAP_CON,$conf['publicbook'],"ObjectClass=inetOrgPerson",array("o"));
   $result1 = ldap_get_binentries($LDAP_CON, $sr);
   //check users private addressbook
-  if(!empty($_SESSION[ldapab][binddn])){
+  if(!empty($_SESSION['ldapab']['binddn'])){
     $sr = @ldap_list($LDAP_CON,
-                    $conf[privatebook].','.$_SESSION[ldapab][binddn],
+                    $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
                     "ObjectClass=inetOrgPerson",array("o"));
     $result2 = ldap_get_binentries($LDAP_CON, $sr);
   }
-  $result = array_merge($result1,$result2);
+  $result = array_merge((array)$result1,(array)$result2);
 
   if(count($result)){
     foreach ($result as $entry){
-      if(!empty($entry[o][0])){
-        array_push($orgs, $entry[o][0]);
+      if(!empty($entry['o'][0])){
+        array_push($orgs, $entry['o'][0]);
       }
     }
   }
@@ -168,20 +175,20 @@ function tpl_categories(){
   global $LDAP_CON;
   global $smarty;
 
-  if(!$conf[openxchange]) return;
+  if(!$conf['openxchange']) return;
 
   $categories = array();
 
-  $sr = ldap_list($LDAP_CON,$conf[publicbook],"ObjectClass=OXUserObject",array("OXUserCategories"));
+  $sr = ldap_list($LDAP_CON,$conf['publicbook'],"ObjectClass=OXUserObject",array("OXUserCategories"));
   $result1 = ldap_get_binentries($LDAP_CON, $sr);
   //check users private addressbook
-  if(!empty($_SESSION[ldapab][binddn])){
+  if(!empty($_SESSION['ldapab']['binddn'])){
     $sr = @ldap_list($LDAP_CON,
-                    $conf[privatebook].','.$_SESSION[ldapab][binddn],
+                    $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
                     "ObjectClass=OXUserObject",array("OXUserCategories"));
     $result2 = ldap_get_binentries($LDAP_CON, $sr);
   }
-  $result = array_merge($result1,$result2);
+  $result = array_merge((array)$result1,(array)$result2);
 
   if(count($result)){
     foreach ($result as $entry){
@@ -206,20 +213,20 @@ function tpl_timezone(){
   global $LDAP_CON;
   global $smarty;
 
-  if(!$conf[openxchange]) return;
+  if(!$conf['openxchange']) return;
 
   $timezone = array();
 
-  $sr = ldap_list($LDAP_CON,$conf[publicbook],"ObjectClass=OXUserObject",array("OXTimeZone"));
+  $sr = ldap_list($LDAP_CON,$conf['publicbook'],"ObjectClass=OXUserObject",array("OXTimeZone"));
   $result1 = ldap_get_binentries($LDAP_CON, $sr);
   //check users private addressbook
-  if(!empty($_SESSION[ldapab][binddn])){
+  if(!empty($_SESSION['ldapab']['binddn'])){
     $sr = @ldap_list($LDAP_CON,
-                    $conf[privatebook].','.$_SESSION[ldapab][binddn],
+                    $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
                     "ObjectClass=OXUserObject",array("OXTimeZone"));
     $result2 = ldap_get_binentries($LDAP_CON, $sr);
   }
-  $result = array_merge($result1,$result2);
+  $result = array_merge((array)$result1,(array)$result2);
 
   if(count($result)){
     foreach ($result as $entry){
@@ -244,20 +251,20 @@ function tpl_country(){
   global $LDAP_CON;
   global $smarty;
 
-  if(!$conf[openxchange]) return;
+  if(!$conf['openxchange']) return;
 
   $country = array();
 
-  $sr = ldap_list($LDAP_CON,$conf[publicbook],"ObjectClass=OXUserObject",array("userCountry"));
+  $sr = ldap_list($LDAP_CON,$conf['publicbook'],"ObjectClass=OXUserObject",array("userCountry"));
   $result1 = ldap_get_binentries($LDAP_CON, $sr);
   //check users private addressbook
-  if(!empty($_SESSION[ldapab][binddn])){
+  if(!empty($_SESSION['ldapab']['binddn'])){
     $sr = @ldap_list($LDAP_CON,
-                    $conf[privatebook].','.$_SESSION[ldapab][binddn],
+                    $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
                     "ObjectClass=OXUserObject",array("userCountry"));
     $result2 = ldap_get_binentries($LDAP_CON, $sr);
   }
-  $result = array_merge($result1,$result2);
+  $result = array_merge((array)$result1,(array)$result2);
 
   if(count($result)){
     foreach ($result as $entry){