mmosel Posted March 22, 2006 Share Posted March 22, 2006 Ok, I'm building a script in my admin section so that I can switch the site on and off completely. I also have message options to be displayed when the site is offline. I'm also creating a warning or notice switch to warn current users about the pending shutdown of the site as I don't want to shut people down in the middle of a transaction. So, I'm wondering how I can automate the shutdown process so that the site warns them 15 minutes before the actual shutdown? I think some sort of timed script would do the trick, but how? How can I do it within PHP? Or would I have to use CRON or something else?Thanks for any tips! Quote Link to comment https://forums.phpfreaks.com/topic/5546-warn-visitors-about-site-going-offline/ Share on other sites More sharing options...
redarrow Posted March 22, 2006 Share Posted March 22, 2006 [!--quoteo(post=357437:date=Mar 22 2006, 11:35 PM:name=mmosel)--][div class=\'quotetop\']QUOTE(mmosel @ Mar 22 2006, 11:35 PM) [snapback]357437[/snapback][/div][div class=\'quotemain\'][!--quotec--]Ok, I'm building a script in my admin section so that I can switch the site on and off completely. I also have message options to be displayed when the site is offline. I'm also creating a warning or notice switch to warn current users about the pending shutdown of the site as I don't want to shut people down in the middle of a transaction. So, I'm wondering how I can automate the shutdown process so that the site warns them 15 minutes before the actual shutdown? I think some sort of timed script would do the trick, but how? How can I do it within PHP? Or would I have to use CRON or something else?Thanks for any tips![/quote]why not just redirect the user to a warning page if the site completly off.[code]if($site==off) {http// redirect}if($offline) {http// redirect}[/code]A thortgood luck. Quote Link to comment https://forums.phpfreaks.com/topic/5546-warn-visitors-about-site-going-offline/#findComment-19794 Share on other sites More sharing options...
mmosel Posted March 23, 2006 Author Share Posted March 23, 2006 Already have that. That's not what I'm asking... Quote Link to comment https://forums.phpfreaks.com/topic/5546-warn-visitors-about-site-going-offline/#findComment-19802 Share on other sites More sharing options...
.-INSANE-. Posted March 23, 2006 Share Posted March 23, 2006 in most admin cps there is a place to turn the site off and a page sayin if your off Quote Link to comment https://forums.phpfreaks.com/topic/5546-warn-visitors-about-site-going-offline/#findComment-19846 Share on other sites More sharing options...
Prismatic Posted March 23, 2006 Share Posted March 23, 2006 Cron would be your best bet. If anything make it manual. Put in a way to show a message @ the top of all your pages (easy) that says site coming down in 15 minues or something, and then in 15 mins, just shut it down yourself. Quote Link to comment https://forums.phpfreaks.com/topic/5546-warn-visitors-about-site-going-offline/#findComment-19854 Share on other sites More sharing options...
redbullmarky Posted March 23, 2006 Share Posted March 23, 2006 without going as far as the time warning, i have a function on most of my sites that allows me to take it offline. in every page in my site, i include a 'configuration.php' file, which along with making sure certain settings are set up, etc, also checks my database to see if i have requested the site to go offline. just a simple SELECT from the database. if the site is offline, i just use:[code]if ($offline){ header("Location: bebacklater.php"); exit;}[/code]to do the redirect.if you wanted to do a time warning then:(assiming that $offlinetime is the timestamp you have set to go offline, read from the database. ie 15 minutes into the future)[code]if ($offline){ if (time()>=$offlinetime) { header("Location: bebacklater.php"); exit; } else { // how many minutes before shutdown? $timetoshutdown = ($offlinetime- time()) / 60; $timetoshutdown = round($timetoshutdown); $system_message = "The site will go offline in approximately ".$timetoshutdown." minutes"; }}[/code]you can then use the variable $system_message to display a message to users on pages they visit during a timeout period.so to kick off the above, then in your admin panel all you need is a mysql_query that sets an 'offline' field to true, and a field 'offlinetime' to: time()+(60*15).hope that makes sense. Quote Link to comment https://forums.phpfreaks.com/topic/5546-warn-visitors-about-site-going-offline/#findComment-19862 Share on other sites More sharing options...
mmosel Posted March 23, 2006 Author Share Posted March 23, 2006 [!--quoteo(post=357509:date=Mar 23 2006, 02:51 AM:name=redbullmarky)--][div class=\'quotetop\']QUOTE(redbullmarky @ Mar 23 2006, 02:51 AM) [snapback]357509[/snapback][/div][div class=\'quotemain\'][!--quotec--]you can then use the variable $system_message to display a message to users on pages they visit during a timeout period.so to kick off the above, then in your admin panel all you need is a mysql_query that sets an 'offline' field to true, and a field 'offlinetime' to: time()+(60*15).hope that makes sense.[/quote]Hmm, thanks. That's interesting. So, I would designate the time in the future that i want the site to go offline, and if someone visits the page and the math works out then the site is offline. I dig it.I already have a system that I wrote that includes a customizable site alert message that I can turn on at the top of every page. I also have a switch to shut the site completely off. I can then choose 1 of 3 changeable messages to show to visitors.In my first script I check the db for both switches (alert and offline). If offline is true, then I simply include my offline.php and exit(); out of my script. It works great, but I think I'm going to try and incorporate your code example to see if I can have it automated so that users can see the time reducing as they surf! That would be nice. 15mins - 10 - 5 etc. before site goes offline.Thanks for everyones input! I'll give it a go tomorrow night maybe... Quote Link to comment https://forums.phpfreaks.com/topic/5546-warn-visitors-about-site-going-offline/#findComment-19889 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.