<?php
error_reporting(0);
//----------
include ('inc/config.inc.php.php');
//----------
session_name('sid');
session_start();
//----------
connect_to_db();
include ('inc/autorize.php.php');
include ('inc/online.php.php');
$rands = rand(1000, 10000);
//-----------
if (!$autorize) {
header('Location: index.php?partner='.$partner.'&mod='.$mod.'&'.$srand.'='.$r_rand.'&'.session_name().'='.session_id());
}
//----------
$partner = intval($_GET['partner']); if ($partner == 0) $partner = 1;
//----------
$arr = mysql_query("SELECT COUNT(*) FROM `love_partner`;");
$part_users = mysql_result($arr, 0);
if($partner > $part_users) $partner = 1;
//----------
$partner_arr = @mysql_query("SELECT * FROM `love_partner` WHERE `partner` = ".$partner." LIMIT 1;");
$row = @mysql_fetch_array($partner_arr);
$partner_site = $row['site'];
$partner_name = $row['name'];
//----------
$title = 'Сменить пароль';
include ('header.php');
echo $header;
if($mod == '1') echo '<p align="center"><small>';
//-----------
if(!$_GET['f'] || ($_SESSION['rand'] != $_GET['f'])) {
$_SESSION['rand'] = rand(1000,9999);
echo $class_d2;
echo 'Сменить пароль<br/>';
echo $class_divz;
if($mod == '1') echo '</small></p><p align="left"><small>';
if($mod == '1') {
echo 'Введите старый пароль:</small><br/>';
if($_GET['error'] == '1') echo '<small><b>Ошибка!</b> Введите старый пароль!</small><br/>';
if($_GET['error'] == '4') echo '<small><b>Ошибка!</b> Не верно введён старый пароль!</small><br/>';
echo '<input name="nm'.$rands.'" maxlength="15" type="password" /><br/>';
echo '<small>Введите новый пароль:</small><br/>';
if($_GET['error'] == '2') echo '<small><b>Ошибка!</b> Введите новый пароль!<br/>';
if($_GET['error'] == '3') echo '<small><b>Ошибка!</b> В пароле разрешено использовать символы, a-zA-Z0-9 от 4 до 12</small><br/>';
echo '<input name="nm1'.$rands.'" maxlength="15" type="password" /><br/>';
echo '<small><anchor>Сохранить<go href="'.$PHP_SELF.'?f='.$_SESSION['rand'].'&amp;partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'" method="post">';
echo "<postfield name='nm' value='$(nm".$rands.")' />";
echo "<postfield name='nm1' value='$(nm1".$rands.")' />";
echo "<postfield name='nm2' value='$(nm2".$rands.")' />";
echo "<postfield name='nm3' value='$(nm3".$rands.")' />";
echo "<postfield name='nm4' value='$(nm4".$rands.")' />";
echo "<postfield name='nm5' value='$(nm5".$rands.")' />";
echo '</go></anchor><br/>';
}
else
{
echo '<form action="'.$PHP_SELF.'?f='.$_SESSION['rand'].'&amp;partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'" method="post">';
echo $class_d1;
echo 'Введите старый пароль:<br/>';
if($_GET['error']=="1") echo '<b>Ошибка!</b> Введите старый пароль!<br/>';
if($_GET['error']=="4") echo '<b>Ошибка!</b> Не верно введён старый пароль!<br/>';
echo '<input name="nm" maxlength="15" type="password" class="button" /><br/>';
echo 'Введите новый пароль:<br/>';
if($_GET['error']=="2") echo '<b>Ошибка!</b> Введите новый пароль!<br/>';
if($_GET['error']=="3") echo '<b>Ошибка!</b> В пароле разрешено использовать символы, a-zA-Z0-9 от 4 до 12<br/>';
echo '<input name="nm1" maxlength="15" type="password" class="button" /><br/>';
echo '<input type="submit" value="Сменить" class="do_button" />';
echo $class_divz;
echo '</form>';
}
echo $class_d0;
if($mod == '1') echo '---<br/>';
echo '&#171;- <a href="/menu.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'">Назад</a><br/>';
if($mod == '1') echo '---<br/>';
echo $class_divz.$class_d1;
echo '[7] <a href="http://'.$_SERVER['HTTP_HOST'].'/index.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.session_name().'='.session_id().'" accesskey="7">Поиск</a> [8] <a href="http://'.$_SERVER['HTTP_HOST'].'/menu.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.session_name().'='.session_id().'" accesskey="8">Личное меню</a> [9] <a href="http://'.$_SERVER['HTTP_HOST'].'/out.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.session_name().'='.session_id().'" accesskey="9">Выход</a><br/>';
if($mod == '1') echo '</small></p><p align="center"><small>';
echo $class_divz.$class_d2;
echo $class_divz.$class_d2.$class_version.$class_divz.$class_div;
echo $class_endpage;
exit;
}

