<?

header('Cache-Control: no-store, no-cache, must-revalidate');
if ($ver=="wml")header ("Content-type:text/vnd.wap.wml; charset=utf-8");
else header("Content-Type:text/html; charset=UTF-8");

require("inc.php");
$link = connect_db();
list($row, $id, $ps, $fsize1, $fsize2) = check_login($link);
require("version.php");

$cm = mysql_query ("select count(id) as num from news WHERE 1;");
$cmc = mysql_fetch_array($cm);
$news = $cmc["num"]; 

if ($ver=="wml"){
echo $xml;
echo $dtd;
echo "<wml>\n";
echo "<card title=\"Новости чата\">\n";
echo "<p align=\"left\">\n";
}else{
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css.css\"/>";
echo "<title>Новости чата</title>";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body>";
echo "<div align=\"left\">\n";
}
$new = mysql_query ("select count(id) as num from news;");
$news = mysql_fetch_array($new);
$num = $news["num"]; 
if(!isset($s))$s=0;
$mx=round(($num/5)+0.45);
if($s>$mx)$s=$mx;
if($s==0)$s=1;
$ot=(($s-1)*5)+1;
$do=$s*5;
if($do>$num)$do=$num;
$o=$ot-1;
$n=$ot;
if($do==0)$n=$o;
echo $fsize1;
echo "Показывает $n-$do из $num<br/>\n";
echo $divide;
echo $fsize2;
$r = mysql_query ("select * from `news` order by id desc limit $o,$do");
for ($i=$ot;$i<=$do;$i++){
$arr = mysql_fetch_array($r);
echo $fsize1;
echo "<b>".$arr['date']."</b><br/> ".$arr['content']."<br/>";
echo "<u>Разместил(а):</u><b> ".$arr['login']."</b><br/>";
echo $divide;
echo $fsize2; 
}
mysql_close($link);
$next=$s+1;
$prev=$s-1;
if ($num>$do) {
$ot=(($next-1)*5)+1;
$do=$next*5;
if($do>$num)$do=$num;
echo $fsize1;
echo "<a href=\"news.php?$ses&amp;s=$next&amp;ref=$ref\">&gt;&gt;$ot-$do&gt;&gt;</a><br/>\n";
echo $fsize2;
}
if($s>1) {
$ot=(($prev-1)*5)+1;
$do=$prev*5;
echo $fsize1;
echo "<a href=\"news.php?$ses&amp;s=$prev&amp;ref=$ref\">&lt;&lt;$ot-$do&lt;&lt;</a><br/>\n";
echo $fsize2;
}
echo $fsize1;
echo $divide;
echo "<a href=\"enter.php?$ses&amp;ref=$ref\">&#8592; Прихожая</a><br/>";
echo $fsize2; 
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>";
//mysql_close($link);
?>