From f42d1c75316f76b00c3e1b4ae7f890048ae1b117 Mon Sep 17 00:00:00 2001
From: Andreas Gohr <andi@splitbrain.org>
Date: Thu, 27 Oct 2005 20:34:10 +0200
Subject: [PATCH] option for disabling debug output

darcs-hash:20051027183410-7ad00-5ca48cf2d4058016f5cf07887d9eaa7b07a4043f.gz
---
 conf/dokuwiki.php   | 1 +
 doku.php            | 2 +-
 inc/common.php      | 6 ++++++
 inc/parserutils.php | 6 +++---
 lib/exe/detail.php  | 3 +--
 5 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/conf/dokuwiki.php b/conf/dokuwiki.php
index 87639ddd8..d12fb27fc 100644
--- a/conf/dokuwiki.php
+++ b/conf/dokuwiki.php
@@ -37,6 +37,7 @@ $conf['deaccent']    = 1;                 //convert accented chars to unaccented
 $conf['useheading']  = 0;                 //use the first heading in a page as its name
 $conf['refcheck']    = 1;                 //check for references before deleting media files
 $conf['refshow']     = 0;                 //how many references should be shown, 5 is a good value
+$conf['allowdebug']  = 1;                 //make debug possible, disable after install! 0|1
 
 /* Antispam Features */
 
diff --git a/doku.php b/doku.php
index ba4dac1fd..7913354f7 100644
--- a/doku.php
+++ b/doku.php
@@ -45,7 +45,7 @@
   if(empty($ACT)) $ACT = 'show';
 
 
-  if($ACT == 'debug'){
+  if($conf['allowdebug'] && $ACT == 'debug'){
     html_debug();
     exit;
   }
diff --git a/inc/common.php b/inc/common.php
index e5ab385ca..531e11477 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -1120,6 +1120,12 @@ function check(){
   }else{
     msg('mb_string extension not available - PHP only replacements will be used',0);
   }
+
+  if($conf['allowdebug']){
+    msg('Debugging support is enabled. If you don\'t need it you should set $conf[\'allowdebug\'] = 0',-1);
+  }else{
+    msg('Debugging support is disabled',1);
+  }
  
   msg('Your current permission for this page is '.$INFO['perm'],0);
 
diff --git a/inc/parserutils.php b/inc/parserutils.php
index ba8d8df36..7a263bf22 100644
--- a/inc/parserutils.php
+++ b/inc/parserutils.php
@@ -90,16 +90,16 @@ function p_cached_xhtml($file){
   {
     //well then use the cache
     $parsed = io_readfile($cache);
-    $parsed .= "\n<!-- cachefile $cache used -->\n";
+    if($conf['allowdebug']) $parsed .= "\n<!-- cachefile $cache used -->\n";
   }else{
     $parsed = p_render('xhtml', p_cached_instructions($file),$info); //try to use cached instructions
 
     if($info['cache']){
       io_saveFile($cache,$parsed); //save cachefile
-      $parsed .= "\n<!-- no cachefile used, but created -->\n";
+      if($conf['allowdebug']) $parsed .= "\n<!-- no cachefile used, but created -->\n";
     }else{
       @unlink($cache); //try to delete cachefile
-      $parsed .= "\n<!-- no cachefile used, caching forbidden -->\n";
+      if($conf['allowdebug']) $parsed .= "\n<!-- no cachefile used, caching forbidden -->\n";
     }
   }
 
diff --git a/lib/exe/detail.php b/lib/exe/detail.php
index 5d7de0119..a090039cb 100644
--- a/lib/exe/detail.php
+++ b/lib/exe/detail.php
@@ -14,8 +14,7 @@
   $IMG  = getID('media');
   $ID   = cleanID($_REQUEST['id']);
 
-	//FIXME remove me later
-	if($_REQUEST['debug']){
+	if($conf['allowdebug'] && $_REQUEST['debug']){
 			print '<pre>';
 			foreach(explode(' ','basedir userewrite baseurl useslash') as $x){
 					print '$'."conf['$x'] = '".$conf[$x]."';\n";
-- 
GitLab