Michael Morris
02-21-2005, 03:50 AM
This is pissing me the Hell off.
function spamkill($post)
{
eval('$blacklist = "' . fetch_template('mtblacklist') . '";');
$spamlist = explode("\n", $blacklist);
foreach ($spamlist as $spam)
{
// Chop off comment text at the end of some lines as necessary
if (strstr($spam, '#'))
{
$spam = trim(substr($spam, 0, strpos($spam,"#") - 1));
}
if (!strstr($spam, '#') AND strlen($spam) != 0)
{
preg_match("#$spam#siU", $post['message'], $matches);
echo $matches[0] . "<br />";
}
}
die;
return false;
}
Template mtblacklist contains this file
http://www.jayallen.org/comment_spam/blacklist.txt
The explode statement works, breaking that list into a line by line array.
The first if statement works, lopping off the comment text.
The preg_match isn't working. Neither will ereg, eregi, strstr or stristr. In fact, NOTHING IS WORKING!!! Even when the post is an EXACTLY COPIED LINE from the blacklist a if($post['message'] == $spam) statement DOESN'T WORK. I'm about to punch a hole in my laptop monitor here. Help.
function spamkill($post)
{
eval('$blacklist = "' . fetch_template('mtblacklist') . '";');
$spamlist = explode("\n", $blacklist);
foreach ($spamlist as $spam)
{
// Chop off comment text at the end of some lines as necessary
if (strstr($spam, '#'))
{
$spam = trim(substr($spam, 0, strpos($spam,"#") - 1));
}
if (!strstr($spam, '#') AND strlen($spam) != 0)
{
preg_match("#$spam#siU", $post['message'], $matches);
echo $matches[0] . "<br />";
}
}
die;
return false;
}
Template mtblacklist contains this file
http://www.jayallen.org/comment_spam/blacklist.txt
The explode statement works, breaking that list into a line by line array.
The first if statement works, lopping off the comment text.
The preg_match isn't working. Neither will ereg, eregi, strstr or stristr. In fact, NOTHING IS WORKING!!! Even when the post is an EXACTLY COPIED LINE from the blacklist a if($post['message'] == $spam) statement DOESN'T WORK. I'm about to punch a hole in my laptop monitor here. Help.