Location: PHPKode > projects > Dominant Creature RPG > resend.php
<?

session_start();

include 'database.php';

?>

<HTML>

<HEAD>

<TITLE>Dominant Evil</TITLE>

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">

<SCRIPT SRC="class/boxover.js"></SCRIPT>

<style>

body {

background: #1E1E1E url(images/index_01.jpg) top repeat-x;

color: #fff;

font-size: 11px;

font-family: Verdana;

}



td {

color: #fff;

font-size: 11px;

font-family: Verdana;

}



#foot {

color: #fff;

font-size: 11px;

font-family: Verdana;

width: 808px;

height: 24px;

background: #1E1E1E url(images/footbg.jpg) top center repeat-x;

}



a, a:visited {

color: #D9C5C5;

font-weight: bold;

text-decoration: none;

}



a:hover, a:active {

color: #fff;

font-weight: bold;

text-decoration: none;

}



#head {

background: #1E1E1E url(images/index_02.jpg) no-repeat;

width: 808px;

height: 154px;

font-size: 11px;

font-family: Verdana;

}



#menu {

background: #1E1E1E url(images/index_04.jpg) no-repeat;

width: 808px;

height: 30px;

font-size: 11px;

font-family: Verdana;

padding-top: 6px;

padding-left: 16px;

}



#body {

background: #1E1E1E url(images/index_05.jpg) repeat-y;

width: 580px;

height: 500px;

font-size: 11px;

font-family: Verdana;

padding-top: 10px;

padding-left: 20px;

}



#body-right {

background: #1E1E1E url(images/index_06.jpg) repeat-y;

width: 208px;

height: 500px;

font-size: 11px;

font-family: Verdana;

}



input, select {

font-size: 11px;

}



</style>



</HEAD>

<BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>

<!-- ImageReady Slices (psd.psd) -->

<TABLE align=center width='808' BORDER=0 CELLPADDING=0 CELLSPACING=0>

	<TR>

		<TD colspan='2' valign='top' id='head'>

		</TD>

	</TR>

	<TR>

		<TD colspan='2' valign='top' id='menu'>

<a href='index.php'>Homepage</a> | <a href='register.php'>Join the game</a> | <a href='resend.php'>Lost pass?</a>



		</TD>

	</TR>

	<TR>

		<TD valign='top' align='left' id='body'>

<?

if(isset($_POST['resend']))

{

	

	$email = mysql_real_escape_string($_POST["email"]);

	

	if ($email == '') {

		

		echo '<script>alert("Enter something...mail adress would be best!");</script>';

		echo '<script>history.back(1);</script>';

		exit;	



	}

	if((!strstr($email , "@")) || (!strstr($email , ".")))

	{

	

		echo '<script>alert("You have entered non-valid email adress. Please try again.");</script>';

		echo '<script>history.back(1);</script>';

		exit;



	}

	



	$q = mysql_query("SELECT * FROM users WHERE email = '$email'") or die(mysql_error());

	if(mysql_num_rows($q) > 0)

	{



		$q2 = mysql_fetch_assoc($q);

		

		$user = $q2[user];

		//$pass = $q2[pass];

			

	}

	

	else {

		

		echo '<script>alert("There is no such email adress in DB. Please check again.");</script>';

		echo '<script>history.back(1);</script>';

		exit;

		

	}



	function makePassword($len = 8)

	{

		$vowels = array('a', 'e', 'i', 'o', 'u', 'y');

		$confusing = array('I', 'l', '1', 'Z', '0');

		$replacements = array('A', 'k', '3', 'U', '9');

		$choices = array(0 => rand(0, 1), 1 => rand(0, 1), 2 => rand(0, 2));

		$parts = array(0 => '', 1 => '', 2 => '');

		 

		if ($choices[0]) $parts[0] = rand(1, rand(9,99));

		if ($choices[1]) $parts[2] = rand(1, rand(9,99));

		 

		$len -= (strlen($parts[0]) + strlen($parts[2]));

		for ($i = 0; $i < $len; $i++)

		{

			if ($i % 2 == 0) $parts[1] .= chr(rand(97, 122));

			else $parts[1] .= $vowels[array_rand($vowels)];

		}

		if ($choices[2]) $parts[1] = ucfirst($parts[1]);

		if ($choices[2] == 2) $parts[1] = strrev($parts[1]);

		 

		$r = $parts[0] . $parts[1] . $parts[2];

		$r = str_replace($confusing, $replacements, $r);

		return $r;

	}



	$p = makePassword(8); // easy to control pass lenght

	$pass = md5($p);



	

	$query = mysql_query(

	"UPDATE users SET pass = '$pass' WHERE email = '$email' AND user = '$user'"

	) or die(mysql_error());

	

	

	$send = mail($email , "Password retrieval" , "You or someone using your mail has requested a password reset.\r\nYour data is:\r\nUsername: $user\r\nPassword: $p\n\r\n\rYou can now login, thank you.", "FROM: hide@address.com;");

	



	if($query && $send)

	{



		echo '

				<div class="info">

				<p>Your new password has been sent to mail adress provided.</p>

				<p>Once you get it, click <a href="index.php">here</a> to login.</p>

				</div>

				';	



	} else {



		echo  '

				<div>

				<p>Accept our apologies, we have encountered some problems.</p>

				<p>Your data is not lost, no need to worry. Pass: '.$p.' User: '.$user.'</p>

				<p>Try again later.</p>

				</div>

				';	



	}





} 



else {

?>



<div><strong>Account re-activation!</strong></div>

<br>



  <p>If your activation e-mail didn't arrived, fill up fields below.</p><br />

  <form method="post" action="resend.php">

  <p>Email:<br>  

  <input name="email" type="text" class="textBox">

  <p>

    <input name="resend" type="submit" class="textBox" id="resend" value="Resend email">    

  </form>

  </p><br />

After you enter your e-mail, we will check if it exists in database and if so,<br />will send activation code to you.</div>



<?

}

?>

		 

		</TD>

		<TD valign='top' align='left' id='body-right'>



		<br />

		</td>

	</TR>

	<tr>

	<td colspan='2' align='right' id='foot'>copyright by Nosf // 2008 | core engine by <a href='http://www.bbgdev.com/' target='_blank'>Dominant Creature</a></td>

	</tr>

</TABLE>

<!-- End ImageReady Slices -->

</BODY>

</HTML>

Return current item: Dominant Creature RPG