20) { redirect("register.php?error=username_too_long&highlight=username"); } if (strlen($firstname) > 30) { redirect("register.php?error=field_too_long&highlight=username"); } if (strlen($lastname) > 30) { redirect("register.php?error=field_too_long&highlight=username"); } if ($firstname == $lastname) { redirect("register.php?error=Your first name must be different to your last name"); } if (!is_email_valid($email)) { redirect("register.php?error=email_invalid&highlight=email"); } $username_check = sql_query("SELECT passportid FROM user WHERE username = '{$username}'"); if ($username_check) { redirect("register.php?error=username_already_used&highlight=username"); } $email_check = sql_query("SELECT passportid FROM email WHERE email = '{$email}'"); if ($email_check) { redirect("register.php?error=email_already_used&highlight=email"); } if (!is_numeric($dob_day)) { redirect("register.php?error=field_non_numeric&highlight=dob_day"); } if (!is_numeric($dob_month)) { redirect("register.php?error=field_non_numeric&highlight=dob_month"); } if (!is_numeric($dob_year)) { redirect("register.php?error=field_non_numeric&highlight=dob_year"); } if ($gender != 'M' AND $gender != 'F') { redirect("register.php?error=gender_invalid&highlight=gender"); } if ($dob_day < 1 OR $dob_day > 31) { redirect("register.php?error=dob_invalid&highlight=dob_day"); } if ($dob_month < 1 OR $dob_month > 12) { redirect("register.php?error=dob_invalid&highlight=dob_month"); } if ($dob_year < 1900 OR $dob_year > date('Y', time())) { redirect("register.php?error=dob_invalid&highlight=dob_year"); } $dateofbirth = $dob_year ."-". $dob_month ."-". $dob_day; //Password checks, excluding min length if (strstr($password, $username)) { redirect("register.php?error=Your password can not be the same as your username&highlight=username"); } if (strstr($password, $firstname)) { redirect("register.php?error=Your password can not contain your name&highlight=firstname"); } if (strstr($password, $lastname)) { redirect("register.php?error=Your password can not contain your name&highlight=lasttname");} $userSalt = generateSalt(); $password = hashPass($password,$userSalt); //$password = md5($password); $status = sql_do("INSERT INTO user (username, firstname, lastname, securePass, userSalt, dateofbirth, gender, country, registered, msn, aol, icq) values('{$username}', '{$firstname}', '{$lastname}', '{$password}','{$userSalt}', '{$dateofbirth}', '{$gender}', '{$country}', now(), '{$msn}', '{$aol}', '{$icq}')"); if (!$status) { redirect("register.php?error=Error generating passport"); } $user = sql_query("SELECT passportid, username FROM user WHERE username = '{$username}'"); if (!$user) { redirect("register.php?error=Passport creation error"); } passport_log($user['passportid'], 2, "", get_ip()); passport_email_add($user['passportid'], $email, 1); session_login($user['passportid'], $user['username']); setcookie("register_username", false); setcookie("register_firstname", false); setcookie("register_lastname", false); setcookie("register_dob_day", false); setcookie("register_dob_month", false); setcookie("register_dob_year", false); setcookie("register_gender", false); setcookie("register_country", false); setcookie("register_email", false); setcookie("register_msn", false); setcookie("register_aol", false); setcookie("register_icq", false); redirect("main/?welcome=1"); } require("header.php"); ?> ".chr(13); if (isset($_GET['error'])) { $key = $_GET['error']; switch ($key) { case "incomplete": $text = "All fields are required"; break; case "missing_field": $text = "Required field missing"; break; case "passport_already_found": $text = "You already have a passport account"; break; case "username_already_used": $text = "The username you entered is already in use (Please try again)"; break; case "email_already_used": $text = "The email you entered is already in use (Please try again)"; break; case "field_non_numeric": $text = "Invalid field. Only numbers are valid (Please try again)"; break; case "field_non_alpha": $text = "Invalid field. Only numbers/letters/spaces are valid (Please try again)"; break; case "username_non_alpha": $text = "The username you entered contains special chars. Only numbers/letters/spaces are valid (Please try again)"; break; case "username_too_short": $text = "Your Username must be atleast 3 characters long (Please try again)"; break; case "username_no_spaces": $text = "Your Username can not contain any spaces (Please try again)"; break; case "firstname_too_short": $text = "Your First name must be atleast 3 characters long (Please try again)"; break; case "lastname_too_short": $text = "Your Last name must be atleast 3 characters long (Please try again)"; break; case "password_too_short": $text = "Your password must be atleast 5 characters long (Please try again)"; break; case "username_too_long": $text = "Your username is too long. Maximum of 20 characters. (Please try again)"; break; case "field_too_long": $text = "Field too long (Please try again)"; break; case "dob_invalid": $text = "Your date of birth is not a valid date (Please try again)"; break; case "email_invalid": $text = "Your email address is invalid (Please try again)"; break; case "gender_invalid": $text = "Please select your gender (Please try again)"; break; default: $text = $key; break; } print "
"; notice_error($text); } if ($view == "register") { if (isset($_COOKIE['register_username'])) { $username = $_COOKIE['register_username']; } else { $username = ""; } if (isset($_COOKIE['register_firstname'])) { $firstname = $_COOKIE['register_firstname']; } else { $firstname = ""; } if (isset($_COOKIE['register_lastname'])) { $lastname = $_COOKIE['register_lastname']; } else { $lastname = ""; } if (isset($_COOKIE['register_dob_day'])) { $dob_day = $_COOKIE['register_dob_day']; } else { $dob_day = ""; } if (isset($_COOKIE['register_dob_month'])) { $dob_month = $_COOKIE['register_dob_month']; } else { $dob_month = ""; } if (isset($_COOKIE['register_dob_year'])) { $dob_year = $_COOKIE['register_dob_year']; } else { $dob_year = ""; } if (isset($_COOKIE['register_gender'])) { $gender = $_COOKIE['register_gender']; } else { $gender = ""; } if (isset($_COOKIE['register_country'])) { $country = $_COOKIE['register_country']; } else { $country = ""; } if (isset($_COOKIE['register_email'])) { $email = $_COOKIE['register_email']; } else { $email = ""; } if (isset($_COOKIE['register_msn'])) { $msn = $_COOKIE['register_msn']; } else { $msn = ""; } if (isset($_COOKIE['register_aol'])) { $aol = $_COOKIE['register_aol']; } else { $aol = ""; } if (isset($_COOKIE['register_icq'])) { $icq = $_COOKIE['register_icq']; } else { $icq = ""; } $class_username = "input1"; $class_firstname = "input1"; $class_lastname = "input1"; $class_dob_day = "input1"; $class_dob_month = "select1"; $class_dob_year = "input1"; $class_gender = "select1"; $class_country = "select1"; $class_email = "input1"; $class_password = "input1"; if (isset($_GET['highlight'])) { $highlight = clean_string($_GET['highlight']); switch ($highlight) { case "username": $class_username = "highlight"; break; case "firstname": $class_firstname = "highlight"; break; case "lastname": $class_lastname = "highlight"; break; case "dob_day": $class_dob_day = "highlight"; break; case "dob_month": $class_dob_month = "highlight"; break; case "dob_year": $class_dob_year = "highlight"; break; case "gender": $class_gender = "highlight"; break; case "country": $class_country = "highlight"; break; case "email": $class_email = "highlight"; break; case "password": $class_password = "highlight"; break; } } ?>