Jump to content


Photo

flood controll with the floor statement.


  • Please log in to reply
8 replies to this topic

#1 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 30 July 2006 - 06:19 AM

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

$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!":

}

?>










Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 30 July 2006 - 07:01 AM

why dont this work what have i done wrong cheers.

the code should floor the minutes via 10 miuntes.

<?
$minutes=date("i");

$advance_minutes=strtotime($minutes);

$result=floor($advance_minutes/600);

echo $result;

?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 30 July 2006 - 07:05 AM

This should work why not cheers.
<?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!";

}

?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 30 July 2006 - 08:21 AM

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.

<?php

$time_know=date("h:i:s");

$result_know=strtotime($time_know);

$result=floor($result_know/87000);

echo "<br>$result<br>";

?>


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 30 July 2006 - 08:41 AM

I copied your piece of code and the $result has stayed the same 13267. The local time here is 0340 3:40 am

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#6 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 30 July 2006 - 08:43 AM

does not make sence as the time stamp is correct
<?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>";

?>

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

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#7 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 30 July 2006 - 08:58 AM

i think i got it not sure theo


does it look correct.

<?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>";

?>


13359 time from database as above

13959 time from above with 10 minutes in front



Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#8 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 30 July 2006 - 09:23 AM

try
<?php
$database_time="10:12:30";
if (time() < strtotime("+10 minutes $database_time")) {
	echo "wait 10 mins" ;
}
else
{
	echo "process post data";
}
?>

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#9 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 30 July 2006 - 10:13 AM

no luck

windows wont let me do it the baby way iver

any idears please cheers.


<?php
$database_time="10:30:33";

$m=date("i")-60*5;
$time_know=date("h:i:s ",$m);

echo $time_know;

?>


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users