Файл: news.php
Строк: 58
<?php
// mod Gemorroj
require 'moduls/config.php';
require 'moduls/header.php';
$str = '';
$title .= $_SESSION['language']['news'];
// кол-во на страницу
$onpage = get2ses('onpage');
if ($onpage < 3) {
$onpage = 3;
}
$page = isset($_GET['page']) ? abs($_GET['page']) : 1;
if ($page < 1) {
$page = 1;
}
$out='';
$banner='';
$Reklames = new Reklames(); // Создаем экземпляр класса Reklames
$out.= $Reklames->Top();
$banner.= $Reklames->Bottom();
$id = isset($_GET['id']) ? abs($_GET['id']) : 0;
// всего новостей
$all = mysql_result(mysql_query('SELECT COUNT(1) FROM `news`', $mysql), 0);
if (!$all) {
error($_SESSION['language']['news yet'],$banner);
}
echo '<div class="mainzag">'.$title.'</div>'.$out;
$pages = ceil($all / $onpage);
if (!$pages) {
$pages = 1;
}
if ($page > $pages) {
$page = 1;
}
if ($page) {
$start = ($page - 1) * $onpage;
} else {
$start = 0;
}
if ($start > $all || $start < 1) {
$start = 0;
}
$q = mysql_query('
SELECT `news`.*, COUNT(k.id) AS count
FROM `news`
LEFT JOIN `news_komments` AS k ON `news`.`id` = k.id_news
WHERE `news`.`id` > 0
GROUP BY `news`.`id`
ORDER BY `news`.`id` DESC
LIMIT ' . $start . ', ' . $onpage,
$mysql);
// поле в БД
$news = 'news';
if ($_SESSION['langpack'] == 'russian') {
$news = 'rus_news';
}
while ($arr = mysql_fetch_assoc($q)) {
$str .= '<div class="row2">' . tm($arr['time']) . '<br/><span style="font-size:9px;">' . $arr[$news] . '</span><br/><img src="/dis/comment.png" alt="comment"/><a href="' . DIRECTORY . 'news_komm/' . $arr['id'] . '">' . $_SESSION['language']['comments'] . '</a> [' . $arr['count'] . ']</div>';
}
echo $str;
if ($pages > 1) {
echo '<div class="row">' . $_SESSION['language']['pages'] . ': ';
$asd = $page - 2;
$asd2 = $page + 3;
if ($asd < $all && $asd > 0 && $page > 3) {
echo '<a href="' . DIRECTORY . 'news/1">1</a> ... ';
}
for ($i = $asd; $i < $asd2; ++$i) {
if ($i <= $all && $i > 0) {
if ($i > $pages) {
break;
}
if ($page == $i) {
echo '<strong>[' . $i . ']</strong> ';
} else {
echo '<a href="' . DIRECTORY . 'news/' . $i . '">' . $i . '</a> ';
}
}
}
if ($i <= $pages) {
if ($asd2 < $all) {
echo ' ... <a href="' . DIRECTORY . 'news/' . $pages . '">' . $pages . '</a>';
}
}
echo '<br/>';
echo '</div>';
}
echo'<div class="foot"><a href="' . DIRECTORY . $back['id'] . '">' . $_SESSION['language']['back'] . '</a> |</div>';
echo $banner;
require 'moduls/foot.php';
?>