# Create as many usernames and passwords as you wish below.
# Format : $u['username'] = 'password';
# If possible do not associate the same password with more than one username.
# If you wish to remove authentication from the system simply remove any user details below.
$u['admin'] = 'admin';
$u['admin2'] = 'admin2';
# This can be any value. It is recommended that this value is a variable to ensure maximum security.
# The default is todays date as this value is variable.
$secretkey = date("m.d.y");
##
## No need to edit below.
##
if (@$_GET['do'] == 'logout') {
setcookie ("user", '', time() - 12200);
setcookie ("token", '', time() - 12200);
$ref = $_SERVER['HTTP_REFERER'];
header("Location: $ref");
}
if (!empty($u)) {
if(@$_GET['do'] == 'login') {
$username = $_POST['username'];
$password = $_POST['password'];
if( array_search($password, $u) == $username && $u[$username] == $password ) {
setcookie ("user", $username, time() + 12200);
setcookie ("token", sha1($username.$secretkey), time() + 12200);
header('Location: index.php');
} else {
show_login("Username & Password Do Not Match.");
die();
}
}
if (!$_COOKIE['token'] || !$_COOKIE['user'])
{
show_login("Please Login");
die();
} else {
if ( sha1($_COOKIE['user'].$secretkey) !== $_COOKIE['token'] ) {
setcookie ("user", "", time() - 3600);
setcookie ("token", "", time() - 3600);
show_login("Please Login");
die();
}
}
}
function show_login($message) {
?>
}
?>