<?php
session_start();
include("connect.php");
include("includes/func_news.php");
$folder=$foldernews;
$action = $_GET['action'];
if(!isset($action)) $action = "home";

IF ($action=="home"){
$m1=$d12;
$m2=$k12;
tpl_header($LANGAUGE[60]);
bar($namelinks1,$LANGAUGE[60],"","");

table($LANGAUGE[60],indexcats(),1);

tpl_footer();


}ELSEIF ($action=="cat"){

$id = intval($_GET["id"]);

$sql = @mysql_query("select * from news_cat where id='$id' AND active='1'");
$Row = @mysql_fetch_array($sql);
if (!$Row)
{
error();
exit;
}
$namecatnews = text(3,$Row['name']);
$idcatnews   = $Row[id];

$m1 = text(3,$Row['description']);
$m2 = text(3,$Row['keywords']);

tpl_header($namecatnews);
bar($namelinks1,$namelinks10,$namecatnews,"");

table($namecatnews,catstext(),1);

tpl_footer();

}ELSEIF ($action=="view"){

$id = intval($_GET["id"]);

$sql = @mysql_query("select * from news where id='$id' AND active='1'");
$Row = @mysql_fetch_array($sql);
if (!$Row)
{
error();
exit;
}

$m1 = text(3,$Row['short']);
$m2 = text(3,$Row['keywords']);
$Row['image'] = text(3,$Row['image']);

if($Row['image'] == ""){
$i = "";
}else{
$i = "<div align='center'><img src='".$Row['image']."' alt='".text(3,$Row['sub'])."' border='0' /></div>";
}


if($Row['bbcodes']==1){
$text = text(2,$Row['news']);
}else{
include("includes/bbcode.php");
$text = text(3,$Row['news']);
$text = Replace($text);
}

$nam   = text(3,$Row['sub']);
$d = date("j/n/Y",$Row['date']);
$cat   = $Row['cat'];
$visi = $Row['vis'];

if($Row['url']==""){
$Row['url'] = text(3,$Row['url']);
$ur = "<a href='".$name_url."'>".$name_url."</a>";
}else{
$ur = "<a href='".$Row['url']."'>".$Row['url']."</a>";
}

if($Row['editor']==""){
$wr = $name_site;
}else{
$wr = text(3,$Row['editor']);
}

$sql2 = @mysql_query("SELECT * FROM news_cat where id='$cat'");
$Row2 = @mysql_fetch_array($sql2);
$names_cats = text(3,$Row2['name']);
if ($htmlorphp=="1"){
$ccat = "<a href='news_cat-$cat.html'>$names_cats</a>";
}else{
$ccat = "<a href='news.php?action=cat&id=$cat'>$names_cats</a>";
}

$sql2 = @mysql_query("update news set vis=vis+1 where id='$id'") or die ("Query failed");

$x = "<div class='info'>
<table class='xtable' width='100%' id='Auber1f5'>

<tr>
<td width='30%' class='xtr'>".$LANGAUGE[187]."</td>
<td width='70%' class='xtd'>$d</td>
</tr>

<tr>
<td width='30%' class='xtr'>".$LANGAUGE[189]."</td>
<td width='70%' class='xtd'>".$Row['vis']."</td>
</tr>

<tr>
<td width='30%' class='xtr'>".$LANGAUGE[190]."</td>
<td width='70%' class='xtd'>$ur</td>
</tr>

<tr>
<td width='30%' class='xtr'>".$LANGAUGE[186]."</td>
<td width='70%' class='xtd'>$wr</td>
</tr>

<tr>
<td width='30%' class='xtr'>".$LANGAUGE[188]."</td>
<td width='70%' class='xtd'>$ccat</td>
</tr>

</table>
</div>";

tpl_header($nam);

bar($namelinks1,$namelinks10,$ccat,$nam);

table($nam,$i.$text."<br />".$x."".comment_form(1,$id,$allowcomment_news,$allowshowcomment_news)."",1);

tpl_footer();

}ELSEIF ($action=="archive"){
$m1=$d12;
$m2=$k12;
tpl_header($LANGAUGE[85]);
bar($namelinks1,$namelinks10,$LANGAUGE[85],"");

table($LANGAUGE[85],archivethreads(),1);

tpl_footer();
}
?>