Файл: news/index.php
Строк: 93
<?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 = 'menu_razd'>Список новостей</div>";
#Список новостей
if ($k_post == 0) {
echo "<table class = 'foot'><tr><td class = 'null'>";
echo "<img src = '/style/icons/bullet_error.png' /> Нет новостей";
echo "</td></tr></table>";
}
while ($post = mysql_fetch_assoc($q)) {
$like = mysql_result(mysql_query("SELECT COUNT(*) FROM `news_like` WHERE `id_news` = '" . $post['id'] . "'"), 0);
$kum = @mysql_result(mysql_query("SELECT id_user FROM `news_like` WHERE `id_news` = '$post[id]'"), 0);
$kom = @mysql_result(mysql_query("SELECT nick FROM `user` WHERE `id` = '$kum' LIMIT 1"), 0);
$kem = $like - 1;
echo "<table class = 'foot'><tr><td class = 'null'>";
echo "<img src = '/style/icons/feed.png' /> <a href = '?news=$post[id]'>" . htmlspecialchars($post['title']) . "</a> ";
echo "(<small>$post[avtor] " . vremja($post['time']) . "</small>) <br/>";
echo "" . text::for_opis_mini($post['msg']) . "<br/>";
echo "<img src = '/style/icons/eye1.png' /> $post[prosm] ";
echo "<img src = '/style/icons/comment_white.png' /> " . mysql_result(mysql_query("SELECT COUNT(*) FROM `news_komm` WHERE `id_news` = '$post[id]'"), 0) . " ";
echo "<img src = '/style/icons/thumb_up.png' /> <a href = '?news=$post[id]&like_all'>$like</a><br/>";
if ($post['link'] != NULL) {
echo "<a href = '" . htmlentities($post['link'], ENT_QUOTES, 'UTF-8') . "'><small>Подробности</small></a>";
if (user_access('adm_news_edit') && user_access('adm_news_delete')) {
echo " <small>::</small> ";
}
}
if (user_access('adm_news_edit')) {
echo "<a href = '?edit=$post[id]'><small>Редактировать</small></a>";
}
if (user_access('adm_news_edit') && user_access('adm_news_delete')) {
echo " <small>::</small> ";
}
if (user_access('adm_news_delete')) {
echo "<a href = '?delete=$post[id]'><small>Удалить</small></a>";
}
if ($like == 1) {
echo "<div>";
echo "Новость понравилась <a href='/info.php?id=$kum'>$kom</a>";
echo "</div>";
} elseif ($like == 2) {
echo "<div>";
echo "Новость понравилась <a href = '/info.php?id=$kum'>$kom</a> и <a href = '/news/?news=$post[id]&like_all'> ещё $kem пользователю.</a>";
echo "</div>";
} elseif ($like >= 3) {
echo "<div>";
echo "Новость понравилась <a href = '/info.php?id=$kum'>$kom</a> и <a href = '/news/?news=$post[id]&like_all'> ещё $kem пользователям.</a>";
echo "</div>";
}
echo "</td></tr></table>";
}
echo "<a href = '/news/rss.php'><div class = 'foot'><img src = '/style/icons/rss.png' /> RSS</div></a>";
if (user_access('adm_news_add')) {
echo "<a href = '/news/add.php'><div class = 'foot'><img src = '/style/icons/feed--plus.png' /> Добавить новость</div></a>";
}
if ($k_page > 1) {
str('index.php?', $k_page, $page);
}
}
require_once '../sys/inc/tfoot.php';