Файл: user/notification/index.php
Строк: 246
<?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();
#Навигация
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'>Уведомления</a></li>";
echo "</ul>";
echo "</nav>";
echo "<div class='card'>";
echo "<div class='card-header'>Уведомления</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: ?act=feed");
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]'");
}
}
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]");
$new_j = mysql_result(mysql_query('SELECT COUNT(*) FROM `f_journal` WHERE `read` = "0" AND `id_user` = ' . $user['id']), 0) . "";
$new_n = mysql_result(mysql_query("SELECT COUNT(*) FROM `notification` WHERE `id_kont` = '$user[id]' AND `read` = '0'"), 0);
$new_ns = mysql_result(mysql_query("SELECT COUNT(*) FROM `notifications` WHERE `id_kont` = '$user[id]' AND `read` = '0'"), 0);
if ($new_j > 0) {
$new_j = '+' . mysql_result(mysql_query('SELECT COUNT(*) FROM `f_journal` WHERE `read` = "0" AND `id_user` = ' . $user['id']), 0);
} else {
$new_j = null;
}
if ($new_n > 0) {
$new_n = '+' . mysql_result(mysql_query("SELECT COUNT(*) FROM `notification` WHERE `id_kont` = '$user[id]' AND `read` = '0'"), 0);
} else {
$new_n = null;
}
if ($new_ns > 0) {
$new_ns = '+' . mysql_result(mysql_query("SELECT COUNT(*) FROM `notifications` WHERE `id_kont` = '$user[id]' AND `read` = '0'"), 0);
} else {
$new_ns = null;
}
echo "<div class='card-block'>";
echo "<ul class='nav nav-tabs'>";
echo "<li class='nav-item'><a class='nav-link' href='?'>Ответы $new_n</a></li>";
echo "<li class='nav-item'><a class='nav-link active'>Новости $new_ns</a></li>";
echo "<li class='nav-item'><a class='nav-link' href='/modules/forum/journal.php'>Форум $new_j</a></li>";
echo "</ul>";
echo '</div>';
if ($k_post == 0) {
echo "<div class='card-block'>";
echo "<i class='material-icons'>feedback</i> Нет результатов";
echo "</div>";
}
while ($post = mysql_fetch_assoc($q)) {
$ank = get_user($post['id_user']);
if ($post['read'] == 0) {
mysql_query("UPDATE `notification_set` SET `read` = '1' WHERE `id` = '$post[id]'");
}
echo "<table class='card-block' style='border-bottom: 1px solid #dcdee3;'><tr><td class = 'icon14'>";
avatar($ank['id'], '40', 'border-radius: 2px;');
echo "</td><td class='null'>";
echo "<div style='float:right;'><font color='grey'><small title='" . date::time($post['time']) . "'>" . date::timek($post['time']) . "</small></font></div>";
if ($ank['id'] == 0) {
echo "<i class='material-icons'>person</i> Система";
} else {
user($ank['id']);
}
echo "<br />";
echo "<span style='float:right;' id='hides'>";
echo "<a href='set_user.php?id=$ank[id]' title='Настроить'><i class='material-icons'>settings</i></a>";
echo "<a href='index.php?act=feed&del=$post[id]' title='Удалить'><i class='material-icons'>delete</i></a>";
echo "</span>";
if ($ank['id'] == 0) {
echo "<font color='grey'>Сообщение удалено...</font>";
} else {
echo "<font color='grey'>" . toOutput($post['msg']) . "</font>";
}
echo "</td></tr></table>";
}
if ($k_page > 1) {
str("?id=$user[id]&", $k_page, $page);
}
if ($k_post == 0) {
} else {
echo "<div class='card-block'>";
echo "<a href='?page=$page&delete=all'><i class='material-icons'>delete</i> Очистить журнал</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]");
$new_j = mysql_result(mysql_query('SELECT COUNT(*) FROM `f_journal` WHERE `read` = "0" AND `id_user` = ' . $user['id']), 0) . "";
$new_n = mysql_result(mysql_query("SELECT COUNT(*) FROM `notification` WHERE `id_kont` = '$user[id]' AND `read` = '0'"), 0);
$new_ns = mysql_result(mysql_query("SELECT COUNT(*) FROM `notifications` WHERE `id_kont` = '$user[id]' AND `read` = '0'"), 0);
if ($new_j > 0) {
$new_j = '+' . mysql_result(mysql_query('SELECT COUNT(*) FROM `f_journal` WHERE `read` = "0" AND `id_user` = ' . $user['id']), 0);
} else {
$new_j = null;
}
if ($new_n > 0) {
$new_n = '+' . mysql_result(mysql_query("SELECT COUNT(*) FROM `notification` WHERE `id_kont` = '$user[id]' AND `read` = '0'"), 0);
} else {
$new_n = null;
}
if ($new_ns > 0) {
$new_ns = '+' . mysql_result(mysql_query("SELECT COUNT(*) FROM `notifications` WHERE `id_kont` = '$user[id]' AND `read` = '0'"), 0);
} else {
$new_ns = null;
}
echo "<div class='card-block'>";
echo "<ul class='nav nav-tabs'>";
echo "<li class='nav-item'><a class='nav-link active'>Ответы $new_n</a></li>";
echo "<li class='nav-item'><a class='nav-link' href='?act=feed'>Новости $new_ns</a></li>";
echo "<li class='nav-item'><a class='nav-link' href='/modules/forum/journal.php'>Форум $new_j</a></li>";
echo "</ul>";
echo '</div>';
if ($k_post == 0) {
echo "<div class='card-block'>";
echo "<i class='fa fa-info-circle fa-fw'></i> Нет результатов";
echo "</div>";
}
while ($post = mysql_fetch_assoc($q)) {
$ank = get_user($post['id_user']);
echo "<table class='card-block' style='border-bottom: 1px solid #dcdee3;'><tr><td class = 'icon14'>";
avatar($ank['id'], '40', 'border-radius: 2px;');
echo "</td><td class='null'>";
echo "<div style='float:right;'><font color='grey'><small title='" . date::time($post['time']) . "'>" . date::timek($post['time']) . "</small></font></div>";
if ($ank['id'] == 0) {
echo "<i class='material-icons'>person</i> Система";
} else {
user($ank['id']);
}
echo "<br />";
#Кнопка удаления уведомления
echo "<span style='float:right;' id='hides'><a href='?del=$post[id]' title='Удалить'><i class='material-icons'>delete</i></a></span>";
if ($ank['id'] == 0) {
echo "<font color='grey'>Сообщение удалено...</font>";
} else {
echo "<font color='grey'>" . toOutput($post['msg']) . "</font>";
}
echo "</td></tr></table>";
}
if ($k_page > 1) {
echo "<div class='card-block'>";
str("?id=$user[id]&", $k_page, $page);
echo "</div>";
}
if ($k_post == 0) {
} else {
echo "<div class='card-block'>";
echo "<a href='?page=$page&delete=all'><i class='material-icons'>delete</i> Очистить журнал</a>";
echo "</div>";
}
break;
}
echo "</div>";
require_once H . 'sys/inc/tfoot.php';