Файл: user/settings/private.php
Строк: 145
<?php
/* DCMS S (Special)
* Версия файла 0.0.1
* Дата последнего редактирования 24.10.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';
require_once H . 'sys/inc/thead.php';
user::only_reg();
$set['title'] = 'Приватность';
title();
aut();
err();
echo '<div class="busi_switcher"><table><tr><td style = "width: 20%;">';
echo "<a href = '/user/settings.php' class = 'brd'>Общие</a>";
echo '</td><td style = "width: 20%;">';
echo "<a href = '/user/settings/them.php' class = 'brd'>Вид</a>";
echo '</td><td style = "width: 20%;">';
echo "<a href = '/user/settings/time.php' class = 'brd'>Время</a>";
echo '</td><td style = "width: 20%;">';
echo "<a class = 'active brd'>Приватность</a>";
echo '</td><td style = "width: 20%;">';
echo "<a href = '/user/settings/password.php' class = 'brd'>Пароль</a>";
echo '</td></tr></table></div>';
$act = (isset($_GET['act'])) ? htmlspecialchars($_GET['act']) : null;
switch ($act) {
default:
if (!isset($user)) {
err('Доступ закрыт гостям');
} else {
echo "<div class = 'comm'>";
echo "<a href = '?act=profile_access' style = 'color:#48A0DC;'><img src = '/style/icons/play.png' /> Приватность профиля</a><br />";
echo "</div>";
echo "<div class = 'comm'>";
echo "<a href = '?act=anketa_access' style = 'color:#48A0DC;'><img src = '/style/icons/play.png' /> Приватность анкеты</a><br />";
echo "</div>";
}
break;
case 'anketa_access':
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 `anketa_access` = '$access', `anketa_password` = '" . mysql_real_escape_string($password) . "' WHERE `id` = '$user[id]'");
msg('Изменения успешно приняты');
header("Refresh: 1; url=/user/settings/private.php");
echo "<div class = 'comm'><a href = '/user/settings/private.php' style = 'color: #88C057;'><img src = '/style/icons/left.png'/> Назад</a></div>";
require_once H . 'sys/inc/tfoot.php';
exit();
}
}
if (!isset($user)) {
err('Доступ закрыт гостям');
} else {
echo "<form class = 'comm' action = '' method = 'POST'>";
echo "<span style = 'float:right;'><img src = '/style/icons/Locked2.png' /></span>";
echo "<b>Кому доступна моя анкета?</b><br />";
echo "<label><input type = 'radio' name = 'access' value = 'all' " . ($user['anketa_access'] == 'all' ? " checked = 'checked'" : NULL) . "/><img src = '/style/icons/vol.png'/> Всем</label><br />";
echo "<input type = 'radio' name = 'access' value = 'only_me' " . ($user['anketa_access'] == 'only_me' ? " checked='checked'" : NULL) . "/><img src = '/style/icons/lock.png'/> Только мне <br />";
echo "<label><input type='radio' name='access' value='friends' " . ($user['anketa_access'] == 'friends' ? " checked='checked'" : NULL) . "/><img src = '/style/icons/users.png'/> Только друзьям</label><br />";
echo "<label><input type='radio' name='access' value='pass' " . ($user['anketa_access'] == 'pass' ? " checked='checked'" : NULL) . " /><img src = '/style/icons/key.png'/> Только по паролю <br />";
echo "<input name = 'passwd' size = '16' maxlength = '16' type = 'text' value = '" . htmlspecialchars($user['anketa_password']) . "' /></label><br /><br />";
echo "<button name = 'submited' class = 'button-green'>Сохранить</button>";
echo "</form>";
echo "<div class = 'comm'><a href = '/user/settings/private.php' style = 'color: #88C057;'><img src = '/style/icons/left.png'/> Назад</a></div>";
}
break;
case 'profile_access':
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]'");
msg('Изменения успешно приняты');
header("Refresh: 1; url=/user/settings/private.php");
echo "<div class = 'comm'><a href = '/user/settings/private.php' style = 'color: #88C057;'><img src = '/style/icons/left.png'/> Назад</a></div>";
require_once H . 'sys/inc/tfoot.php';
exit();
}
}
if (!isset($user)) {
err('Доступ закрыт гостям');
} else {
echo "<form class = 'comm' action = '' method = 'POST'>";
echo "<span style = 'float:right;'><img src = '/style/icons/Locked2.png' /></span>";
echo "<b>Кому доступен мой профиль?</b><br />";
echo "<label><input type = 'radio' name = 'access' value = 'all' " . ($user['profile_access'] == 'all' ? " checked = 'checked'" : NULL) . "/><img src = '/style/icons/vol.png'/> Всем</label><br />";
echo "<input type = 'radio' name = 'access' value = 'only_me' " . ($user['profile_access'] == 'only_me' ? " checked='checked'" : NULL) . "/><img src = '/style/icons/lock.png'/> Только мне <br />";
echo "<label><input type='radio' name='access' value='friends' " . ($user['profile_access'] == 'friends' ? " checked='checked'" : NULL) . "/><img src = '/style/icons/users.png'/> Только друзьям</label><br />";
echo "<label><input type='radio' name='access' value='pass' " . ($user['profile_access'] == 'pass' ? " checked='checked'" : NULL) . " /><img src = '/style/icons/key.png'/> Только по паролю <br />";
echo "<input name = 'passwd' size = '16' maxlength = '16' type = 'text' value = '" . htmlspecialchars($user['profile_password']) . "' /></label><br /><br />";
echo "<button name = 'submited' class = 'button-green'>Сохранить</button>";
echo "</form>";
echo "<div class = 'comm'><a href = '/user/settings/private.php' style = 'color: #88C057;'><img src = '/style/icons/left.png'/> Назад</a></div>";
}
break;
}
echo "<div class = 'comm'><a href = '/umenu.php' style = 'color: #88C057;'><img src = '/style/icons/left.png'/> Кабинет</a></div>";
require_once H . 'sys/inc/tfoot.php';