Jump to content


Photo

Ban IP for 1 day


  • Please log in to reply
2 replies to this topic

#1 Crypt

Crypt
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 28 April 2006 - 02:52 PM

I would like to incorperate this into my "tag-board" where after they post a message it bans their ip from posting another one for 1 day..

#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 28 April 2006 - 03:13 PM

Have a table called lets say ipban, which has a column called IP and a column called timestamp.
Then, when the user posts check:
$ip = getenv('REMOTE_ADDR');
$sql="SELECT timestamp FROM `ipban` WHERE IP='$ip' ORDER BY timestamp ASC LIMIT 1"; //we want the last time stamp of the user's IP
$result=mysql_query($sql);
if(mysql_num_rows($result)>0){
$last_ban=mysql_result($result, 0);
$24h=60*60*24;
$ban_until=$lastban+$24h;
$now=time();
if($ban_until>$now)
{die("You cant post more than once in 24 hours.");}
};

//rest of code

Hope it helps,
Orio.
Think you're smarty?

(Gone until 20 to November)

#3 Crypt

Crypt
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 28 April 2006 - 10:43 PM

Thank you very much, hope this works.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users