diff options
author | Andreas Gohr <andi@splitbrain.org> | 2013-01-20 12:46:10 -0800 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2013-01-20 12:46:10 -0800 |
commit | ad4665dacc59ec9fd68631764253a87d55ec05b0 (patch) | |
tree | 7cf8132473942e39bcdf8f70c9eb64a1824c64ab | |
parent | ed66f2f0d753a8c11439116a5bc330054afdd48e (diff) | |
parent | 8451f4ad87cd104e80eb42532adebd7b2882e62e (diff) | |
download | rpg-ad4665dacc59ec9fd68631764253a87d55ec05b0.tar.gz rpg-ad4665dacc59ec9fd68631764253a87d55ec05b0.tar.bz2 |
Merge pull request #154 from gturri/searchDepth
Check search limit depth with an inequality
-rw-r--r-- | inc/search.php | 11 |
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; } |