Файл: user/friends/access.php
Строк: 83
<?php
require_once '../../sys/inc/start.php';
require_once '../../sys/inc/compress.php';
require_once '../../sys/inc/sess.php';
require_once '../../sys/inc/settings.php';
require_once '../../sys/inc/db_connect.php';
require_once '../../sys/inc/ipua.php';
require_once '../../sys/inc/fnc.php';
require_once '../../sys/inc/user.php';
only_reg();
$set['title'] = "Настройки";
require_once '../../sys/inc/thead.php';
title();
aut();
if (isset($_POST['submited'])) {
if (in_array($_POST['access'], array('all', 'only_me', 'friends', 'pass'))) {
$access = $_POST['access'];
} else {
$access = 'all';
}
if ($access == 'pass') {
if (utf8_strlen($_POST['passwd']) < 1) {
$err[] = 'Введите пароль.';
}
if (utf8_strlen($_POST['passwd']) > 16) {
$err[] = 'Пароль слишком длинный.';
}
$password = $_POST['passwd'];
} else {
$password = NULL;
}
if (!isset($err)) {
mysql_query("UPDATE `user` SET `friends_access` = '$access', `friends_password` = '" . mysql_real_escape_string($password) . "' WHERE `id` = '$user[id]'");
header("Location: /user/friends");
}
$user['friendship'] = (isset($_POST['friendship']) && $_POST['friendship']) ? '1' : '0';
mysql_query("UPDATE `user` SET `friendship` = '" . mysql_real_escape_string($user['friendship']) . "' WHERE `id` = '$user[id]' LIMIT 1");
exit();
}
echo "<div class = 'foot'>";
echo "Кто может видеть ваших друзей";
err();
echo "<form action = '' method = 'post'>";
echo "<input type = 'radio' name = 'access' value = 'all' " . ($user['friends_access'] == 'all' ? " checked = 'checked'" : NULL) . "/>";
echo "<label><img src = '/style/icons/globe-small.png'/>Все</label><br/>";
echo "<input type = 'radio' name = 'access' value = 'only_me' " . ($user['friends_access'] == 'only_me' ? " checked='checked'" : NULL) . "/>";
echo "<label><img src = '/style/icons/lock-small.png' />Только я</label><br/>";
echo "<input type='radio' name='access' value='friends' " . ($user['friends_access'] == 'friends' ? " checked='checked'" : NULL) . "/>";
echo "<label><img src='/style/icons/user-small.png' />Мои друзья</label><br/>";
echo "<input type='radio' name='access' value='pass' " . ($user['friends_access'] == 'pass' ? " checked='checked'" : NULL) . " />";
echo "<label><img src='/style/icons/bullet_key.png' /> Только по паролю:</label><br/>";
echo "Пароль:<br/><input name='passwd' size='16' maxlength='16' type='text' value='" . htmlspecialchars($user['friends_password']) . "' /><br/>";
echo "<label><input type = 'checkbox'" . ($user['friendship'] ? " checked = 'checked'" : null) . " name = 'friendship' value = '1' />Запред на предложения дружбы</label><br/>";
echo "<div class = 'button_blue'>";
echo "<button name = 'submited'>Сохранить изменения</button>";
echo "</div></form></div>";
echo "<a href = '/user/friends/'><div class = 'razd'><img src = '/style/icons/left.png' /> Назад</div></a>";
require_once '../../sys/inc/tfoot.php';