if($_SESSION['rand'] == $_GET['f']) {
$nm = trim(htmlspecialchars(mysql_escape_string($_POST['nm'])));
$nm1 = trim(htmlspecialchars(mysql_escape_string($_POST['nm1'])));
$nm = substr($nm, 0, 15);
$nm1 = substr($nm1, 0, 15);
if($nm != "") {
if($nm1 != "") {
if(preg_match('#^[A-Za-z1-9]{4,12}$#',$nm1)) {
$query = mysql_query("SELECT `pas` FROM `love_user` WHERE `id` = '".intval($autorize['id'])."';");
$arr = mysql_fetch_array($query);
$pass = $arr['pas'];
if($pass == $nm) {
unset($_SESSION['rand']);
@mysql_query("UPDATE `love_user` SET `pas` = '".$nm1."' WHERE `id` = '".intval($autorize['id'])."';");
//----------
echo $class_d2;
echo 'Сменить пароль<br/>';
echo $class_divz.$class_d0;
if($mod == '1') echo '</small></p><p align="left"><small>';
echo 'Пароль успешно изменён<br/>';
echo 'Ваш новый пароль: <b>'.$nm1.'</b><br/>';
unset($_SESSION['nick']);
unset($_SESSION['pas']);
session_destroy();
session_name('sid');
session_start();
echo $class_divz.$class_d0;
if($mod == '1') echo '---<br/>';
echo '&#171;- <a href="/menu.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'">Назад</a><br/>';
if($mod == '1') echo '---<br/>';
echo $class_divz.$class_d1;
echo '[7] <a href="http://'.$_SERVER['HTTP_HOST'].'/index.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.session_name().'='.session_id().'" accesskey="7">Поиск</a> [8] <a href="http://'.$_SERVER['HTTP_HOST'].'/menu.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.session_name().'='.session_id().'" accesskey="8">Личное меню</a> [9] <a href="http://'.$_SERVER['HTTP_HOST'].'/out.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.session_name().'='.session_id().'" accesskey="9">Выход</a><br/>';
if($mod == '1') echo '</small></p><p align="center"><small>';
echo $class_divz.$class_d2;
echo $class_divz.$class_d2.$class_version.$class_divz.$class_div;
echo $class_endpage;
} else { header('Location: '.$PHP_SELF.'?error=4&partner='.$partner.'&mod='.$mod.'&'.$srand.'='.$r_rand.'&'.session_name().'='.session_id()); }
} else { header('Location: '.$PHP_SELF.'?error=3&partner='.$partner.'&mod='.$mod.'&'.$srand.'='.$r_rand.'&'.session_name().'='.session_id()); }
} else { header('Location: '.$PHP_SELF.'?error=2&partner='.$partner.'&mod='.$mod.'&'.$srand.'='.$r_rand.'&'.session_name().'='.session_id()); }
} else { header('Location: '.$PHP_SELF.'?error=1&partner='.$partner.'&mod='.$mod.'&'.$srand.'='.$r_rand.'&'.session_name().'='.session_id()); }
}

?>