Location: PHPKode > projects > Mummi (Multi-user MOD_MP3 Interface) > mummi.0.6/htroot/signup.php
<?

//  This get the document root specified in the virtual host of apache
$GLOBALS[int_path] = getenv(DOCUMENT_ROOT);

// This will be changed to look at a file that the user can set the prefrence of.
$GLOBALS[lib_path] = "$GLOBALS[int_path]/../lib";

include "$GLOBALS[lib_path]/config.inc";
include "$GLOBALS[lib_path]/mysql.inc";
include "$GLOBALS[lib_path]/overseer.inc";
include "$GLOBALS[lib_path]/user_db.inc";
include "$GLOBALS[lib_path]/design.inc";

$os = new OVERSEER;
$os->connect("$GLOBALS[dbhost]","$GLOBALS[dbusername]","$GLOBALS[dbuserpassword]","$GLOBALS[dbname]");

$user_db = new USER_DB();
if(!$user_db->connect("$GLOBALS[dbhost]","$GLOBALS[dbusername]","$GLOBALS[dbuserpassword]","$GLOBALS[dbname]")) header("Location: $url_path/error_db_fail.php");

// Set the user navbars.
if(!$HTTP_COOKIE_VARS[login_active]) $nav_array = array(main);
elseif($os->num_rows("SELECT user_name FROM users WHERE user_name='$session_array[user_name]' AND user_type='1'")) $nav_array = array(user_main, user_admin);
else $nav_array = array(user_main);


//the blank page..
$GLOBALS[signup00] = <<<ENDsignup00
					<font face="$GLOBALS[body_font_face]" size="$GLOBALS[body_font_size]">
					<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr>
						<td align="left" valign="top">
							<form method="POST" action="$PHP_SELF">
							<table cellpadding="1" cellspacing="2" border="0"><tr>
								<td align="left" valign="top">
									<table cellpadding="1" cellspacing="0" border="0"><tr>
										<td align=right>First&nbsp;Name:</td>
										<td><input type="text" name="first_name" value="" size="25" maxlength="25"></td>
									</tr><tr>
										<td align="right">Last&nbsp;Name:</td>
										<td><input type="text" name="last_name" value="" size="25" maxlength="25"></td>
									</tr><tr>
										<td align="right">Email:</td>
										<td><input type="text" name="user_email" value="" size="25" maxlength="40"></td>
									</tr><tr>
										<td align="right">User&nbsp;Name:</td>
										<td><input type="text" name="user_name" value="" size="25" maxlength="15"></td>
									</tr><tr>
										<td>&nbsp;</td>
										<td>
										<input type="hidden" name="signupdt00" value="true">
										<input type="button" value="<- Back">
										<input type="submit" value="Next ->">
									</tr></table>
								</td>
								<td valign="top">This is the Audiodevil demo signup form. Upon your sucessful completion of this form, you will be sent an email with further instructions. You must fill-in all the blanks here.</td>
							</tr></table>
							</form>
						</td>
					</tr></table>
					</font>
ENDsignup00;

// page for *something was empty
$GLOBALS[signup01] = <<<ENDsignup01
					<font face="$GLOBALS[body_font_face]" size="$GLOBALS[body_font_size]">
					<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr>
						<td align="left" valign="top">
							<form method="POST" action="$PHP_SELF">
							<table cellpadding="1" cellspacing="2" border="0"><tr>
								<td align="left" valign="top">
									<table cellpadding="1" cellspacing="0" border="0"><tr>
										<td align=right>First&nbsp;Name:</td>
										<td><input type="text" name="first_name" value="$HTTP_POST_VARS[first_name]" size="25" maxlength="25"></td>
									</tr><tr>
										<td align="right">Last&nbsp;Name:</td>
										<td><input type="text" name="last_name" value="$HTTP_POST_VARS[last_name]" size="25" maxlength="25"></td>
									</tr><tr>
										<td align="right">Email:</td>
										<td><input type="text" name="user_email" value="$HTTP_POST_VARS[user_email]" size="25" maxlength="40"></td>
									</tr><tr>
										<td align="right">User&nbsp;Name:</td>
										<td><input type="text" name="user_name" value="$HTTP_POST_VARS[user_name]" size="25" maxlength="15"></td>
									</tr><tr>
										<td>&nbsp;</td>
										<td>
										<input type="hidden" name="signupdt00" value="true">
										<input type="button" value="<- Back">
										<input type="submit" value="Next ->">
									</tr></table>
								</td>
								<td valign="top">
									<font color="red"><b>All fields are required</b></font><br>
									Make sure all these fields are correct. An email will be sent to you with further instructions. Click the "Back" button to edit anything that need to change.
								</td>
							</tr></table>
							</form>
						</td>
					</tr></table>
					</font>
