Файл: news/index.php
Строк: 165
<?php
/*
* Новости
* DCMS Special
* Модифицировал densnet
* Файл index.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';
$set['title'] = 'Новости';
require_once '../sys/inc/thead.php';
aut();
if (isset($_GET['edit'])) {
require_once '../news/edit.php';
} elseif (isset($_GET['delete'])) {
require_once '../news/delete.php';
} elseif (isset($_GET['edit_komm'])) {
require_once '../news/edit_komm.php';
} elseif (isset($_GET['news'])) {
require_once '../news/news.php';
} elseif (isset($_GET['new_komm'])) {
require_once '../news/komm.php';
} elseif (isset($_GET['add'])) {
require_once '../news/add.php';
} else {
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `news`"), 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 `news` ORDER BY `id` DESC LIMIT $start, $set[p_str]");
echo "<div class = 'blok'>Список новостей</div>";
#Список новостей
if ($k_post == 0) {
echo "<div class = 'razd'>";
echo "<img src = '/style/img/error.png' /> Нет результатов";
echo "</div>";
}
while ($post = mysql_fetch_assoc($q)) {
$like = mysql_result(mysql_query("SELECT COUNT(*) FROM `news_like` WHERE `id_news` = '" . $post['id'] . "'"), 0);
$komm = "" . mysql_result(mysql_query("SELECT COUNT(*) FROM `news_komm` WHERE `id_news` = '$post[id]'"), 0) . "";
echo "<table class = 'razd'><tr><td class = 'null'>";
echo "<img src = '/style/img/feed.png' /> <a href = '?news=$post[id]'><b>" . htmlspecialchars($post['title']) . "</b></a> <br />";
echo "" . text::for_opis($post['msg']) . "<br />";
echo "<span class = 'tiptip'>";
echo "<a class = 'button left' title = 'Автор новости'><span class = 'icon icon191' /><span class = 'label'>$post[avtor]</span></a>";
echo "<a class = 'button right' title = 'Время создания новости'><span class = 'label'>" . vremja($post['time']) . "</span></a><br />";
echo "<a class = 'button left' title = 'Просмотров $post[prosm]'><span class = 'icon icon84' /><span class = 'label'>$post[prosm]</span></a>";
if ($post['close'] == 1) {
echo "<a href = '/news/?news=$post[id]' class = 'button middle_red' title = 'Комментариев $komm. Комментировать запрещено'><span class = 'icon icon145' /><span class = 'label'>$komm</span></a>";
} else {
echo "<a href = '/news/?news=$post[id]' class = 'button middle' title = 'Комментариев $komm'><span class = 'icon icon145' /><span class = 'label'>$komm</span></a>";
}
if ($post['link'] != NULL) {
echo "<a href = '" . htmlentities($post['link'], ENT_QUOTES, 'UTF-8') . "' class = 'button middle' title = 'Перейти, чтобы узнать подробности'><span class = 'icon icon119' /><span class = 'label'>Ссылка</span></a>";
}
if (isset($user)) {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `news_like` WHERE `id_news` = '$post[id]' AND `id_user` = '$user[id]' LIMIT 1"), 0) == 0) {
echo "<a href = '/news/?news=$post[id]&likess' class = 'button middle' title = 'Мне нравится'><span class = 'icon icon101' /></a>";
} else {
echo "<a href = '/news/?news=$post[id]&unlikess' class = 'button middle on' title = 'Не нравится'><span class = 'icon icon100' /></a>";
}
echo "<a href = '?news=$post[id]&like_all' class = 'button right' title = 'Список тех, кому понравилась новость'><span class = 'label'>$like</span></a>";
} else {
echo "<a class = 'button middle' title = 'Понравилось $like людям'><span class = 'icon icon101' /><span class = 'label'>$like</span></a>";
}
echo "</span>";
if (user_access('adm_news_edit') && user_access('adm_news_delete')) {
echo "<br /><div class = 'dropdown'>";
echo "<a href = '#' class = 'button'><span class = 'icon icon96' /><span class = 'label'>Опции</span><span class = 'toggle'></span></a>";
echo "<div class = 'dropdown-slider'>";
if (user_access('adm_news_edit')) {
echo "<a href = '?edit=$post[id]' class = 'ddm'><span class = 'icon icon145' /><span class = 'label'>Изменить</span></a>";
}
if (user_access('adm_news_delete')) {
echo "<a href = '?delete=$post[id]' class = 'ddm negative'><span class = 'icon icon58' /><span class = 'label'>Удалить</span></a>";
}
echo "</div></div>";
}
echo "</td></tr></table>";
}
echo "<div class = 'razd'>";
if (isset($user)) {
echo "<a href = '/news/rss.php' class = 'button left'><span class = 'icon icon140' />RSS</a>";
}else{
echo "<a href = '/news/rss.php' class = 'button'><span class = 'icon icon140' />RSS</a>";
}
if (isset($user)) {
if (user_access('adm_news_add')) {
$color_add = "<font color = 'green'>Добавить новость</font>";
} else {
$color_add = "<font color = 'red'>Добавить новость</font>";
}
echo "<a href = '/news/add.php' class = 'button rights'>$color_add</a>";
}
echo "</div>";
if ($k_page > 1) {
str('index.php?', $k_page, $page);
}
}
require_once '../sys/inc/tfoot.php';