Размер файла: 2.06Kb
<?PHP
include '../System/core.php';
$config['title'] = 'Новости каталога';
include '../System/header.php';
if (file_exists(H.'Cache/news.cache') && $system['Cache_news'] == 1)
{
echo implode('', file (H.'Cache/news.cache'));
}
else
{
ob_start();
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `news`"),0); $sql_count++;
if ($count !== '0')
{
$pages = $system['page'];
$page = num($_GET['page']);
$total = intval(($count-1)/$pages) + 1;
if(empty($page) OR $page < 0)
{
$page = 1;
}
if($page > $total)
{
$page = $total;
}
$past = intval($count/$pages);
$start = $page*$pages-$pages;
$query = mysql_query("SELECT * FROM `news` ORDER BY `time` DESC LIMIT ".$start.",".$pages.""); $sql_count++;
while($news = mysql_fetch_array($query))
{
$count_comment = mysql_result(mysql_query("SELECT COUNT(*) FROM `news_comment` WHERE `id_news` = '".$news['id']."'"),0);
echo '<div class="text">';
echo '<b>'.$news['name'].'</b><br />';
echo text(bbcode($news['about'])).'<br />';
echo '<a href="/NewsKomment/'.$news['id'].'/">Комментарии</a> ('.$count_comment.')<br />';
echo '<small style="color: #008000;">Новость добавлена: '.data($news['time']).'</small>';
if (isset($user)){
echo '<br /><a href="/Panel/edit_news.php?id='.$news['id'].'">Редактировать</a> | <a href="/Panel/delete_news.php?id='.$news['id'].'">Удалить</a>';}
echo '</div>';
}
if ($pages < $count)
echo $navigation = navigation($total, $page, '/News/');
}
else
echo '<div class="text">Новостей нет</div>';
echo '<div class="back"><a href="/"><img src="/Style/icons/back.png" alt="" /> На главную</a></div>';
$body = ob_get_contents();
ob_end_clean();
if($system['Cache_news'] == 1)
{
wCache($body, 'news.cache');
echo $body;
}
else
echo $body;
}
include '../System/footer.php';
?>