Author Topic: Stoping spammers posting junk using IP address!!!  (Read 451 times)

0 Members and 1 Guest are viewing this topic.

Offline npsariTopic starter

  • Enthusiast
  • Posts: 367
  • Gender: Male
    • View Profile
    • Npsari.com - Free local online classifieds
Stoping spammers posting junk using IP address!!!
« on: May 17, 2007, 06:14:28 PM »
hi guys

I am back with a new interesting question

I have a colomb which stores the users IP

I use this code to insert data

Code: [Select]
<?php 
mysql_select_db
("databse"$con); 

$IP=GetHostByName($REMOTE_ADDR); 
$Date date("Y/m/d");

$tim localtime(time(),true);
$Time=($tim['tm_hour'].":".$tim['tm_min'].":".$tim['tm_sec']);

$query="INSERT INTO ads (Email, Title, Date, Time, IP) VALUES ('$Email', '$Title', '$Date', '$Time', '$IP')"

print 
"Data was inserted successfully"
?>


How can I stop the same IP adding to databse unless minium 6 hours pass by

what should i add
« Last Edit: May 17, 2007, 06:27:38 PM by npsari »

Offline per1os

  • Fanatic
  • Posts: 4,005
  • Gender: Female
  • badger badger badger
    • View Profile
Re: Stoping spammers posting junk using IP address!!!
« Reply #1 on: May 17, 2007, 06:18:15 PM »
You should probably add a timeentered column so you have a date to reference and than before you insert another ad pull out all ads from a certain ip and than do a date/timecheck with the timeentered in the db and if the timeentered is less than 6 hours do not allow it to be inserted.
Note: I do not test most of my code before posting, be aware!!!!

Offline npsariTopic starter

  • Enthusiast
  • Posts: 367
  • Gender: Male
    • View Profile
    • Npsari.com - Free local online classifieds
Re: Stoping spammers posting junk using IP address!!!
« Reply #2 on: May 17, 2007, 06:29:31 PM »
Dont need to exhaust you, but can someone show me the technique

Just the Time function

(I can relate it to the rest)

How can I write the if function which says: Time is less that 6 hours
« Last Edit: May 17, 2007, 06:31:09 PM by npsari »

Offline per1os

  • Fanatic
  • Posts: 4,005
  • Gender: Female
  • badger badger badger
    • View Profile
Re: Stoping spammers posting junk using IP address!!!
« Reply #3 on: May 17, 2007, 06:38:40 PM »
Code: [Select]
<?php

$timeAgainst 
strtotime($dbTime);
$timeNow time()-3600*6// time now minus 6 hours ago

if ($timeAgainst $timeNow) {
     echo 
'Sorry you recently entered an ad, please wait at least 6 hours from time of entry.';
}else {
     echo 
'Data has been inserted!';
}
?>


I always screw up on date logic, do some tests and see if that jives. if not try flipping the > to < and see what happens.
Note: I do not test most of my code before posting, be aware!!!!

Offline npsariTopic starter

  • Enthusiast
  • Posts: 367
  • Gender: Male
    • View Profile
    • Npsari.com - Free local online classifieds
Re: Stoping spammers posting junk using IP address!!!
« Reply #4 on: May 17, 2007, 06:56:00 PM »
Can we do it differently

How can I say...

Code: [Select]
Time (when IP was submitted which i will derive) - Time now = Less than 6 hours

print "Sorry";

Show me function please, with these variables:
Time now is $Timenow
Time submitted is $Time

Offline per1os

  • Fanatic
  • Posts: 4,005
  • Gender: Female
  • badger badger badger
    • View Profile
Re: Stoping spammers posting junk using IP address!!!
« Reply #5 on: May 18, 2007, 11:13:51 AM »
Code: [Select]
<?php

$timeAgainst 
strtotime($dbTime);
$timeNow time(); // time now minus 6 hours ago

if (($timeAgainst $timeNow) < time()-3600*6) {
     echo 
'Sorry you recently entered an ad, please wait at least 6 hours from time of entry.';
}else {
     echo 
'Data has been inserted!';
}
?>

Note: I do not test most of my code before posting, be aware!!!!