Файл: user/private/index.php
Строк: 77
<?php
/* Мод "Приватность"
 * Версия v0.0.1
 * Дата последнего редактирования 20.01.2015
 * Двиг DCMS Special
 * Модифицировал densnet
 * Файл index.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';
require_once H . 'sys/inc/thead.php';
user::only_reg();
$set['title'] = 'Приватность';
title();
aut();
err();
if (isset($user)) {
    echo "<table class = 'title'><tr><td>";
    echo "<center>";
    echo "<a class = 'act2 rl' href = '/info.php' title = 'Страница пользователя'>" . img24('001.png') . "</a>";
    echo "</center>";
    echo "</td><td>";
    echo "<center>";
    echo "<a class = 'act rl' title = 'Приватность страницы'>" . img24('lock.png') . "</a>";
    echo "</center>";
    echo "</td><td>";
    echo "<center>";
    echo "<a class = 'act2' href = '/user/hello.php' title = 'Приветствие страницы'>" . img24('status.png') . "</a>";
    echo "</center>";
    echo "</td></tr></table>";
}
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 `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 "<b>Кому доступен мой профиль?</b><br/>";
    echo "<label><input type = 'radio' name = 'access' value = 'all' " . ($user['profile_access'] == 'all' ? " checked = 'checked'" : NULL) . "/>" . img16('globe.png') . " Всем</label><br />";
    echo "<label><input type = 'radio' name = 'access' value = 'only_me' " . ($user['profile_access'] == 'only_me' ? " checked='checked'" : NULL) . "/>" . img16('lock.png') . " Только мне</label> <br />";
    echo "<label><input type='radio' name='access' value='friends' " . ($user['profile_access'] == 'friends' ? " checked='checked'" : NULL) . "/>" . img16('users.png') . " Только друзьям</label><br />";
    echo "<label><input type='radio' name='access'  value='pass' " . ($user['profile_access'] == 'pass' ? " checked='checked'" : NULL) . " />" . img16('key.png') . " Только по паролю <br />";
    echo "<div class = 'inputs'>";
    echo "<input name = 'passwd' size = '16' maxlength = '16' type = 'text' value = '" . htmlspecialchars($user['profile_password']) . "' />";
    echo "<div class = 'input-icon'>" . img16('key.png') . "</div>";
    echo "</div></label>";
    echo "<button name = 'submited' class = 'button sign-ins'>" . img16('save.png') . " Сохранить";
    echo "</button></form>";
}
require_once H . 'sys/inc/tfoot.php';