Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Spam filter [PERL]

Name: Anonymous 2010-05-04 6:51

This is driving me insane! I've been trying to make a working spam filter for a long time but I still cannot accomplish this simple task!

my @SPAM; # Spam check
tie @SPAM, 'Tie::File', BOARD_SPAM, memory => 20000000, mode => O_RDONLY;
(tied @SPAM)->flock(LOCK_SH) if -e BOARD_SPAM;
for (@SPAM) {
    /^(.*)$/;
    Abort('Comment contains a blacklisted item') if $comment =~ /$1/gi;
}
untie @SPAM;


BOARD_SPAM = spam.txt file. Inside this text file are two items:
test.1
test;2


So, whenever the comment contains any of those two lines anywhere, the script is supposed to abort with an error.

However, this does not happen!

What happens is this: If you have test.1 in the comment, it does NOT abort the script, as it should.

But if you have test;2 in the comment, it works perfectly and it aborts. It only seems to filter the LAST line of spam.txt

I do not understand why it does this. for (@SPAM) means it should go through every single line, not just the last line, right?!

Name: Anonymous 2010-05-04 9:04

I tried this on my web server, but the filter still doesn't trigger... Do you think this has something to do with the server itself rather than the code?

Because looking at your code, it doesn't actually do anything different than the one I posted, other than the fact that it doesn't use Tie::File

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List