Файл: user/friends/access.php
Строк: 83
<?php
/* Мод "Друзья"
 * Версия v0.0.1
 * Дата последнего редактирования 31.01.2015
 * Двиг DCMS Special
 * Модифицировал densnet
 * Файл access.php
 * Описание: настройки друзей, приватность, запрет на предложение дружбы
 */
require_once '../../sys/inc/start.php';
require_once H . 'sys/inc/compress.php';
require_once H . 'sys/inc/sess.php';
require_once H . 'sys/inc/settings.php';
require_once H . 'sys/inc/db_connect.php';
require_once H . 'sys/inc/ipua.php';
require_once H . 'sys/inc/fnc.php';
require_once H . 'sys/inc/user.php';
user::only_reg();
$set['title'] = "Настройки";
require_once H . 'sys/inc/thead.php';
title();
aut();
err();
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 (text::utf8_strlen($_POST['passwd']) < 1) {
            $err[] = 'Введите пароль.';
        }
        if (text::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 "<form class = 'razd' action = '' method = 'post'>";
echo "Кому доступен список Ваших друзей?<br />";
echo "<label><input type = 'radio' name = 'access' value = 'all' " . ($user['friends_access'] == 'all' ? " checked = 'checked'" : NULL) . "/>" . img16('globe.png') . " Всем</label><br />";
echo "<label><input type = 'radio' name = 'access' value = 'only_me' " . ($user['friends_access'] == 'only_me' ? " checked='checked'" : NULL) . "/>" . img16('lock.png') . " Только мне</label> <br />";
echo "<label><input type='radio' name='access' value='friends' " . ($user['friends_access'] == 'friends' ? " checked='checked'" : NULL) . "/>" . img16('users.png') . " Только друзьям</label><br />";
echo "<label><input type='radio' name='access'  value='pass' " . ($user['friends_access'] == 'pass' ? " checked='checked'" : NULL) . " />" . img16('key.png') . " Только по паролю <br />";
echo "<input name = 'passwd' size = '16' maxlength = '16' type = 'text' value = '" . htmlspecialchars($user['friends_password']) . "' /></label><br />";
echo "<label><input type = 'checkbox'" . ($user['friendship'] ? " checked = 'checked'" : null) . " name = 'friendship' value = '1' />Запретить предлогать мне дружбу</label><br/>";
echo "<button name = 'submited' class = 'button sign-ins'>".  img16('save.png')." Сохранить";
echo "</button></form>";
echo "<a href = '/user/friends/'><div class = 'razd'>" . img16('left.png') . " Назад</div></a>";
require_once H . 'sys/inc/tfoot.php';