File size: 6.38Kb
<?php
if(!$authorize)
{
header("Location: ".$forumdir);
}
else
{
if(empty($_POST['sv']))
{
if($version == "xhtml")
{
header("Content-type: text/html; chatset=utf-8");
header("Last-Modified:".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-relative");
echo('<html>
<head>
<title>Сменить пароль</title>
</head>
<body bgcolor="'.$style['background'].'" link="'.$style['link'].'" vlink="'.$style['link'].'" text="#000000">
<form action="./?p=21&v=xhtml&sid='.$sid.'" method="post">
<table align="center" border="0" cellspacing="1" cellpadding="5" width="350">
<tr><td align="center" bgcolor="'.$style['title'].'" colspan="2">
<font color="#FFFFFF"><b>Сменить пароль</b></font>
</td></tr>
<tr><td bgcolor="'.$style['bottom'].'" colspan="2"></td></tr>
<tr bgcolor="'.$style['text'].'"><td>
'.$tag.'Старый пароль:'.$tagC.'</td><td><input type="password" name="old" /></td></tr>
<tr bgcolor="'.$style['text'].'"><td>
'.$tag.'Новый пароль:'.$tagC.'</td><td><input type="password" name="new" /></td></tr>
<tr bgcolor="'.$style['text'].'"><td>
'.$tag.'Повторите пароль:'.$tagC.'</td><td><input type="password" name="re" /></td></tr>
<tr bgcolor="'.$style['text'].'"><td align="center" colspan="2">
<input type="hidden" name="sv" value="1" />
<input type="submit" value="Сменить" />
</td></tr>
<tr bgcolor="'.$style['bottom'].'"><td colspan="2">
'.$tag.'<a href="./?p=0&v=xhtml&sid='.$sid.'">В форум</a>'.$tagC.'
</td></tr></table>
</form>
</body></html>');
} elseif($version == "wml")
{
header("Content-type: text/vnd.wap.wml; chatset=utf-8");
header("Cache-Control: no-cache");
echo(doctype("Сменить пароль").$tag);
echo('Старый пароль:'.$tagC.' <br />
<input type="password" name="old" /><br />
'.$tag.'Новый пароль: '.$tagC.'<br />
<input type="password" name="new" /><br />
'.$tag.'Повторите новый пароль:'.$tagC.' <br />
<input type="password" name="re" /><br />
<anchor>[Сменить]
<go href="./?p=21&v=wml&sid='.$sid.'" method="post">
<postfield name="old" value="$(old)" />
<postfield name="new" value="$(new)" />
<postfield name="re" value="$(re)" />
<postfield name="sv" value="1" />
</go></anchor>
<br />'.$tag.'
- - - - <br />
<a href="./?p=0&v=wml&sid='.$sid.'">В форум</a>
'.$tagC.'</p>
</card></wml>');
}
}
else
{
$newPass = trim(sql($_POST['new']));
$reNewPass = trim(sql($_POST['re']));
$oldPass = trim(sql($_POST['old']));
$error = "";
if(!mysql_result(mysql_query("SELECT COUNT(*) FROM `users` WHERE `username`='".$username."' AND `password`='".$oldPass."'"), 0))
{
$error .= "Неверный пароль!<br />\r\n";
}
if(!preg_match("|^[-\._a-z0-9]+$|i", $newPass))
{
$error .= "В пароле могут присутствовать символы латинского алфавита, цифры, знак подчеркивания, тире и точка!<br />\r\n";
}
if($newPass != $reNewPass)
{
$error .= "Пароли не совпадают!<br />\r\n";
}
if(!empty($error))
{
if($version == "xhtml")
{
header("Content-type: text/html; chatset=utf-8");
header("Last-Modified:".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-relative");
echo('<html>
<head>
<title>Сменить пароль</title>
</head>
<body bgcolor="'.$style['background'].'" link="'.$style['link'].'" vlink="'.$style['link'].'" text="#000000">
<form action="./?p=21&v=xhtml&sid='.$sid.'" method="post">
<table align="center" border="0" cellspacing="1" cellpadding="5" width="350">
<tr><td align="center" bgcolor="'.$style['title'].'">
<font color="#FFFFFF"><b>Сменить пароль</b></font>
</td></tr>
<tr><td bgcolor="'.$style['bottom'].'"></td></tr>
<tr><td bgcolor="'.$style['text'].'">'.$tag.$error.$tagC.'</td></tr>
<tr><td bgcolor="'.$style['bottom'].'"> '.$tag.'
<a href="./?p=21&rnd='.$ref.'&sid='.$sid.'&v=xhtml">Повторить</a><br />
<a href="./?p=0&v=xhtml&sid='.$sid.'">В форум</a>
'.$tagC.'</td></tr>
</table>
</body></html>');
} elseif($version == "wml")
{
header("Content-type: text/vnd.wap.wml; chatset=utf-8");
header("Cache-Control: no-cache");
echo(doctype("Ошибка").$tag);
echo($error);
echo("- - - - <br />\r\n");
echo("<a href=\"./?p=21&v=wml&sid=".$sid."&rnd=".mt_rand(1111, 99999)."\">Повторить</a><br />\r\n");
echo("<a href=\"./?p=0&v=wml&sid=".$sid."\">В форум</a>\r\n");
echo($tagC."</p></card></wml>");
}
}
else
{
mysql_query("UPDATE `users` SET `password`='".$newPass."' WHERE `username`='".$username."'");
mysql_query("UPDATE `session` SET `password`='".$newPass."' WHERE `nickname`='".$username."'");
if($version == "xhtml")
{
header("Content-type: text/html; chatset=utf-8");
header("Last-Modified:".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-relative");
echo('<html>
<head>
<title>Сменить пароль</title>
</head>
<body bgcolor="'.$style['background'].'" link="'.$style['link'].'" vlink="'.$style['link'].'" text="#000000">
<form action="./?p=21&v=xhtml&sid='.$sid.'" method="post">
<table align="center" border="0" cellspacing="1" cellpadding="5" width="350">
<tr><td align="center" bgcolor="'.$style['title'].'">
<font color="#FFFFFF"><b>Сменить пароль</b></font>
</td></tr>
<tr><td bgcolor="'.$style['bottom'].'"></td></tr>
<tr><td bgcolor="'.$style['text'].'">'.$tag.'Пароль успешно изменен!'.$tagC.'</td></tr>
<tr><td bgcolor="'.$style['bottom'].'">'.$tag.'
<a href="./?p=0&v=xhtml&sid='.$sid.'">В форум</a>
'.$tagC.'</td></tr>
</table>
</body></html>');
} elseif($version == "wml")
{
header("Content-type: text/vnd.wap.wml; chatset=utf-8");
header("Cache-Control: no-cache");
echo(doctype("Ошибка").$tag);
echo("Пароль успешно изменен!");
echo("- - - - <br />\r\n");
echo("<a href=\"./?p=0&v=wml&sid=".$sid."\">В форум</a>\r\n");
echo($tagC."</p></card></wml>");
}
}
}
}
?>