Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Apr 2005
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow Guestbook Anti-Spam Help

    My guestbook gets spammed around 2 or more times a dayw with gamling and poker ads. Could someone help how to make an anti-spam for my guestbook.
    I don't want to use IP banning, coz the spammer uses a lot of different IPs on evry posts.
    I want it whenever a guest submits a post and the words "poker, gamling, casino etc." is on the message, an error message would display and it won't be added on the guestbook.
    Does someone know how could I do that? I posted my PHP file that adds the entry to the guestbook:

    Code:
    <?php include("navigation.txt");
    
    include("mydb.php");
    
    $name = $_POST['gbname'];
    $email = $_POST['gbemail'];
    $website = $_POST['gbwebsite'];
    $message = $_POST['gbmessage'];
    $ip = $_POST['ip'];
    $date = $_POST['date'];
    
    // check if there are any blank entry
    if ($name == '' || $email == '' || $message == '' || $date == '' || $ip == '')
    {
    	echo "<p class=\"head\">Error!</p>Please go back and fill in all the required fields!<br>";
    	include("tagboard.txt");
    	die("&nbsp;");
    
    }
    
    else {
    
    
    $message = str_replace("<","&lt;",$message);
    $message = str_replace(">","&gt;",$message);
    $message = str_replace("\n","<br>",$message);
    
    $message = str_replace(":)","<img src=smiley/yellow_smilies/smile.gif border=0>",$message);
    $message = str_replace(":(","<img src=smiley/yellow_smilies/sad.gif border=0>",$message);
    $message = str_replace(":P","<img src=smiley/yellow_smilies/tongue.gif border=0>",$message);
    $message = str_replace(":D","<img src=smiley/yellow_smilies/teeth.gif border=0>",$message);
    $message = str_replace("8)","<img src=smiley/yellow_smilies/sunglass.gif border=0>",$message);
    $message = str_replace(":[","<img src=smiley/yellow_smilies/mad.gif border=0>",$message);
    $message = str_replace("%)","<img src=smiley/yellow_smilies/confused.gif border=0>",$message);
    $message = str_replace("*)","<img src=smiley/yellow_smilies/rosycheek.gif border=0>",$message);
    
    
    $q = "INSERT into guestbook (id,name,email,website,date,ip,message) VALUES ('$id','$name','$email','$website','$date','$ip','$message')";
    $result = mysql_query($q,$connection);
    
    if ($result)
    	{
    	echo "<p class=\"head\">Guestbook Entry</p>Thank you, <b>$name</b>! Your entry has been added to the guestbook! Click <a href=\"guestbook.php\">here</a> to return to the guestbook.";
    	}
    else { echo "Can't connebt to MySQL! Please report this to the webmaster."; include("tagboard.txt");
    		die ("&nbsp;");
    	}
    }
    include("tagboard.txt"); ?>

  • #2
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,795
    Thanks
    19
    Thanked 156 Times in 147 Posts
    Just use one of the string functions (http://us3.php.net/strings) with $message to locate all occurrences of a certain substring within the larger string....if the function finds one of the offending substrings (i.e., "poker"), then display your error message and keep the form from being submitted.....

    Sounds like you kind of already know what you need to do....
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #3
    New Coder
    Join Date
    Apr 2005
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by chump2877
    Just use one of the string functions (http://us3.php.net/strings) with $message to locate all occurrences of a certain substring within the larger string....if the function finds one of the offending substrings (i.e., "poker"), then display your error message and keep the form from being submitted.....

    Sounds like you kind of already know what you need to do....
    *gulp* I actually dunno how to code it...

    EDIT: I found this http://us3.php.net/manual/en/function.strpbrk.php
    Is this what I should use?
    Last edited by CosmicGraffiti; 06-25-2005 at 09:22 AM.

  • #4
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,795
    Thanks
    19
    Thanked 156 Times in 147 Posts
    Try this one instead: http://us3.php.net/manual/en/function.stripos.php

    An example of how strpos() is used (also at this URL):

    PHP Code:
    <?php
    $findme    
    'a';
    $mystring1 'xyz';
    $mystring2 'ABC';

    $pos1 stripos($mystring1$findme);
    $pos2 stripos($mystring2$findme);

    // Nope, 'a' is certainly not in 'xyz'
    if ($pos1 === false) {
       echo 
    "The string '$findme' was not found in the string '$mystring1'";
    }

    Edit: So, in your case, you would say something like:

    PHP Code:
    if ($pos1 === true) {
       die(
    "Unable to add guest book entry");

    to kill the script or whatever you want to do when you find one of these words.....
    Last edited by chump2877; 06-25-2005 at 10:10 AM.
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!


  •  

    Posting Permissions

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