* * * * This script displays the contents for the 'Registation' page. Don't * * forget the 12 space indent for all content pages. * * * * Last modified : September 14th, 2002 (JJS) * \******************************************************************************/ /* Call this file directly, get sent back */ $file_name = "register.php"; /* Get the negative length of $file_name */ $file_name_length = -(strlen($file_name)); /* Check if the values match, if so, redirect */ if (substr($_SERVER['SCRIPT_NAME'], $file_name_length) == $file_name) header("Location: ../index.php"); /* Grab the veriables held by super globals */ $username = GetVars("username"); $password = GetVars("password"); $email = GetVars("email"); $location = GetVars("location"); $occupation = GetVars("occupation"); $homepage = GetVars("homepage"); $picture = GetVars("picture"); $interests = GetVars("interests"); $aim = GetVars("aim"); $icq = GetVars("icq"); $yahoo = GetVars("yahoo"); $signature = GetVars("signature"); $include_sig = GetVars("include_sig"); $action = GetVars("action"); $step = GetVars("step"); /* Parse any user input */ CheckVars(&$step, 1); CheckVars(&$username, 64); CheckVars(&$password, 64); CheckVars(&$confirm_password, 64); CheckVars(&$email, 128); CheckVars(&$location, 128); CheckVars(&$occupation, 64); CheckVars(&$homepage, 128); CheckVars(&$picture, 128); CheckVars(&$interests, 255); CheckVars(&$aim, 16); CheckVars(&$icq, 16); CheckVars(&$yahoo, 32); CheckVars(&$signature, 255); CheckVars(&$include_sig, 1); /* Strip   from the username */ $username = str_replace(" ", "", $username); /* Check that the user isn't trying to mess with the $step variable */ if ( $step == "" || ( $step != 1 && $step != 2 && $step != 3 && $step != 4 ) ) $step = 1; /* Make sure the user isn't feeding information via the query string, thwart all attempts!! */ if ( ( ( $username == "" || $password == "" || $email == "" ) && ( $step == 3 || $step == 4 ) ) || ( ( $step == 1 && $QUERY_STRING != "pid=register" ) || ( $step == 2 && $QUERY_STRING != "pid=register&step=2" ) || ( $step == 3 && $QUERY_STRING != "pid=register&step=3" ) || ( $step == 4 && $QUERY_STRING != "pid=register" ) ) || ( ( $step != 1 && $step != 2 ) && ( strlen(trim($username)) == 0 || strlen(trim($password)) == 0 || strlen(trim($email)) == 0 ) ) ) { /* If so, give them an error */ echo "
Malformed request detected!

\n"; $step = 1; } /* Determine which step to go to */ if ($action == "Edit Information") $step = 2; else if ($action == "Submit Information") $step = 4; /* Parse some of the variables to ensure accurate values */ if ( $step == 2 && $homepage == "" ) $homepage = "http://"; if ( $step == 2 && $picture == "" ) $picture = "http://"; /* Strip out all escape characters */ if ($step == 2) { $username = stripslashes(strip_tags($username)); $password = stripslashes(strip_tags($password)); $email = stripslashes(strip_tags($email)); $location = stripslashes(strip_tags($location)); $occupation = stripslashes(strip_tags($occupation)); $homepage = stripslashes(strip_tags($homepage)); $picture = stripslashes(strip_tags($picture)); $interests = stripslashes(strip_tags($interests)); $aim = stripslashes(strip_tags($aim)); $icq = stripslashes(strip_tags($icq)); $yahoo = stripslashes(strip_tags($yahoo)); $signature = stripslashes(strip_tags($signature)); } /* Again, with some sig clean up */ if ($step == 3) { $username = stripslashes(strip_tags($username)); $password = stripslashes(strip_tags($password)); $email = stripslashes(strip_tags($email)); $location = stripslashes(strip_tags($location)); $occupation = stripslashes(strip_tags($occupation)); $homepage = stripslashes(strip_tags($homepage)); $picture = stripslashes(strip_tags($picture)); $interests = stripslashes(strip_tags($interests)); $aim = stripslashes(strip_tags($aim)); $icq = stripslashes(strip_tags($icq)); $yahoo = stripslashes(strip_tags($yahoo)); $signature = stripslashes(htmlspecialchars($signature)); $signature = nl2br($signature); $signature = str_replace("
", "
", $signature); } /* This time, just signature clean up */ if ($step == 4) { $signature = htmlspecialchars($signature); $signature = str_replace("<BR>", "
", $signature); } /* To step, or not to step! */ switch ($step) { /* Display the TOS */ default: case 1: /* Start displaying the TOS */ echo " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . "
Usage Policy
\n" . " Registration for our community is 100% free! If you agree to abide by our rules below, you should press the \"Agree\" button, which will enable you to register. If you do not agree, press the \"Cancel\" button.\n" . "
\n"; /* Grab the TOS */ require("language/tos.php"); /* Display the TOS */ echo " " . TERMS_OF_SERVICE . "\n"; /* Finish off the page */ echo "
\n" . "
\n" . " Agree | Cancel\n" . "
\n"; break; /* Display the form for the user to fill out */ case 2: ShowRegistrationForm( $username, $password, $confirm_password, $email, $location, $occupation, $homepage, $picture, $interests, $aim, $icq, $yahoo, $signature, $include_sig ); break; /* Display the info the user supplied and prompt them to continue or edit */ case 3: /* Line starts here, no cutting [or pasting ;)] */ echo "
\n" . " \n" . " \n" . " \n" . " \n"; /* Set the active color */ $the_color = TABLE_COLOR_2; /* Display the mandatory fields */ PreviewSection ( $username, "Username", &$the_color ); PreviewSection ( $password, "Password", &$the_color ); PreviewSection ( $email, "Email", &$the_color ); /* Display the optional fields, if they were filled in */ if ( $location != "" ) PreviewSection( $location, "Location", &$the_color ); if ( $occupation != "" ) PreviewSection( $occupation, "Occupation", &$the_color ); if ( $homepage != "" && $homepage != "http://" ) PreviewSection( $homepage, "Homepage", &$the_color ); if ( $picture != "" && $picture != "http://" ) PreviewSection ( $picture, "Picture", &$the_color ); if ( $interests != "" ) PreviewSection ( $interests, "Interests", &$the_color ); if ( $aim != "" ) PreviewSection ( $aim, "AOL Instant Messenger", &$the_color ); if ( $icq != "" ) PreviewSection ( $icq, "ICQ", &$the_color ); if ( $yahoo != "" ) PreviewSection ( $yahoo, "Yahoo Pager", &$the_color ); if ( $signature != "" ) { /* Swap the colors */ if ($the_color == TABLE_COLOR_1) $the_color = TABLE_COLOR_2; else $the_color = TABLE_COLOR_1; /* Start the section */ echo " \n" . " \n" . " \n" . " \n"; } /* And then we finish off the form */ echo "
Registration Preview
Signature:\n" . " $signature

\n" . " \n"; /* Display if the signature will be added by default */ if ($include_sig == 1) echo " You have chosen to include this signature on new posts.\n"; else echo " You have chosen to not include this signature on new posts.\n"; /* Finish off the section */ echo " \n" . " \n" . " \n" . "
\n" . "

\n" . "
\n"; break; /* Check the user's input, add the user to the database, and display the results */ case 4: /* Make sure it was POSTed, if it wasn't they are trying to be slick */ if ( $REQUEST_METHOD == "POST" ) { /* No errors... yet */ $no_err = 0; /* Pull the number of accounts with the same username */ $SQL = "SELECT COUNT(*) as user_exists FROM " . TABLE_PREFIX . "users WHERE user_name='$username';"; $results = ExeSQL($SQL); /* Grab the data, parse the results */ while ($row = mysql_fetch_array($results)) { /* If the username exists, error out */ if ($row["user_exists"] != 0) { echo "
That username already exists!

\n"; $no_err++; } } /* Pull the number of accounts with the same email */ $SQL = "SELECT COUNT(*) as email_exists FROM " . TABLE_PREFIX . "users WHERE user_email='$email';"; $results = ExeSQL($SQL); /* Grab the data, parse the results */ while ($row = mysql_fetch_array($results)) { /* If the email exists, then error out */ if ($row["email_exists"] != 0) { echo "
Someone has already registered using that email address!

\n"; $no_err++; } } /* If there are no errors, then proceed with the registration */ if ($no_err == 0) { /* Clear out the URL variables if they still contain 'http://' */ if ($homepage == "http://") { $homepage = ""; } if ($picture == "http://") { $picture = ""; } /* Crypt the password to a random salt */ $password = crypt($password); /* Determine if the sig will be added by default */ if ($include_sig != 1) $include_sig == 0; /* Insert the user into the database */ $SQL = "INSERT INTO " . TABLE_PREFIX . "users (user_name, user_email, user_pass, user_location, user_occupation, user_homepage, user_picture, user_interests, user_aim, user_icq, user_yahoo, user_signature, user_usesig) VALUES ('$username', '$email', '$password', '$location', '$occupation', '$homepage', '$picture', '$interests', '$aim', '$icq', '$yahoo', '$signature', '$include_sig');"; $results = ExeSQL($SQL); /* Log the new user in */ SetCookie("user_name", $username, time() + 86400, '', $_SERVER['HTTP_HOST']); SetCookie("user_pass", $password, time() + 86400, '', $_SERVER['HTTP_HOST']); /* Set their login status */ $logged_in = 1; /* Finish off the registration */ echo "
\n" . " Thanks for registering!
\n" . " Click here to log in!\n" . "
\n" . "
\n"; require("./content/view_forums.php"); return; } else ShowRegistrationForm( $username, $password, $confirm_password, $email, $location, $occupation, $homepage, $picture, $interests, $aim, $icq, $yahoo, $signature, $include_sig ); } else { /* If they didn't POST it, then error out */ echo "
Malformed request detected!

\n"; ShowRegistrationForm( $username, $password, $confirm_password, $email, $location, $occupation, $homepage, $picture, $interests, $aim, $icq, $yahoo, $signature, $include_sig ); } break; } /* * Show the registration form */ function ShowRegistrationForm( $username, $password, $confirm_password, $email, $location, $occupation, $homepage, $picture, $interests, $aim, $icq, $yahoo, $signature, $include_sig ) { /* Start displaying the damned thing */ echo " \n" . "
\n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . "
Required Information
Username: Max: 64 characters
Password: Min 6 characters - Max: 64 characters
Confirm Password: Min: 6 characters - Max: 64 characters
Email: Max: 128 characters
Optional Information
Location: Max: 128 characters
Occupation: Max: 64 characters
Homepage: Max: 128 characters
Picture: Max: 128 characters
Interests: Max: 255 characters
AOL Instant Messenger: Max: 16 characters
ICQ: Max: 16 characters
Yahoo Pager: Max: 32 characters
Signature:\n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . "
 Max: 255 characters
\n"; /* Check the box if the signature is to be included */ if ($include_sig == 1) $checked = " checked"; else $checked = ""; /* Display the rest of the form */ echo " Include Signature on New Posts?\n" . "
\n" . "
\n" . "

\n" . "
\n"; } /* * Display the portion that is being previewed */ function PreviewSection ( $section_value, $section_title, $the_color ) { /* Swap the colors */ if ($the_color == TABLE_COLOR_1) $the_color = TABLE_COLOR_2; else $the_color = TABLE_COLOR_1; /* Display the start of the section */ echo " \n" . " $section_title:\n" . " \n"; /* Don't display the password, for security reasons and all */ if ($section_title == "Password") echo " Password is hidden for security purposes.\n"; else echo " $section_value\n"; /* If it's the AIM section, then swap out the variables to make sure everything is okay */ if ($section_title == "AOL Instant Messenger") $section_title = "aim"; else $section_title = strtolower($section_title); /* And, we're out */ echo " \n" . " \n" . " \n"; } ?>