Logout // // Author : Mukesh Dak // Author_Email : md@mukeshdak.com // Author_URL : http://facebook.com/mukeshdak // // =================================================================== // Login Username and Passwords array $LOGIN_DB = array( 'user' => 'password', 'user2' => 'password2' ); // request login? // true -> show login and password boxes, // false -> show password box only define('USE_USERNAME', true); // User will be redirected to this page after logout define('LOGOUT_URL', 'http://'.$_SERVER["HTTP_HOST"]); // time out after this minutes of inactivity. Set to 0 to not timeout define('TIMEOUT_MINUTES', 15); // This parameter is only useful when TIMEOUT_MINUTES is not zero // true -> timeout time from last activity, // false -> timeout time from login define('TIMEOUT_CHECK_ACTIVITY', true); if(isset($_GET['help'])) { die('Include following code into every page you would like to protect, at the very beginning (first line):
'); } // ##################### DO NOT EDIT SCRIPT BELOW THIS LINE ################## // timeout in seconds $timeout = (TIMEOUT_MINUTES == 0 ? 0 : time() + TIMEOUT_MINUTES * 60); // logout? if(isset($_GET['logout'])) { setcookie("verify", '', $timeout, '/'); // clear password; header('Location: ' . LOGOUT_URL); exit(); } if(!function_exists('show_login_form')) { // show login form function show_login_form($error_msg) { ?> Login Required
Login Required
Powered by MD Login Protect v1.0
$val) { // creating cookie variable for each login. $lp = (USE_USERNAME ? $key : '') .'%'.$val; if ($_COOKIE['verify'] == md5($lp)) { $found = true; // prolong timeout if (TIMEOUT_CHECK_ACTIVITY) { setcookie("verify", md5($lp), $timeout, '/'); } break; } } if (!$found) // Cookie is not as per usernames and passwords. { show_login_form(""); } } ?>