function mystery_process_authentication() { // this function processes a user's authentication, displaying login forms, // error messages, etc. global $_MYSTERY; if (@$_SESSION['is_logged_in'] == 'yes') { return; } mystery_setup_default_session(); if (@$_REQUEST['username'] == '' || @$_REQUEST['password'] == '') { // the user didn't send a password / username, so just display the form mystery_header(); mystery_display_authentication_form(); mystery_footer(); } else { // user provided some authentication information, attempt to authenticate if (!mystery_auth($_REQUEST['username'], $_REQUEST['password'])) { // user couldn't be authenticated, display error message and login box again mystery_header(); mystery_display_user_error('You entered an invalid username or password, or cannot login from your current location. Please try again.'); mystery_display_authentication_form(); mystery_footer(); } } }
if (isset($_REQUEST['username']) && isset($_REQUEST['password'])) { if (mystery_auth($_REQUEST['username'], $_REQUEST['password'])) { if (!isset($_COOKIE['cookietest'])) { // they know their username and password but since they do not // have cookies enabled, they won't be able to use the site $login_failed = 'yes'; $login_failure_reason = 'cookie'; } else { mystery_redirect($lastloc); } } else { $login_failed = 'yes'; } } // destroy any existing sessions mystery_setup_default_session(); // display alert messages if necessary if ($login_failed == 'yes') { if ($login_failure_reason == 'cookie') { $alert = '<p class="error-message"><strong>There was a problem signing in.</strong><br> It appears that you do not have cookies enabled. You must enable cookies in order to use this site.</p>'; } else { $alert = '<p class="error-message"><strong>There was a problem signing in.</strong><br> Please check your username and password again. If you do not know your password, contact your teacher or school administrator.</p>'; } } if (isset($_REQUEST['signout'])) { $alert = ' <p class="alert-message"><strong>Sign-out successful</strong><br>