= 7) {
// Если был запрос на юзера, то получаем его данные
$req = mysql_query("SELECT * FROM `users` WHERE `id` = '$id' LIMIT 1");
if (mysql_num_rows($req)) {
$user = mysql_fetch_assoc($req);
if ($user['rights'] > $datauser['rights']) {
// Если не хватает прав, выводим ошибку
echo display_error('Вы не можете редактировать анкету старшего Вас по должности');
require_once ('../incfiles/end.php');
exit;
}
}
else {
echo display_error('Такого пользователя не существует');
require_once ('../incfiles/end.php');
exit;
}
}
else {
$id = false;
$user = $datauser;
}
if ($id && $rights >= 7 && $act == 'reset') {
// Сброс настроек
mysql_query("UPDATE `users` SET `set_user` = '', `set_forum` = '', `set_chat` = '' WHERE `id` = '" . $user['id'] . "'");
echo '
';
require_once ('../incfiles/end.php');
exit;
}
echo '';
if (isset($_GET['delavatar'])) {
// Удаляем аватар
@unlink('../files/avatar/' . $user['id'] . '.png');
echo '';
} elseif (isset($_GET['delphoto'])) {
// Удаляем фото
@unlink('../files/photo/' . $user['id'] . '.jpg');
@unlink('../files/photo/' . $user['id'] . '_small.jpg');
echo '';
} elseif (isset($_POST['submit'])) {
$error = array();
// Данные юзера
$user['imname'] = isset($_POST['imname']) ? check(mb_substr($_POST['imname'], 0, 25)) : '';
$user['strana'] = isset($_POST['strana']) ? check(mb_substr($_POST['strana'], 0, 20)) : '';
$user['live'] = isset($_POST['live']) ? check(mb_substr($_POST['live'], 0, 50)) : '';$user['celz'] = isset($_POST['celz']) ? check(mb_substr($_POST['celz'], 0, 20)) : '';$user['glaza'] = isset($_POST['glaza']) ? check(mb_substr($_POST['glaza'], 0, 15)) : '';$user['volosi'] = isset($_POST['volosi']) ? check(mb_substr($_POST['volosi'], 0, 15)) : '';$user['telo'] = isset($_POST['telo']) ? check(mb_substr($_POST['telo'], 0, 25)) : '';$user['zanim'] = isset($_POST['zanim']) ? check(mb_substr($_POST['zanim'], 0, 25)) : '';$user['sait'] = isset($_POST['sait']) ? check(mb_substr($_POST['sait'], 0, 80)) : '';$user['privet'] = isset($_POST['privet']) ? check(mb_substr($_POST['privet'], 0, 100)) : '';$user['kurit'] = isset($_POST['kurit']) ? check(mb_substr($_POST['kurit'], 0, 8)) : '';$user['xarakter'] = isset($_POST['xarakter']) ? check(mb_substr($_POST['xarakter'], 0, 25)) : '';
$user['dayb'] = isset($_POST['dayb']) ? intval($_POST['dayb']) : 0;
$user['monthb'] = isset($_POST['monthb']) ? intval($_POST['monthb']) : 0;
$user['yearofbirth'] = isset($_POST['yearofbirth']) ? intval($_POST['yearofbirth']) : 0;
$user['about'] = isset($_POST['about']) ? check(mb_substr($_POST['about'], 0, 500)) : '';
$user['mibile'] = isset($_POST['mibile']) ? check(mb_substr($_POST['mibile'], 0, 40)) : '';
$user['mail'] = isset($_POST['mail']) ? check(mb_substr($_POST['mail'], 0, 40)) : '';
$user['mailvis'] = isset($_POST['mailvis']) ? 1 : 0;
$user['icq'] = isset($_POST['icq']) ? intval($_POST['icq']) : 0; $user['rost'] = isset($_POST['rost']) ? intval($_POST['rost']) : 0; $user['ves'] = isset($_POST['ves']) ? intval($_POST['ves']) : 0;
$user['skype'] = isset($_POST['skype']) ? check(mb_substr($_POST['skype'], 0, 40)) : '';
$user['jabber'] = isset($_POST['jabber']) ? check(mb_substr($_POST['jabber'], 0, 40)) : '';
$user['www'] = isset($_POST['www']) ? check(mb_substr($_POST['www'], 0, 40)) : '';
// Данные юзера (для Администраторов)
$user['name'] = isset($_POST['name']) ? check(mb_substr($_POST['name'], 0, 20)) : $user['name'];
$user['status'] = isset($_POST['status']) ? check(mb_substr($_POST['status'], 0, 50)) : '';
$user['immunity'] = isset($_POST['immunity']) ? 1 : 0;
$user['karma_off'] = isset($_POST['karma_off']) ? 1 : 0;
$user['sex'] = isset($_POST['sex']) && $_POST['sex'] == 'm' ? 'm' : 'zh';
$user['rights'] = isset($_POST['rights']) ? abs(intval($_POST['rights'])) : 0;
// Проводим необходимые проверки
if ($user['id'] == $user_id)
$user['rights'] = $datauser['rights'];
if ($rights >= 7) {
if (mb_strlen($user['name']) < 2)
$error[] = 'Минимальная длина Ника - 2 символа';
$lat_nick = rus_lat(mb_strtolower($user['name']));
if (preg_match("/[^1-9a-z\-\@\*\(\)\?\!\~\_\=\[\]]+/", $lat_nick))
$error[] = 'Недопустимые символы в Нике
';
}
if ($user['dayb'] || $user['monthb'] || $user['yearofbirth']) {
if ($user['dayb'] < 1 || $user['dayb'] > 31 || $user['monthb'] < 1 || $user['monthb'] > 12)
$error[] = 'Дата рождения указана неправильно';
}
if ($user['icq'] && ($user['icq'] < 10000 || $user['icq'] > 999999999))
$error[] = 'Номер ICQ должен состоять минимум из 5 цифр и максимум из 10'; if ($user['rost'] && ($user['rost'] < 0 || $user['rost'] > 999))
$error[] = 'В поле "рост" разрешено 0-3 цифр'; if ($user['ves'] && ($user['ves'] < 0 || $user['ves'] > 999))
$error[] = 'В поле "вес" разрешено 0-3 цифр ';if (!$error) {
mysql_query("UPDATE `users` SET
`imname` = '" . $user['imname'] . "',`strana` = '" . $user['strana'] . "',`privet` = '" . $user['privet'] . "',`sait` = '" . $user['sait'] . "',`live` = '" . $user['live'] . "',`orint` = '" . $user['orint'] . "',`ves` = '" . $user['ves'] . "',`rost` = '" . $user['rost'] . "',`glaza` = '" . $user['glaza'] . "',`celz` = '" . $user['celz'] . "',`volosi` = '" . $user['volosi'] . "',`celz` = '" . $user['celz'] . "',`xarakter` = '" . $user['xarakter'] . "',`zanim` = '" . $user['zanim'] . "',`kurit` = '" . $user['kurit'] . "',`telo` = '" . $user['telo'] . "',
`dayb` = '" . $user['dayb'] . "',
`monthb` = '" . $user['monthb'] . "',
`yearofbirth` = '" . $user['yearofbirth'] . "',
`about` = '" . $user['about'] . "',
`mibile` = '" . $user['mibile'] . "',
`mail` = '" . $user['mail'] . "',
`mailvis` = '" . $user['mailvis'] . "',
`status` = '" . $user['status'] . "',
`icq` = '" . $user['icq'] . "',
`skype` = '" . $user['skype'] . "',
`jabber` = '" . $user['jabber'] . "',`sex` = '" . $user['sex'] . "',
`www` = '" . $user['www'] . "'
WHERE `id` = '" . $user['id'] . "' LIMIT 1");
if ($rights >= 7) {
mysql_query("UPDATE `users` SET
`name` = '" . $user['name'] . "',`immunity` = '" . $user['immunity'] . "',
`karma_off` = '" . $user['karma_off'] . "',`rights` = '" . $user['rights'] . "'
WHERE `id` = '" . $user['id'] . "' LIMIT 1");
}
echo 'Данные сохранены
';
}
else {
echo display_error($error);
}
}
echo '';
echo '';
require_once ('../incfiles/end.php');
?>