rofl90 Posted March 8, 2008 Share Posted March 8, 2008 How would you go about turning off your website, I mean I already have an option in my backend to specify maintenance, but to have it on each page as opposed to the outdated index, index2, mechanism, to check if the user is authenticated, and if not kill the script, but how would I do that without doubling my code, and inturn doubling my load time. Quote Link to comment https://forums.phpfreaks.com/topic/95031-maintenance-page/ Share on other sites More sharing options...
unsider Posted March 8, 2008 Share Posted March 8, 2008 write login code, whatever, and check if($session->logged_in){ // display site } else { header("http://www.google.com"); } Otherwise I'm confused by your question, maybe more clarification? Quote Link to comment https://forums.phpfreaks.com/topic/95031-maintenance-page/#findComment-486776 Share on other sites More sharing options...
rofl90 Posted March 8, 2008 Author Share Posted March 8, 2008 It needs to check if the site is on maintenance too. Quote Link to comment https://forums.phpfreaks.com/topic/95031-maintenance-page/#findComment-486786 Share on other sites More sharing options...
unsider Posted March 8, 2008 Share Posted March 8, 2008 Wouldn't you rather determine that for yourself and just set a user/pass for your friends/viewers to use, and give it to them if they wanna see it? Quote Link to comment https://forums.phpfreaks.com/topic/95031-maintenance-page/#findComment-486789 Share on other sites More sharing options...
laffin Posted March 8, 2008 Share Posted March 8, 2008 depends how u store the switching of site on/off line.. easiest is prollly mysql, using a table for yer vars... CREATE TABLE `vars` ( `name` varchar(32) NOT NULL default '', `i` int(10) NOT NULL default '0', `u` int(10) unsigned NOT NULL default '0', `f` double NOT NULL default '0', `s` varchar(100) NOT NULL default '', PRIMARY KEY (`name`) ) ENGINE=MyISAM; than ya can add a switching system in the admin page on login, ya want to check this value, if admin or other special case users allow it, otherwise deny the user. Quote Link to comment https://forums.phpfreaks.com/topic/95031-maintenance-page/#findComment-486791 Share on other sites More sharing options...
rofl90 Posted March 8, 2008 Author Share Posted March 8, 2008 would this work: Check if the page is on maintenance if yes, check if the user is logged in, if not include a maintenance page and leave it at that implying an else continue ???I this possible ??? Quote Link to comment https://forums.phpfreaks.com/topic/95031-maintenance-page/#findComment-486795 Share on other sites More sharing options...
unsider Posted March 8, 2008 Share Posted March 8, 2008 Yes it's possible, with 2 if statements you could achieve that. Or the database solution laffin showed you. Quote Link to comment https://forums.phpfreaks.com/topic/95031-maintenance-page/#findComment-486798 Share on other sites More sharing options...
laffin Posted March 8, 2008 Share Posted March 8, 2008 if(!$siteonline && !$userloggedin) header("Location: http://my.site.com/oopsie.html"); a multiconditional works as well Quote Link to comment https://forums.phpfreaks.com/topic/95031-maintenance-page/#findComment-486802 Share on other sites More sharing options...
rofl90 Posted March 8, 2008 Author Share Posted March 8, 2008 forgot your {} Anyway that looks good laffin, I will use a multiconditional statement. Quote Link to comment https://forums.phpfreaks.com/topic/95031-maintenance-page/#findComment-486805 Share on other sites More sharing options...
laffin Posted March 8, 2008 Share Posted March 8, 2008 { } only needed when ya have more than 1 statement (a block) of code Quote Link to comment https://forums.phpfreaks.com/topic/95031-maintenance-page/#findComment-486810 Share on other sites More sharing options...
rofl90 Posted March 8, 2008 Author Share Posted March 8, 2008 got it working <?php session_start(); require("inc/connectdb.php"); $thequery= "SELECT * FROM settings"; $maintenancequery = mysql_query($thequery) or die(mysql_error()); $settings = mysql_fetch_array($maintenancequery); $siteonline = $settings['maintenance']; if($siteonline == '0' && $_SESSION["access"] != 'granted') { header("Location: http://www.codeetech.com/maintenance.php"); } else { //blablabla } ?> Quote Link to comment https://forums.phpfreaks.com/topic/95031-maintenance-page/#findComment-486813 Share on other sites More sharing options...
laffin Posted March 8, 2008 Share Posted March 8, 2008 Congrats And thanks for sharing code, pretty shure others will find it useful Quote Link to comment https://forums.phpfreaks.com/topic/95031-maintenance-page/#findComment-486832 Share on other sites More sharing options...
rofl90 Posted March 8, 2008 Author Share Posted March 8, 2008 Your welcome, and thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/95031-maintenance-page/#findComment-486835 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.