Jump to content

comment spam regexes failing


AndyB

Recommended Posts

I'm running the comment spam catcher that's exactly as shown at http://www.imarc.net/blog/61/stopping_blog_comment_spam_with_php/

Can't post the code here because the IPS rejects the post  :o

When I have a plain text string without any of the 'common spam' words, it works.  As soon as I include a common spam word, it throws a Warning: Unknown modifier '\' in c:\phpdev\www\ ... on line 33 (which is the line in the phpBB links section):

[code]$total_matches += 5 * preg_match_all($regex, $text, $trash);[/code]

Anyone care to point out the corrective action needed, or point me to an effective alternative?
Link to comment
Share on other sites

Since[tt] / [/tt] is the delimiter, any[tt] /[/tt]'s in the pattern must be escaped: [tt]/[\s*[b]/[/b]\s*url\s*]/i[/tt]. Even with that escaped, I still don't agree with the pattern: the [tt][ ][/tt]'s are not escaped, therefore specifying a character class instead of actual braces. All they should need for counting the links is [tt]/ \ [ url =/ i[/tt] at the bare minimum. (Spaces were added so this forum would not interpret it as bbcode.)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.