<?php
define('PROTECTOR', 1);

$headmod = 'news';//фикс. места

$textl='Новости';
include('files/path.php');
include($path.'files/db.php');
include($path.'files/auth.php');
include($path.'files/func.php');
include($path.'files/core.php');
include($path.'files/head.php');
include($path.'files/zag.php');
function s($text){
$msg=str_replace("\r\n",'<br />',$text);
$msg=str_replace("\\r\\n",'<br />',$text);
$msg=str_replace("\r",'<br />',$text);
$msg=str_replace("\n",'<br />',$text);
$msg=str_replace("\\r",'<br />',$text);
$msg=str_replace("\\n",'<br />',$text);
return $text;  }

if($udata[info_news] == 1){
mysql_query("UPDATE `users` SET `info_news`='0' WHERE `usr` = '$log'"); }
if ($_GET[page] == "" || $_GET[page] < 0 || $_GET[page] == "0")
{
$_GET[page] = 0;
}
$next = $_GET[page] + 1;
$back = $_GET[page] - 1;
$num = $_GET[page] * 1;
if($_GET[page] == "0")
{$i = 1;}
else{$i = ($_GET[page]*1)+1;}
$viso = mysql_num_rows(mysql_query("SELECT title FROM news"));
$puslap = floor($viso/1);
if (is_double($num) || !is_integer($num))
{
echo "Ошибка!<br/>";
}
else {
$asd = mysql_query("SELECT id,title, text, time FROM news ORDER BY id DESC LIMIT $num,1");
while($dsa = mysql_fetch_array($asd))
{
$i2 = $i++;
$title = strip_tags($dsa['title']);
$text = $dsa['text'];
$time = strip_tags($dsa['time']);
$komm = mysql_result(mysql_query("SELECT COUNT(*) FROM `news_komm` WHERE `id_news` = '$dsa[id]'"),0);
echo "<b>$title</b><small><b>[$time]</b></small><br/>".s($text)."<br/><a href=\"news_comm.php?id=$dsa[id]\">Обсудить</a> [".$komm."]<br/>";
}
if ($_GET[page] > 0)
{
echo "<a href=\"news.php?page=$back\">< Назад</a>";
}
if($_GET[page] < $puslap || $_GET[page] == "" || $_GET[page] == 0)
{echo "<a href=\"news.php?page=$next&\"> Далее ></a><br/>";}

}
echo"<a href=\"index.php?\">В кабинет</a>";
include($path.'files/down.php');
?>
