redarrow Posted July 30, 2006 Share Posted July 30, 2006 Please can you advise me if this is the correct way to do a flood contoll on my database cheers.in the database got the time in the format ofh:m:s$time="01:30:10":how do i do the flood so that a user can not post untill they have waited 10 minsexample of my code idear but needs help i think.[code]<?$database_time="01:30:30";$advance_minutes=date("i")+10;$new_time=date("h:$advance_minutes:s");if($new_time > $database_time){let the user post data}else{echo "sorry please wait 10 minutes to post agin thank you!":}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15998-flood-controll-with-the-floor-statement/ Share on other sites More sharing options...
redarrow Posted July 30, 2006 Author Share Posted July 30, 2006 why dont this work what have i done wrong cheers.the code should floor the minutes via 10 miuntes. [code]<?$minutes=date("i");$advance_minutes=strtotime($minutes);$result=floor($advance_minutes/600);echo $result;?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15998-flood-controll-with-the-floor-statement/#findComment-65747 Share on other sites More sharing options...
redarrow Posted July 30, 2006 Author Share Posted July 30, 2006 This should work why not cheers.[code]<?php// database time.$database_time="08:20:40";//convert datbase time to a time stamp.$time_stamp=strtotime($database);// tell the time stamp the secons in a day.$time_stamp_result=floor($time_stamp/86400);// get the current time.$minutes=date("h:i:s");// put current time in a time stamp$advance_minutes=strtotime($minutes);// tell the time stamp 600 secons what is 10 mins more to the time.$result=floor($advance_minutes/600);//get the time stamp with current time.$new_time=date("h:$result:s");// if new time is grater then database time then submit else halt on message.if($new_time > $time_stamp){// post data as new time is lees then database time.echo"let the user post data";}else{// halt becouse database time is more then new time.echo "sorry please wait 10 minutes to post agin thank you!";}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15998-flood-controll-with-the-floor-statement/#findComment-65749 Share on other sites More sharing options...
redarrow Posted July 30, 2006 Author Share Posted July 30, 2006 can you tell me if this is correct the $result should be 10 minutes in front am i correct.there are 86400 seconds in a day.and there are 600 secons for 10 minutes.so 86400 + 600 = 87000 secons that should be 1 day and 10 mins please help cheers.[code]<?php$time_know=date("h:i:s");$result_know=strtotime($time_know);$result=floor($result_know/87000);echo "<br>$result<br>";?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15998-flood-controll-with-the-floor-statement/#findComment-65761 Share on other sites More sharing options...
tomfmason Posted July 30, 2006 Share Posted July 30, 2006 I copied your piece of code and the $result has stayed the same 13267. The local time here is 0340 3:40 am Quote Link to comment https://forums.phpfreaks.com/topic/15998-flood-controll-with-the-floor-statement/#findComment-65763 Share on other sites More sharing options...
redarrow Posted July 30, 2006 Author Share Posted July 30, 2006 does not make sence as the time stamp is correct [code]<?php$database_time="09:40:22";$result=strtotime($database_time);$result_database=floor($result/86400);echo "<br>$result_database<br>";$time_know=date("h:i:s");echo $time_know;$result_know=strtotime($time_know);$result=floor($result_know/87000);echo "<br>$result<br>";?>[/code]result.[code]13359 // time stamp from database as above.09:45:09 // echoed time for know as above13267 // time stamp should be 10 minutes in front as above 87000 seconsas you can see the timestamp tacken away not added the 10 minutes.[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15998-flood-controll-with-the-floor-statement/#findComment-65766 Share on other sites More sharing options...
redarrow Posted July 30, 2006 Author Share Posted July 30, 2006 i think i got it not sure theodoes it look correct.[code]<?php$database_time="09:52:22";$result=strtotime($database_time);$result_database=floor($result/86400);echo "<br>$result_database<br>";$time_know=date("h:i:s");echo $time_know;$result_know=strtotime($time_know);$result=floor($result_know/86400)+600;echo "<br>$result<br>";?>[/code][code]13359 time from database as above13959 time from above with 10 minutes in front[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15998-flood-controll-with-the-floor-statement/#findComment-65769 Share on other sites More sharing options...
Barand Posted July 30, 2006 Share Posted July 30, 2006 try[code]<?php$database_time="10:12:30";if (time() < strtotime("+10 minutes $database_time")) { echo "wait 10 mins" ;}else{ echo "process post data";}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15998-flood-controll-with-the-floor-statement/#findComment-65772 Share on other sites More sharing options...
redarrow Posted July 30, 2006 Author Share Posted July 30, 2006 no luckwindows wont let me do it the baby way iverany idears please cheers.[code]<?php$database_time="10:30:33";$m=date("i")-60*5;$time_know=date("h:i:s ",$m);echo $time_know;?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15998-flood-controll-with-the-floor-statement/#findComment-65784 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.