ENDsignup01;

// Username already in the database
$GLOBALS[signup02] = <<<ENDsignup02
					<font face="$GLOBALS[body_font_face]" size="$GLOBALS[body_font_size]">
					<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr>
						<td align="left" valign="top">
							<form method="POST" action="$PHP_SELF">
							<table cellpadding="1" cellspacing="2" border="0"><tr>
								<td align="left" valign="top">
									<table cellpadding="1" cellspacing="0" border="0"><tr>
										<td align=right>First&nbsp;Name:</td>
										<td><input type="text" name="first_name" value="$HTTP_POST_VARS[first_name]" size="25" maxlength="25"></td>
									</tr><tr>
										<td align="right">Last&nbsp;Name:</td>
										<td><input type="text" name="last_name" value="$HTTP_POST_VARS[last_name]" size="25" maxlength="25"></td>
									</tr><tr>
										<td align="right">Email:</td>
										<td><input type="text" name="user_email" value="$HTTP_POST_VARS[user_email]" size="25" maxlength="40"></td>
									</tr><tr>
										<td align="right">User&nbsp;Name:</td>
										<td><input type="text" name="user_name" value="" size="25" maxlength="15"></td>
									</tr><tr>
										<td>&nbsp;</td>
										<td>
										<input type="hidden" name="signupdt00" value="true">
										<input type="button" value="<- Back">
										<input type="submit" value="Next ->">
									</tr></table>
								</td>
								<td valign="top">
									<font color="red"><b>Username in use</b></font><br>
									Sorry, that username is already being used.  Please select a new username and try again.
								</td>
							</tr></table>
							</form>
						</td>
					</tr></table>
					</font>
ENDsignup02;

// Bad email address given
$GLOBALS[signup03] = <<<ENDsignup03
					<font face="$GLOBALS[body_font_face]" size="$GLOBALS[body_font_size]">
					<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr>
						<td align="left" valign="top">
							<form method="POST" action="$PHP_SELF">
							<table cellpadding="1" cellspacing="2" border="0"><tr>
								<td align="left" valign="top">
									<table cellpadding="1" cellspacing="0" border="0"><tr>
										<td align=right>First&nbsp;Name:</td>
										<td><input type="text" name="first_name" value="$HTTP_POST_VARS[first_name]" size="25" maxlength="25"></td>
									</tr><tr>
										<td align="right">Last&nbsp;Name:</td>
										<td><input type="text" name="last_name" value="$HTTP_POST_VARS[last_name]" size="25" maxlength="25"></td>
									</tr><tr>
										<td align="right">Email:</td>
										<td><input type="text" name="user_email" value="" size="25" maxlength="40"></td>
									</tr><tr>
										<td align="right">User&nbsp;Name:</td>
										<td><input type="text" name="user_name" value="$HTTP_POST_VARS[user_name]" size="25" maxlength="15"></td>
									</tr><tr>
										<td>&nbsp;</td>
										<td>
										<input type="hidden" name="signupdt00" value="true">
										<input type="button" value="<- Back">
										<input type="submit" value="Next ->">
									</tr></table>
								</td>
								<td valign="top">
									<font color="red"><b>Invalid email address</b></font><br>
									The email address you provided is not in the correct format.  Correct format should be
									<b><i>hide@address.com</i></b>.  Please enter a valid email address and try again.
								</td>
							</tr></table>
							</form>
						</td>
					</tr></table>
					</font>
ENDsignup03;

