summaryrefslogtreecommitdiff
path: root/inc/common.php
diff options
context:
space:
mode:
authormatthiasgrimm <matthiasgrimm@users.sourceforge.net>2005-05-25 18:16:58 +0200
committermatthiasgrimm <matthiasgrimm@users.sourceforge.net>2005-05-25 18:16:58 +0200
commit5749f1ce740e4cfd6d886e8d2fda6b8782389d33 (patch)
tree49ab4432a0cf2028392913f8edef580ac8a947ac /inc/common.php
parent3bc80094f97f3145ebaf4a39d6d21657371a46e3 (diff)
downloadrpg-5749f1ce740e4cfd6d886e8d2fda6b8782389d33.tar.gz
rpg-5749f1ce740e4cfd6d886e8d2fda6b8782389d33.tar.bz2
fix for history navigation buttons
This patch adds some sanity checks for the history start parameter 'first'. Only the needed history entries will be loaded at once now. This will reduce server load a bit darcs-hash:20050525161658-7ef76-1ab681b4c784bbe834fae91301ee7b9cd2a2cd8b.gz
Diffstat (limited to 'inc/common.php')
-rw-r--r--inc/common.php17
1 files changed, 11 insertions, 6 deletions
diff --git a/inc/common.php b/inc/common.php
index 775071b7f..162a1a8e4 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -476,16 +476,18 @@ function addLogEntry($date,$id,$summary=""){
/**
* returns an array of recently changed files using the
* changelog
+ * first : first entry in array returned
* num : return 'num' entries
- * num = 0: return count of entries set by $conf['recent']
- * num = -1: return all available entries
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
-function getRecents($num=0,$incdel=false){
+function getRecents($first,$num,$incdel=false){
global $conf;
$recent = array();
- if(!$num) $num = $conf['recent'];
+ $names = array();
+
+ if(!$num)
+ return $recent;
if(!@is_readable($conf['changelog'])){
msg($conf['changelog'].' is not readable',-1);
@@ -500,17 +502,20 @@ function getRecents($num=0,$incdel=false){
if(empty($line)) continue; //skip empty lines
$info = split("\t",$line); //split into parts
//add id if not in yet and file still exists and is allowed to read
- if(!$recent[$info[2]] &&
+ if(!$names[$info[2]] &&
(@file_exists(wikiFN($info[2])) || $incdel) &&
(auth_quickaclcheck($info[2]) >= AUTH_READ)
){
+ $names[$info[2]] = 1;
+ if(--$first >= 0) continue; /* skip "first" entries */
+
$recent[$info[2]]['date'] = $info[0];
$recent[$info[2]]['ip'] = $info[1];
$recent[$info[2]]['user'] = $info[3];
$recent[$info[2]]['sum'] = $info[4];
$recent[$info[2]]['del'] = !@file_exists(wikiFN($info[2]));
}
- if($num != -1 && count($recent) >= $num){
+ if(count($recent) >= $num){
break; //finish if enough items found
}
}