Jump to content

Ban IP for 1 day


Crypt

Recommended Posts

Have a table called lets say ipban, which has a column called IP and a column called timestamp.
Then, when the user posts check:
[code]
$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
[/code]

Hope it helps,
Orio.
Link to comment
https://forums.phpfreaks.com/topic/8637-ban-ip-for-1-day/#findComment-31701
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.