From b9ac8716a5af742f88887fb9c1315b0e01d244a3 Mon Sep 17 00:00:00 2001 From: chris <chris@jalakai.co.uk> Date: Sun, 22 Jan 2006 02:12:49 +0100 Subject: [PATCH] adds support for wordblock.local.conf darcs-hash:20060122011249-9b6ab-fdd9188322e1dc4441562a905ac481f66b703db2.gz --- inc/common.php | 8 +++++--- inc/confutils.php | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/inc/common.php b/inc/common.php index c943ffa3c..b5c29d621 100644 --- a/inc/common.php +++ b/inc/common.php @@ -365,7 +365,7 @@ function checkwordblock(){ if(!$conf['usewordblock']) return false; - $blockfile = file(DOKU_CONF.'wordblock.conf'); + $wordblocks = getWordblocks(); //how many lines to read at once (to work around some PCRE limits) if(version_compare(phpversion(),'4.3.0','<')){ //old versions of PCRE define a maximum of parenthesises even if no @@ -377,7 +377,7 @@ function checkwordblock(){ //MAX_PATTERN_SIZE in modern PCRE $chunksize = 600; } - while($blocks = array_splice($blockfile,0,$chunksize)){ + while($blocks = array_splice($wordblocks,0,$chunksize)){ $re = array(); #build regexp from blocks foreach($blocks as $block){ @@ -386,7 +386,9 @@ function checkwordblock(){ if(empty($block)) continue; $re[] = $block; } - if(preg_match('#('.join('|',$re).')#si',$TEXT)) return true; + if(preg_match('#('.join('|',$re).')#si',$TEXT, $match=array())) { + return true; + } } return false; } diff --git a/inc/confutils.php b/inc/confutils.php index 9432c10d5..cc1d8064a 100644 --- a/inc/confutils.php +++ b/inc/confutils.php @@ -115,6 +115,23 @@ function getInterwiki() { return $wikis; } +/** + * returns array of wordblock patterns + * + */ +function getWordblocks() { + static $wordblocks = NULL; + if ( !$wordblocks ) { + $wordblocks = file(DOKU_CONF.'wordblock.conf'); + if (@file_exists(DOKU_CONF.'wordblock.local.conf')) { + $local = file(DOKU_CONF.'wordblock.local.conf'); + $wordblocks = array_merge($wordblocks, $local); + } + } + return $wordblocks; +} + + /** * Builds a hash from a configfile * -- GitLab