Файл: user/notification.php
Строк: 229
<?php
/* DCMS S (Special)
* Версия файла 0.0.1
* Дата последнего редактирования 02.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();
err();
aut();
echo "<div style = 'font-size: 18px;font-weight: bold;' class = 'comm'>Уведомления</div>";
$razdel = (isset($_GET['act'])) ? htmlspecialchars($_GET['act']) : null;
switch ($razdel) {
case 'feed':
if (isset($_GET['delete']) && $_GET['delete'] == 'all') {
if (isset($user)) {
mysql_query("DELETE FROM `notifications` WHERE `id_kont` = '$user[id]'");
header("Location: ?");
exit;
}
}
if (isset($_GET['del'])) {
if (isset($_GET['del']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `notifications` WHERE `id` = '" . intval($_GET['del']) . "'"), 0) == 1) {
$post = mysql_fetch_assoc(mysql_query("SELECT * FROM `notifications` WHERE `id` = '" . intval($_GET['del']) . "' LIMIT 1"));
mysql_query("DELETE FROM `notifications` WHERE `id` = '$post[id]'");
}
}
if (isset($_GET['settings'])) {
$not_set = mysql_fetch_array(mysql_query("SELECT * FROM `notification_set` WHERE `id_user` = '" . $user['id'] . "' LIMIT 1"));
if (isset($_POST['save'])) {
if (isset($_POST['lenta_foto']) && ($_POST['lenta_foto'] == 0 || $_POST['lenta_foto'] == 1)) {
mysql_query("UPDATE `notification_set` SET `lenta_foto` = '" . intval($_POST['lenta_foto']) . "' WHERE `id_user` = '$user[id]'");
}
if (isset($_POST['lenta_avatar']) && ($_POST['lenta_avatar'] == 0 || $_POST['lenta_avatar'] == 1)) {
mysql_query("UPDATE `notification_set` SET `lenta_avatar` = '" . intval($_POST['lenta_avatar']) . "' WHERE `id_user` = '$user[id]'");
}
if (isset($_POST['lenta_friends']) && ($_POST['lenta_friends'] == 0 || $_POST['lenta_friends'] == 1)) {
mysql_query("UPDATE `notification_set` SET `lenta_friends` = '" . intval($_POST['lenta_friends']) . "' WHERE `id_user` = '$user[id]'");
}
if (isset($_POST['lenta_forum']) && ($_POST['lenta_forum'] == 0 || $_POST['lenta_forum'] == 1)) {
mysql_query("UPDATE `notification_set` SET `lenta_forum` = '" . intval($_POST['lenta_forum']) . "' WHERE `id_user` = '$user[id]'");
}
if (isset($_POST['lenta_news']) && ($_POST['lenta_news'] == 0 || $_POST['lenta_news'] == 1)) {
mysql_query("UPDATE `notification_set` SET `lenta_news` = '" . intval($_POST['lenta_news']) . "' WHERE `id_user` = '$user[id]'");
}
msg('Изменения успешно приняты');
header('Location: ?act=feed');
exit;
}
err();
aut();
echo "<form class = 'comm' action = '?' method = 'POST'>";
echo "Уведомления о новых друзьях<br />";
echo "<input name = 'lenta_friends' type = 'radio' " . ($not_set['lenta_friends'] == 1 ? ' checked = "checked"' : null) . " value = '1' /> Да ";
echo "<input name = 'lenta_friends' type = 'radio' " . ($not_set['lenta_friends'] == 0 ? ' checked = "checked"' : null) . " value = '0' /> Нет <br />";
echo "Уведомления о новых темах в форуме<br />";
echo "<input name = 'lenta_forum' type = 'radio' " . ($not_set['lenta_forum'] == 1 ? ' checked = "checked"' : null) . " value = '1' /> Да ";
echo "<input name = 'lenta_forum' type = 'radio' " . ($not_set['lenta_forum'] == 0 ? ' checked = "checked"' : null) . " value = '0' /> Нет <br />";
echo "Уведомления о новых фото<br />";
echo "<input name = 'lenta_foto' type = 'radio' " . ($not_set['lenta_foto'] == 1 ? ' checked = "checked"' : null) . " value = '1' /> Да ";
echo "<input name = 'lenta_foto' type = 'radio' " . ($not_set['lenta_foto'] == 0 ? ' checked = "checked"' : null) . " value = '0' /> Нет <br />";
echo "Уведомления о смене аватаров<br />";
echo "<input name = 'lenta_avatar' type = 'radio' " . ($not_set['lenta_avatar'] == 1 ? ' checked = "checked"' : null) . " value = '1' /> Да ";
echo "<input name = 'lenta_avatar' type = 'radio' " . ($not_set['lenta_avatar'] == 0 ? ' checked = "checked"' : null) . " value = '0' /> Нет <br />";
echo "<button class = 'button-green' name = 'save'>Сохранить</button>";
echo "</form>";
echo "<div class = 'comm'><a href = '?act=feed' style = 'color:#88C057;'><img src = '/style/icons/left.png' /> Вернуться</a></div>";
require_once H . 'sys/inc/tfoot.php';
exit();
}
mysql_query("UPDATE `notifications` SET `read` = '1' WHERE `id_kont` = '$user[id]' AND `read` = '0'");
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `notifications` WHERE `id_kont` = '$user[id]' "), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
$q = mysql_query("SELECT * FROM `notifications` WHERE `id_kont` = '$user[id]' ORDER BY `id` DESC LIMIT $start, $set[p_str]");
echo '<div class="busi_switcher"><table><tr><td style = "width: 50%;">';
echo "<a href = '?' class = 'brd'>Ответы</a>";
echo '</td><td style = "width: 50%;">';
echo "<a href = '?act=feed' class = 'active brd'>Новости</a>";
echo '</td></tr></table></div>';
if ($k_post == 0) {
echo "<div class = 'errs'>";
echo "<img src = '/style/icons/error.png' /> Нет результатов";
echo "</div>";
}
while ($post = mysql_fetch_assoc($q)) {
$ank = user::get_user($post['id_user']);
if ($post['read'] == 0) {
mysql_query("UPDATE `notification_set` SET `read` = '1' WHERE `id` = '$post[id]'");
}
echo "<table class = 'razd'><tr><td class = 'icon14'>";
avatar($ank['id'], '40');
echo "</td><td class = 'null'>";
echo "<div style = 'float:right;'><font color = 'grey'><small>" . date::time($post['time']) . "</small></font></div>";
user($ank['id']);
echo "<br />";
echo "<div style = 'float:right;' id = 'hide'>";
echo "<a href = 'notification_set.php?id=$ank[id]' title = 'Настроить'><img src = '/style/icons/set.png' /></a>";
echo "<a href = '?del=$post[id]' title = 'Удалить'><img src = '/style/icons/del.png' /></a>";
echo "</div>";
echo text::toOutput($post['msg']);
echo "</td></tr></table>";
}
if ($k_page > 1) {
str("?id=$user[id]&", $k_page, $page);
}
if ($k_post == 0) {
echo "<div class = 'razd'>";
echo "<a href = '?settings'><img src = '/style/icons/setting.png' /> Настройки</a>";
echo "</div>";
} else {
echo "<div class = 'razd'>";
echo "<a href = '?settings'><img src = '/style/icons/setting.png' /> Настройки</a>";
echo "<a href = '?page=$page&delete=all'><img src = '/style/icons/left.png' /> Очистить журнал</a>";
echo "</div>";
}
break;
default:
if (isset($_GET['delete']) && $_GET['delete'] == 'all') {
if (isset($user)) {
mysql_query("DELETE FROM `notification` WHERE `id_kont` = '$user[id]'");
header("Location: ?");
exit;
}
}
if (isset($_GET['del'])) {
if (isset($_GET['del']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `notification` WHERE `id` = '" . intval($_GET['del']) . "'"), 0) == 1) {
$post = mysql_fetch_assoc(mysql_query("SELECT * FROM `notification` WHERE `id` = '" . intval($_GET['del']) . "' LIMIT 1"));
mysql_query("DELETE FROM `notification` WHERE `id` = '$post[id]'");
}
}
mysql_query("UPDATE `notification` SET `read` = '1' WHERE `id_kont` = '$user[id]' AND `read` = '0'");
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `notification` WHERE `id_kont` = '$user[id]' "), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
$q = mysql_query("SELECT * FROM `notification` WHERE `id_kont` = '$user[id]' ORDER BY `id` DESC LIMIT $start, $set[p_str]");
echo '<div class="busi_switcher"><table><tr><td style = "width: 50%;">';
echo "<a href = '?' class = 'active brd'>Ответы</a>";
echo '</td><td style = "width: 50%;">';
echo "<a href = '?act=feed' class = 'brd'>Новости</a>";
echo '</td></tr></table></div>';
if ($k_post == 0) {
echo "<div class = 'errs'>";
echo "<img src = '/style/icons/error.png' /> Нет результатов";
echo "</div>";
}
while ($post = mysql_fetch_assoc($q)) {
$ank = user::get_user($post['id_user']);
echo "<table class = 'comm'><tr><td class = 'icon14'>";
avatar($ank['id'], '40');
echo "</td><td class = 'null'>";
echo "<div style = 'float:right;'><font color = 'grey'><small>" . date::times($post['time']) . "</small></font></div>";
user($ank['id']);
echo "<br />";
echo "<div style = 'float:right;' id = 'hide'>";
echo "<a href = '?del=$post[id]' title = 'Удалить'><img src = '/style/icons/del.png' /></a>";
echo "</div>";
echo text::toOutput($post['msg']);
echo "</td></tr></table>";
}
if ($k_page > 1) {
str("?id=$user[id]&", $k_page, $page);
}
if ($k_post == 0) {
} else {
echo "<div class = 'comm'>";
echo "<a href = '?page=$page&delete=all'>Очистить журнал</a>";
echo "</div>";
}
break;
}
require_once H . 'sys/inc/tfoot.php';