printable version
- email this article
View article without comments
How To install the keyword filter
by PP
Tuesday, Sep. 26, 2006 at 2:12 PM
small howto on how to install the keyword filter.
1) in 'local/templates/pages/spam.tpl' add the following line:
<li><h3><a href="/admin/log/file_viewer.php?filename=banned_keywords.txt">keyword block</a></h3></li>
2) add a file named 'banned_keywords.txt' in 'local/cache'. Make sure your webserver can write to it (otherwise you can't use it in admin). In this file you add keywords.
3) add the following line to your spam section in 'local/config/sfactive.cfg'
$GLOBALS['spam_filter_keywords'] = 1; // filter for banned keywords .
The number is the amount of keywords it needs to reach before you get blocked out.
4) apply the following code to 'shared/classes/spam_class.inc':
/** block posts if they contain certain keywords. */
if ($GLOBALS['spam_filter_keywords'] > 0) {
$keywords = file(SF_CACHE_PATH.'/banned_keywords.txt','r');
$matched_keywords = array();
for ( $i=0; $i= $GLOBALS['spam_filter_keywords']) {
$ret=1;
$keyword_string = implode(' ', $matched_keywords);
$this->Log("Keyword Spam Detected: " . $keyword_string);
}
}
.
this should come in you 'Detect' method.
note: if you put 'free' as a keyword it will also block 'freedom' 'freeze' ...
meta refresh
by author
Monday, Oct. 02, 2006 at 4:55 AM
i suggest to add meta refresh in there too, to avoid the typical linkspammers that have been targetting many imc's lately.
didn't work...
by try this
Wednesday, Oct. 04, 2006 at 12:02 AM
i think the above code for the spam class need work. i made some fixes but it fires positive at the moment with just one word matched.
/** block posts if they contain certain keywords. */
if ($GLOBALS['spam_filter_keywords'] > 0) {
$full_text=$_POST['heading'].$_POST['author'].$_POST['summary'].$_POST['article'];
$keywords = file(SF_CACHE_PATH.'/banned_keywords.txt','r');
$matched_keywords = array();
for ( $i=0 ; $i < count($keywords) ; $i++)
{
$keyword = trim($keywords[$i]);
if ( strlen( $keyword ) > 0 )
{
if (eregi($keyword, $full_text) )
{
$ret= 1;
$this->Log("Keyword Spam Detected: " . $keyword_string);
}
}
}
}
oops this should look better
by try this
Wednesday, Oct. 04, 2006 at 12:03 AM
/** block posts if they contain certain keywords. */
if ($GLOBALS['spam_filter_keywords'] > 0) {
//echo SF_CACHE_PATH.'/banned_keywords.txt';
//die();
$full_text=$_POST['heading'].$_POST['author'].$_POST['summary'].$_POST['article'];
//die($full_text);
$keywords = file(SF_CACHE_PATH.'/banned_keywords.txt','r');
$matched_keywords = array();
for ( $i=0 ; $i < count($keywords) ; $i++)
{
$keyword = trim($keywords[$i]);
//$keyword = $keywords[$i];
if ( strlen( $keyword ) > 0 )
{
if (eregi($keyword, $full_text) )
{
$ret= 1;
$this->Log("Keyword Spam Detected: " . $keyword_string);
}
}
}
}
|