mforan Posted August 24, 2008 Share Posted August 24, 2008 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 More sharing options...
unrelenting Posted August 25, 2008 Share Posted August 25, 2008 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 } ?> Link to comment https://forums.phpfreaks.com/topic/121156-solved-locking-out-a-page-for-x-time/#findComment-624585 Share on other sites More sharing options...
mforan Posted August 25, 2008 Author Share Posted August 25, 2008 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 Link to comment https://forums.phpfreaks.com/topic/121156-solved-locking-out-a-page-for-x-time/#findComment-624594 Share on other sites More sharing options...
unrelenting Posted August 25, 2008 Share Posted August 25, 2008 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 } ?> Link to comment https://forums.phpfreaks.com/topic/121156-solved-locking-out-a-page-for-x-time/#findComment-624595 Share on other sites More sharing options...
mforan Posted August 25, 2008 Author Share Posted August 25, 2008 $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. Link to comment https://forums.phpfreaks.com/topic/121156-solved-locking-out-a-page-for-x-time/#findComment-624603 Share on other sites More sharing options...
unrelenting Posted August 25, 2008 Share Posted August 25, 2008 $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. Link to comment https://forums.phpfreaks.com/topic/121156-solved-locking-out-a-page-for-x-time/#findComment-624633 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.