summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2013-01-20 12:46:10 -0800
committerAndreas Gohr <andi@splitbrain.org>2013-01-20 12:46:10 -0800
commitad4665dacc59ec9fd68631764253a87d55ec05b0 (patch)
tree7cf8132473942e39bcdf8f70c9eb64a1824c64ab /inc
parented66f2f0d753a8c11439116a5bc330054afdd48e (diff)
parent8451f4ad87cd104e80eb42532adebd7b2882e62e (diff)
downloadrpg-ad4665dacc59ec9fd68631764253a87d55ec05b0.tar.gz
rpg-ad4665dacc59ec9fd68631764253a87d55ec05b0.tar.bz2
Merge pull request #154 from gturri/searchDepth
Check search limit depth with an inequality
Diffstat (limited to 'inc')
-rw-r--r--inc/search.php11
1 files changed, 8 insertions, 3 deletions
diff --git a/inc/search.php b/inc/search.php
index 1cecfd5ec..53bd240e8 100644
--- a/inc/search.php
+++ b/inc/search.php
@@ -247,11 +247,16 @@ function search_pagename(&$data,$base,$file,$type,$lvl,$opts){
* @author Andreas Gohr <andi@splitbrain.org>
*/
function search_allpages(&$data,$base,$file,$type,$lvl,$opts){
+ if(isset($opts['depth']) && $opts['depth']){
+ $parts = explode('/',ltrim($file,'/'));
+ if(($type == 'd' && count($parts) > $opts['depth'])
+ || ($type != 'd' && count($parts) > $opts['depth'] + 1)){
+ return false; // depth reached
+ }
+ }
+
//we do nothing with directories
if($type == 'd'){
- if(!$opts['depth']) return true; // recurse forever
- $parts = explode('/',ltrim($file,'/'));
- if(count($parts) == $opts['depth']) return false; // depth reached
return true;
}