<?PHP
{
}
//навигация
$max = 1;
@$page = $_GET['page'];
$result00 = mysql_query("SELECT COUNT(*) FROM ".PREFIX
."_sarticles WHERE moderated='1'"); $posts = $temp[0];
$total = (($posts - 1) / $max) + 1;
if(empty($page) or
$page < 0
) $page = 1; if($page > $total) $page = $total;
// Вычисляем начиная с какого номера
// следует выводить сообщения
$start = $page * $max - $max;
if (!$result)
{
echo "<p>Запрос на выборку данных из базы не прошел. Напишите об этом администратору. <br> <strong>Код ошибки:</strong></p>";
}
// Проверяем нужны ли стрелки назад
if ($page != 1) $pervpage = '<a href=?page=1>Первая</a> | <a href=?page='. ($page - 1) .'>Предыдущая</a> | ';
// Проверяем нужны ли стрелки вперед
if ($page != $total) $nextpage = ' | <a href=?page='. ($page + 1) .'>Следующая</a> | <a href=?page=' .$total. '>Последняя</a>';
// Находим две ближайшие станицы с обоих краев, если они есть
if($page - 5 > 0) $page5left = ' <a href=?page='. ($page - 5) .'>'. ($page - 5) .'</a> | ';
if($page - 4 > 0) $page4left = ' <a href=?page='. ($page - 4) .'>'. ($page - 4) .'</a> | ';
if($page - 3 > 0) $page3left = ' <a href=?page='. ($page - 3) .'>'. ($page - 3) .'</a> | ';
if($page - 2 > 0) $page2left = ' <a href=?page='. ($page - 2) .'>'. ($page - 2) .'</a> | ';
if($page - 1 > 0) $page1left = '<a href=?page='. ($page - 1) .'>'. ($page - 1) .'</a> | ';
if($page + 5 <= $total) $page5right = ' | <a href=?page='. ($page + 5) .'>'. ($page + 5) .'</a>';
if($page + 4 <= $total) $page4right = ' | <a href=?page='. ($page + 4) .'>'. ($page + 4) .'</a>';
if($page + 3 <= $total) $page3right = ' | <a href=?page='. ($page + 3) .'>'. ($page + 3) .'</a>';
if($page + 2 <= $total) $page2right = ' | <a href=?page='. ($page + 2) .'>'. ($page + 2) .'</a>';
if($page + 1 <= $total) $page1right = ' | <a href=?page='. ($page + 1) .'>'. ($page + 1) .'</a>';
// Вывод меню если страниц больше одной
if ($total > 1)
{
$content.= "<div class=\"pstrnav\">";
$content.= $pervpage.$page5left.$page4left.$page3left.$page2left.$page1left.'<b>'.$page.'</b>'.$page1right.
$page2right.$page3right.$page4right.$page5right.$nextpage;
$content.= "</div>";;
}
//конец навигации
$query = mysql_query("SELECT * FROM ".PREFIX
."_articles WHERE moderated='1' DESC LIMIT $start,$max"); $getquery = mysql_query("SELECT * FROM ".PREFIX
."_articles WHERE moderated='1' AND id='".intval($_GET['id'])."'"); $catquery = mysql_query("SELECT * FROM ".PREFIX
."_articles WHERE moderated='1' AND cat_id='".intval($_GET['cat_id'])."'"); $squery = mysql_query("SELECT * FROM ".PREFIX
."_sarticles WHERE moderated='1' ORDER BY `id` DESC LIMIT $start,$max"); $sgetquery = mysql_query("SELECT * FROM ".PREFIX
."_sarticles WHERE moderated='1' AND id='".intval($_GET['id'])."' DESC LIMIT $start,$max"); $scatquery = mysql_query("SELECT * FROM ".PREFIX
."_sarticles WHERE moderated='1' AND cat_id='".intval($_GET['cat_id'])."' DESC LIMIT $start,$max"); //full новость
{
$title = $data['title'];
$titlenews .= ''.$data['title'].' » ';
$titles .= ' » <a href="index.php?do=article&cat_id='.$xcat['id'].'">'.$xcat['name'].'</a> » '.$data['title'].'';
$content .= '
<div class="base btype2">
<div class="heading">
<h3><b><span>'.$data['title'].'</span></b></h3>
</div>
<div class="bci_block"><div class="bci_border"><div class="bci_cont">
<table width="100%" border="0">
<tr height="30px">';
$content .= '<td width="15%" align="left"><strong>Категория:</strong> <a href="index.php?do=article&cat_id='.$xcat['id'].'">'.$xcat['name'].'</a><div style="float:right;"><strong>Дата:</strong> '.$data['dates'].'</div></td>';
$content .= '
</tr>
</table>
<table width="100%" border="0">
<tr>
<td background="/template/images/mline.gif" height="1" colspan="2"></td>
</tr>
</table>'.$data['article'].'
<div style="clear:both;"></div>
<!-- Сохронить -->
<div style="float:right;">
<script type="text/javascript" src="http://vkontakte.ru/js/api/share.js?10" charset="windows-1251"></script>
<script type="text/javascript"><!--
document.write(VK.Share.button(false,{type: "round", text: "Сохранить"}));
--></script></div>
<!-- Like -->
<div style="float:left;">
<div id="vk_like"></div>
<script type="text/javascript">
VK.Widgets.Like("vk_like", {type: "mini"});
</script></div>
';
$content .= '<br></div></div></div>';
$content .= '</div>';
$content .= '
<!-- Коментарии -->
<div id="vk_comments"></div>
<script type="text/javascript">
VK.Widgets.Comments("vk_comments", {limit: 20, width: "945", attach: "*"});
</script>';
}
} else {
$content = <<<HTML
<div class="base btype2">
<div class="heading">
<h3><b><span>Ошибка</span></b></h3>
</div>
<div class="bci_block"><div class="bci_border"><div class="bci_cont">Искомой статьи нет</div></div></div>
</div>
<a href="javascript:history.go(-1)" mce_href="javascript:history.go(-1)">Вернуться</a>
HTML;
}
}
//short новость
elseif(empty($_GET['id']) && !empty($_GET['cat_id'])) {
$titlenews .= ''.$ycat['name'].' » ';
$titles .= ' » '.$ycat['name'].'';
$content .= '
<div class="base btype2">
<div class="heading">
<h3><b><span><a href="index.php?do=article&id='.$data['id'].'">'.$data['title'].'</a></span></b></h3>
</div>
<div class="bci_block"><div class="bci_border"><div class="bci_cont">
<table width="100%" border="0">
<tr height="30px">';
$content .= '<td width="15%" align="left"><strong>Категория:</strong> <a href="index.php?do=article&cat_id='.$ycat['id'].'">'.$ycat['name'].'</a><div style="float:right;"><strong>Дата:</strong> '.$data['dates'].'</div></td>';
$content .= '
</tr>
</table>
<table width="100%" border="0">
<tr>
<td background="/template/images/mline.gif" height="1" colspan="2"></td>
</tr>
</table>'.$data['article'].'</div></div></div>';
$content .= '</div>';
}
} else {
$content = <<<HTML
<div class="base btype2">
<div class="heading">
<h3><b><span>Ошибка</span></b></h3>
</div>
<div class="bci_block"><div class="bci_border"><div class="bci_cont">Категории нет</div></div></div>
</div>
<a href="javascript:history.go(-1)" mce_href="javascript:history.go(-1)">Вернуться</a>
HTML;
}
}
else
{
$content .= '
<div class="base btype2">
<div class="heading">
<h3><b><span><a href="index.php?do=article&id='.$data['id'].'">'.$data['title'].'</a></span></b></h3>
</div>
<div class="bci_block"><div class="bci_border"><div class="bci_cont">
<table width="100%" border="0">
<tr height="30px">';
$content .= '<td width="15%" align="left"><strong>Категория:</strong> <a href="index.php?do=article&cat_id='.$ycat['id'].'">'.$ycat['name'].'</a><div style="float:right;"><strong>Дата:</strong> '.$data['dates'].'</div></td>';
$content .= '
</tr>
</table>
<table width="100%" border="0">
<tr>
<td background="/template/images/mline.gif" height="1" colspan="2"></td>
</tr>
</table>'.$data['article'].'</div></div></div>';
$content .= '</div>';
}
} else {
$content = <<<HTML
<div class="base btype2">
<div class="heading">
<h3><b><span>Ошибка</span></b></h3>
</div>
<div class="bci_block"><div class="bci_border"><div class="bci_cont">Статей нет</div></div></div>
</div>
<a href="javascript:history.go(-1)" mce_href="javascript:history.go(-1)">Вернуться</a>
HTML;
}
}
?>