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. */ ?> "user_login.php?type=$type") ); echo i18n("{$user_what[$type]} registration is not open"); echo "
"; send_footer(); exit; } if($reg_mode == 'invite') { send_header("{$user_what[$type]} Registration", array("{$user_what[$type]} Login" => "user_login.php?type=$type") ); echo i18n("{$user_what[$type]} Registration is by invitation only. You can not create a new account.")."

"; echo i18n("In order to register you must have your account created for you by the science fair committee.")."

"; echo i18n("Once your account is created you'll be invited via email to login and complete your {$user_what[$type]} registration information. If you have been invited already, you need to use login using the email address that you were invited with. If you need an invitation, please contact the science fair committee by sending us an email: %1.", array($config['fairname'],$config['fairmanageremail'])); echo "
"; send_footer(); exit; } /* We're going to use a case statement here, so we can break out of * it at any moment.. there are a lot of reasons why we don't want * to create a new account.. too many to nest inside IF statements.. * this is the one time I wish php had a goto statement. */ switch($action) { case 'new': $data_fn = mysql_escape_string(stripslashes($_POST['fn'])); $data_ln = mysql_escape_string(stripslashes($_POST['ln'])); $data_email = stripslashes($_POST['email']); $sql_email = mysql_escape_string($data_email); $registrationpassword = $_POST['registrationpassword']; /* Check the registration singlepassword */ if($reg_mode == 'singlepassword') { if($reg_single_password != $_POST['registrationpassword']) { $notice = 'singlepassword_wrong'; break; /* Don't want to create an account */ } } /* See if this email already exists */ $q = mysql_query("SELECT id,types FROM users WHERE email='$sql_email' OR username='$sql_email'"); if(mysql_num_rows($q) > 0) { /* It already exists, make sure they're not already in this role */ $r = mysql_fetch_object($q); $types = split(',', $r->types); if(in_array($type, $types)) { $notice = 'role_exists'; break; /* Don't want to create an account */ } else { /* If they're already logged in, we can go ahead and * add this role. We've passed all the required checks * for creating a new user of this role. * The user has already been warned about being logged * out. */ if(isset($_SESSION['users_id'])) { /* user_create does last minute checks, like * ensuring a student doesn't try to also * register as a judge */ $u = user_load($_SESSION['users_id']); $u = user_create($type, $u); $_SESSION['users_type'] = $type; header("location: user_login.php?action=logout¬ice=login_multirole&redirect=roleattached"); exit; } /* forward the user to the login page for whatever role * they already have (it doesn't matter), and * setup a login role_add redirect */ header("location: user_login.php?type={$types[0]}¬ice=multirole&redirect=roleadd&redirectdata=$type"); exit; } } /* Strict validate the email */ if(!user_valid_email($data_email)) { $notice = 'email_invalid'; $data_email = ''; break; /* Don't want to create an account */ } /* Check the names */ if($data_fn == '' or $data_ln == '') { $notice = 'name_invalid'; break; /* Don't want to create an account */ } /* If we havne't encountered a break; or an exit; yet, then go ahead * and create the account */ /* Generate a password */ $password = generatePassword(12); /* Add the user */ $u = user_create($type); $u['firstname'] = $data_fn; $u['lastname'] = $data_ln; $u['username'] = $data_email; $u['password'] = $password; $u['email'] = $data_email; user_save($u); /* Send the email */ email_send($welcome_email, $data_email, array("FAIRNAME"=>i18n($config['fairname'])), array("PASSWORD"=>$password, "EMAIL"=>$data_email) ); /* now redirect to the login page */ header("Location: user_login.php?type=$type¬ice=created_sent"); exit; } send_header("{$user_what[$type]} Registration", array("{$user_what[$type]} Login" => "user_login.php?type=$type") ); switch($notice) { case 'email_invalid': echo '
'; echo error(i18n("The email address is invalid")); echo '
'; break; case 'name_invalid': echo '
'; echo error(i18n("You must enter your first and last name")); echo '
'; break; case 'singlepassword_wrong': echo '
'; echo error(i18n("The {$user_what[$type]} Registration Password you have entered is incorrect.")); echo '
'; break; case 'role_exists': echo '
'; echo error(i18n("That email address has an existing {$user_what[$type]} registration")); echo notice(i18n("Use the 'recover password' option on the %1 {$user_what[$type]} login page %2 if you have forgotten your password", array("", ""))); echo '
'; break; } ?>
:
:
:
"; echo i18n("Remember, once you click the Register button below, you will be logged out. You can immediately log back in."); echo "
"; } if($reg_mode == 'singlepassword') { echo '
'; echo i18n("{$user_what[$type]} Registration is protected by a password. You must know the {$user_what[$type]} Registration Password in order to create an account. Please contact the committee to obtain the password if you wish to register."); echo "
"; echo i18n("{$user_what[$type]} Password").":"; echo "
"; } ?>
/>
"; echo i18n("When you click the 'Register' button, your password will be randomly created and emailed to you. When you login for the first time you will be prompted to change your password. It can sometimes take several minutes for the email to send, so be patient."); echo "
"; } send_footer(); ?>