Файл: user/private/index.php
Строк: 67
<?php
/* Мод "Приватность"
 * Версия v0.0.1
 * Дата последнего редактирования 21.11.2014
 * Двиг DCMS Special
 * Модифицировал densnet
 * Файл index.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';
require_once '../../sys/inc/thead.php';
only_reg();
$set['title'] = 'Приватность';
title();
aut();
err();
#Навигация
echo "<div class = 'razd'><a href = '/index.php'>Главная</a> > <a href = '/umenu.php'>Кабинет</a> > <a href = '?'><b>Приватность</b></a></div>";
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 `profile_access` = '$access', `profile_password` = '" . mysql_real_escape_string($password) . "' WHERE `id` = '$user[id]'");
        header("Location: /user/private/");
        exit();
    }
}
if (!isset($user)) {
    err('Доступ закрыт гостям');
} else {
    echo "<form class = 'razd' action = '' method = 'POST'>";
    echo "Кому доступен мой профиль?<br/>";
    echo "<label><input type = 'radio' name = 'access' value = 'all' " . ($user['profile_access'] == 'all' ? " checked = 'checked'" : NULL) . "/>" . img('globe-small.png') . "Всем</label><br />";
    echo "<label><input type = 'radio' name = 'access' value = 'only_me' " . ($user['profile_access'] == 'only_me' ? " checked='checked'" : NULL) . "/>" . img('lock-small.png') . "Только мне</label> <br />";
    echo "<label><input type='radio' name='access' value='friends' " . ($user['profile_access'] == 'friends' ? " checked='checked'" : NULL) . "/>" . img('user-small.png') . "Только друзьям</label><br />";
    echo "<label><input type='radio' name='access'  value='pass' " . ($user['profile_access'] == 'pass' ? " checked='checked'" : NULL) . " />" . img('bullet_key.png') . "Только по паролю <br />";
    echo "<input name = 'passwd' size = '16' maxlength = '16' type = 'text' value = '" . htmlspecialchars($user['profile_password']) . "' /></label><br />";
    echo "<button name = 'submited' class = 'action'>";
    echo "<span class = 'label'><span class = 'icon icon67' /> Сохранить</span>";
    echo "</button></form>";
}
require_once '../../sys/inc/tfoot.php';