Copyright (C) 2005 James Grant Copyright (C) 2007 David Grant This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ ?> password != $pass) return false; /* Login successful */ return $r->id; } /* If there is no session, accept a type from the URL, else, * if there is a session, always take the session's type. The idea is * eventually, you'll never be able to see a login page if you're already * logged in. */ $type = false; if(isset($_SESSION['users_type'])) { $type = $_SESSION['users_type']; } else { $type = $_GET['type']; /* user_types is in user.inc.php */ if(!in_array($type, $user_types)) $type = false; } $notice=$_GET['notice']; switch($type) { case 'volunteer': // returns "notopenyet", "closed", or "open" $reg_open = user_volunteer_registration_status(); break; case 'committee': $reg_open = 'notpermitted'; break; case 'judge': $reg_open = user_judge_registration_status(); break; case 'student': default: $reg_open = 'closed'; break; } if($_POST['action']=="login" ) { if($_POST['pass'] && $_POST['user']) { $id = try_login($_POST['user'], $_POST['pass']); if($id == false) { header("location: user_login.php?type=$type¬ice=login_failed"); exit; } else { $u = user_load($id); $_SESSION['name']="{$u['firstname']} {$u['lastname']}"; $_SESSION['username']=$u['username']; $_SESSION['email']=$u['email']; $_SESSION['users_id']=$u['id']; $_SESSION['users_type']=$u['type']; /* Check for an expired password */ $now = date('Y-m-d H:i:s'); if($now > $u['passwordexpiry']) { $_SESSION['password_expired'] = true; /* The main page (or any other user page) will catch this now and * require them to set a password */ } /* FIXME: call a type sepcific function to set type specific session variables */ mysql_query("UPDATE users SET lastlogin=NOW() WHERE id={$u['id']}"); if(count($u['types']) > 1) { $_SESSION['multirole'] = true; header("location: user_multirole.php"); } else { $_SESSION['multirole'] = false; header("location: {$type}_main.php"); } exit; } } header("location: user_login.php?type=$type¬ice=login_failed"); exit; } else if($_GET['action']=="logout") { /* Do these explicitly because i'm paranoid */ unset($_SESSION['name']); unset($_SESSION['username']); unset($_SESSION['email']); unset($_SESSION['users_id']); unset($_SESSION['users_type']); /* Take care of anything else */ $keys = array_keys($_SESSION); foreach($keys as $k) unset($_SESSION[$k]); header("location: user_login.php?type=$type¬ice=logged_out"); exit; } else if($_GET['action']=="recover") { send_header("{$user_what[$type]} - Password Recovery", array("{$user_what[$type]} Login" => "user_login.php?type=$type")); $recover_link = "user_login.php?type=$type&action=recover"; ?>


:
:
:
" />



firstname, $fn)!=0 || strcasecmp($r->lastname, $ln)!=0) { header("Location: user_login.php?type=$type¬ice=recover_name_error"); exit; } $password = ''; $pchars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; for($x=0;$x<12;$x++) $password .= $pchars{rand(0,61)}; mysql_query("UPDATE users SET password='$password',passwordexpiry='0000-00-00' WHERE id={$r->id}"); /* volunteer_recover_password, judge_recover_password, student_recover_password, committee_recover_password */ email_send("{$type}_recover_password", $email, array("FAIRNAME"=>i18n($config['fairname'])), array( "PASSWORD"=>$password, "EMAIL"=>$email) ); header("Location: user_login.php?type=$type¬ice=recover_sent"); exit; } else { header("Location: user_login.php?type=$type¬ice=recover_email_error"); exit; } } header("Location: user_login.php?type=$type¬ice=email_error"); exit; } else { send_header("{$user_what[$type]} - Login", array()); switch($notice) { case 'created_sent': echo happy(i18n("Your new password has been sent to your email address. Please check your email and use the password to login")); break; case 'recover_sent': echo notice(i18n("Your password has been sent to your email address")); break; case 'recover_email_error': echo error(i18n("Could not find your email address for recovery")); break; case 'recover_name_error': echo error(i18n("The name you entered does not match the one in your account")); break; case 'email_error': echo error(i18n("Email address error")); break; case 'login_failed': echo error(i18n("Invalid Email/Password")); break; case 'auth_required': echo error(i18n("You must login to view that page")); break; case 'logged_out': echo notice(i18n("You have been successfully logged out")); break; } $recover_link = "user_login.php?type=$type&action=recover"; $new_link = "user_new.php?type=$type"; ?>
:
:
/>

click here to recover it")?>.


click here.
"); break; case 'closed': echo i18n("Registration for the %1 %2 is now closed", array( $config['FAIRYEAR'], $config['fairname']), array("Fair year","Fair name") ); break; case 'notpermitted': default: break; } } send_footer(); ?>