Jump to content

Warn visitors about site going offline?


mmosel

Recommended Posts


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!
Link to comment
Share on other sites

[!--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 thort

good luck.


Link to comment
Share on other sites

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.
Link to comment
Share on other sites

[!--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...
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.