// Email address is already taken on the system
$GLOBALS[signup04] = <<<ENDsignup04
					<font face="$GLOBALS[body_font_face]" size="$GLOBALS[body_font_size]">
					<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr>
						<td align="left" valign="top">
							<form method="POST" action="$PHP_SELF">
							<table cellpadding="1" cellspacing="2" border="0"><tr>
								<td align="left" valign="top">
									<table cellpadding="1" cellspacing="0" border="0"><tr>
										<td align=right>First&nbsp;Name:</td>
										<td><input type="text" name="first_name" value="$HTTP_POST_VARS[first_name]" size="25" maxlength="25"></td>
									</tr><tr>
										<td align="right">Last&nbsp;Name:</td>
										<td><input type="text" name="last_name" value="$HTTP_POST_VARS[last_name]" size="25" maxlength="25"></td>
									</tr><tr>
										<td align="right">Email:</td>
										<td><input type="text" name="user_email" value="" size="25" maxlength="40"></td>
									</tr><tr>
										<td align="right">User&nbsp;Name:</td>
										<td><input type="text" name="user_name" value="$HTTP_POST_VARS[user_name]" size="25" maxlength="15"></td>
									</tr><tr>
										<td>&nbsp;</td>
										<td>
										<input type="hidden" name="signupdt00" value="true">
										<input type="button" value="<- Back">
										<input type="submit" value="Next ->">
									</tr></table>
								</td>
								<td valign="top">
									<font color="red"><b>Email address already taken</b></font><br>
									The email address you provided is alrady being used.  Please enter another email address and try again.
								</td>
							</tr></table>
							</form>
						</td>
					</tr></table>
					</font>
ENDsignup04;

// Everything looks good, confirm and click next or click back to reenter info
$GLOBALS[signup05] = <<<ENDsignup05
					<font face="$GLOBALS[body_font_face]" size="$GLOBALS[body_font_size]">
					<table width="100%" cellpadding="1" cellspacing="0" border="0"><tr>
						<td align="left" valign="top">
							<form method="POST" action="$PHP_SELF">
							<table cellpadding="1" cellspacing="2" border="0"><tr>
								<td align="left" valign="top">
									<table cellpadding="1" cellspacing="0" border="0"><tr>
										<td align=right>First&nbsp;Name:</td>
										<td><b>$HTTP_POST_VARS[first_name]<b></td>
									</tr><tr>
										<td align="right">Last&nbsp;Name:</td>
										<td><b>$HTTP_POST_VARS[last_name]</b></td>
									</tr><tr>
										<td align="right">Email:</td>
										<td><b>$HTTP_POST_VARS[user_email]</b></td>
									</tr><tr>
										<td align="right">User&nbsp;Name:</td>
										<td><b>$HTTP_POST_VARS[user_name]</b></td>
									</tr><tr>
										<td>&nbsp;</td>
										<td>
										<input type="hidden" name="first_name" value="$HTTP_POST_VARS[first_name]">
										<input type="hidden" name="last_name" value="$HTTP_POST_VARS[last_name]">
										<input type="hidden" name="user_email" value="$HTTP_POST_VARS[user_email]">
										<input type="hidden" name="user_name" value="$HTTP_POST_VARS[user_name]">
										<input type="hidden" name="signupdt01" value="true">
										<input type="button" value="<- Back">
										<input type="submit" value="Next ->">
									</tr></table>
								</td>
								<td valign="top">Just to make sure, check all the information for accuracy.  Click back if you need to change anything.  Click next to continue.</td>
							</tr></table>
							</form>
						</td>
					</tr></table>
					</font>
ENDsignup05;

// email just sent to user right after confirmation of all info
$GLOBALS[signup06] = <<<ENDsignup06
					<font face="$GLOBALS[body_font_face]" size="$GLOBALS[body_font_size]">
					<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr>
						<td align="left" valign="top">
							<table cellpadding="1" cellspacing="2" border="0"><tr>
								<td valign="top">Thank you for registering with AudioDevil.  You will be sent an email shortly on how to finish the registration process.<br><br>Thank you</td>
							</tr></table>
						</td>
					</tr></table>
					</font>
ENDsignup06;

