<?php
ob_start();
include("config.php");

?>

<html>
<head>
<title>Ultimatecrime - Wachtwoord Resetten!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="Meld je hier aan en speel gratis mee met duizenden andere fanatieke criminelen!">
<meta name="keywords" content="Gang Wars, world, gangster, criminal, mafia, games, game, multiplayer, rpg, mmorpg, online game, online multiplayer">
<meta name="Robots" CONTENT="follow">
<meta name="REVISIT-AFTER" CONTENT="7 days">
<link rel="stylesheet" type="text/css" href="style_general.css">
</head>
<body background="layout/images/layout_12.gif" bgproperties="fixed">
<br>
<br>
<br>
<form action="algemeen-wwreset2.php" method="post" name="ww" onSubmit="return submitForm(this.submit);">
<table width="600" border="0" align="center">
	<tr>
		<td colspan="2" class="subtitle">&nbsp;</td>
	</tr>
	<tr>
		<td width="170" class="maintxtS" style="padding: 0;"><div align="center"><img src="layout/images/logo_signup.jpg" width="146" height="62" /></div></td>
		<td width="430" valign="top" class="maintxt"><p><span class="tekstheader">Wachtwoord vergeten? Reset het dan hier! </span><br />Je ontvangt een code per email waarmee je je wachtwoord kan resetten. Je ontvangt vervolgens per email een nieuwe.</p>    </td>
	</tr>
	<tr>
		<td colspan="2" class="subtitle">&nbsp;</td>
	</tr>

<?php

	if(isset($_POST['submit'])){
	$dbres		=	mysql_query("SELECT *,UNIX_TIMESTAMP(`time`) AS `time`,0 FROM `wwreset` WHERE `code`='{$_POST['resetcode']}'");
	$code		=	mysql_fetch_object($dbres);
	$controlle	=	mysql_num_rows($dbres);

		if($controlle == 0 || $code->time + 900 < time()){

?>

	<tr>
		<td colspan="2" class="maintxt"><table width="550" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td width="25" valign="top"><img src="layout/images/icons/light_uitroepteken.jpg"></td>
				<td>Ongeldige reset code (code is 15 min geldig)!</td>
			</tr>
		</table></td>
	</tr>
	<tr>
		<td colspan="2" class="subtitle">&nbsp;</td>
	</tr>

<?php

		} else {

		$dbres	=	mysql_query("SELECT `login`,`email` FROM `gebruiker` WHERE `login`='{$code->login}'");
		$man	=	mysql_fetch_object($dbres);

		include_once("rndPass.class.php");
		$code	=	new rndPass(10);
		$code	=	$code->PassGen();
		$pass	=	md5($code);
		mysql_query("DELETE FROM `wwreset` WHERE `code`='{$_POST['resetcode']}'");
		mysql_query("UPDATE `gebruiker` SET `pass`='$pass' WHERE `login`='{$man->login}'");

		$subj		=	"Nieuw wachtwoord - Stap 2/2";
		$emess		=	"Ultimatecrime\n\nJe hebt je wachtwoord via de website van Ultimatecrime gereset!\nWe hebben voor je een nieuw wachtwoord gegenereerd.\nJe nieuwe wachtwoord voor Ultimatecrime is: $code\n\n\n\nDe Grote Raad";
		$headers	.=	"From: Ultimatecrime <info@ultimatecrime.nl>";
		mail("{$man->email}","$subj","$emess","$headers");

?>

	<tr>
		<td colspan="2" class="maintxt"><table width="550" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td width="25" valign="top"><img src="layout/images/icons/light_vink.jpg" width="16" height="16" /></td>
				<td>Er is een nieuw wachtwoord gestuurd naar je email.</td>
			</tr>
		</table></td>
	</tr>
	<tr>
		<td colspan="2" class="subtitle">&nbsp;</td>
	</tr>

<?php

		}
	}

?>

	<tr>
		<td colspan="2" class="maintxt"><table width="560" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td width="30"><img src="layout/images/icons/light_lock.jpg" width="16" height="16"></td>
				<td width="530" class="tekstheader">Vul de reset code in die je per email hebt ontvangen</td>
			</tr>
			<tr>
				<td width="30">&nbsp;</td>
				<td width="530"><br /><input name="resetcode" type="text" style="width: 150;" value="" maxlength="10" /></td>
			</tr>
		</table></td>
	</tr>
	<tr>
		<td colspan="2" class="maintxt"><table width="560" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td width="30" valign="middle"><img src="layout/images/icons/light_vink.jpg" width="16" height="16" /></td>
				<td width="530" valign="middle"><input name="submit" style="width: 325; text-align: center;" type="submit" value="&nbsp;&nbsp;&nbsp; Stuur mij een nieuw wachtwoord! &nbsp;&nbsp;&nbsp;" /></td>
			</tr>
		</table></td>
	</tr>
	<tr>
		<td colspan="2" class="subtitle">&nbsp;</td>
	</tr>
</table>
</form>
</body>
</html>
