Kate (kate_nepveu) wrote,

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

  • Attention Attolia & Hamilton fans

    Attolia sings "Fight for It " to the tune of "Wait for It." comment(s) | add comment ( how-to) | link

  • I will make a real post about Hamilton later

    But in advance of the certain deluge of Hamilton/Burr hatesex from Yuletide, may I suggest to the slash writers Hamilton/Laurens, which is also…

  • The Martian (movie)

    We saw this last Friday and I haven't had the time to write it up, but honestly I'm doing more so out of obligation/putting things on the record:…

Comments for this post were disabled by the author