MyBB Community Forums

Full Version: http authentication
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
were can i put this script to protect my admin page when logging in?

<? 
if (@$_SERVER['PHP_AUTH_USER'] != 'john' && @$_SERVER['PHP_AUTH_PW'] != 'secret') {
      
    header('WWW-Authenticate: Basic realm="Site Administration Area"');
    header('Status: 401 Unauthorized');
    /* Special Header for CGI mode */
    header('HTTP-Status: 401 Unauthorized');
    
    ?>

<html>
<head>
<title>Access Unauthorized</title>
</head>
<body>
<h1>Access to the requested page denied</h1>
You have been denied access to this page for entering an 
incorrect or non-exist username and password.<br><br>
Press 'Refresh' to retry the login procedure.
</body>
</html>

    <?php
    exit;
} 

echo 'Welcome to our site, username ' . $_SERVER['PHP_AUTH_USER'];

?>
You could stick it in global.php I guess. That would protect all pages.