From 652610a2c1fbc4fceb692d4aba7012c0eaddae3e Mon Sep 17 00:00:00 2001 From: andi Date: Thu, 3 Feb 2005 20:02:09 +0100 Subject: editor names for old revisions #85 darcs-hash:20050203190209-9977f-e246ffa72e9eded86aaaf3502efbee75c608ec3b.gz --- inc/common.php | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 94dfd03a0..6be27570a 100644 --- a/inc/common.php +++ b/inc/common.php @@ -147,6 +147,18 @@ function pageinfo(){ $info['editable'] = ($info['writable'] && empty($info['lock'])); $info['lastmod'] = @filemtime($info['filepath']); + //who's the editor + if($REV){ + $revinfo = getRevisionInfo($ID,$REV); + }else{ + $revinfo = getRevisionInfo($ID,$info['lastmod']); + } + $info['ip'] = $revinfo['ip']; + $info['user'] = $revinfo['user']; + $info['sum'] = $revinfo['sum']; + $info['editor'] = $revinfo['ip']; + if($revinfo['user']) $info['editor'].= ' ('.$revinfo['user'].')'; + return $info; } @@ -633,10 +645,10 @@ function dbg($msg,$hidden=false){ * * @author Andreas Gohr */ -function addLogEntry($id,$summary=""){ +function addLogEntry($date,$id,$summary=""){ global $conf; $id = cleanID($id); - $date = time(); + if(!$date) $date = time(); //use current time if none supplied $remote = $_SERVER['REMOTE_ADDR']; $user = $_SERVER['REMOTE_USER']; @@ -685,6 +697,25 @@ function getRecents($num=0,$incdel=false){ return $recent; } +/** + * gets additonal informations for a certain pagerevison + * from the changelog + * + * @author Andreas Gohr + */ +function getRevisionInfo($id,$rev){ + global $conf; + $loglines = file($conf['changelog']); + $loglines = preg_grep("/$rev\t\d+\.\d+\.\d+\.\d+\t$id\t/",$loglines); + rsort($loglines); //reverse sort on timestamp (shouldn't be needed) + $line = split("\t",$loglines[0]); + $info['date'] = $line[0]; + $info['ip'] = $line[1]; + $info['user'] = $line[3]; + $info['sum'] = $line[4]; + return $info; +} + /** * Saves a wikitext by calling io_saveFile * @@ -713,7 +744,7 @@ function saveWikiText($id,$text,$summary){ $del = false; } - addLogEntry($id,$summary); + addLogEntry(@filemtime($file),$id,$summary); notify($id,$old,$summary); //purge cache on add by updating the purgefile -- cgit v1.2.3