Jump to content

[SOLVED] locking out a page for X time


mforan

Recommended Posts

hi there i want to lock out pages from users at a specified daily time, rather like a lockout or downtime.

the time it would do this would be 23:55:00 and allow access to the pages at 00:05:00

 

the idea being, that users cannot do anything for 10 minutes until the time has passed!

 

i checked the time() codes as such but im a bit confused as to how this can actually be achieved suitably.

 

the idea would be to output an echo'd message like " sorry downtime till X "

 

 

any ideas guys? much appreciated.

Link to comment
https://forums.phpfreaks.com/topic/121156-solved-locking-out-a-page-for-x-time/
Share on other sites

My first thought would be something like this although this might not work properly, I didn't test it.

 

<?php

$now = time();
$current_time = date(H:i, $now);
$start = "23:55";
$end = "24:00";

if (($current_time > $start) && ($current_time < $end))
{
echo 'sorry downtime till X';
}
else
{
//execute code as usual
}

?>

i see where you're coming from with this, but the time has to go at least 5 minutes past 00:00:00 gmt. thats means, no matter what the time will goto 00:05. i thought maybe using || to list the time as 0001 || 0002 || 0003 etc might do the trick, or would there be another way around it? seems a bit tedious

Try it with 00:05 instead. Or rather:

 

<?php

$now = time();
$current_time = date(Hi, $now);
$start = "2355";
$end = "2405";

if (($current_time > $start) && ($current_time < $end))
{
echo 'sorry downtime till X';
}
else
{
        //execute code as usual
}

?>

$ct = date("Hi", time());

$start = "2355";

$end = "0005";

if (($ct > $start) || ($ct < $end))

{ mysql_close(); die("10 minute daily game downtime</body></html>"); }

 

 

^^ works a treet ^^

 

note: : isnt required and id say would probably cause problems in the example the guy posted above, though this coded idea was initially from the one above and works (for anyone that needs this kinda thing in the future.

 

 

solved.

$ct = date("Hi", time());

$start = "2355";

$end = "0005";

if (($ct > $start) || ($ct < $end))

{ mysql_close(); die("10 minute daily game downtime</body></html>"); }

 

 

^^ works a treet ^^

 

note: : isnt required and id say would probably cause problems in the example the guy posted above, though this coded idea was initially from the one above and works (for anyone that needs this kinda thing in the future.

 

 

solved.

 

Ahh, yes || would work better.

Archived

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

×
×
  • Create New...

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.