SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot Tikila's Avatar
    Join Date
    Jun 2007
    Location
    Toronto
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Still needs help with this spam filter code

    I'd be grateful if anyone can help me overcome following difficulties with this code:

    PHP Code:
    $badwords = array("badword1","badword2","</div>");
    $pattern sprintf('/\b(%s)\b/i'implode('|'array_map('preg_quote'$badwords)));
     if (
    preg_match($pattern$message)) {     // case insensitive badword found } 
    problem i have is that the code does not work if includes bad words like "</div>","</p>" // the slash part.
    Last edited by Tikila; Apr 5, 2009 at 11:31.

  2. #2
    Twitter: @TimIgoe silver trophy TimIgoe's Avatar
    Join Date
    Feb 2005
    Location
    Blackpool, UK
    Posts
    1,056
    Mentioned
    27 Post(s)
    Tagged
    1 Thread(s)
    Woudln't ti be more useful to use strip_tags to perform the removing of invalid tags from your string rahter than just trying to 'badwords' some of them.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •