Файл: sys/inc/news_main.php
Строк: 104
<?php
$q = mysql_query("SELECT * FROM `news` WHERE `main_time` > '" . TIME . "' ORDER BY `id` DESC LIMIT 1");
if (mysql_num_rows($q) == 1) {
$news = mysql_fetch_assoc($q);
$hide = mysql_result(mysql_query("SELECT COUNT(*) FROM `news_hide` WHERE `nid` = '$news[id]' AND uid = '{$user['id']}'"), 0);
$like = mysql_result(mysql_query("SELECT COUNT(*) FROM `news_like` WHERE `id_news` = '$news[id]'"), 0);
$kum = @mysql_result(mysql_query("SELECT id_user FROM `news_like` WHERE `id_news` = '$news[id]'"), 0);
$kom = @mysql_result(mysql_query("SELECT nick FROM `user` WHERE `id` = '$kum' LIMIT 1"), 0);
$kem = $like - 1;
if ($hide == 0) {
echo "<div class = 'foot'>";
echo "<img src = '/style/icons/feed.png' /> <a href = '/news/'>$news[title]</a> - <small>$news[avtor]</small>";
echo "</div><div class = 'foot'>";
if (isset($user)) {
echo "<div class = 'right' id = 'hide'>";
echo "<a href = '/news/?news=$news[id]&hide' title = 'Отметить как прочитанное'><img src = '/style/icons/hide.png' /></a>";
echo "</div>";
}
echo "" . text::for_opis($news['msg']) . "";
echo "</div><div class = 'foot'>";
echo "<img src = '/style/icons/time_mini.png' /> <font color = '#808080'><small>" . vremja($news['time']) . "</small></font><br/>";
if ($news['link'] != NULL) {
echo "<img src = '/style/icons/url_mini.png' /> <a href = '" . htmlentities($news['link'], ENT_QUOTES, 'UTF-8') . "'><small>Подробности</small></a><br/>";
}
if (isset($user)) {
echo "<img src = '/style/icons/comment_white_mini.png' /> <a href = '/news/?news=$news[id]'><small>Комментарии</small></a> <small>" . mysql_result(mysql_query("SELECT COUNT(*) FROM `news_komm` WHERE `id_news` = '$news[id]'"), 0) . "</small><br/>";
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `news_like` WHERE `id_news` = '$news[id]' AND `id_user` = '$user[id]' LIMIT 1"), 0) == 0) {
if ($like == 0) {
echo "<img src = '/style/icons/like.png' /> <a href = '/news/?news=$news[id]&likes'><small>Мне нравится</small> </a><br/>";
} else {
echo "<img src = '/style/icons/like.png' /> <a href = '/news/?news=$news[id]&likes'><small>Мне нравится</small> </a>";
echo "<img src = '/style/icons/thumb_up_mini.png' /> <a href = '/news/?news=$news[id]&like_all'><small>$like</small></a><br/>";
}
} else {
if ($like == 0) {
echo "<img src = '/style/icons/thumb_up_mini.png' /> <a href = '/news/?news=$news[id]&unlikes'><small>Не нравится</small> </a><br/>";
} else {
echo "<img src = '/style/icons/like.png' /> <a href = '/news/?news=$news[id]&unlikes'><small>Не нравится</small> </a>";
echo "<img src = '/style/icons/thumb_up_mini.png' /> <a href = '/news/?news=$news[id]&like_all'><small>$like</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=$news[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=$news[id]&like_all'> ещё $kem пользователям.</a>";
echo "</div>";
}
} else {
echo "<img src = '/style/icons/comment_white_mini.png' /> <a href = '/news/?news=$news[id]'><small>Комментарии</small></a>";
}
echo "</div>";
}
}