Файл: user/friends/access.php
Строк: 93
<?php
/* DCMS S (Special)
* Версия файла 0.0.1
* Дата последнего редактирования 22.11.2015
* Модифицировал densnet
*/
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 = 'list-group-item' action = '' method = 'post'>";
echo "<b>Кому доступен список Ваших друзей?</b><br />";
echo "<div class='radio'>";
echo "<label><input type='radio' name='access' value='all' " . ($user['friends_access'] == 'all' ? " checked='checked'" : NULL) . "/><span class='fa fa-globe fa-fw'></span> Всем</label><br />";
echo "<label><input type='radio' name='access' value='only_me' " . ($user['friends_access'] == 'only_me' ? " checked='checked'" : NULL) . "/><span class='fa fa-lock fa-fw'></span> Только мне</label> <br />";
echo "<label><input type='radio' name='access' value='friends' " . ($user['friends_access'] == 'friends' ? " checked='checked'" : NULL) . "/><span class='fa fa-users fa-fw'></span> Только друзьям</label><br />";
echo "<label><input type='radio' name='access' value='pass' " . ($user['friends_access'] == 'pass' ? " checked='checked'" : NULL) . " /><span class='fa fa-key fa-fw'></span> Только по паролю <br />";
echo "</div>";
echo "<input class='form-control' name='passwd' maxlength='16' type='text' value='" . htmlspecialchars($user['friends_password']) . "' /></label>";
echo "<label class='c-input c-checkbox'>";
echo "<input type='checkbox'" . ($user['friendship'] ? " checked='checked'" : null) . " name='friendship' value='1' /><span class='c-indicator'></span> Запретить предлогать мне дружбу<br/>";
echo "</label>";
echo "<button name='submited' class='btn btn-success'><span class='fa fa-save'></span> Сохранить</button>";
echo "</form>";
echo "<div class='list-group-item'><a href='/user/friends/'><span class='fa fa-arrow-left'></span> Назад</a></div>";
require_once H . 'sys/inc/tfoot.php';