diff options
Diffstat (limited to 'inc/common.php')
-rw-r--r-- | inc/common.php | 218 |
1 files changed, 8 insertions, 210 deletions
diff --git a/inc/common.php b/inc/common.php index 016c7922d..271446f55 100644 --- a/inc/common.php +++ b/inc/common.php @@ -6,13 +6,14 @@ * @author Andreas Gohr <andi@splitbrain.org> */ - if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/'); - require_once(DOKU_CONF.'dokuwiki.php'); - require_once(DOKU_INC.'inc/io.php'); - require_once(DOKU_INC.'inc/changelog.php'); - require_once(DOKU_INC.'inc/utf8.php'); - require_once(DOKU_INC.'inc/mail.php'); - require_once(DOKU_INC.'inc/parserutils.php'); +if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/'); +require_once(DOKU_CONF.'dokuwiki.php'); +require_once(DOKU_INC.'inc/io.php'); +require_once(DOKU_INC.'inc/changelog.php'); +require_once(DOKU_INC.'inc/utf8.php'); +require_once(DOKU_INC.'inc/mail.php'); +require_once(DOKU_INC.'inc/parserutils.php'); +require_once(DOKU_INC.'inc/infoutils.php'); /** * These constants are used with the recents function @@ -169,45 +170,6 @@ function buildAttributes($params){ /** - * print a message - * - * If HTTP headers were not sent yet the message is added - * to the global message array else it's printed directly - * using html_msgarea() - * - * - * Levels can be: - * - * -1 error - * 0 info - * 1 success - * - * @author Andreas Gohr <andi@splitbrain.org> - * @see html_msgarea - */ -function msg($message,$lvl=0,$line='',$file=''){ - global $MSG; - $errors[-1] = 'error'; - $errors[0] = 'info'; - $errors[1] = 'success'; - - if($line || $file) $message.=' ['.basename($file).':'.$line.']'; - - if(!headers_sent()){ - if(!isset($MSG)) $MSG = array(); - $MSG[]=array('lvl' => $errors[$lvl], 'msg' => $message); - }else{ - $MSG = array(); - $MSG[]=array('lvl' => $errors[$lvl], 'msg' => $message); - if(function_exists('html_msgarea')){ - html_msgarea(); - }else{ - print "ERROR($lvl) $message"; - } - } -} - -/** * This builds the breadcrumb trail and returns it as array * * @author Andreas Gohr <andi@splitbrain.org> @@ -696,34 +658,6 @@ function con($pre,$text,$suf,$pretty=false){ } /** - * print debug messages - * - * little function to print the content of a var - * - * @author Andreas Gohr <andi@splitbrain.org> - */ -function dbg($msg,$hidden=false){ - (!$hidden) ? print '<pre class="dbg">' : print "<!--\n"; - print_r($msg); - (!$hidden) ? print '</pre>' : print "\n-->"; -} - -/** - * Print info to a log file - * - * @author Andreas Gohr <andi@splitbrain.org> - */ -function dbglog($msg){ - global $conf; - $file = $conf['cachedir'].'/debug.log'; - $fh = fopen($file,'a'); - if($fh){ - fwrite($fh,date('H:i:s ').$_SERVER['REMOTE_ADDR'].': '.$msg."\n"); - fclose($fh); - } -} - -/** * Saves a wikitext by calling io_writeWikiPage * * @author Andreas Gohr <andi@splitbrain.org> @@ -969,142 +903,6 @@ function obfuscate($email) { } /** - * Return DokuWikis version - * - * @author Andreas Gohr <andi@splitbrain.org> - */ -function getVersion(){ - //import version string - if(@file_exists('VERSION')){ - //official release - return 'Release '.trim(io_readfile(DOKU_INC.'/VERSION')); - }elseif(is_dir('_darcs')){ - //darcs checkout - read last 2000 bytes of inventory - $sz = filesize('_darcs/inventory'); - $seek = max(0,$sz-2000); - $fh = fopen('_darcs/inventory','rb'); - fseek($fh,$seek); - $chunk = fread($fh,2000); - fclose($fh); - $inv = preg_grep('#\*\*\d{14}[\]$]#',explode("\n",$chunk)); - $cur = array_pop($inv); - preg_match('#\*\*(\d{4})(\d{2})(\d{2})#',$cur,$matches); - return 'Darcs '.$matches[1].'-'.$matches[2].'-'.$matches[3]; - }else{ - return 'snapshot?'; - } -} - -/** - * Run a few sanity checks - * - * @author Andreas Gohr <andi@splitbrain.org> - */ -function check(){ - global $conf; - global $INFO; - - msg('DokuWiki version: '.getVersion(),1); - - if(version_compare(phpversion(),'4.3.0','<')){ - msg('Your PHP version is too old ('.phpversion().' vs. 4.3.+ recommended)',-1); - }elseif(version_compare(phpversion(),'4.3.10','<')){ - msg('Consider upgrading PHP to 4.3.10 or higher for security reasons (your version: '.phpversion().')',0); - }else{ - msg('PHP version '.phpversion(),1); - } - - if(is_writable($conf['changelog'])){ - msg('Changelog is writable',1); - }else{ - if (@file_exists($conf['changelog'])) { - msg('Changelog is not writable',-1); - } - } - - if (isset($conf['changelog_old']) && @file_exists($conf['changelog_old'])) { - msg('Old changelog exists.', 0); - } - - if (@file_exists($conf['changelog'].'_failed')) { - msg('Importing old changelog failed.', -1); - } else if (@file_exists($conf['changelog'].'_importing')) { - msg('Importing old changelog now.', 0); - } else if (@file_exists($conf['changelog'].'_import_ok')) { - msg('Old changelog imported.', 1); - if (!plugin_isdisabled('importoldchangelog')) { - msg('Importoldchangelog plugin not disabled after import.', -1); - } - } - - if(is_writable($conf['datadir'])){ - msg('Datadir is writable',1); - }else{ - msg('Datadir is not writable',-1); - } - - if(is_writable($conf['olddir'])){ - msg('Attic is writable',1); - }else{ - msg('Attic is not writable',-1); - } - - if(is_writable($conf['mediadir'])){ - msg('Mediadir is writable',1); - }else{ - msg('Mediadir is not writable',-1); - } - - if(is_writable($conf['cachedir'])){ - msg('Cachedir is writable',1); - }else{ - msg('Cachedir is not writable',-1); - } - - if(is_writable($conf['lockdir'])){ - msg('Lockdir is writable',1); - }else{ - msg('Lockdir is not writable',-1); - } - - if(is_writable(DOKU_CONF.'users.auth.php')){ - msg('conf/users.auth.php is writable',1); - }else{ - msg('conf/users.auth.php is not writable',0); - } - - if(function_exists('mb_strpos')){ - if(defined('UTF8_NOMBSTRING')){ - msg('mb_string extension is available but will not be used',0); - }else{ - msg('mb_string extension is available and will be used',1); - } - }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); - - if(is_writable($INFO['filepath'])){ - msg('The current page is writable by the webserver',0); - }else{ - msg('The current page is not writable by the webserver',0); - } - - if($INFO['writable']){ - msg('The current page is writable by you',0); - }else{ - msg('The current page is not writable you',0); - } -} - -/** * Let us know if a user is tracking a page * * @author Andreas Gohr <andi@splitbrain.org> |