Show DevBest [PHP]Maintenance page switcher

Status
Not open for further replies.

Macemore

Circumcised pineapples
Aug 26, 2011
1,681
819
Fairly simple Maintenance page switcher.
Downlaod:
changemaint.php:
PHP:
<?php
 
error_reporting('0');
session_start();
 
# Variables #
$htacc = ".htaccess"; # Location of HTAccess file #
$data = "DirectoryIndex maint.html"; # The new HTAccess file's contence #
$data2 = "DirectoryIndex index.php"; # The old HTAccess file's contence #
# Don't touch anything below this  #
 
switch($_GET['page']) {
 case '1':
   $_SESSION['maint'] = $_GET['page'];
   $fh = fopen($htacc, 'w') or die("can't open file (Error code: 1)");
   fwrite($fh, $data);
   fclose($fh);
   echo "Maintenance page is <b>Enabled</b><br />Click <a href='./changemaint.php?page=2'>here</a> to Disable";
   break;
 case '2':
   $_SESSION['maint'] = $_GET['page'];
   $fh = fopen($htacc, 'w') or die("can't open file (Error code: 2)");
   fwrite($fh, $data2);
   fclose($fh);
   echo "Maintenance page is <b>Disabled</b><br />Click <a href='./changemaint.php?page=1'>here</a> to Enable";
   break;
 default:
   $_SESSION['maint'] = '2';
   echo "Maintenance page is <b>Disabled</b><br />Click <a href='./changemaint.php?page=2'>here</a> to Enable";
}
?>

It's super easy just upload to your website and go to
The downside of this is it's not secure but it can easily be slapped onto a login system.

Things to note:
  • This overwrites your existing .htaccess file (see below how to fix!)
  • You need PHP to use this (doh)
You shouldn't have anything to change on this EXCEPT line 10. Only change line 10 to your currect .htaccess contents if you already have one. Otherwise it's going to get erased and you'll be super butthurt.

Enjoy.
 

Macemore

Circumcised pineapples
Aug 26, 2011
1,681
819
fixed the demo:

You also need to CHMOD 777 or some crap like that.
 
Status
Not open for further replies.

Users who are viewing this thread

Top