Jump to content

[SOLVED] Making a maintenance script


adamjones

Recommended Posts

Hi,

 

I was wondering anyone could help make a maintenance script, or give a ink to one.

 

Basically, i want to add something like;

 

<?

if(! maintenance == 1}

header("location:maintenance.php");

}

?>

 

To the top of my pages, and I would like to turn maintenance on or off, through an external file. Therefore, if it's set to 1, then it would redirect the user to maintenance.php, and if its set to anything else, it wouldn't redirect. If that makes sense?

 

Any help on this would be great!

Cheers.

Link to comment
https://forums.phpfreaks.com/topic/125194-solved-making-a-maintenance-script/
Share on other sites

there are many ways of doing this... but yes, the most simple way would be to add

 

if(MAINTENANCE == true) {
   header('location:maintenance.php');
   die();
}

 

to the top of every page or to a bootstrap file and then have somewhere above that, also likely on a bootstrap file...

 

define('MAINTENANCE', true); // or false

 

you can manually change.

 

of course most requirements for maintenance are much more complicated than that, but it's a good starting point.

Ok. I see. So if I add;

 

<?

 

@include check.php

 

if(MAINTENANCE == true) {

  header('location:maintenance.php');

  die();

}

 

?>

 

And then make a file called check.php, what would I add to the check.php file to set it to true/false?

 

Cheers.

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.