<?
include_once "../SYSTEM/include/functions.php";
include_once "../SYSTEM/include/mysql.php";
include_once "../SYSTEM/include/param.php";
include_once "../SYSTEM/include/ban.php";
include_once "../SYSTEM/include/sess.php";
include_once "../SYSTEM/include/ban_2.php";
include_once "../SYSTEM/include/theme.php";
$title='Архив новостей';
$mesto='Читает архив новостей';
head();

echo "<div class=\"h\">Архив новостей</div>\n";
echo "<hr />\n";

$k_page = 1;

$q = mysql_query("SELECT COUNT(*) FROM `$mysql[pref]news`;");
$k_news = mysql_result($q, 0);

if($k_news > 0)
{



$page=1;
if (isset($_GET['page']) && $_GET['page']!='')
{
if ($_GET['page']=='end')
{
$page=$k_news;
}
else
{
$page=intval($_GET['page']);
}
}
$page=intval($page);
if ($k_news<$page){$page=$k_news;}
if (0>$page){$page=1;}
$i=$page-1;
$q = mysql_query("SELECT * FROM `$mysql[pref]news` ORDER BY time DESC LIMIT $i, 1;");
while($news = mysql_fetch_array($q))
{
$timep=vremja($news['time']+$timesdvig);
echo "<div class=\"mess\">\n";
echo "<div class=\"title\"><b>$news[title] ($news[nick])</b></div>";
echo "<span style=\"color:$color[post_time]\"><small>[$timep]</small></span>";
echo "<br />\n";
echo "<span style=\"color:$color[post]\">".smiles($news['text'])."</span><br />\n";


$q = mysql_query("SELECT COUNT(*) FROM `$mysql[pref]news` WHERE `id` = '$news[id]' AND `id_t` <> '0';");
if (mysql_result($q, 0)>0) {
$q = mysql_query("SELECT COUNT(*) FROM `$mysql[pref]forum_p` WHERE `id_f` = '$id_news_forum' AND `id_r` = '$id_news_razd' AND `id_t` = '$news[id_t]';");
echo "<a href=\"".BASEDIR."forum/index.php?id_forum=$id_news_forum&amp;id_razd=$id_news_razd&amp;id_them=$news[id_t]\">Обсудить</a> <a href=\"".BASEDIR."forum/index.php?id_forum=$id_news_forum&amp;id_razd=$id_news_razd&amp;id_them=$news[id_t]&amp;page=end\">[".mysql_result($q, 0)."]</a><br />\n";
} else {
$q = mysql_query("SELECT COUNT(*) FROM `$mysql[pref]news_komm` WHERE `id_n` = '$news[id]';");
echo "<a href=\"komm.php?id=$news[id]\">Комментарии</a> <a href=\"komm.php?id=$news[id]&amp;page=end\">[".mysql_result($q, 0)."]</a><br />\n";
}
echo "Прочитано $news[times_read] ".plural_form($news['times_read'], "раз", "раза", "раз").".<br />\n";

if (isset($user) && $user['level']>2)
echo "<a href=\"del.php?id=$news[id]\">Удалить новость</a><br />\n";


echo "</div>\n";
echo "<br />\n";
}
}
else
{
echo "Нет новостей<br />\n";
}
echo "<hr />\n<div class=\"str\">";
str("arhiv.php?",$k_news,$page);
echo "</div><hr />\n";
echo "<a href=\"index.php\">&lt;&lt; Назад</a><br />\n";
echo "<a href=\"../index.php\">&lt;&lt; На главную</a>\n";

foot();
?>
