Jump to content

Archived

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

redarrow

flood controll with the floor statement.

Recommended Posts

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 of

h:m:s

$time="01:30:10":

how do i do the flood so that a user can not post untill they have waited 10 mins

example 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]








Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites
I copied your piece of code and the $result has stayed the same 13267. The local time here is 0340 3:40 am

Share this post


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

13267 // time stamp should be 10 minutes in front as above 87000 secons

as you can see the timestamp tacken away not added the 10 minutes.
[/code]

Share this post


Link to post
Share on other sites
i think i got it not sure theo


does 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 above

13959 time from above with 10 minutes in front

[/code]

Share this post


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

Share this post


Link to post
Share on other sites
no luck

windows wont let me do it the baby way iver

any 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]

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.