Results 1 to 2 of 2

Thread: Help searching submitted text

  1. #1

    Thread Starter
    Fanatic Member neicedover1982's Avatar
    Join Date
    Jun 2005
    Posts
    566

    Exclamation Help searching submitted text

    Hi, I have had a problem with bots and spammers writing spam and such into my guestbook. I have decided to have my PHP script do a quick run through of key words and if it finds any, it ignores the submission.

    Right now my code
    PHP Code:
        $subject $mymessage;
        
    $pattern "/url/";
        if (
    preg_match($pattern$subject)) {
             
    // Spam filter found something
            
    $thankyou_block "This message is considered spam>";
        } else {
            
    // Spam filter found nothing so enter it
            
    ..... 
    I can only search for the keyword "url", but I want to ba able to make a list and have it search for any of the words on the list, like "url,link,[/". How do I edit the code to do this. I have searched and searched but have not been able to find anything on the web. Please help.
    Kevin | New England Iced Over | http://www.kevincawleyjr.com

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Help searching submitted text

    Unfortunatly mechanisms like yours are easy to circum-navigate. I recommend, that before submitting the post you use image validation. Generating images in PHP uis quite trivial compared to attempting to filter out huge lists of words and potentially produces false positives.

    Check out this tutorial: http://www.zend.com/zend/tut/tutorial-mehmet1.php

    If you still wnat to go the word search way then I recommend you construct an array of "bad words", loop through the array and search for each word in the string using the stripos() function, or for more powerful matach, (e.g: the word in isolation), use preg_match on each word. To search for a word in isolation you would use a regular expression like this:
    Code:
    /(^|\b)url(\b|$)/i
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

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



Click Here to Expand Forum to Full Width