Crypt Posted April 28, 2006 Share Posted April 28, 2006 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.. Link to comment https://forums.phpfreaks.com/topic/8637-ban-ip-for-1-day/ Share on other sites More sharing options...
Orio Posted April 28, 2006 Share Posted April 28, 2006 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 More sharing options...
Crypt Posted April 28, 2006 Author Share Posted April 28, 2006 Thank you very much, hope this works. Link to comment https://forums.phpfreaks.com/topic/8637-ban-ip-for-1-day/#findComment-31823 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.