Jump to content


Photo

Warn visitors about site going offline?


  • Please log in to reply
6 replies to this topic

#1 mmosel

mmosel
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts

Posted 22 March 2006 - 11:35 PM


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!

#2 redarrow

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

Posted 22 March 2006 - 11:46 PM

[!--quoteo(post=357437:date=Mar 22 2006, 11:35 PM:name=mmosel)--][div class=\'quotetop\']QUOTE(mmosel @ Mar 22 2006, 11:35 PM) View Post[/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.

if($site==off) {

http// redirect

}


if($offline) {

http// redirect

}


A thort

good luck.



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 mmosel

mmosel
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts

Posted 23 March 2006 - 12:53 AM

Already have that. That's not what I'm asking...


#4 .-INSANE-.

.-INSANE-.
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 23 March 2006 - 04:28 AM

in most admin cps there is a place to turn the site off and a page sayin if your off

#5 Prismatic

Prismatic
  • Members
  • PipPipPip
  • Advanced Member
  • 503 posts
  • LocationSan Diego

Posted 23 March 2006 - 05:47 AM

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.

#6 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 23 March 2006 - 07:51 AM

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:

if ($offline)
{
   header("Location: bebacklater.php");
   exit;
}

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)
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";
   }
}

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.
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!

#7 mmosel

mmosel
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts

Posted 23 March 2006 - 10:20 AM

[!--quoteo(post=357509:date=Mar 23 2006, 02:51 AM:name=redbullmarky)--][div class=\'quotetop\']QUOTE(redbullmarky @ Mar 23 2006, 02:51 AM) View Post[/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...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users