Jump to content

[SOLVED] Maintenance page


rofl90

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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..

Link to comment
Share on other sites

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,..

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.