Файл: user/notification.php
Строк: 228
<?php
/* Мод "Уведомления"
* Версия v0.0.1
* Дата последнего редактирования 31.01.2015
* Двиг DCMS Special
* Модифицировал densnet
* Файл notification.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';
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 = 'razd'>" . img24('not.png') . " Уведомления</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 = 'razd' 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 = 'active' name = 'save'>";
echo "<img src = '/style/icons/save.png' /> Сохранить изменения";
echo "</button></form>";
echo "<a href = '?act=feed'><div class = 'razd'>" . img16('left.png') . " Вернуться</div></a>";
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 = 'razd'>";
echo "<a href = '?' class = 'noactiv'>Ответы</a>";
echo "<a href = '?act=feed' class = 'activ'>Новости</a>";
echo "</div>";
if ($k_post == 0) {
echo "<div class = 'errs'>";
echo img16('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;'><small>" . date::time($post['time']) . "</small></div>";
user($ank['id']);
echo "<br />";
echo "<div style = 'float:right;' id = 'hide'>";
echo "<a href = 'notification_set.php?id=$ank[id]' title = 'Настроить'>" . img16('set.png') . "</a>";
echo "<a href = '?del=$post[id]' title = 'Удалить'>" . img16('musor.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 class = 'add' href = '?settings'> " . img16('set.png') . " Настройки</a>";
echo "</div>";
} else {
echo "<div class = 'razd'>";
echo "<a class = 'add' href = '?settings'>" . img16('set.png') . " Настройки</a>";
echo "<a class = 'add' href = '?page=$page&delete=all'>" . img16('musor.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 = 'razd'>";
echo "<a href = '?' class = 'activ'>Ответы</a>";
echo "<a href = '?act=feed' class = 'noactiv'>Новости</a>";
echo "</div>";
if ($k_post == 0) {
echo "<div class = 'errs'>";
echo img16('error.png') . " Нет результатов";
echo "</div>";
}
while ($post = mysql_fetch_assoc($q)) {
$ank = user::get_user($post['id_user']);
echo "<table class = 'razd'><tr><td class = 'icon14'>";
avatar($ank['id'], '40');
echo "</td><td class = 'null'>";
echo "<div style = 'float:right;'><small>" . date::time($post['time']) . "</small></div>";
user($ank['id']);
echo "<br />";
echo "<div style = 'float:right;' id = 'hide'>";
#echo "<a href = 'user_settings.php?id=$ank[id]' title = 'Настроить'>" . img16('set.png') . "</a>";
echo "<a href = '?del=$post[id]' title = 'Удалить'>" . img16('musor.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 class = 'add' href = '?settings'> ".img16('set.png')." Настройки</a>";
//echo "</div>";
} else {
echo "<div class = 'razd'>";
//echo "<a class = 'add' href = '?settings'>".img16('set.png')." Настройки</a><br/>";
echo "<a class = 'add' href = '?page=$page&delete=all'>" . img16('musor.png') . " Очистить журнал</a>";
echo "</div>";
}
break;
}
require_once H . 'sys/inc/tfoot.php';