From 5cf31920a1920c348a360b2847233e43257f136f Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 8 Jan 2010 14:26:57 +0100 Subject: Read version from last Git log --- inc/infoutils.php | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) (limited to 'inc/infoutils.php') diff --git a/inc/infoutils.php b/inc/infoutils.php index b43dd40be..d5356969b 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -55,36 +55,31 @@ function getVersionData(){ //official release $version['date'] = trim(io_readfile(DOKU_INC.'VERSION')); $version['type'] = 'Release'; - return $version; - }elseif(is_dir(DOKU_INC.'_darcs')){ - if(is_file(DOKU_INC.'_darcs/inventory')){ - $inventory = DOKU_INC.'_darcs/inventory'; - }elseif(is_file(DOKU_INC.'_darcs/hashed_inventory')){ - $inventory = DOKU_INC.'_darcs/hashed_inventory'; - }else{ - $version['date'] = 'unknown'; - $version['type'] = 'Darcs'; - return $version; - } - - //darcs checkout - read last 2000 bytes of inventory - $sz = filesize($inventory); - $seek = max(0,$sz-2000); - $fh = fopen($inventory,'rb'); - fseek($fh,$seek); - $chunk = fread($fh,2000); - fclose($fh); + }elseif(is_dir(DOKU_INC.'.git')){ + $version['type'] = 'Git'; + $version['date'] = 'unknown'; - preg_match_all('#\*\*(\d{4})(\d{2})(\d{2})\d{6}(?:\]|$)#m', $chunk, $matches, - PREG_SET_ORDER); - $version['date'] = implode('-', array_slice(array_pop($matches), 1)); - $version['type'] = 'Darcs'; - return $version; + $inventory = DOKU_INC.'.git/logs/HEAD'; + if(is_file($inventory)){ + $sz = filesize($inventory); + $seek = max(0,$sz-2000); // read from back of the file + $fh = fopen($inventory,'rb'); + fseek($fh,$seek); + $chunk = fread($fh,2000); + fclose($fh); + $chunk = trim($chunk); + $chunk = array_pop(explode("\n",$chunk)); //last log line + $chunk = array_shift(explode("\t",$chunk)); //strip commit msg + $chunk = explode(" ",$chunk); + array_pop($chunk); //strip timezone + $date = date('Y-m-d',array_pop($chunk)); + if($date) $version['date'] = $date; + } }else{ $version['date'] = 'unknown'; $version['type'] = 'snapshot?'; - return $version; } + return $version; } /** -- cgit v1.2.3 From 16905344219a6293705b71cd526fad3ba07b04eb Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 31 Jan 2010 19:02:14 +0100 Subject: first attempt to centralize all include loading Classes are loaded throug PHP5's class autoloader, all other includes are just loaded by default. This skips a lot of require_once calls. Parser and Plugin stuff isn't handled by the class loader yet. --- inc/infoutils.php | 1 - 1 file changed, 1 deletion(-) (limited to 'inc/infoutils.php') diff --git a/inc/infoutils.php b/inc/infoutils.php index d5356969b..6f2874fe5 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -7,7 +7,6 @@ */ if(!defined('DOKU_INC')) die('meh.'); if(!defined('DOKU_MESSAGEURL')) define('DOKU_MESSAGEURL','http://update.dokuwiki.org/check/'); -require_once(DOKU_INC.'inc/HTTPClient.php'); /** * Check for new messages from upstream -- cgit v1.2.3 From 0af14a6e25ba35e88d96762bc73325838868e3fe Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 1 Feb 2010 15:38:41 +0100 Subject: removed more unneeded require_once() calls --- inc/infoutils.php | 1 - 1 file changed, 1 deletion(-) (limited to 'inc/infoutils.php') diff --git a/inc/infoutils.php b/inc/infoutils.php index 6f2874fe5..00a3ad2d3 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -222,7 +222,6 @@ function check(){ 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; -- cgit v1.2.3 From 134937946849b8225648f9c191a006ec60c1f013 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 8 Feb 2010 13:33:41 +0100 Subject: run dbg() output through htmlspecialchars --- inc/infoutils.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'inc/infoutils.php') diff --git a/inc/infoutils.php b/inc/infoutils.php index d5356969b..001a33f66 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -289,9 +289,15 @@ function msg($message,$lvl=0,$line='',$file=''){ * @author Andreas Gohr */ function dbg($msg,$hidden=false){ - (!$hidden) ? print '
' : print "";
+    if($hidden){
+        echo "";
+    }else{
+        echo '
';
+        echo hsc(print_r($msg,true));
+        echo '
'; + } } /** -- cgit v1.2.3 From 69266de50f71b3d43011378cf0b0e8b8185c3609 Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Thu, 24 Jun 2010 14:26:15 +0200 Subject: fixed handling of MSG msg() now stores always the message to the MSG array until headers are sent. After this, a call of msg will print out all messages from the MSG array immediately through html_msgarea. This prevents double posting and losses of messages from the MSG array. --- inc/infoutils.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'inc/infoutils.php') diff --git a/inc/infoutils.php b/inc/infoutils.php index 32baa9450..096662d24 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -265,17 +265,15 @@ function msg($message,$lvl=0,$line='',$file=''){ 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(!isset($MSG)) $MSG = array(); + $MSG[]=array('lvl' => $errors[$lvl], 'msg' => $message); + if(headers_sent()){ if(function_exists('html_msgarea')){ html_msgarea(); }else{ print "ERROR($lvl) $message"; } + unset($GLOBALS['MSG']); } } -- cgit v1.2.3 From 3f803e5e8df5f91507a14467a07e89271f9e4e8e Mon Sep 17 00:00:00 2001 From: Gina Haeussge Date: Sat, 26 Jun 2010 18:25:41 +0200 Subject: FS#1878: Hide Dokuwiki version information from metadata and only show it to admins and manager in do=check. Also protected meta files README, VERSION and COPYING additionally to .ht* --- inc/infoutils.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'inc/infoutils.php') diff --git a/inc/infoutils.php b/inc/infoutils.php index 096662d24..87b29d7af 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -100,7 +100,9 @@ function check(){ global $conf; global $INFO; - msg('DokuWiki version: '.getVersion(),1); + if ($INFO['isadmin'] || $INFO['ismanager']){ + msg('DokuWiki version: '.getVersion(),1); + } if(version_compare(phpversion(),'5.1.2','<')){ msg('Your PHP version is too old ('.phpversion().' vs. 5.1.2+ needed)',-1); -- cgit v1.2.3 From ef362bb863eb95d3968a3a1df35562914a1bbdef Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Sun, 27 Jun 2010 13:58:07 +0100 Subject: moved update message from its own file (conf/msg) into doku.php (FS#1800) --- inc/infoutils.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'inc/infoutils.php') diff --git a/inc/infoutils.php b/inc/infoutils.php index 87b29d7af..ac6a0a84c 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -16,6 +16,7 @@ if(!defined('DOKU_MESSAGEURL')) define('DOKU_MESSAGEURL','http://update.dokuwiki function checkUpdateMessages(){ global $conf; global $INFO; + global $updateVersion; if(!$conf['updatecheck']) return; if($conf['useacl'] && !$INFO['ismanager']) return; @@ -23,12 +24,10 @@ function checkUpdateMessages(){ $lm = @filemtime($cf); // check if new messages needs to be fetched - if($lm < time()-(60*60*24) || $lm < @filemtime(DOKU_CONF.'msg')){ - $num = @file(DOKU_CONF.'msg'); - $num = is_array($num) ? (int) $num[0] : 0; + if($lm < time()-(60*60*24) || $lm < @filemtime(DOKU_INC.'doku.php')){ $http = new DokuHTTPClient(); $http->timeout = 8; - $data = $http->get(DOKU_MESSAGEURL.$num); + $data = $http->get(DOKU_MESSAGEURL.$updateVersion); io_saveFile($cf,$data); }else{ $data = io_readFile($cf); -- cgit v1.2.3