]> git.sur5r.net Git - contagged/commitdiff
PHP5 notice cleanups
authorPaul Howarth <paul@city-fan.org>
Mon, 11 Sep 2006 11:04:42 +0000 (13:04 +0200)
committerPaul Howarth <paul@city-fan.org>
Mon, 11 Sep 2006 11:04:42 +0000 (13:04 +0200)
This patch removes all of the remaining notices when running on PHP 5.1.4.
Contagged should now run cleanly with error reporting on E_ALL.

darcs-hash:20060911110442-df059-46a1680ffd06f4021129af3fc44535aa70fd7f5e.gz

ajax.php
entry.php
functions.php
index.php
login.php
tags.php
template.php
templates/list_entry.tpl

index 564e59d36e1e427174b3c5ab94ebb9943781e104..e26031bfe4bc3e036551446b65883738e667a165 100644 (file)
--- a/ajax.php
+++ b/ajax.php
@@ -4,11 +4,11 @@ ldap_login();
 
 header('Content-Type: text/html; charset=utf-8');
 
-if($_REQUEST['taglookup']){
+if(!empty($_REQUEST['taglookup'])){
   ajax_taglookup($_REQUEST['taglookup']);
-}elseif($_REQUEST['addnote']){
+}elseif(!empty($_REQUEST['addnote'])){
   ajax_addnote($_REQUEST['addnote'],$_REQUEST['note']);
-}elseif($_REQUEST['settags']){
+}elseif(!empty($_REQUEST['settags'])){
   ajax_settags($_REQUEST['settags'],$_REQUEST['tags']);
 }
 
index c081da428596df7191effc51549e4a48efda1264..0b22eca1b21e9675a02ab1caf7d8d4607f288a5e 100644 (file)
--- a/entry.php
+++ b/entry.php
@@ -5,6 +5,7 @@
   $users = get_users();
 
   //select template to use
+  if (empty($_REQUEST['mode'])) { $_REQUEST['mode']='show'; }
   if( $_SESSION['ldapab']['username'] &&
      ($_REQUEST['mode']=='edit' || $_REQUEST['mode']=='copy')){
     $template='entry_edit.tpl';
     $template='entry_show.tpl';
   }
 
-  $dn = $_REQUEST['dn'];
-  #$dn = 'cn=bar foo, ou=contacts, o=cosmocode, c=de';
+  if (empty($_REQUEST['dn'])) {
+    $dn = "";
+  }else{
+    $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'] && !empty($_REQUEST['save']) && $_REQUEST['save']){
     // prepare special data
     $_REQUEST['entry']['jpegPhoto'][]=_getUploadData();
     $_REQUEST['entry']['marker'] = explode(',',$_REQUEST['entry']['markers']);
@@ -41,7 +46,7 @@
       $smarty->assign('error','No dn was given');
       $template = 'error.tpl';
     }
-  }elseif($_REQUEST['del']){
+  }elseif(!empty($_REQUEST['del']) && $_REQUEST['del']){
     _delEntry($dn);
   }elseif(!_fetchData($dn)){
     $smarty->assign('error',"The requested entry '$dn' was not found");
@@ -89,7 +94,7 @@
     $entry  = $result[0];
 
     //remove dn from entry when copy
-    if($_REQUEST['mode'] == 'copy'){
+    if(!empty($_REQUEST['mode']) && $_REQUEST['mode'] == 'copy'){
       $entry['dn']='';
     }
 
@@ -101,6 +106,8 @@ print_r($entry);
 print '</pre>';*/
 
     // make username from dn for manager:
+    if (empty($entry['manager'])) { $entry['manager']=array(""); }
+    if (empty($users[$entry['manager'][0]])) { $users[$entry['manager'][0]]=''; }
     $smarty->assign('managername',$users[$entry['manager'][0]]);
     return true;
   }
@@ -116,7 +123,7 @@ print '</pre>';*/
     $entries = namedentries();
     $entries['mail']='mail';  //special field mail isn't in entries so we add it here
     if($conf['extended']){
-      $entries['marker']='marker'; //same for marker inextended schema
+      $entries['marker']='marker'; //same for marker in extended schema
     }
 
     $entry = $_REQUEST['entry'];
@@ -124,6 +131,7 @@ print '</pre>';*/
     //construct new dn
     $now    = time();
     $newdn  = 'uid='.$now;
+    if (empty($_REQUEST['type'])) { $_REQUEST['type']='public'; }
     if($_REQUEST['type'] == 'private'){
       $newdn .= ', '.$conf['privatebook'].', '.$_SESSION['ldapab']['binddn'];
     }else{
@@ -158,6 +166,7 @@ print '</pre>';
         if($key == 'dn'){
           continue;
         }elseif(empty($entry[$key])){
+          if (empty($_REQUEST['delphoto'])) { $_REQUEST['delphoto']=0; }
           if($key == 'jpegPhoto' && !$_REQUEST['delphoto']){
             continue;
           }
index 3f68561161991ac58c1d1d7c461c4d4aab9aca3a..afa2e430faf490ca72ca5cfe8f2fa20cbd0a7f6c 100644 (file)
@@ -25,7 +25,7 @@ function ldap_login(){
     // use HTTP auth if wanted and possible
     $_SESSION['ldapab']['username'] = $_SERVER['PHP_AUTH_USER'];
     $_SESSION['ldapab']['password'] = $_SERVER['PHP_AUTH_PW'];
-  } elseif ($_COOKIE['ldapabauth']) {
+  } elseif (!empty($_COOKIE['ldapabauth'])) {
     // check persistent cookie
     $cookie = base64_decode($_COOKIE['ldapabauth']);
     $cookie = x_Decrypt($cookie,get_cookie_secret());
@@ -34,7 +34,8 @@ function ldap_login(){
     $_SESSION['ldapab']['password'] = $p;
   }
 
-  if(!do_ldap_bind($_SESSION['ldapab']['username'],
+  if(empty($_SESSION['ldapab']) ||
+     !do_ldap_bind($_SESSION['ldapab']['username'],
                    $_SESSION['ldapab']['password'],
                    $_SESSION['ldapab']['binddn'])){
     header('Location: login.php?username=');
@@ -111,6 +112,10 @@ function do_ldap_bind($user,$pass,$dn=""){
  */
 function auth_browseruid(){
   $uid  = '';
+  if (empty($_SERVER['HTTP_USER_AGENT']))      { $_SERVER['HTTP_USER_AGENT']='USER_AGENT'; }
+  if (empty($_SERVER['HTTP_ACCEPT_ENCODING'])) { $_SERVER['HTTP_ACCEPT_ENCODING']='ACCEPT_ENCODING'; }
+  if (empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $_SERVER['HTTP_ACCEPT_LANGUAGE']='ACCEPT_LANGUAGE'; }
+  if (empty($_SERVER['HTTP_ACCEPT_CHARSET']))  { $_SERVER['HTTP_ACCEPT_CHARSET']='ACCEPT_CHARSET'; }
   $uid .= $_SERVER['HTTP_USER_AGENT'];
   $uid .= $_SERVER['HTTP_ACCEPT_ENCODING'];
   $uid .= $_SERVER['HTTP_ACCEPT_LANGUAGE'];
@@ -132,10 +137,10 @@ function set_session($user,$pass,$dn){
   $_SESSION['ldapab']['password']  = $pass;
   $_SESSION['ldapab']['browserid'] = auth_browseruid();
 
-  // (re)set the persistant auth cookie
+  // (re)set the persistent auth cookie
   if($user == ''){
     setcookie('ldapabauth','',time()+60*60*24*365);
-  }elseif($_REQUEST['remember']){
+  }elseif(!empty($_REQUEST['remember'])){
     $cookie = serialize(array($user,$pass));
     $cookie = x_Encrypt($cookie,get_cookie_secret());
     $cookie = base64_encode($cookie);
@@ -144,8 +149,8 @@ function set_session($user,$pass,$dn){
 }
 
 /**
- * Creates a random string to encrypt persistant auth
- * cookies the string is stored inside the cache dir
+ * Creates a random string to encrypt persistent auth
+ * cookies; the string is stored inside the cache dir
  */
 function get_cookie_secret(){
   $file = dirname(__FILE__).'/cache/.htcookiesecret.php';
@@ -338,6 +343,7 @@ function get_users(){
 
   $sr = ldap_list($LDAP_CON,$conf['usertree'],"ObjectClass=inetOrgPerson");
   $result = ldap_get_binentries($LDAP_CON, $sr);
+  $users = array();
   if(count($result)){
     foreach ($result as $entry){
       if(!empty($entry['sn'][0])){
index 8649ec657c907780ae4f830f10f7c8008ceb70f6..72a84b0154e914a131f43d0843c2fd248b4fd71a 100644 (file)
--- a/index.php
+++ b/index.php
                     $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
                     $ldapfilter);
     $result2 = ldap_get_binentries($LDAP_CON, $sr);
+  }else{
+    $result2 = '';
   }
   
   $result = array_merge((array)$result1,(array)$result2);
 
   // select entry template
-  if($_REQUEST['export'] == 'csv'){
+  if(!empty($_REQUEST['export']) && $_REQUEST['export'] == 'csv'){
     $entrytpl = 'export_list_csv_entry.tpl';
   }else{
     $entrytpl = 'list_entry.tpl';
   tpl_categories();
   tpl_timezone();
   tpl_country();
+  if (empty($_REQUEST['filter'])) $_REQUEST['filter']='';
+  if (empty($_REQUEST['marker'])) $_REQUEST['marker']='';
+  if (empty($_REQUEST['search'])) $_REQUEST['search']='';
   $smarty->assign('list',$list);
   $smarty->assign('filter',$_REQUEST['filter']);
   $smarty->assign('marker',$_REQUEST['marker']);
   $smarty->assign('search',$_REQUEST['search']);
   //display templates
-  if($_REQUEST['export'] == 'csv'){
+  if(!empty($_REQUEST['export']) && $_REQUEST['export'] == 'csv'){
     if ($conf['userlogreq'] == 1 && $user == '')
     {
       header("HTTP/1.1 401 ACCESS DENIED");
@@ -76,6 +81,8 @@
    */
   function _namesort($a,$b){
     global $result;
+    if (empty($result[$a]['givenName'])) { $result[$a]['givenName']=''; }
+    if (empty($result[$b]['givenName'])) { $result[$b]['givenName']=''; }
     $x = $result[$a]['sn'][0].$result[$a]['givenName'][0];
     $y = $result[$b]['sn'][0].$result[$b]['givenName'][0];
     return(strcasecmp($x,$y));
   function _makeldapfilter(){
     //handle given filter
 
+    if (empty($_REQUEST['filter'])) { $_REQUEST['filter']=''; }
+    if (empty($_REQUEST['search'])) { $_REQUEST['search']=''; }
+    if (empty($_REQUEST['org'])) { $_REQUEST['org']=''; }
+    if (empty($_REQUEST['marker'])) { $_REQUEST['marker']=''; }
+    if (empty($_REQUEST['categories'])) { $_REQUEST['categories']=''; }
     $filter = ldap_filterescape($_REQUEST['filter']);
     $search = ldap_filterescape($_REQUEST['search']);
     $org    = ldap_filterescape($_REQUEST['org']);
index 96ba2368200c1f23879cddbe14c05271483c9aa8..1e4b0d0e5ace54cd55f41f657ba817110e35ecb4 100644 (file)
--- a/login.php
+++ b/login.php
@@ -3,6 +3,7 @@
 
   $msg = $lang['msg_login'];
   if(isset($_REQUEST['username'])){
+    if (empty($_REQUEST['password'])) { $_REQUEST['password']=''; }
     if (do_ldap_bind($_REQUEST['username'],$_REQUEST['password'])){
       //forward to next page
       if(!empty($_SESSION['ldapab']['lastlocation'])){
index 740c0aae6b91a755ff3f4caeb5c96bc1e0a752e2..bd26632768980a60d296f070d20f45e91b52bbad 100644 (file)
--- a/tags.php
+++ b/tags.php
     $max = 0;
     $tags = array();
     foreach ($result as $entry){
-      if(count($entry['marker'])){
+      if(!empty($entry['marker']) && count($entry['marker'])){
         foreach($entry['marker'] as $marker){
           $marker = strtolower($marker);
+          if (empty($tags[$marker])) { $tags[$marker]=0; }
           $tags[$marker] += 1;
           if($tags[$marker] > $max) $max = $tags[$marker];
         }
index e5731666ca7dc5b898bf785ddec912417cdad13d..f0fe1fa75a86a94523c6435bef2bd56b0fa17638 100644 (file)
@@ -35,11 +35,11 @@ function tpl_entry($in){
   global $smarty;
   global $conf;
   $entries = namedentries();
-
+  $out=array();
 
   //handle named entries
   foreach(array_keys($entries) as $key){
-    if($in[$key]){
+    if(!empty($in[$key])){
       if(is_array($in[$key])){
         $out[$entries[$key]] = $in[$key][0];
       }else{
@@ -49,7 +49,8 @@ function tpl_entry($in){
   }
 
   //set the type
-  $out['dn']        = normalize_dn($out['dn']);
+  if (empty($out['dn'])) { $out['dn']=''; }
+  $out['dn']          = normalize_dn($out['dn']);
   $conf['publicbook'] = normalize_dn($conf['publicbook']);
   if($out['dn']){
     if(strstr($out['dn'],$conf['publicbook'])){
@@ -59,15 +60,17 @@ function tpl_entry($in){
     }
   }
 
-  //mail entries are handled special
+  //mail entries are handled specially
+  if (empty($in['mail'])) { $in['mail']=''; }
   $out['mail'] = $in['mail'];
   if ($conf['extended']){
-    //handle marker special in extended mode
+    //handle marker specially in extended mode
+    if (empty($in['marker'])) { $in['marker']=''; }
     $out['marker'] = $in['marker'];
     if(is_array($in['marker'])) $out['markers'] = join(', ',$in['marker']);
   }
   if ($conf['openxchange']){
-    //handle categories special in openxchange mode
+    //handle categories specially in openxchange mode
     $out['categories'] = $in['OXUserCategories'];
   }
 
@@ -116,12 +119,14 @@ function tpl_markers(){
                     $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
                     "ObjectClass=inetOrgPerson",array("marker"));
     $result2 = ldap_get_binentries($LDAP_CON, $sr);
+  }else{
+    $result2 = '';
   }
   $result = array_merge((array)$result1,(array)$result2);
 
   if(count($result)){
     foreach ($result as $entry){
-      if(count($entry['marker'])){
+      if(!empty($entry['marker']) && count($entry['marker'])){
         foreach($entry['marker'] as $marker){
           array_push($markers, $marker);
         }
index c1e57591167bf16fc55f6ee14f044e89179583d7..e6a9ed5dd9d145df1bf2b97a5ddd61273e7eca56 100644 (file)
@@ -1,3 +1,4 @@
+{if $entry.type}
 <tr>
   <td class="result" width="25">
     <img src="pix/{$entry.type}.png" border="0" width="16" height="16" align="middle" title="{$entry.type}">
@@ -22,4 +23,4 @@
     {/if}
   </td>
 </tr>
-
+{/if}