Maintenance mode

Views: 89 Last modified: August 03rd, 2011 Comments: 0

This function will redirect your visitors if your site is going under maintenance.

Keep this function out of your main template files, but in a file which is always included. For example a php file which is always included in your header.

function maintenance($M_mode, $Redirect)
{
    if ($M_mode === true)
    {
        $url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
        if (trim($url) != trim($Redirect))
        {
            header('Location:'.trim($Redirect));
        }
    }
}

How to use

Include this function somewhere in your header, or at least a included/required file which always will be called so no backdoors are open.

// $M_mode must be false if your website is online, set to true if you are busy with maintenance
// $Redirect url to redirect to
maintenance($M_mode = false, $Redirect = 'http://localhost/maintenance/sorry.php');
VN:F [1.9.13_1145]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.13_1145]
Rating: 0 (from 0 votes)

    Mail this!

    To: From:Sum {0+8} =  
    Anything to add ?

        You must be logged in to post a comment.