// This is the page user sees if the email is already in the tmp_users database
$GLOBALS[signup07] = <<<ENDsignup07
					<font face="$GLOBALS[body_font_face]" size="$GLOBALS[body_font_size]">
					<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr>
						<td align="left" valign="top">
							<form method="POST" action="$PHP_SELF">
							<table cellpadding="1" cellspacing="2" border="0"><tr>
								<td align="left" valign="top">
									<table cellpadding="1" cellspacing="0" border="0"><tr>
										<td align=right>First&nbsp;Name:</td>
										<td><input type="text" name="first_name" value="$HTTP_POST_VARS[first_name]" size="25" maxlength="25"></td>
									</tr><tr>
										<td align="right">Last&nbsp;Name:</td>
										<td><input type="text" name="last_name" value="$HTTP_POST_VARS[last_name]" size="25" maxlength="25"></td>
									</tr><tr>
										<td align="right">Email:</td>
										<td><input type="text" name="user_email" value="" size="25" maxlength="40"></td>
									</tr><tr>
										<td align="right">User&nbsp;Name:</td>
										<td><input type="text" name="user_name" value="$HTTP_POST_VARS[user_name]" size="25" maxlength="15"></td>
									</tr><tr>
										<td>&nbsp;</td>
										<td>
										<input type="hidden" name="signupdt00" value="true">
										<input type="button" value="<- Back">
										<input type="submit" value="Next ->">
									</tr></table>
								</td>
								<td valign="top">
									<font color="red"><b>Email address already taken</b></font><br>
									It appears that you, or somebody else,
									has already registered for membership using this email address,
									but is not yet a confirmed user yet.
									To correct this situation please choose another email address.
								</td>
							</tr></table>
							</form>
						</td>
					</tr></table>
					</font>
ENDsignup07;

// This is the page user sees if the username is already in the tmp_users database
$GLOBALS[signup08] = <<<ENDsignup08
					<font face="$GLOBALS[body_font_face]" size="$GLOBALS[body_font_size]">
					<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr>
						<td align="left" valign="top">
							<form method="POST" action="$PHP_SELF">
							<table cellpadding="1" cellspacing="2" border="0"><tr>
								<td align="left" valign="top">
									<table cellpadding="1" cellspacing="0" border="0"><tr>
										<td align=right>First&nbsp;Name:</td>
										<td><input type="text" name="first_name" value="$HTTP_POST_VARS[first_name]" size="25" maxlength="25"></td>
									</tr><tr>
										<td align="right">Last&nbsp;Name:</td>
										<td><input type="text" name="last_name" value="$HTTP_POST_VARS[last_name]" size="25" maxlength="25"></td>
									</tr><tr>
										<td align="right">Email:</td>
										<td><input type="text" name="user_email" value="$HTTP_POST_VARS[user_email]" size="25" maxlength="40"></td>
									</tr><tr>
										<td align="right">User&nbsp;Name:</td>
										<td><input type="text" name="user_name" value="" size="25" maxlength="15"></td>
									</tr><tr>
										<td>&nbsp;</td>
										<td>
										<input type="hidden" name="signupdt00" value="true">
										<input type="button" value="<- Back">
										<input type="submit" value="Next ->">
									</tr></table>
								</td>
								<td valign="top">
									<font color="red"><b>Username already taken</b></font><br>
									It appears that you, or somebody else,
									has already registered for membership using this username,
									but is not yet a confirmed user yet.
									To correct this situation please choose another username.
								</td>
							</tr></table>
							</form>
						</td>
					</tr></table>
					</font>
ENDsignup08;



/*
// If login detected, redirect to the users screen.. can't create unless not logged in
if($login_active){
$signup_form = <<<ENDsignup_form
	<br>You cannot setup another account while currently logged into a session.  Please log out and try again.
ENDsignup_form;
}else{


}
*/

