Kate (kate_nepveu) wrote,
Kate
kate_nepveu

Solved: PHP regular expression help

ETA: solved by [personal profile] avram!

I have this little Movable Type plugin for my booklog that runs a simple PHP script and stops very common spam from even getting into the MT interface. Except I can't figure out how to make it stop one particular kind of spam. I'm sure this is dead obvious to people who aren't cargo-culting their way through things, can anyone help?

So the plugin checks a text file called "rules.txt" that contains things like:

if (preg_match('@casino@i',$fields)) { exit('Your comment has been blocked as spam; rephrase it or e-mail the administrator.'); }

Meaning if "casino" appears in the name, e-mail, or URL fields of the submitted comment, then the website immediately returns a page with that text.

I'm getting a ton of spam comments of the form "Hello!" plus a new line. "preg_match('@^Hello!$@i',$body)" doesn't catch them. And I don't want to catch anyone that might be enthusiastic and have actual text follow their "Hello!", just the spammers who are adding a new line after.

What do I need to do?

comment count unavailable comment(s) | reply | link
Tags: help me internets
Subscribe
Comments for this post were disabled by the author