From 6dffa0e0121b02d0258a96b5108dd43dee44c673 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 26 May 2009 14:07:48 +0200 Subject: fixed a spam check hole FS#1620 and made the wordblock check more flexible Ignore-this: 74d18220baea88b5826d46c78998fa04 darcs-hash:20090526120748-7ad00-b3a0bddc53ba3c6c3b824cfbed15450cc0ec406e.gz --- inc/common.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/inc/common.php b/inc/common.php index fd54b7faf..c056e8f31 100644 --- a/inc/common.php +++ b/inc/common.php @@ -531,17 +531,23 @@ function script($script='doku.php'){ * [name] - real name (if logged in) * * @author Andreas Gohr - * Michael Klier + * @author Michael Klier + * @param string $text - optional text to check, if not given the globals are used + * @return bool - true if a spam word was found */ -function checkwordblock(){ +function checkwordblock($text=''){ global $TEXT; + global $PRE; + global $SUF; global $conf; global $INFO; if(!$conf['usewordblock']) return false; + if(!$text) $text = "$PRE $TEXT $SUF"; + // we prepare the text a tiny bit to prevent spammers circumventing URL checks - $text = preg_replace('!(\b)(www\.[\w.:?\-;,]+?\.[\w.:?\-;,]+?[\w/\#~:.?+=&%@\!\-.:?\-;,]+?)([.:?\-;,]*[^\w/\#~:.?+=&%@\!\-.:?\-;,])!i','\1http://\2 \2\3',$TEXT); + $text = preg_replace('!(\b)(www\.[\w.:?\-;,]+?\.[\w.:?\-;,]+?[\w/\#~:.?+=&%@\!\-.:?\-;,]+?)([.:?\-;,]*[^\w/\#~:.?+=&%@\!\-.:?\-;,])!i','\1http://\2 \2\3',$text); $wordblocks = getWordblocks(); //how many lines to read at once (to work around some PCRE limits) -- cgit v1.2.3