Jump to content

Archived

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

Crypt

Ban IP for 1 day

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

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.