adamjones Posted September 21, 2008 Share Posted September 21, 2008 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 More sharing options...
genericnumber1 Posted September 21, 2008 Share Posted September 21, 2008 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. Link to comment https://forums.phpfreaks.com/topic/125194-solved-making-a-maintenance-script/#findComment-647129 Share on other sites More sharing options...
adamjones Posted September 21, 2008 Author Share Posted September 21, 2008 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. Link to comment https://forums.phpfreaks.com/topic/125194-solved-making-a-maintenance-script/#findComment-647137 Share on other sites More sharing options...
genericnumber1 Posted September 21, 2008 Share Posted September 21, 2008 define('MAINTENANCE', true); Also, don't use short tags, don't use @, and put quotes around check.php. Link to comment https://forums.phpfreaks.com/topic/125194-solved-making-a-maintenance-script/#findComment-647140 Share on other sites More sharing options...
adamjones Posted September 21, 2008 Author Share Posted September 21, 2008 Thank's generic, all working now. Link to comment https://forums.phpfreaks.com/topic/125194-solved-making-a-maintenance-script/#findComment-647148 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.