<?php
///////////////////////////////////////////////////////////////////////////////
//                                                                           //
//   Program Name         : ProPhotoHost                                     //
//   Release Version      : 1.0                                              //
//   Home Page            : http://www.prophotohost.com                      //
//   Program Author       : Jake P                                           //
//   Supplied by          : drew010                                          //
//   Nullified by         : CyKuH [WTN]                                      //
//   Distribution         : via WebForum, ForumRU and associated file dumps  //
//                                                                           //
///////////////////////////////////////////////////////////////////////////////
session_start();
include('i.setup.php');
include('i.connection.php');
include('i.function.php');

if($mode == "forgot") {
	
	$result = mysql_query("SELECT member_email FROM member WHERE member_status = 'A' AND member_email = '$email'", $db);
	$data = mysql_fetch_object($result);
	$rows = mysql_num_rows($result);
	
	if($rows < 1) {
		header("location: ./error.php?error=forgot");
		exit;
	}
	
	$password = random(6, "");
	$enc_password = MD5($password);
	
	$date = now();
	
	$sql = "UPDATE member SET member_password='$enc_password', updated_on='$date' WHERE member_email = '$email'";
	$result = mysql_query($sql);
	
	$message .= "Your password has been reset to: " . $password . "\n\n";
	$message .= "Please follow the link below to login and change your password\n";
	$message .= $page_url . "\n\n";
	
	mail($data->member_email, "Lost password - " . $page_name, $message, "From: " . $page_support_email);
	header("location: ./confirmation.php?confirm=forgot");
	
}
?>

<html>

<head>
<title><?php print($page_title); ?></title>

<meta name="description" content="<?php print($page_desc); ?>">
<meta name="keywords" content="<?php print($page_key); ?>">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">

<?php include('i.style.php'); ?>

</head>

<body <?php if($session_access == false) { ?>onload="document.login.email.focus();"<?php } ?> marginwidth="0" marginheight="0" leftmargin="0" topmargin="0" rightmargin="0">
	
	<table width="100%" cellpadding="0" cellspacing="0">
		
		<?php include('i.header.php'); ?>
		
		<tr>
			
			<td valign="top">
				
				<table cellpadding="0" cellspacing="0">
					
					<tr>
						
						<td><font face="verdana" size="1">&nbsp;&nbsp;&nbsp;</font></td>
						
					</tr>
					
				<tr>
					
					<td><font face="verdana" size="1">&nbsp;&nbsp;&nbsp;</font></td>
					
					<td valign="top">
						
						<table cellpadding="0" cellspacing="0">
							
							<?php include('i.tab.php'); ?>
							
						</table>
						
					</td>
					
					<td><font face="verdana" size="1">&nbsp;&nbsp;</font></td>
					
					<td valign="top" width="100%">
						
						<table width="100%" cellpadding="0" cellspacing="0">
							
							<tr>
								
								<td><font face="verdana" size="1">&nbsp;</font></td>
								
								<td width="100%">
									
									<table width="100%" cellpadding="0" cellspacing="0">
										
										<tr>
											
											<td><img src="./images/heading.forgot.gif"></td>
											
										</tr>
										
										<tr>
											
											<td height="8" background="images/hr.gif"></td>
											
										</tr>
										
										<tr>
											
											<td><font face="verdana" size="1">&nbsp;</font></td>
											
										</tr>
										
										<tr>
											
											<td valign="top" height="250">
												
												<table>
													
													<form name="forgot" method="post" action="<?php print($PHP_SELF); ?>?mode=forgot">
														
														<tr>
															
															<td><font face="verdana" size="1">Enter your e-mail address and we will e-mail you a new password.</font></td>
															
														</tr>
														
														<tr>
															
															<td><input type="text" name="email" class="form" style="width: 300px;"></td>
															
														</tr>
														
														<tr>
															
															<td><input type="image" src="./images/bu.send.gif" name="send_button"></td>
															
														</tr>
														
													</form>
													
												</table>
												
											</td>
											
										</tr>
										
										<tr>
										
										<tr>
											
											<td><font face="verdana" size="1">&nbsp;</font></td>
											
										</tr>
										
										<tr>
											
											<td height="8" background="images/hr.gif"></td>
											
										</tr>
										
									</table>
									
								</td>
								
								<td><font face="verdana" size="1">&nbsp;</font></td>
								
							</tr>
							
						</table>
						
					</td>
					
				</tr>
				
			</table>
			
		</td>
		
	</tr>
	
	<?php include('i.footer.php'); ?>
	
	</table>
	
</body>

</html>