diff --git a/conf/dokuwiki.php b/conf/dokuwiki.php index 2d89d1cde4c3cf44968927d18684867ce951f34e..65383017c5c06ea71eff1ee9cee447f3de2d1612 100644 --- a/conf/dokuwiki.php +++ b/conf/dokuwiki.php @@ -79,6 +79,7 @@ $conf['spellchecker']= 0; //enable Spellchecker (needs PHP >= 4.3 $conf['subscribers'] = 0; //enable change notice subscription support $conf['pluginmanager'] = 0; //enable automated plugin management (requires plugin) $conf['compress'] = 1; //Strip whitespaces and comments from Styles and JavaScript? 1|0 +$conf['hidepages'] = ''; //Regexp for pages to be skipped from RSS, Search and Recent Changes $conf['rss_type'] = 'rss1'; //type of RSS feed to provide, by default: // 'rss' - RSS 0.91 // 'rss1' - RSS 1.0 diff --git a/inc/common.php b/inc/common.php index 4e8dd1f8510b89dc9c5479f5066dd696aa2634ae..4092eb76661b0cd87ca9cd7f9a9297e5d713b4ff 100644 --- a/inc/common.php +++ b/inc/common.php @@ -660,6 +660,9 @@ function _handleRecent($line,$ns,$flags){ // remember in seen to skip additional sights $seen[$id] = 1; + // check if it's a hidden page + if(isHiddenPage($id)) return false; + // filter namespace if (($ns) && (strpos($id,$ns.':') !== 0)) return false; diff --git a/inc/fulltext.php b/inc/fulltext.php index 4d4b8138c5e46a4986edf33245784b88391ed96b..f4825054802e598720296974872c55411b911016 100644 --- a/inc/fulltext.php +++ b/inc/fulltext.php @@ -44,6 +44,11 @@ function ft_pageSearch($query,&$poswords){ } if(!count($docs)) return array(); + // create a list of hidden pages in the result + $hidden = array(); + $hidden = array_filter(array_keys($docs),'isHiddenPage'); + $not = array_merge($not,$hidden); + // remove negative matches foreach($not as $n){ unset($docs[$n]); @@ -95,13 +100,14 @@ function ft_backlinks($id){ // quick lookup of the pagename $page = noNS($id); $sw = array(); // we don't use stopwords here - $matches = idx_lookup(idx_tokenizer($page,$sw)); //pagename may contain specials (_ or .) - $docs = ft_resultCombine(array_values($matches)); + $matches = idx_lookup(idx_tokenizer($page,$sw)); // pagename may contain specials (_ or .) + $docs = array_keys(ft_resultCombine(array_values($matches))); + $docs = array_filter($docs,'isVisiblePage'); // discard hidden pages if(!count($docs)) return $result; require_once(DOKU_INC.'inc/parserutils.php'); // check instructions for matching links - foreach(array_keys($docs) as $match){ + foreach($docs as $match){ $instructions = p_cached_instructions(wikiFN($match),true); if(is_null($instructions)) continue; @@ -161,6 +167,7 @@ function ft_pageLookup($id,$pageonly=true){ } } + $pages = array_filter($pages,'isVisiblePage'); // discard hidden pages if(!count($pages)) return array(); // check ACL permissions diff --git a/inc/pageutils.php b/inc/pageutils.php index 1dc66981d44fcd81bf6985c0a6cd0a58588d1bb1..0f9b47e47ce7a5f7e6c7f0cd9445daa2c9108ded 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -301,4 +301,28 @@ function getCacheName($data,$ext=''){ return $file; } +/** + * Checks a pageid against $conf['hidepages'] + * + * @author Andreas Gohr <gohr@cosmocode.de> + */ +function isHiddenPage($id){ + global $conf; + if(empty($conf['hidepages'])) return false; + + if(preg_match('/'.$conf['hidepages'].'/ui',':'.$id)){ + return true; + } + return false; +} + +/** + * Reverse of isHiddenPage + * + * @author Andreas Gohr <gohr@cosmocode.de> + */ +function isVisiblePage($id){ + return !isHiddenPage($id); +} + //Setup VIM: ex: et ts=2 enc=utf-8 : diff --git a/inc/search.php b/inc/search.php index ffe85adc1b5d892485555449eb0019fbc6f05676..4000c445dff6f931aaf97f3f5a2465cfba255a2b 100644 --- a/inc/search.php +++ b/inc/search.php @@ -125,8 +125,14 @@ function search_index(&$data,$base,$file,$type,$lvl,$opts){ return false; } - //check ACL $id = pathID($file); + + //check hidden + if($type=='f' && isHiddenPage($id)){ + return false; + } + + //check ACL if($type=='f' && auth_quickaclcheck($id) < AUTH_READ){ return false; } diff --git a/inc/template.php b/inc/template.php index 302d9d1f51f10dc691c0bb906afbf79cbfbbb12f..71bb64b4c42b771e01c6e7ae3921f8c0a13d718b 100644 --- a/inc/template.php +++ b/inc/template.php @@ -905,6 +905,8 @@ function tpl_indexerWebBug(){ global $INFO; if(!$INFO['exists']) return; + if(isHiddenPage($ID)) return; //no need to index hidden pages + $p = array(); $p['src'] = DOKU_BASE.'lib/exe/indexer.php?id='.urlencode($ID). '&'.time();