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

IF ($action=="home"){
$m1=$d2;
$m2=$k2;
tpl_header($LANGAUGE[51]);
bar($namelinks1,$LANGAUGE[51],"","");

table($LANGAUGE[51],mhadrat_cats(),1);

tpl_footer();

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

$sql = mysql_query("select * from mhadrat_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,$namelinks2,$Row['name_cat'],"");

table($Row['name_cat'],mhadrat(),1);

tpl_footer();

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

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

$sql = mysql_query("select * from mhadrat where id='$id' AND active='1'");
$Row = mysql_fetch_array($sql);
if (!$Row)
{
error();
exit;
}
$Row['name']    = text(3,$Row['name']);
$url            = text(3,$Row['url']);
$vis            = $Row['vis'];
$cat            = $Row['cat'];
$text = text(3,$Row['text']);
$Row['urlother'] = text(3,$Row['urlother']);

$m1 = text(3,$Row['metadescription']);
$m2 = text(3,$Row['metakeywords']);

$datex = date("j/n/Y",$Row['date']);

$url = explode("[*]", $Row['url']);
$files = count($url);

if(intval($_GET['n']) > ($files-1)){
error();
exit;
}

$fx = intval($_GET['n']);
$cpath = $url[$fx];

$ro = "";
$rox = "";
$ii = 0;
for($i=0;$i<$files;$i++){
$ii++;
if($ii != $files){
$fff = "&nbsp;";
}

if ($htmlorphp=="1"){
$lx = "mhadrat_show-".$Row['id']."-".$i.".html";
}else{
$lx = "sound.php?action=mhadrat_show&id=$Row[id]".$Row['id']."&n=".$i."";
}

if($fx==$i){
$ro .= typefile($url[$i],$Row['name']).$fff;
}else{
$ro .= "<a href='".$lx."'>".typefile($url[$i],$Row['name'])."</a>".$fff;
}
$rox .= "<tr>
      <td width='30%' class='xtr'>".$LANGAUGE[164]." ( ".$i." )</td>
      <td width='70%' class='xtd'><a href='".$url[$i]."'>".typefile($url[$i],$LANGAUGE[89])."</a></td>
    </tr>";
}

$dss = "";
if($files > 1){
$dss .= "<div class='savetable'>".$LANGAUGE[194]."<br /><br />".$ro."</div>";
}

if($text == ""){
$ex = "";
}else{
$ex = "<tr>
      <td width='30%' class='xtr'>".$LANGAUGE[163]."</td>
      <td width='70%' class='xtd'>".nl2br($text)."</td>
    </tr>";
}

if($Row['urlother'] == ""){
$exw = "";
}else{
$exw = "<tr>
      <td width='30%' class='xtr'>".$LANGAUGE[104]."</td>
      <td width='70%' class='xtd'><a target='_blank'href='".$Row['urlother']."'><img src='$folder/icons/html.gif' alt='".$Row['urlother']."' border='0' /></a></td>
    </tr>";
}

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

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

tpl_header($Row['name']);
bar($namelinks1,$namelinks2,$xxcat,$Row['name']);

$F = "<div align='center'>".embed($cpath,300,60)."</div>";
$F .= "<br />";
$F .= $dss;
$F .= "<br />";
$F .= "<table class='xtable' width='100%' id='Auber1f5'>

    <tr>
      <td width='30%' class='xtr'>".$LANGAUGE[165]."</a></td>
      <td width='70%' class='xtd'>$xxcat</td>
    </tr>
    <tr>
      <td width='30%' class='xtr'>".$LANGAUGE[93]."</td>
      <td width='70%' class='xtd'>$vis</td>
    </tr>
    <tr>
      <td width='30%' class='xtr'>".$LANGAUGE[187]."</td>
      <td width='70%' class='xtd'>$datex</td>
    </tr>
    $ex
    $exw
    ".$rox."
  </table>";

table($Row['name'],$F,1);

tpl_footer();
}
?>