summaryrefslogtreecommitdiff
path: root/inc/infoutils.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2009-10-20 23:23:38 +0200
committerAndreas Gohr <andi@splitbrain.org>2009-10-20 23:23:38 +0200
commitdb959ae30700e3924a73350a3a43a2c36b431de7 (patch)
treef89b3fb0609abb72cf93fa8060f7fc27f4c15f40 /inc/infoutils.php
parent8ec3f7bdbf7a5f702a3022332a6f6cb424d0981a (diff)
downloadrpg-db959ae30700e3924a73350a3a43a2c36b431de7.tar.gz
rpg-db959ae30700e3924a73350a3a43a2c36b431de7.tar.bz2
Coding Standard Cleanup
Ignore-this: 259cb5773c3144c6c706d87298dcf674 darcs-hash:20091020212338-7ad00-6bf1c5c403491f136a1c02af5ecd9f84d7227107.gz
Diffstat (limited to 'inc/infoutils.php')
-rw-r--r--inc/infoutils.php435
1 files changed, 217 insertions, 218 deletions
diff --git a/inc/infoutils.php b/inc/infoutils.php
index c2db31f7d..a334e0942 100644
--- a/inc/infoutils.php
+++ b/inc/infoutils.php
@@ -49,25 +49,25 @@ function checkUpdateMessages(){
* @author Andreas Gohr <andi@splitbrain.org>
*/
function getVersion(){
- //import version string
- if(@file_exists(DOKU_INC.'VERSION')){
- //official release
- return 'Release '.trim(io_readfile(DOKU_INC.'VERSION'));
- }elseif(is_dir(DOKU_INC.'_darcs')){
- //darcs checkout - read last 2000 bytes of inventory
- $sz = filesize(DOKU_INC.'_darcs/inventory');
- $seek = max(0,$sz-2000);
- $fh = fopen(DOKU_INC.'_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?';
- }
+ //import version string
+ if(@file_exists(DOKU_INC.'VERSION')){
+ //official release
+ return 'Release '.trim(io_readfile(DOKU_INC.'VERSION'));
+ }elseif(is_dir(DOKU_INC.'_darcs')){
+ //darcs checkout - read last 2000 bytes of inventory
+ $sz = filesize(DOKU_INC.'_darcs/inventory');
+ $seek = max(0,$sz-2000);
+ $fh = fopen(DOKU_INC.'_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?';
+ }
}
/**
@@ -76,148 +76,147 @@ function getVersion(){
* @author Andreas Gohr <andi@splitbrain.org>
*/
function check(){
- global $conf;
- global $INFO;
-
- msg('DokuWiki version: '.getVersion(),1);
-
- if(version_compare(phpversion(),'5.0.0','<')){
- msg('Your PHP version is too old ('.phpversion().' vs. 5.0.0+ recommended)',-1);
- }else{
- msg('PHP version '.phpversion(),1);
- }
-
- $mem = (int) php_to_byte(ini_get('memory_limit'));
- if($mem){
- if($mem < 16777216){
- msg('PHP is limited to less than 16MB RAM ('.$mem.' bytes). Increase memory_limit in php.ini',-1);
- }elseif($mem < 20971520){
- 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);
- }elseif($mem < 33554432){
- 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);
+ global $conf;
+ global $INFO;
+
+ msg('DokuWiki version: '.getVersion(),1);
+
+ if(version_compare(phpversion(),'5.0.0','<')){
+ msg('Your PHP version is too old ('.phpversion().' vs. 5.0.0+ recommended)',-1);
+ }else{
+ msg('PHP version '.phpversion(),1);
+ }
+
+ $mem = (int) php_to_byte(ini_get('memory_limit'));
+ if($mem){
+ if($mem < 16777216){
+ msg('PHP is limited to less than 16MB RAM ('.$mem.' bytes). Increase memory_limit in php.ini',-1);
+ }elseif($mem < 20971520){
+ 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);
+ }elseif($mem < 33554432){
+ 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);
+ }else{
+ msg('More than 32MB RAM ('.$mem.' bytes) available.',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('More than 32MB RAM ('.$mem.' bytes) available.',1);
+ 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($conf['changelog'])){
- msg('Changelog is writable',1);
- }else{
- if (@file_exists($conf['changelog'])) {
- msg('Changelog is not writable',-1);
+ if($conf['authtype'] == 'plain'){
+ 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 (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(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);
+ if(ini_get('mbstring.func_overload') != 0){
+ msg('mb_string function overloading is enabled, this will cause problems and should be disabled',-1);
+ }
+ }
+ }else{
+ msg('mb_string extension not available - PHP only replacements will be used',0);
}
- }
-
- 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($conf['authtype'] == 'plain'){
- if(is_writable(DOKU_CONF.'users.auth.php')){
- msg('conf/users.auth.php is writable',1);
+
+ if($conf['allowdebug']){
+ msg('Debugging support is enabled. If you don\'t need it you should set $conf[\'allowdebug\'] = 0',-1);
}else{
- msg('conf/users.auth.php is not writable',0);
+ msg('Debugging support is disabled',1);
}
- }
- if(function_exists('mb_strpos')){
- if(defined('UTF8_NOMBSTRING')){
- msg('mb_string extension is available but will not be used',0);
+ if($INFO['userinfo']['name']){
+ msg('You are currently logged in as '.$_SERVER['REMOTE_USER'].' ('.$INFO['userinfo']['name'].')',0);
+ msg('You are part of the groups '.join($INFO['userinfo']['grps'],', '),0);
}else{
- msg('mb_string extension is available and will be used',1);
- if(ini_get('mbstring.func_overload') != 0){
- msg('mb_string function overloading is enabled, this will cause problems and should be disabled',-1);
- }
+ msg('You are currently not logged in',0);
+ }
+
+ 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 by you',0);
+ }
+
+ require_once(DOKU_INC.'inc/HTTPClient.php');
+ $check = wl('','',true).'data/_dummy';
+ $http = new DokuHTTPClient();
+ $http->timeout = 6;
+ $res = $http->get($check);
+ if(strpos($res,'data directory') !== false){
+ msg('It seems like the data directory is accessible from the web.
+ Make sure this directory is properly protected
+ (See <a href="http://www.dokuwiki.org/security">security</a>)',-1);
+ }elseif($http->status == 404 || $http->status == 403){
+ msg('The data directory seems to be properly protected',1);
+ }else{
+ msg('Failed to check if the data directory is accessible from the web.
+ Make sure this directory is properly protected
+ (See <a href="http://www.dokuwiki.org/security">security</a>)',-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);
- }
-
- if($INFO['userinfo']['name']){
- msg('You are currently logged in as '.$_SERVER['REMOTE_USER'].' ('.$INFO['userinfo']['name'].')',0);
- msg('You are part of the groups '.join($INFO['userinfo']['grps'],', '),0);
- }else{
- msg('You are currently not logged in',0);
- }
-
- 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 by you',0);
- }
-
- require_once(DOKU_INC.'inc/HTTPClient.php');
- $check = wl('','',true).'data/_dummy';
- $http = new DokuHTTPClient();
- $http->timeout = 6;
- $res = $http->get($check);
- if(strpos($res,'data directory') !== false){
- msg('It seems like the data directory is accessible from the web.
- Make sure this directory is properly protected
- (See <a href="http://www.dokuwiki.org/security">security</a>)',-1);
- }elseif($http->status == 404 || $http->status == 403){
- msg('The data directory seems to be properly protected',1);
- }else{
- msg('Failed to check if the data directory is accessible from the web.
- Make sure this directory is properly protected
- (See <a href="http://www.dokuwiki.org/security">security</a>)',-1);
- }
}
/**
@@ -238,26 +237,26 @@ function check(){
* @see html_msgarea
*/
function msg($message,$lvl=0,$line='',$file=''){
- global $MSG;
- $errors[-1] = 'error';
- $errors[0] = 'info';
- $errors[1] = 'success';
- $errors[2] = 'notify';
-
- 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();
+ global $MSG;
+ $errors[-1] = 'error';
+ $errors[0] = 'info';
+ $errors[1] = 'success';
+ $errors[2] = 'notify';
+
+ if($line || $file) $message.=' ['.basename($file).':'.$line.']';
+
+ if(!headers_sent()){
+ if(!isset($MSG)) $MSG = array();
+ $MSG[]=array('lvl' => $errors[$lvl], 'msg' => $message);
}else{
- print "ERROR($lvl) $message";
+ $MSG = array();
+ $MSG[]=array('lvl' => $errors[$lvl], 'msg' => $message);
+ if(function_exists('html_msgarea')){
+ html_msgarea();
+ }else{
+ print "ERROR($lvl) $message";
+ }
}
- }
}
/**
@@ -268,9 +267,9 @@ function msg($message,$lvl=0,$line='',$file=''){
* @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-->";
+ (!$hidden) ? print '<pre class="dbg">' : print "<!--\n";
+ print_r($msg);
+ (!$hidden) ? print '</pre>' : print "\n-->";
}
/**
@@ -279,19 +278,19 @@ function dbg($msg,$hidden=false){
* @author Andreas Gohr <andi@splitbrain.org>
*/
function dbglog($msg,$header=''){
- global $conf;
- if(is_object($msg) || is_array($msg)){
- $msg = print_r($msg,true);
- }
-
- if($header) $msg = "$header\n$msg";
-
- $file = $conf['cachedir'].'/debug.log';
- $fh = fopen($file,'a');
- if($fh){
- fwrite($fh,date('H:i:s ').$_SERVER['REMOTE_ADDR'].': '.$msg."\n");
- fclose($fh);
- }
+ global $conf;
+ if(is_object($msg) || is_array($msg)){
+ $msg = print_r($msg,true);
+ }
+
+ if($header) $msg = "$header\n$msg";
+
+ $file = $conf['cachedir'].'/debug.log';
+ $fh = fopen($file,'a');
+ if($fh){
+ fwrite($fh,date('H:i:s ').$_SERVER['REMOTE_ADDR'].': '.$msg."\n");
+ fclose($fh);
+ }
}
/**
@@ -300,44 +299,44 @@ function dbglog($msg,$header=''){
* @author Gary Owen <gary_owen@bigfoot.com>
*/
function dbg_backtrace(){
- // Get backtrace
- $backtrace = debug_backtrace();
-
- // Unset call to debug_print_backtrace
- array_shift($backtrace);
-
- // Iterate backtrace
- $calls = array();
- $depth = count($backtrace) - 1;
- foreach ($backtrace as $i => $call) {
- $location = $call['file'] . ':' . $call['line'];
- $function = (isset($call['class'])) ?
- $call['class'] . $call['type'] . $call['function'] : $call['function'];
-
- $params = array();
- if (isset($call['args'])){
- foreach($call['args'] as $arg){
- if(is_object($arg)){
- $params[] = '[Object '.get_class($arg).']';
- }elseif(is_array($arg)){
- $params[] = '[Array]';
- }elseif(is_null($arg)){
- $param[] = '[NULL]';
- }else{
- $params[] = (string) '"'.$arg.'"';
+ // Get backtrace
+ $backtrace = debug_backtrace();
+
+ // Unset call to debug_print_backtrace
+ array_shift($backtrace);
+
+ // Iterate backtrace
+ $calls = array();
+ $depth = count($backtrace) - 1;
+ foreach ($backtrace as $i => $call) {
+ $location = $call['file'] . ':' . $call['line'];
+ $function = (isset($call['class'])) ?
+ $call['class'] . $call['type'] . $call['function'] : $call['function'];
+
+ $params = array();
+ if (isset($call['args'])){
+ foreach($call['args'] as $arg){
+ if(is_object($arg)){
+ $params[] = '[Object '.get_class($arg).']';
+ }elseif(is_array($arg)){
+ $params[] = '[Array]';
+ }elseif(is_null($arg)){
+ $param[] = '[NULL]';
+ }else{
+ $params[] = (string) '"'.$arg.'"';
+ }
}
}
- }
- $params = implode(', ',$params);
+ $params = implode(', ',$params);
- $calls[$depth - $i] = sprintf('%s(%s) called at %s',
- $function,
- str_replace("\n", '\n', $params),
- $location);
- }
- ksort($calls);
+ $calls[$depth - $i] = sprintf('%s(%s) called at %s',
+ $function,
+ str_replace("\n", '\n', $params),
+ $location);
+ }
+ ksort($calls);
- return implode("\n", $calls);
+ return implode("\n", $calls);
}
/**