1c29dc6e4SAndreas Gohr<?php 2c29dc6e4SAndreas Gohr/** 3c29dc6e4SAndreas Gohr * Information and debugging functions 4c29dc6e4SAndreas Gohr * 5c29dc6e4SAndreas Gohr * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6c29dc6e4SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 7c29dc6e4SAndreas Gohr */ 8fa8adffeSAndreas Gohrif(!defined('DOKU_INC')) die('meh.'); 93d7760aaSAndreas Gohrif(!defined('DOKU_MESSAGEURL')) define('DOKU_MESSAGEURL','http://update.dokuwiki.org/check/'); 10c29dc6e4SAndreas Gohr 11c29dc6e4SAndreas Gohr/** 12c29dc6e4SAndreas Gohr * Check for new messages from upstream 13c29dc6e4SAndreas Gohr * 14c29dc6e4SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 15c29dc6e4SAndreas Gohr */ 16c29dc6e4SAndreas Gohrfunction checkUpdateMessages(){ 17c29dc6e4SAndreas Gohr global $conf; 18c29dc6e4SAndreas Gohr global $INFO; 19c29dc6e4SAndreas Gohr if(!$conf['updatecheck']) return; 20f8cc712eSAndreas Gohr if($conf['useacl'] && !$INFO['ismanager']) return; 21c29dc6e4SAndreas Gohr 22c29dc6e4SAndreas Gohr $cf = $conf['cachedir'].'/messages.txt'; 23c29dc6e4SAndreas Gohr $lm = @filemtime($cf); 24c29dc6e4SAndreas Gohr 25c29dc6e4SAndreas Gohr // check if new messages needs to be fetched 26c29dc6e4SAndreas Gohr if($lm < time()-(60*60*24) || $lm < @filemtime(DOKU_CONF.'msg')){ 27587afae5Schris $num = @file(DOKU_CONF.'msg'); 28587afae5Schris $num = is_array($num) ? (int) $num[0] : 0; 29c29dc6e4SAndreas Gohr $http = new DokuHTTPClient(); 30c29dc6e4SAndreas Gohr $http->timeout = 8; 31c29dc6e4SAndreas Gohr $data = $http->get(DOKU_MESSAGEURL.$num); 32c29dc6e4SAndreas Gohr io_saveFile($cf,$data); 33c29dc6e4SAndreas Gohr }else{ 34c29dc6e4SAndreas Gohr $data = io_readFile($cf); 35c29dc6e4SAndreas Gohr } 36c29dc6e4SAndreas Gohr 37c29dc6e4SAndreas Gohr // show messages through the usual message mechanism 38c29dc6e4SAndreas Gohr $msgs = explode("\n%\n",$data); 39c29dc6e4SAndreas Gohr foreach($msgs as $msg){ 40c29dc6e4SAndreas Gohr if($msg) msg($msg,2); 41c29dc6e4SAndreas Gohr } 42c29dc6e4SAndreas Gohr} 43c29dc6e4SAndreas Gohr 44c29dc6e4SAndreas Gohr 45c29dc6e4SAndreas Gohr/** 4625c07f93SAnika Henke * Return DokuWiki's version (split up in date and type) 47c29dc6e4SAndreas Gohr * 48c29dc6e4SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 49c29dc6e4SAndreas Gohr */ 5025c07f93SAnika Henkefunction getVersionData(){ 5125c07f93SAnika Henke $version = array(); 52c29dc6e4SAndreas Gohr //import version string 53e9208eb1SAndreas Gohr if(@file_exists(DOKU_INC.'VERSION')){ 54c29dc6e4SAndreas Gohr //official release 5525c07f93SAnika Henke $version['date'] = trim(io_readfile(DOKU_INC.'VERSION')); 5625c07f93SAnika Henke $version['type'] = 'Release'; 575cf31920SAndreas Gohr }elseif(is_dir(DOKU_INC.'.git')){ 585cf31920SAndreas Gohr $version['type'] = 'Git'; 5925c07f93SAnika Henke $version['date'] = 'unknown'; 60e570ed43SAndreas Gohr 615cf31920SAndreas Gohr $inventory = DOKU_INC.'.git/logs/HEAD'; 625cf31920SAndreas Gohr if(is_file($inventory)){ 63e570ed43SAndreas Gohr $sz = filesize($inventory); 645cf31920SAndreas Gohr $seek = max(0,$sz-2000); // read from back of the file 65e570ed43SAndreas Gohr $fh = fopen($inventory,'rb'); 66c29dc6e4SAndreas Gohr fseek($fh,$seek); 67c29dc6e4SAndreas Gohr $chunk = fread($fh,2000); 68c29dc6e4SAndreas Gohr fclose($fh); 695cf31920SAndreas Gohr $chunk = trim($chunk); 705cf31920SAndreas Gohr $chunk = array_pop(explode("\n",$chunk)); //last log line 715cf31920SAndreas Gohr $chunk = array_shift(explode("\t",$chunk)); //strip commit msg 725cf31920SAndreas Gohr $chunk = explode(" ",$chunk); 735cf31920SAndreas Gohr array_pop($chunk); //strip timezone 745cf31920SAndreas Gohr $date = date('Y-m-d',array_pop($chunk)); 755cf31920SAndreas Gohr if($date) $version['date'] = $date; 765cf31920SAndreas Gohr } 77c29dc6e4SAndreas Gohr }else{ 7825c07f93SAnika Henke $version['date'] = 'unknown'; 7925c07f93SAnika Henke $version['type'] = 'snapshot?'; 80c29dc6e4SAndreas Gohr } 815cf31920SAndreas Gohr return $version; 82c29dc6e4SAndreas Gohr} 83c29dc6e4SAndreas Gohr 84c29dc6e4SAndreas Gohr/** 8525c07f93SAnika Henke * Return DokuWiki's version (as a string) 8625c07f93SAnika Henke * 8725c07f93SAnika Henke * @author Anika Henke <anika@selfthinker.org> 8825c07f93SAnika Henke */ 8925c07f93SAnika Henkefunction getVersion(){ 9025c07f93SAnika Henke $version = getVersionData(); 9125c07f93SAnika Henke return $version['type'].' '.$version['date']; 9225c07f93SAnika Henke} 9325c07f93SAnika Henke 9425c07f93SAnika Henke/** 95c29dc6e4SAndreas Gohr * Run a few sanity checks 96c29dc6e4SAndreas Gohr * 97c29dc6e4SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 98c29dc6e4SAndreas Gohr */ 99c29dc6e4SAndreas Gohrfunction check(){ 100c29dc6e4SAndreas Gohr global $conf; 101c29dc6e4SAndreas Gohr global $INFO; 102c29dc6e4SAndreas Gohr 103*3f803e5eSGina Haeussge if ($INFO['isadmin'] || $INFO['ismanager']){ 104c29dc6e4SAndreas Gohr msg('DokuWiki version: '.getVersion(),1); 105*3f803e5eSGina Haeussge } 106c29dc6e4SAndreas Gohr 107ab91da89SAndreas Gohr if(version_compare(phpversion(),'5.1.2','<')){ 108ab91da89SAndreas Gohr msg('Your PHP version is too old ('.phpversion().' vs. 5.1.2+ needed)',-1); 109c29dc6e4SAndreas Gohr }else{ 110c29dc6e4SAndreas Gohr msg('PHP version '.phpversion(),1); 111c29dc6e4SAndreas Gohr } 112c29dc6e4SAndreas Gohr 11373038c47SAndreas Gohr $mem = (int) php_to_byte(ini_get('memory_limit')); 11473038c47SAndreas Gohr if($mem){ 11573038c47SAndreas Gohr if($mem < 16777216){ 11673038c47SAndreas Gohr msg('PHP is limited to less than 16MB RAM ('.$mem.' bytes). Increase memory_limit in php.ini',-1); 11773038c47SAndreas Gohr }elseif($mem < 20971520){ 11873038c47SAndreas Gohr msg('PHP is limited to less than 20MB RAM ('.$mem.' bytes), you might encounter problems with bigger pages. Increase memory_limit in php.ini',-1); 11973038c47SAndreas Gohr }elseif($mem < 33554432){ 12073038c47SAndreas Gohr msg('PHP is limited to less than 32MB RAM ('.$mem.' bytes), but that should be enough in most cases. If not, increase memory_limit in php.ini',0); 12173038c47SAndreas Gohr }else{ 12273038c47SAndreas Gohr msg('More than 32MB RAM ('.$mem.' bytes) available.',1); 12373038c47SAndreas Gohr } 12473038c47SAndreas Gohr } 12573038c47SAndreas Gohr 126c29dc6e4SAndreas Gohr if(is_writable($conf['changelog'])){ 127c29dc6e4SAndreas Gohr msg('Changelog is writable',1); 128c29dc6e4SAndreas Gohr }else{ 129c29dc6e4SAndreas Gohr if (@file_exists($conf['changelog'])) { 130c29dc6e4SAndreas Gohr msg('Changelog is not writable',-1); 131c29dc6e4SAndreas Gohr } 132c29dc6e4SAndreas Gohr } 133c29dc6e4SAndreas Gohr 134c29dc6e4SAndreas Gohr if (isset($conf['changelog_old']) && @file_exists($conf['changelog_old'])) { 1352cdbda06SAnika Henke msg('Old changelog exists', 0); 136c29dc6e4SAndreas Gohr } 137c29dc6e4SAndreas Gohr 138c29dc6e4SAndreas Gohr if (@file_exists($conf['changelog'].'_failed')) { 1392cdbda06SAnika Henke msg('Importing old changelog failed', -1); 140c29dc6e4SAndreas Gohr } else if (@file_exists($conf['changelog'].'_importing')) { 141c29dc6e4SAndreas Gohr msg('Importing old changelog now.', 0); 142c29dc6e4SAndreas Gohr } else if (@file_exists($conf['changelog'].'_import_ok')) { 1432cdbda06SAnika Henke msg('Old changelog imported', 1); 144c29dc6e4SAndreas Gohr if (!plugin_isdisabled('importoldchangelog')) { 1452cdbda06SAnika Henke msg('Importoldchangelog plugin not disabled after import', -1); 146c29dc6e4SAndreas Gohr } 147c29dc6e4SAndreas Gohr } 148c29dc6e4SAndreas Gohr 149c29dc6e4SAndreas Gohr if(is_writable($conf['datadir'])){ 150c29dc6e4SAndreas Gohr msg('Datadir is writable',1); 151c29dc6e4SAndreas Gohr }else{ 152c29dc6e4SAndreas Gohr msg('Datadir is not writable',-1); 153c29dc6e4SAndreas Gohr } 154c29dc6e4SAndreas Gohr 155c29dc6e4SAndreas Gohr if(is_writable($conf['olddir'])){ 156c29dc6e4SAndreas Gohr msg('Attic is writable',1); 157c29dc6e4SAndreas Gohr }else{ 158c29dc6e4SAndreas Gohr msg('Attic is not writable',-1); 159c29dc6e4SAndreas Gohr } 160c29dc6e4SAndreas Gohr 161c29dc6e4SAndreas Gohr if(is_writable($conf['mediadir'])){ 162c29dc6e4SAndreas Gohr msg('Mediadir is writable',1); 163c29dc6e4SAndreas Gohr }else{ 164c29dc6e4SAndreas Gohr msg('Mediadir is not writable',-1); 165c29dc6e4SAndreas Gohr } 166c29dc6e4SAndreas Gohr 167c29dc6e4SAndreas Gohr if(is_writable($conf['cachedir'])){ 168c29dc6e4SAndreas Gohr msg('Cachedir is writable',1); 169c29dc6e4SAndreas Gohr }else{ 170c29dc6e4SAndreas Gohr msg('Cachedir is not writable',-1); 171c29dc6e4SAndreas Gohr } 172c29dc6e4SAndreas Gohr 173c29dc6e4SAndreas Gohr if(is_writable($conf['lockdir'])){ 174c29dc6e4SAndreas Gohr msg('Lockdir is writable',1); 175c29dc6e4SAndreas Gohr }else{ 176c29dc6e4SAndreas Gohr msg('Lockdir is not writable',-1); 177c29dc6e4SAndreas Gohr } 178c29dc6e4SAndreas Gohr 1790d487d8fSAndreas Gohr if($conf['authtype'] == 'plain'){ 180c29dc6e4SAndreas Gohr if(is_writable(DOKU_CONF.'users.auth.php')){ 181c29dc6e4SAndreas Gohr msg('conf/users.auth.php is writable',1); 182c29dc6e4SAndreas Gohr }else{ 183c29dc6e4SAndreas Gohr msg('conf/users.auth.php is not writable',0); 184c29dc6e4SAndreas Gohr } 1850d487d8fSAndreas Gohr } 186c29dc6e4SAndreas Gohr 187c29dc6e4SAndreas Gohr if(function_exists('mb_strpos')){ 188c29dc6e4SAndreas Gohr if(defined('UTF8_NOMBSTRING')){ 189c29dc6e4SAndreas Gohr msg('mb_string extension is available but will not be used',0); 190c29dc6e4SAndreas Gohr }else{ 191c29dc6e4SAndreas Gohr msg('mb_string extension is available and will be used',1); 1924222b898SAndreas Gohr if(ini_get('mbstring.func_overload') != 0){ 1934222b898SAndreas Gohr msg('mb_string function overloading is enabled, this will cause problems and should be disabled',-1); 1944222b898SAndreas Gohr } 195c29dc6e4SAndreas Gohr } 196c29dc6e4SAndreas Gohr }else{ 197c29dc6e4SAndreas Gohr msg('mb_string extension not available - PHP only replacements will be used',0); 198c29dc6e4SAndreas Gohr } 199c29dc6e4SAndreas Gohr 200c29dc6e4SAndreas Gohr if($conf['allowdebug']){ 201c29dc6e4SAndreas Gohr msg('Debugging support is enabled. If you don\'t need it you should set $conf[\'allowdebug\'] = 0',-1); 202c29dc6e4SAndreas Gohr }else{ 203c29dc6e4SAndreas Gohr msg('Debugging support is disabled',1); 204c29dc6e4SAndreas Gohr } 205c29dc6e4SAndreas Gohr 2063d3c095dSMike Frysinger if($INFO['userinfo']['name']){ 207c1791678SAndreas Gohr msg('You are currently logged in as '.$_SERVER['REMOTE_USER'].' ('.$INFO['userinfo']['name'].')',0); 208c1791678SAndreas Gohr msg('You are part of the groups '.join($INFO['userinfo']['grps'],', '),0); 2093d3c095dSMike Frysinger }else{ 2103d3c095dSMike Frysinger msg('You are currently not logged in',0); 2113d3c095dSMike Frysinger } 2123d3c095dSMike Frysinger 213c29dc6e4SAndreas Gohr msg('Your current permission for this page is '.$INFO['perm'],0); 214c29dc6e4SAndreas Gohr 215c29dc6e4SAndreas Gohr if(is_writable($INFO['filepath'])){ 216c29dc6e4SAndreas Gohr msg('The current page is writable by the webserver',0); 217c29dc6e4SAndreas Gohr }else{ 218c29dc6e4SAndreas Gohr msg('The current page is not writable by the webserver',0); 219c29dc6e4SAndreas Gohr } 220c29dc6e4SAndreas Gohr 221c29dc6e4SAndreas Gohr if($INFO['writable']){ 222c29dc6e4SAndreas Gohr msg('The current page is writable by you',0); 223c29dc6e4SAndreas Gohr }else{ 2242cdbda06SAnika Henke msg('The current page is not writable by you',0); 225c29dc6e4SAndreas Gohr } 2263b1dfc83SAndreas Gohr 2273b1dfc83SAndreas Gohr $check = wl('','',true).'data/_dummy'; 2283b1dfc83SAndreas Gohr $http = new DokuHTTPClient(); 2293b1dfc83SAndreas Gohr $http->timeout = 6; 2303b1dfc83SAndreas Gohr $res = $http->get($check); 2313b1dfc83SAndreas Gohr if(strpos($res,'data directory') !== false){ 2323b1dfc83SAndreas Gohr msg('It seems like the data directory is accessible from the web. 2333b1dfc83SAndreas Gohr Make sure this directory is properly protected 2343b1dfc83SAndreas Gohr (See <a href="http://www.dokuwiki.org/security">security</a>)',-1); 2353b1dfc83SAndreas Gohr }elseif($http->status == 404 || $http->status == 403){ 2363b1dfc83SAndreas Gohr msg('The data directory seems to be properly protected',1); 2373b1dfc83SAndreas Gohr }else{ 2383b1dfc83SAndreas Gohr msg('Failed to check if the data directory is accessible from the web. 2393b1dfc83SAndreas Gohr Make sure this directory is properly protected 2403b1dfc83SAndreas Gohr (See <a href="http://www.dokuwiki.org/security">security</a>)',-1); 2413b1dfc83SAndreas Gohr } 242c29dc6e4SAndreas Gohr} 243c29dc6e4SAndreas Gohr 244c29dc6e4SAndreas Gohr/** 245c29dc6e4SAndreas Gohr * print a message 246c29dc6e4SAndreas Gohr * 247c29dc6e4SAndreas Gohr * If HTTP headers were not sent yet the message is added 248c29dc6e4SAndreas Gohr * to the global message array else it's printed directly 249c29dc6e4SAndreas Gohr * using html_msgarea() 250c29dc6e4SAndreas Gohr * 251c29dc6e4SAndreas Gohr * 252c29dc6e4SAndreas Gohr * Levels can be: 253c29dc6e4SAndreas Gohr * 254c29dc6e4SAndreas Gohr * -1 error 255c29dc6e4SAndreas Gohr * 0 info 256c29dc6e4SAndreas Gohr * 1 success 257c29dc6e4SAndreas Gohr * 258c29dc6e4SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 259c29dc6e4SAndreas Gohr * @see html_msgarea 260c29dc6e4SAndreas Gohr */ 261c29dc6e4SAndreas Gohrfunction msg($message,$lvl=0,$line='',$file=''){ 262c29dc6e4SAndreas Gohr global $MSG; 263c29dc6e4SAndreas Gohr $errors[-1] = 'error'; 264c29dc6e4SAndreas Gohr $errors[0] = 'info'; 265c29dc6e4SAndreas Gohr $errors[1] = 'success'; 266c29dc6e4SAndreas Gohr $errors[2] = 'notify'; 267c29dc6e4SAndreas Gohr 268c29dc6e4SAndreas Gohr if($line || $file) $message.=' ['.basename($file).':'.$line.']'; 269c29dc6e4SAndreas Gohr 270c29dc6e4SAndreas Gohr if(!isset($MSG)) $MSG = array(); 271c29dc6e4SAndreas Gohr $MSG[]=array('lvl' => $errors[$lvl], 'msg' => $message); 27269266de5SDominik Eckelmann if(headers_sent()){ 273c29dc6e4SAndreas Gohr if(function_exists('html_msgarea')){ 274c29dc6e4SAndreas Gohr html_msgarea(); 275c29dc6e4SAndreas Gohr }else{ 276c29dc6e4SAndreas Gohr print "ERROR($lvl) $message"; 277c29dc6e4SAndreas Gohr } 27869266de5SDominik Eckelmann unset($GLOBALS['MSG']); 279c29dc6e4SAndreas Gohr } 280c29dc6e4SAndreas Gohr} 281c29dc6e4SAndreas Gohr 282c29dc6e4SAndreas Gohr/** 283c29dc6e4SAndreas Gohr * print debug messages 284c29dc6e4SAndreas Gohr * 285c29dc6e4SAndreas Gohr * little function to print the content of a var 286c29dc6e4SAndreas Gohr * 287c29dc6e4SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 288c29dc6e4SAndreas Gohr */ 289c29dc6e4SAndreas Gohrfunction dbg($msg,$hidden=false){ 29013493794SAndreas Gohr if($hidden){ 29113493794SAndreas Gohr echo "<!--\n"; 292c29dc6e4SAndreas Gohr print_r($msg); 29313493794SAndreas Gohr echo "\n-->"; 29413493794SAndreas Gohr }else{ 29513493794SAndreas Gohr echo '<pre class="dbg">'; 29613493794SAndreas Gohr echo hsc(print_r($msg,true)); 29713493794SAndreas Gohr echo '</pre>'; 29813493794SAndreas Gohr } 299c29dc6e4SAndreas Gohr} 300c29dc6e4SAndreas Gohr 301c29dc6e4SAndreas Gohr/** 302c29dc6e4SAndreas Gohr * Print info to a log file 303c29dc6e4SAndreas Gohr * 304c29dc6e4SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 305c29dc6e4SAndreas Gohr */ 3060699d739SAndreas Gohrfunction dbglog($msg,$header=''){ 307c29dc6e4SAndreas Gohr global $conf; 308c7408a63SAndreas Gohr if(is_object($msg) || is_array($msg)){ 309c7408a63SAndreas Gohr $msg = print_r($msg,true); 310c7408a63SAndreas Gohr } 311c7408a63SAndreas Gohr 3120699d739SAndreas Gohr if($header) $msg = "$header\n$msg"; 3130699d739SAndreas Gohr 314c29dc6e4SAndreas Gohr $file = $conf['cachedir'].'/debug.log'; 315c29dc6e4SAndreas Gohr $fh = fopen($file,'a'); 316c29dc6e4SAndreas Gohr if($fh){ 317c29dc6e4SAndreas Gohr fwrite($fh,date('H:i:s ').$_SERVER['REMOTE_ADDR'].': '.$msg."\n"); 318c29dc6e4SAndreas Gohr fclose($fh); 319c29dc6e4SAndreas Gohr } 320c29dc6e4SAndreas Gohr} 321c29dc6e4SAndreas Gohr 322db09e31eSAndreas Gohr/** 323db09e31eSAndreas Gohr * Print a reversed, prettyprinted backtrace 324db09e31eSAndreas Gohr * 325db09e31eSAndreas Gohr * @author Gary Owen <gary_owen@bigfoot.com> 326db09e31eSAndreas Gohr */ 327db09e31eSAndreas Gohrfunction dbg_backtrace(){ 328db09e31eSAndreas Gohr // Get backtrace 329db09e31eSAndreas Gohr $backtrace = debug_backtrace(); 330db09e31eSAndreas Gohr 331db09e31eSAndreas Gohr // Unset call to debug_print_backtrace 332db09e31eSAndreas Gohr array_shift($backtrace); 333db09e31eSAndreas Gohr 334db09e31eSAndreas Gohr // Iterate backtrace 335db09e31eSAndreas Gohr $calls = array(); 336db09e31eSAndreas Gohr $depth = count($backtrace) - 1; 337db09e31eSAndreas Gohr foreach ($backtrace as $i => $call) { 338db09e31eSAndreas Gohr $location = $call['file'] . ':' . $call['line']; 339db09e31eSAndreas Gohr $function = (isset($call['class'])) ? 340db09e31eSAndreas Gohr $call['class'] . $call['type'] . $call['function'] : $call['function']; 341db09e31eSAndreas Gohr 3428259f1aaSAndreas Gohr $params = array(); 343db09e31eSAndreas Gohr if (isset($call['args'])){ 3448259f1aaSAndreas Gohr foreach($call['args'] as $arg){ 3458259f1aaSAndreas Gohr if(is_object($arg)){ 3468259f1aaSAndreas Gohr $params[] = '[Object '.get_class($arg).']'; 3478259f1aaSAndreas Gohr }elseif(is_array($arg)){ 3488259f1aaSAndreas Gohr $params[] = '[Array]'; 3498259f1aaSAndreas Gohr }elseif(is_null($arg)){ 3508259f1aaSAndreas Gohr $param[] = '[NULL]'; 3518259f1aaSAndreas Gohr }else{ 3528259f1aaSAndreas Gohr $params[] = (string) '"'.$arg.'"'; 353db09e31eSAndreas Gohr } 3548259f1aaSAndreas Gohr } 3558259f1aaSAndreas Gohr } 3568259f1aaSAndreas Gohr $params = implode(', ',$params); 357db09e31eSAndreas Gohr 3588259f1aaSAndreas Gohr $calls[$depth - $i] = sprintf('%s(%s) called at %s', 359db09e31eSAndreas Gohr $function, 360db09e31eSAndreas Gohr str_replace("\n", '\n', $params), 361db09e31eSAndreas Gohr $location); 362db09e31eSAndreas Gohr } 363db09e31eSAndreas Gohr ksort($calls); 364db09e31eSAndreas Gohr 365db09e31eSAndreas Gohr return implode("\n", $calls); 366db09e31eSAndreas Gohr} 367db09e31eSAndreas Gohr 36824297a69SAndreas Gohr/** 36924297a69SAndreas Gohr * Remove all data from an array where the key seems to point to sensitive data 37024297a69SAndreas Gohr * 37124297a69SAndreas Gohr * This is used to remove passwords, mail addresses and similar data from the 37224297a69SAndreas Gohr * debug output 37324297a69SAndreas Gohr * 37424297a69SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 37524297a69SAndreas Gohr */ 37624297a69SAndreas Gohrfunction debug_guard(&$data){ 37724297a69SAndreas Gohr foreach($data as $key => $value){ 37824297a69SAndreas Gohr if(preg_match('/(notify|pass|auth|secret|ftp|userinfo|token|buid|mail|proxy)/i',$key)){ 37924297a69SAndreas Gohr $data[$key] = '***'; 38024297a69SAndreas Gohr continue; 38124297a69SAndreas Gohr } 38224297a69SAndreas Gohr if(is_array($value)) debug_guard($data[$key]); 38324297a69SAndreas Gohr } 38424297a69SAndreas Gohr} 385