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

IF ($action=="home"){
$m1=$d13;
$m2=$k13;
tpl_header($LANGAUGE[295]);
bar($namelinks1,$LANGAUGE[295],"","");
table($LANGAUGE[295],textcats(),1);
tpl_footer();

}ELSEIF ($action=="cat"){
$id = intval($_GET["id"]);

$sql = @mysql_query("select * from text_cat where id='$id' AND active='1'");
$Row = @mysql_fetch_array($sql);
if (!$Row)
{
error();
exit;
}
$Row['name_cat'] = text(3,$Row['name_cat']);
$m1 = text(3,$Row['description']);
$m2 = text(3,$Row['keywords']);

tpl_header($Row['name_cat']);
bar($namelinks1,$namelinks16,$Row['name_cat'],"");
table($Row['name_cat'],texts(),1);
tpl_footer();

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

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

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

$name = text(3,$Row['name']);
$url            = text(3,$Row['url']);
$vis            = $Row['vis'];
$cat            = $Row['cat'];
$text = text(2,$Row['text']);
$d = date("j/n/Y",$Row['date']);
$m1 = text(3,$Row['description']);
$m2 = text(3,$Row['keywords']);

$sql2 = @mysql_query("SELECT * FROM text_cat where id='$cat'") or die ("Query failed3");
$cats = @mysql_fetch_array($sql2);
$catnamef = text(3,$cats['name_cat']);
if ($htmlorphp=="1"){
$xxx = "<a href='textcat-$cat.html'>$catnamef</a>";
}else{
$xxx = "<a href='text.php?action=cat&id=$cat'>$catnamef</a>";
}

if($url==""){
$rdd = $name_url;
}else{
$rdd = $url;
}

$sql3 = @mysql_query("update text set vis=vis+1 where id='$id'") or die ("Query failed4");

$F = "<br /><br /><table class='xtable' width='100%' id='Auber1f5'>
    <tr>
      <td width='30%' width='30%' class='xtr'>".$LANGAUGE[104]." :</td>
      <td width='70%' class='xtd'><a target='_blank' href='".$rdd."'>".$rdd."</a></td>
    </tr>
    <tr>
      <td width='30%' width='30%' class='xtr'>".$LANGAUGE[165]."</td>
      <td width='70%' class='xtd'>".$xxx."</td>
    </tr>
    <tr>
      <td width='30%' width='30%' class='xtr'>".$LANGAUGE[93]." :</td>
      <td width='70%' class='xtd'>$vis</td>
    </tr>
    <tr>
      <td width='30%' width='30%' class='xtr'>".$LANGAUGE[83]." :</td>
      <td width='70%' class='xtd'>$d</td>
    </tr>
  </table>";

tpl_header($name);
bar($namelinks1,$namelinks16,$xxx,$name);
table($name,$text.$F,1);
tpl_footer();
}
?>