rofl90 Posted March 24, 2007 Share Posted March 24, 2007 I know to check a valu andif its say 0 using the die() function before the age loads to display a maintenance/offline page, how would I like..: Code in the header/top of each page; Code to change the online/maintenanc/offline status? Thankyou in advance, Charlie Quote Link to comment https://forums.phpfreaks.com/topic/44180-solved-maintenance-page/ Share on other sites More sharing options...
DeathStar Posted March 24, 2007 Share Posted March 24, 2007 How do you mean? Like have a header and body page? <?php session_start(); echo "Header"; echo "<table><tr><td>"; include "Menu.php"; echo "</td></td><td>"; then at the end of the body pages just put: echo "</td></tr></table>"; Quote Link to comment https://forums.phpfreaks.com/topic/44180-solved-maintenance-page/#findComment-214525 Share on other sites More sharing options...
rofl90 Posted March 24, 2007 Author Share Posted March 24, 2007 Na i mean on each page of my site, in my admin panel i can add an option to set the thing offline/online etc i have an option with stops mysql, for debbuging, but not to actually change the page it only doesn't function properly, i need to have an option in admin panel, and i know what it would do at the top of the page eg if a alue is die() etc.. but i don't know the code sorry, im a bit new to PHP.. Quote Link to comment https://forums.phpfreaks.com/topic/44180-solved-maintenance-page/#findComment-214527 Share on other sites More sharing options...
rofl90 Posted March 25, 2007 Author Share Posted March 25, 2007 Hmmm: if ($offline_variable == 1) { require( 'http://www.mydomain/offline.php' ); } but how would i set the variable? Quote Link to comment https://forums.phpfreaks.com/topic/44180-solved-maintenance-page/#findComment-214536 Share on other sites More sharing options...
cmgmyr Posted March 25, 2007 Share Posted March 25, 2007 config.php: $offline_variable = 1; any other page: global $offline_variable; if ($offline_variable == 1) { require( 'http://www.mydomain/offline.php' ); } something like that? Quote Link to comment https://forums.phpfreaks.com/topic/44180-solved-maintenance-page/#findComment-214547 Share on other sites More sharing options...
rofl90 Posted March 25, 2007 Author Share Posted March 25, 2007 Ya i added it to my config file, but how can i change it using a form? eg a options/radio buttons and directly changing the config file from that? Quote Link to comment https://forums.phpfreaks.com/topic/44180-solved-maintenance-page/#findComment-214550 Share on other sites More sharing options...
rofl90 Posted March 25, 2007 Author Share Posted March 25, 2007 Any luck coders and codettes? Quote Link to comment https://forums.phpfreaks.com/topic/44180-solved-maintenance-page/#findComment-214556 Share on other sites More sharing options...
rofl90 Posted March 25, 2007 Author Share Posted March 25, 2007 18 views since ne1 got a solution ;P Quote Link to comment https://forums.phpfreaks.com/topic/44180-solved-maintenance-page/#findComment-214564 Share on other sites More sharing options...
MadTechie Posted March 25, 2007 Share Posted March 25, 2007 yep.. but as you havn't given anyone anything to work with i guess we're all just have to magically write the whole thing for you, also if you need any dishes washed just say.. Quote Link to comment https://forums.phpfreaks.com/topic/44180-solved-maintenance-page/#findComment-214570 Share on other sites More sharing options...
rofl90 Posted March 25, 2007 Author Share Posted March 25, 2007 All i need is eg.. <form action="apply.php"> <input type="radio" value="offline"> <input type="radio" value="online"> </form> and the handler needs to apply value within config.php $offline_variable = 1; change the 1 to 0 and vice versa,.. Quote Link to comment https://forums.phpfreaks.com/topic/44180-solved-maintenance-page/#findComment-214574 Share on other sites More sharing options...
MadTechie Posted March 25, 2007 Share Posted March 25, 2007 So your writting to a php file.. erm.. !!! why? i am guessing you didn't write the "my admin panel" how does that store its settings ? Quote Link to comment https://forums.phpfreaks.com/topic/44180-solved-maintenance-page/#findComment-214575 Share on other sites More sharing options...
rofl90 Posted March 25, 2007 Author Share Posted March 25, 2007 Via MySQL Quote Link to comment https://forums.phpfreaks.com/topic/44180-solved-maintenance-page/#findComment-214576 Share on other sites More sharing options...
MadTechie Posted March 25, 2007 Share Posted March 25, 2007 store the offline var their then.. just add a field Quote Link to comment https://forums.phpfreaks.com/topic/44180-solved-maintenance-page/#findComment-214580 Share on other sites More sharing options...
HaLo2FrEeEk Posted March 25, 2007 Share Posted March 25, 2007 Why not use a database, then in your normal header check whether or not the value of the maintenance variable is set to 0, if it is, then the page should die before printing any code, or, print code that will display a maintenance notification, if it isn't, print the page normally...this is what I would do. Quote Link to comment https://forums.phpfreaks.com/topic/44180-solved-maintenance-page/#findComment-214629 Share on other sites More sharing options...
rofl90 Posted March 26, 2007 Author Share Posted March 26, 2007 sorry errm im not understandig i dont want to use a database i want tostore it in config file Quote Link to comment https://forums.phpfreaks.com/topic/44180-solved-maintenance-page/#findComment-215234 Share on other sites More sharing options...
MadTechie Posted March 26, 2007 Share Posted March 26, 2007 isn't the config file a php file ? well i feel like your shootin yourself in the foot here but you can write the php file just like any other text file. Quote Link to comment https://forums.phpfreaks.com/topic/44180-solved-maintenance-page/#findComment-215334 Share on other sites More sharing options...
trq Posted March 26, 2007 Share Posted March 26, 2007 You are actually better off to use a config file. What if you actually are doing maintainence, and the database isn't available. But yeah, writting to a php file is just like any other. Use fwrite. Quote Link to comment https://forums.phpfreaks.com/topic/44180-solved-maintenance-page/#findComment-215335 Share on other sites More sharing options...
HaLo2FrEeEk Posted March 26, 2007 Share Posted March 26, 2007 Then do that, use the config file like you would the database, each value on its own line, read in the file, then find the maintenance value, read it, if it is 0, stop the header code, if it is not, print the header code like normal, whats the problem? Quote Link to comment https://forums.phpfreaks.com/topic/44180-solved-maintenance-page/#findComment-215612 Share on other sites More sharing options...
rofl90 Posted March 28, 2007 Author Share Posted March 28, 2007 Everyone on this forum is brilliant, but for 9 out of 10 questions, Super administrators are the only that answer perfectly ;P fwrite works fine.. I don't know that much about functions and arrays, so I can't just think 'AHA use that function ect' Thanks again, Charlie Heres my FINAL code: <?php $config = 'config.php'; $offline_var = 1; if (is_writable($config)) { if (!$handle = fopen($config, 'a')) { echo "Cannot open file ($config)"; exit; } if (fwrite($handle, $offline_var) === FALSE) { echo "Cannot write to file ($conig)"; exit; } echo "Success, wrote ($offline_var) to file ($config)"; fclose($handle); } else { echo "The file $config is not writable"; } ?> Looking to orange ugh whats wrong with it guys? Quote Link to comment https://forums.phpfreaks.com/topic/44180-solved-maintenance-page/#findComment-216578 Share on other sites More sharing options...
rofl90 Posted March 28, 2007 Author Share Posted March 28, 2007 Config.php $mosConfig_offline = '1'; $mosConfig_offline_message = 'This site is down for maintenance.<br /> Please check back again soon.'; header.php <?php require ("includes/config.php") ?> <?php global $offline_variable; if ($offline_variable == 1) { echo( '$mosConfig_offline_message' ); } ?> errm it doesn't work hwo do i kill the rest of the page Quote Link to comment https://forums.phpfreaks.com/topic/44180-solved-maintenance-page/#findComment-216597 Share on other sites More sharing options...
MadTechie Posted March 28, 2007 Share Posted March 28, 2007 <?php require ("includes/config.php") ?> <?php global $offline_variable; if ($offline_variable == 1) { die( '$mosConfig_offline_message' ); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/44180-solved-maintenance-page/#findComment-216840 Share on other sites More sharing options...
rofl90 Posted March 28, 2007 Author Share Posted March 28, 2007 Im copying Joomlas config file as it has every var ill need it was $mosConfig_offline and it was $offline_variable Thanks anyways Quote Link to comment https://forums.phpfreaks.com/topic/44180-solved-maintenance-page/#findComment-216884 Share on other sites More sharing options...
trq Posted March 28, 2007 Share Posted March 28, 2007 <?php require "includes/config.php"; if ($mosConfig_offline) { die($mosConfig_offline_message); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/44180-solved-maintenance-page/#findComment-216887 Share on other sites More sharing options...
rofl90 Posted March 28, 2007 Author Share Posted March 28, 2007 The subject does say 'solved' with a tick.. In other words. I've done ;P Quote Link to comment https://forums.phpfreaks.com/topic/44180-solved-maintenance-page/#findComment-216891 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.