/*
00 = blank
01 = something was empty
02 = the username was already taken in the DB
03 = the email address is funky, please fix
04 = the email address is already taken in the DB

05 = all the information looks good, please confirm.
06 = we just sent you an email, please follow the instructions.
07 = email is already in the tmp_user_table, tough luck, go to the verifyuser page.

10 = sign in with the username, and temp pass provided in the email.
11 = please try again, something was wrong.
12 = you have signed in, you must create a password to complete the process.
13 = the password was not the same, and 7 characters long.
14 = the password is set, and you can now login setup your account.



*/





	// Starting the validation

	// entering the correct info
	if(isset($HTTP_POST_VARS[signupdt00])){

		// check that none of the fields were left blank.
		if(empty($HTTP_POST_VARS[first_name]) ||
			empty($HTTP_POST_VARS[last_name]) ||
			empty($HTTP_POST_VARS[user_name]) ||
			empty($HTTP_POST_VARS[user_email])) $GLOBALS[page_table] = array("$GLOBALS[page_title]"=>"$GLOBALS[signup01]");

		// if the email is fake, send them to the fuck-up page, or an page for fixing the email.
		elseif(!$user_db->chk_email($HTTP_POST_VARS[user_email])) $GLOBALS[page_table] = array("$GLOBALS[page_title]"=>"$GLOBALS[signup03]");


		// check the user name to make sure it isn't already in the database.
		elseif($user_db->chk_user_name($HTTP_POST_VARS[user_name])) $GLOBALS[page_table] = array("<b>$GLOBALS[page_title]</b>"=>"$GLOBALS[signup02]");

		// if the email is already taken by somebody else.
		elseif($user_db->chk_user_email($HTTP_POST_VARS[user_email])) $GLOBALS[page_table] = array("$GLOBALS[page_title]"=>"$GLOBALS[signup04]");



		// if the username is already in the tmp_users database
		elseif($user_db->chk_user_name($HTTP_POST_VARS[user_name], "tmp_users")) $GLOBALS[page_table] = array("$GLOBALS[page_title]"=>"$GLOBALS[signup08]");

		// if the email is in the tmp_users database
		elseif($user_db->chk_user_email($HTTP_POST_VARS[user_email], "tmp_users")) $GLOBALS[page_table] = array("$GLOBALS[page_title]"=>"$GLOBALS[signup07]");



		// display the confirmation page
		else $GLOBALS[page_table] = array("$GLOBALS[page_title]"=>"$GLOBALS[signup05]");

	}//eo phase00

	// The page that lets the user confrim that info is good.
	elseif(isset($HTTP_POST_VARS[signupdt01])){

		$GLOBALS[new_pass] = $user_db->pass_gen(8);


// The email text sent to the new user.
$email_str = <<<ENDemail_str

THIS IS AN AUTOMATED EMAIL SYSTEM.
PLEASE DO NOT REPLY TO THIS EMAIL.

Your being sent this email because you, or someone else, applied for an account at $GLOBALS[url_path] using
this email address. If you have not applied for membership at thsi site, then please disregard this email, and sorry to inconvienence you.

In order to activate this account you must enter the follow information at $GLOBALS[url_path]/verifyuser.php
	Username: $HTTP_POST_VARS[user_name]
	     Key: $GLOBALS[new_pass]


ENDemail_str;


		//echo "uname = $HTTP_POST_VARS[user_name]<br>\n".
			"upass = $GLOBALS[new_pass]<br>\n".
			"fname = $HTTP_POST_VARS[first_name]<br>\n".
			"lname = $HTTP_POST_VARS[last_name]<br>\n".
			"umail = $HTTP_POST_VARS[user_email]<br>\n";

		// Making the password an md5 password
		$GLOBALS[new_pass] = md5($GLOBALS[new_pass]);

		// the new user class has the tmp_user function
		if(!$user_db->create_tmp_user($HTTP_POST_VARS[user_name], $GLOBALS[new_pass], $HTTP_POST_VARS[first_name], $HTTP_POST_VARS[last_name], $HTTP_POST_VARS[user_email], time())) $GLOBALS[page_table] = array("$GLOBALS[page_title]"=>"$GLOBALS[signup07]");
		else mail("$HTTP_POST_VARS[user_email]",
			"AudioDevil member signup.",
			"$email_str",
			"From:hide@address.com\nX-Mailer:apache");

		$GLOBALS[page_table] = array("$GLOBALS[page_title]"=>"$GLOBALS[signup06]");
		$GLOBALS[new_pass] = NULL;



	}


	// Display the default page if nothing else happened
	// this should be the last else in the whole clause
	else $GLOBALS[page_table] = array("$GLOBALS[page_title]"=>"$GLOBALS[signup00]");



// Starting page output
draw_header("$GLOBALS[page_title]");
draw_nav($nav_array);
draw_sect($GLOBALS[page_table]);
draw_footer("&nbsp;");
ob_end_flush();
?>
Return current item: Mummi (Multi-user MOD_MP3 Interface)