Файл: modules/forum/journal.php
Строк: 148
<?php
/* DCMS Special
* Дата последнего редактирования 16.12.2015
* Модифицировал densnet
*/
foreach (array('start', 'compress', 'sess', 'settings', 'db_connect', 'ipua', 'fnc', 'user') as $inc) {
require_once "../../sys/inc/{$inc}.php";
}
$set['title'] = lang('Журнал форума');
require_once H . 'sys/inc/thead.php';
aut() . only_reg();
if (!isset($_GET['all']) && !isset($_GET['new'])) {
header('Location: journal.php?new');
exit;
}
define('DIR_FORUM', '/modules/forum/');
$isset = (isset($_GET['type'])) ? '?type=' . mysql_real_escape_string($_GET['type']) . '&' : '?';
$type = (isset($_GET['all'])) ? 'all' : 'new';
$read = (isset($_GET['all'])) ? NULL : 'AND `read` = "0"';
$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);
$new_ev = mysql_result(mysql_query("SELECT COUNT(*) FROM `events` 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;
}
if ($new_ev > 0) {
$new_ev = '+' . mysql_result(mysql_query("SELECT COUNT(*) FROM `events` WHERE `id_kont` = '$user[id]' AND `read` = '0'"), 0);
} else {
$new_ev = null;
}
#Навигация
echo "<div class='list-group-item-null list-group-item-grey'><small>";
echo "<a href='/' class='hint--right' data-hint='" . lang('На главную') . "'><i class='fa fa-home fa-lg'></i></a> <i class='fa fa-angle-right fa-fw'></i> ";
echo "<a href='" . DIR_FORUM . "'>" . lang('Форум') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
echo lang('Уведомления');
echo "</small></div><br />";
echo "<div class='list-group-item-null list-group-item-grey'>";
echo "<ul class='nav nav-tabs' style='margin-bottom: -11px;'>";
echo "<li class='nav-item'><a class='nav-link' href='/user/notification/'>" . lang('Ответы') . " $new_n</a></li>";
echo "<li class='nav-item'><a class='nav-link' href='/user/notification/index.php?act=feed'>" . lang('Новости') . " $new_ns</a></li>";
echo "<li class='nav-item'><a class='nav-link active'>" . lang('Форум') . " $new_j</a></li>";
echo "<li class='nav-item'><a class='nav-link' href='/user/notification/index.php?act=events'>" . lang('События') . " $new_ev</a></li>";
echo "</ul>";
echo '</div>';
echo '<div class="list-group-item-null">';
if (isset($_GET['all'])) {
echo "<ul class='nav nav-pills'>";
echo "<li class='nav-item'><a class='nav-link active' href='journal.php{$isset}all'>" . lang('Все') . "</a></li>";
echo "<li class='nav-item'><a class='nav-link' href='journal.php{$isset}new'>" . lang('Новые') . "</a></li>";
echo "</ul>";
}
if (isset($_GET['new'])) {
echo "<ul class='nav nav-pills'>";
echo "<li class='nav-item'><a class='nav-link' href='journal.php{$isset}all'>" . lang('Все') . "</a></li>";
echo "<li class='nav-item'><a class='nav-link active' href='journal.php{$isset}new'>" . lang('Новые') . "</a></li>";
echo "</ul>";
}
echo '</div>';
$type_j = (isset($_GET['type'])) ? '`type` = "' . mysql_real_escape_string($_GET['type']) . '" AND' : NULL;
$k_post = mysql_result(mysql_query('SELECT COUNT(*) FROM `f_journal` WHERE ' . $type_j . ' `id_user` = ' . $user['id'] . ' ' . $read), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
if ($k_post == 0) {
$doc->NoResult();
} else {
$js = mysql_query('SELECT * FROM `f_journal` WHERE ' . $type_j . ' `id_user` = ' . $user['id'] . ' ' . $read . ' ORDER BY `id` DESC LIMIT ' . $start . ', ' . $set['p_str']);
while ($j = mysql_fetch_object($js)) {
echo "<div class='list-group-item-null'>";
echo toOutput($j->text) . "<br />";
echo date::times($j->time);
echo "</div>";
echo "<div class='hr'></div>";
}
if ($k_page > 1) {
str('journal.php' . $isset . $type, $k_page, $page);
}
if (isset($_GET['new'])) {
mysql_query('UPDATE `f_journal` SET `read` = "1" WHERE `id_user` = ' . $user['id']);
}
}
require_once H . 'sys/inc/tfoot.php';