Jump to content

php guestbook, spam, etc


valoukh

Recommended Posts

Hi all.

 

I have a php guestbook on our website and recently we've been getting a lot of ridiculous spam messages! I'm looking for advice on preventing it. I've looked into using image verification but it's proving difficult to set up so until I manage to figure it out (unless someone knows of some easy code that works!) I'm trying to find a temporary solution. I've noticed that 99% of the spam messages contain URLs, so I thought an IF statement like "if comment doesn't contain "http"" might do the trick. I've tried stuff like this but can't seem to get it working:

 

if not ($row['Comment'] =~ /http/) {

if not ($row['Comment']) =~ /http/ {

if not ($row['Comment'] =~ "http") { etc

 

Any help is much appreciated,

valoukh.

Link to comment
Share on other sites

Thank you. I want it so that it prints all records without 'http' in them so i've written:

 

if not (stristr($row['Comment'], 'http')) { // http is in the string

 

but I'm getting the error:

 

Parse error: syntax error, unexpected T_STRING, expecting '(' in /home/l21denb/public_html/HTML/guestbook.php on line 155

 

Can't work out what's missing!

Link to comment
Share on other sites

This is just an idea I have, and I'm going to write the example off the top of my head, but hopefully it will help. Essentially its a number verification system.

 

Have this on your page inside the form where the user signs the guestbook. It generats a number from 1-100000 and saves it as a variable. It then asks the user to type the number in the textbox.

$number = rand(1, 100000);
echo "$number";
echo "<input type=\"hidden\" value=\"$number\" name=\"realnumber\">";
echo "<input type=\"text\" name=\"usernumber\">";

 

Here, the script compares the two numbers. If they match, it executes the guestbook script. If else, it well, doesnt.

$number = $_POST['number'];
$usernumber = $_POST['usernumber'];
if($number == $usernumber){
execute guestbook script
}
else
{
echo "Incorrect Verification Code!";
}

 

Crude example, but I hope it helps.

Link to comment
Share on other sites

Thanks for the code! Seems to be working, although you can get around it by not entering anything!

 

Do I need something like this?

 

if not(empty($usernumber )) {

if($number == $usernumber){

 

not sure of the syntax for the first IF

Link to comment
Share on other sites

let me explain further:

using Spam-Me-Not(I'm not crazy about writing my own decimal codes for letters), I converted http://jonsjava.com to

&#104;&#116;&#116;&#112;&#58;&#47;&#47;&#106;&#111;&#110;&#115;&#106;&#97;&#118;&#97;&#46;&#99;&#111;&#109;

so I could then just do this:

<a href="&#104;&#116;&#116;&#112;&#58;&#47;&#47;&#106;&#111;&#110;&#115;&#106;&#97;&#118;&#97;&#46;&#99;&#111;&#109;">Mysite</a>(example)

so it would output the link to my site.  Your site doesn't protect against people posting html.  you fix that, and you'll have fixed most of your problem.

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.