Файл: user/friends/access.php
Строк: 123
<?php
/* DCMS Special
* Дата последнего редактирования 15.12.2015
* Модифицировал densnet
*/
foreach (array('start', 'compress', 'sess', 'settings', 'db_connect', 'ipua', 'fnc', 'user') as $inc) {
require_once "../../sys/inc/{$inc}.php";
}
only_reg();
$set['title'] = "Настройки";
require_once H . 'sys/inc/thead.php';
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 (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 "<nav class='navbar navbar-light' style='background-color: #607D8B; color: #fff;'>";
echo "<ul class='nav navbar-nav'>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/'><i class='material-icons'>home</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/info.php?id=$user[id]'>$user[nick]</a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/user/friends/index.php?id=$user[id]'>Друзья</a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'>Настройки</a></li>";
echo "</ul>";
echo "</nav>";
echo "<form class = 'list-group-item' action = '' method = 'post'>";
echo "<b>Кому доступен список Ваших друзей?</b><br />";
echo "<input class='with-gap' name='access' type='radio' " . ($user['friends_access'] == 'all' ? " checked='checked'" : null) . " id='all' value='all' /><label for='all'><i class='material-icons'>public</i> Всем</label><br />";
echo "<input class='with-gap' name='access' type='radio' " . ($user['friends_access'] == 'only_me' ? " checked='checked'" : null) . " id='only_me' value='only_me' /><label for='only_me'><i class='material-icons'>lock</i> Только мне</label><br />";
echo "<input class='with-gap' name='access' type='radio' " . ($user['friends_access'] == 'friends' ? " checked='checked'" : null) . " id='friends' value='friends' /><label for='friends'><i class='material-icons'>group</i> Только друзьям</label><br />";
echo "<input class='with-gap' name='access' type='radio' " . ($user['friends_access'] == 'pass' ? " checked='checked'" : null) . " id='pass' value='pass' /><label for='pass'><i class='material-icons'>vpn_key</i> Только по паролю</label><br />";
echo "<div class='row'>";
echo "<div class='input-field col s12'>";
echo "<input id='password' name='passwd' length='16' type='text' value='" . htmlspecialchars($user['friends_password']) . "' class='validate'>";
echo "<label for='password'>Пароль</label>";
echo "</div>";
echo "</div>";
echo "<div class='switch'>";
echo "<label><input type='checkbox' " . ($user['friendship'] ? " checked='checked'" : null) . " name='friendship' value='1'><span class='lever'></span>Запретить предлогать мне дружбу</label>";
echo "</div><br />";
echo "<button name='submited' class='waves-effect waves-light btn'><i class='material-icons'>save</i> Сохранить</button>";
echo "</form>";
require_once H . 'sys/inc/tfoot.php';