<?
include_once "SYSTEM/include/functions.php";
include_once "SYSTEM/include/mysql.php";
include_once "SYSTEM/include/param.php";
include_once "SYSTEM/include/ban.php";
include_once "SYSTEM/include/sess.php";
include_once "SYSTEM/include/ban_2.php";
include_once "SYSTEM/include/theme.php";
$title='Восстановление пароля';
$mesto='Восстановление пароля';
head();
if (isset($user))
{
header("Location: index.php?".SID."&");
exit;
}



echo "<div class=\"h\">Восстановление пароля</div><hr />\n";

if (isset ($_POST['log']) && isset ($_POST['mail']))
{
$log1=mysql_escape_string($_POST['log']);
$mail1=mysql_escape_string($_POST['mail']);

$q = mysql_query("SELECT * FROM `$mysql[pref]users` WHERE `nickname` >= '$log1' AND `email` = '$mail1';");

if(mysql_num_rows($q) != 0)
{
$ank = mysql_fetch_array($q, 1);

$newpass=passgen();

mysql_query("UPDATE `$mysql[pref]users` SET `password` = '".md5($newpass)."' WHERE `id` = '".$ank['id']."';");

$subject = "Восстановление пароля ($set[title])";
$regmail = "Здраствуйте, $ank[nickname]!!!
Вы запросили восстановление пароля на сайте $set[title].
Ваш новый пароль: $newpass";
$adds = "From: <$set[mail]>\n";
$adds .= "X-sender: <$set[mail]>\n";
$adds .= "Content-Type: text/plain; charset=utf-8\n";
mail($mail1,$subject,$regmail,$adds);

echo "<span style=\"color:$color[msg]\"><b>Ваш новый пароль выслан на E-mail: $mail1</b></span><br/>";


}
}



echo "<form method=\"post\" action=\"pass.php\">\n";
echo "Логин:<br/><input name=\"log\" class=\"form\" value=\"\" type=\"text\" /><br/>\n";
echo "E-mail:<br/><input name=\"mail\" class=\"form\" value=\"@\" type=\"text\" /><br/><br/>\n";
echo "<input value=\"Выслать\" class=\"form\" type=\"submit\" />\n";
echo "</form>\n";




echo "<a href=\"vhod.php\">Авторизация</a><br/>\n";
echo "<a href=\"index.php\">На главную</a><br/>\n";

foot();
?>
