From bb4866bd74ec6b55bf41e75c158d940dced91f2f Mon Sep 17 00:00:00 2001
From: chris <chris@jalakai.co.uk>
Date: Sat, 23 Sep 2006 22:36:09 +0200
Subject: [PATCH] minor bugfix and boring error removal

darcs-hash:20060923203609-9b6ab-ecca679faa254a29772868508050fcf3206b0814.gz
---
 inc/actions.php                   |  2 +-
 inc/auth.php                      |  2 +-
 inc/cache.php                     |  1 +
 inc/common.php                    |  7 ++++---
 inc/html.php                      |  4 ++--
 inc/init.php                      |  6 +++---
 inc/io.php                        |  4 ++--
 inc/parser/xhtml.php              | 10 +++++-----
 inc/template.php                  |  8 ++++----
 lib/plugins/usermanager/admin.php |  1 +
 10 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/inc/actions.php b/inc/actions.php
index cbbbeead6..e3ddfecc0 100644
--- a/inc/actions.php
+++ b/inc/actions.php
@@ -94,7 +94,7 @@ function act_dispatch(){
     //handle admin tasks
     if($ACT == 'admin'){
       // retrieve admin plugin name from $_REQUEST['page']
-      if ($_REQUEST['page']) {
+      if (!empty($_REQUEST['page'])) {
           $pluginlist = plugin_list('admin');
           if (in_array($_REQUEST['page'], $pluginlist)) {
             // attempt to load the plugin
diff --git a/inc/auth.php b/inc/auth.php
index 63f84e141..987de8595 100644
--- a/inc/auth.php
+++ b/inc/auth.php
@@ -543,7 +543,7 @@ function updateprofile() {
   global $lang;
   global $auth;
 
-  if(!$_POST['save']) return false;
+  if(empty($_POST['save'])) return false;
 
   // should not be able to get here without Profile being possible...
   if(!$auth->canDo('Profile')) {
diff --git a/inc/cache.php b/inc/cache.php
index 491fe1923..ae27f4e9e 100644
--- a/inc/cache.php
+++ b/inc/cache.php
@@ -181,6 +181,7 @@ class cache_parser extends cache {
   }
 
   function _addDependencies() {
+    global $conf;
 
     $this->depends['age'] = isset($this->depends['age']) ? 
                    min($this->depends['age'],$conf['cachetime']) : $conf['cachetime'];
diff --git a/inc/common.php b/inc/common.php
index 271446f55..9a3cd6d8b 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -103,8 +103,9 @@ function pageinfo(){
   if($REV){
     $revinfo = getRevisionInfo($ID, $REV, 1024);
   }else{
-    $revinfo = $info['meta']['last_change'];
+    $revinfo = isset($info['meta']['last_change']) ? $info['meta']['last_change'] : getRevisionInfo($ID,$info['lastmod'],1024);
   }
+
   $info['ip']     = $revinfo['ip'];
   $info['user']   = $revinfo['user'];
   $info['sum']    = $revinfo['sum'];
@@ -455,9 +456,9 @@ function checkwordblock(){
 function clientIP($single=false){
   $ip = array();
   $ip[] = $_SERVER['REMOTE_ADDR'];
-  if($_SERVER['HTTP_X_FORWARDED_FOR'])
+  if(!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
     $ip = array_merge($ip,explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']));
-  if($_SERVER['HTTP_X_REAL_IP'])
+  if(!empty($_SERVER['HTTP_X_REAL_IP']))
     $ip = array_merge($ip,explode(',',$_SERVER['HTTP_X_REAL_IP']));
 
   // remove any non-IP stuff
diff --git a/inc/html.php b/inc/html.php
index ee1f60919..46e6bd8c6 100644
--- a/inc/html.php
+++ b/inc/html.php
@@ -1076,7 +1076,7 @@ function html_edit($text=null,$include='edit'){ //FIXME: include needed?
   <div style="width:99%;">
 
    <div class="toolbar">
-      <div id="draft__status"><?php if($INFO['draft']) echo $lang['draftdate'].' '.date($conf['dformat']);?></div>
+      <div id="draft__status"><?php if(!empty($INFO['draft'])) echo $lang['draftdate'].' '.date($conf['dformat']);?></div>
       <div id="tool__bar"><?php if(!$ro){?><a href="<?php echo DOKU_BASE?>lib/exe/mediamanager.php?ns=<?php echo $INFO['namespace']?>"
       target="_blank"><?php echo $lang['mediaselect'] ?></a><?php }?></div>
 
@@ -1143,7 +1143,7 @@ function html_minoredit(){
   $p['id']       = 'minoredit';
   $p['tabindex'] = 3;
   $p['value']    = '1';
-  if($_REQUEST['minor']) $p['checked']='checked';
+  if(!empty($_REQUEST['minor'])) $p['checked']='checked';
   $att = buildAttributes($p);
 
   print '<span class="nowrap">';
diff --git a/inc/init.php b/inc/init.php
index 1b8f99825..d28e179c3 100644
--- a/inc/init.php
+++ b/inc/init.php
@@ -133,9 +133,9 @@ function init_paths(){
                  'lockdir'   => 'locks');
 
   foreach($paths as $c => $p){
-    if(!$conf[$c])   $conf[$c] = $conf['savedir'].'/'.$p;
-    $conf[$c]        = init_path($conf[$c]);
-    if(!$conf[$c])   nice_die("The $c does not exist, isn't accessable or writable.
+    if(empty($conf[$c]))  $conf[$c] = $conf['savedir'].'/'.$p;
+    $conf[$c]             = init_path($conf[$c]);
+    if(empty($conf[$c]))  nice_die("The $c does not exist, isn't accessable or writable.
                                You should check your config and permission settings.
                                Or maybe you want to <a href=\"install.php\">run the
                                installer</a>?");
diff --git a/inc/io.php b/inc/io.php
index 5fd1d6673..3bcde79ce 100644
--- a/inc/io.php
+++ b/inc/io.php
@@ -199,7 +199,7 @@ function io_saveFile($file,$content,$append=false){
     fclose($fh);
   }
 
-  if(!$fileexists and $conf['fperm']) chmod($file, $conf['fperm']);
+  if(!$fileexists and !empty($conf['fperm'])) chmod($file, $conf['fperm']);
   io_unlock($file);
   return true;
 }
@@ -291,7 +291,7 @@ function io_lock($file){
     if ((time() - $timeStart) > 3) break;
     $locked = @mkdir($lockDir, $conf['dmode']);
     if($locked){
-      if($conf['dperm']) chmod($lockDir, $conf['dperm']);
+      if(!empty($conf['dperm'])) chmod($lockDir, $conf['dperm']);
       break;
     }
     usleep(50);
diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index 5190e7916..d896d8eab 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -915,11 +915,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
         $ret  = '';
         $ret .= $link['pre'];
         $ret .= '<a href="'.$link['url'].'"';
-        if($link['class'])  $ret .= ' class="'.$link['class'].'"';
-        if($link['target']) $ret .= ' target="'.$link['target'].'"';
-        if($link['title'])  $ret .= ' title="'.$link['title'].'"';
-        if($link['style'])  $ret .= ' style="'.$link['style'].'"';
-        if($link['more'])   $ret .= ' '.$link['more'];
+        if(!empty($link['class']))  $ret .= ' class="'.$link['class'].'"';
+        if(!empty($link['target'])) $ret .= ' target="'.$link['target'].'"';
+        if(!empty($link['title']))  $ret .= ' title="'.$link['title'].'"';
+        if(!empty($link['style']))  $ret .= ' style="'.$link['style'].'"';
+        if(!empty($link['more']))   $ret .= ' '.$link['more'];
         $ret .= '>';
         $ret .= $link['name'];
         $ret .= '</a>';
diff --git a/inc/template.php b/inc/template.php
index b03a0b2ee..bcfbff8ea 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -139,7 +139,7 @@ function tpl_content_core(){
 function tpl_admin(){
 
     $plugin = NULL;
-    if ($_REQUEST['page']) {
+    if (!empty($_REQUEST['page'])) {
         $pluginlist = plugin_list('admin');
 
         if (in_array($_REQUEST['page'], $pluginlist)) {
@@ -181,7 +181,7 @@ function tpl_metaheaders($alt=true){
   $head['meta'][] = array( 'name'=>'generator', 'content'=>'DokuWiki '.getVersion() );
   $head['link'][] = array( 'rel'=>'start', 'href'=>'DOKU_BASE' );
   $head['link'][] = array( 'rel'=>'contents', 'href'=> wl($ID,'do=index',false,'&'),
-                           'title'=>$lang['index'] );
+                           'title'=>$lang['btn_index'] );
 
   if($alt){
     $head['link'][] = array( 'rel'=>'alternate', 'type'=>'application/rss+xml',
@@ -223,7 +223,7 @@ function tpl_metaheaders($alt=true){
     }
 
     // keywords (explicit or implicit)
-    if($INFO['meta']['subject']){
+    if(!empty($INFO['meta']['subject'])){
       $head['meta'][] = array( 'name'=>'keywords', 'content'=>join(',',$INFO['meta']['subject']));
     }else{
       $head['meta'][] = array( 'name'=>'keywords', 'content'=>str_replace(':',',',$ID));
@@ -369,7 +369,7 @@ function tpl_button($type){
       #most complicated type - we need to decide on current action
       if($ACT == 'show' || $ACT == 'search'){
         if($INFO['writable']){
-          if($INFO['draft']){
+          if(!empty($INFO['draft'])){
             echo html_btn('draft',$ID,'e',array('do' => 'draft'),'post');
           }else{
             if($INFO['exists']){
diff --git a/lib/plugins/usermanager/admin.php b/lib/plugins/usermanager/admin.php
index 1335c9ef1..9e5133de3 100644
--- a/lib/plugins/usermanager/admin.php
+++ b/lib/plugins/usermanager/admin.php
@@ -255,6 +255,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin {
      */
     function _htmlUserForm($cmd,$user='',$userdata=array(),$indent=0) {
         global $conf;
+        global $ID;
 
         $name = $mail = $groups = '';
         $notes = array();
-- 
GitLab