<?PHP include("components/boot.php"); ?>
<?PHP

$_OPTIMIZATION["title"] = "Новости";
$_OPTIMIZATION["description"] = "Новости проекта";
$_OPTIMIZATION["keywords"] = "Новости нашего проекта";
?>
<br/>
<?PHP

if(isset($_SESSION["user_id"]))
{
	$db->Query("SELECT * FROM db_users_a WHERE id = '$usid' LIMIT 1");
	$user_data = $db->FetchArray();
	$newsus = $user_data["news"];

	$numnews = 0;
	$db->Query("SELECT * FROM db_news ORDER BY id DESC");
	while($newses = $db->FetchArray()){
	$numnews = $numnews+1;
	}

	if($numnews > $newsus)
	{
		$db->Query("UPDATE db_users_a SET news = '$numnews' WHERE id = '$usid'");
		Header("Location: /news");
	}
}

$db->Query("SELECT * FROM db_news ORDER BY id DESC");

if($db->NumRows() > 0){

	while($news = $db->FetchArray()){
	
	?>
<div class="foot_human">
<div class="row flex jcsb aifs">
<img class="main_hum1" src="img/hum.png" alt="">
</div>
</div>
<div class="wr_inf_in3">
<div class="row flex jcc aic fww pt20 pb20">
<div class="xl_100 tal no_aut_head">Новости</div>
<div class="xl_100">
<div class="sp_title xl_100 active tal pl10" onclick="$(this).toggleClass('active').next().slideToggle('slow');"><i class="fa fa-sort pr10"></i>#<?=$news["id"]; ?> <?=$news["title"]; ?> <span class="pull-right"><?=date("d.m.Y",$news["date_add"]); ?></span></div>
<div class="sp_content tal" >
<?=$news["news"]; ?>
</div>
<?PHP
	
	}

}else echo "<center class='alert alert-danger'>Новостей нет :(</center>";

?>
</div>
</div>
</div>
</section>
<?PHP include("components/foot.php"); ?>