Файл: user/notification.php
Строк: 247
<?php
/* Мод "Уведомления"
* Версия v0.0.1
* Дата последнего редактирования 22.11.2014
* Двиг DCMS Special
* Модифицировал densnet
* Файл notification.php
* Описание: выводит уведомления пользователя
*/
require_once '../sys/inc/start.php';
require_once '../sys/inc/compress.php';
require_once '../sys/inc/sess.php';
require_once '../sys/inc/settings.php';
require_once '../sys/inc/db_connect.php';
require_once '../sys/inc/ipua.php';
require_once '../sys/inc/fnc.php';
require_once '../sys/inc/user.php';
user::only_reg();
$set['title'] = 'Уведомления';
require_once '../sys/inc/thead.php';
title();
err();
aut();
#Навигация
echo "<div class = 'navigation'><a href = '/index.php'>Главная</a> > <a href = '/info.php'>Профиль</a> > <a href = 'notification.php'><b>Уведомления</b></a></div>";
echo "<div style = 'font-size: 18px;font-weight: bold;' class = 'razdel'>" . img('books.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'>".img('left.png')." Вернуться</div></a>";
require_once '../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 = 'tabs t_bar clear_fix'>";
echo "<a href = '?'>Ответы</a>";
echo "<a href = '?act=feed' class = 'active'>Новости</a>";
echo "</div>";
if ($k_post == 0) {
echo "<div class = 'errs'>";
echo img('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('set_mini.png') . "</a>";
echo "<a href = '?del=$post[id]' title = 'Удалить'>" . img('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 class = 'count' href = '?settings'> " . img('set_mini.png') . " Настройки</a>";
echo "</div>";
} else {
echo "<div class = 'razd'>";
echo "<a class = 'count' href = '?settings'>" . img('set_mini.png') . " Настройки</a>";
echo "<a class = 'count' href = '?page=$page&delete=all'>" . img('del.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 = 'tabs t_bar clear_fix'>";
echo "<a href = '?' class = 'active'>Ответы</a>";
echo "<a href = '?act=feed'>Новости</a>";
echo "</div>";
if ($k_post == 0) {
echo "<div class = 'errs'>";
echo img('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;'><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 = 'user_settings.php?id=$ank[id]' title = 'Настроить'>" . img('set_mini.png') . "</a>";
echo "<a href = '?del=$post[id]' title = 'Удалить'>" . img('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 class = 'count' href = '?settings'> ".img('set_mini.png')." Настройки</a>";
//echo "</div>";
} else {
echo "<div class = 'razd'>";
//echo "<a class = 'count' href = '?settings'>".img('set_mini.png')." Настройки</a><br/>";
echo "<a class = 'count' href = '?page=$page&delete=all'>" . img('del.png') . " Очистить журнал</a>";
echo "</div>";
}
break;
}
require_once '../sys/inc/tfoot.php';