<?php
function mhadrat_cats() {
global  $htmlorphp,$mhadrat_catsloop,$LANGAUGE;

if($mhadrat_catsloop=="1"){$width = "100%";}
elseif($mhadrat_catsloop=="2"){$width = "50%";}
elseif($mhadrat_catsloop=="3"){$width = "33%";}
elseif($mhadrat_catsloop=="4"){$width = "25%";}
elseif($mhadrat_catsloop=="5"){$width = "20%";}
elseif($mhadrat_catsloop=="6"){$width = "16%";}
else{$width = "";}

$sql = @mysql_query("SELECT * FROM  mhadrat_cat where sub='0' AND active='1' order by order_cat");
$nu = mysql_num_rows($sql);
if($nu == 0){
$printcats = $LANGAUGE[91];
}else{
$printcats = "<table border='0' width='100%' id='AutoNumber2' style='border-collapse: collapse'>";

$tslsls = '0';
while ($Row2 = @mysql_fetch_array($sql))
{
$sql2 = @mysql_query("SELECT id FROM mhadrat where cat='".$Row2['id']."' AND active='1'");
$nu = mysql_num_rows($sql2);

++$tslsls;
if($tslsls=="$mhadrat_catsloop"){
$tslslats = "</tr><tr>";
$tslsls="0";
}else{
$tslslats = "";
}

$Row2[name_cat] = text(3,$Row2[name_cat]);

if ($htmlorphp=="1"){
$printcats .= "<td width='$width' class='category'><div><a href='mhadrat_cat-$Row2[id].html'>$Row2[name_cat]</a></div></td>
$tslslats";
}else{
$printcats .= "<td width='$width' class='category'><div><a href='sound.php?action=mhadrat&id=$Row2[id]'>$Row2[name_cat]</a></div></td>
$tslslats";
}
}
$printcats .= "</table>";
}
return $printcats;
}


function mhadrat() {
global $id,$mhadrat_catsloop,$LANGAUGE,$htmlorphp,$folder;

if($mhadrat_catsloop=="1"){$width = "100%";}
elseif($mhadrat_catsloop=="2"){$width = "50%";}
elseif($mhadrat_catsloop=="3"){$width = "33%";}
elseif($mhadrat_catsloop=="4"){$width = "25%";}
elseif($mhadrat_catsloop=="5"){$width = "20%";}
elseif($mhadrat_catsloop=="6"){$width = "16%";}
else{$width = "";}

$sqlx = @mysql_query("SELECT * FROM  mhadrat_cat where sub='$id' AND active='1' order by order_cat");
$nux = mysql_num_rows($sqlx);

if($nux == 0){
$printcats = "";
}else{

$printcats = "<table border='0' width='100%' id='AutoNumber2' style='border-collapse: collapse'>";
$tslsls = '0';
while ($Row2 = @mysql_fetch_array($sqlx))
{
$sql2 = @mysql_query("SELECT id FROM mhadrat where cat='".$Row2['id']."' AND active='1'");
$nu = mysql_num_rows($sql2);

++$tslsls;
if($tslsls=="$mhadrat_catsloop"){
$tslslats = "</tr><tr>";
$tslsls="0";
}else{
$tslslats = "";
}

$Row2[name_cat] = text(3,$Row2[name_cat]);

if ($htmlorphp=="1"){
$printcats .= "<td width='$width' class='category'><div><a href='mhadrat_cat-$Row2[id].html'>$Row2[name_cat]</a></div></td>
$tslslats";
}else{
$printcats .= "<td width='$width' class='category'><div><a href='sound.php?action=mhadrat&id=$Row2[id]'>$Row2[name_cat]</a></div></td>
$tslslats";
}
}
$printcats .= "</table>";
}

$page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]);
$page = ($page == 0 ? 1 : $page);
$perpage = 30;
$startpoint = ($page * $perpage) - $perpage;

$sql = @mysql_query("SELECT * FROM mhadrat where cat='$id' AND active='1' order by id desc limit $startpoint,$perpage");
$nu = mysql_num_rows($sql);

if($nu != 0 AND $nux != 0){
$printcats .= "<br />";
}

if($nu == 0){
if($nux == 0){
$printcats .= $LANGAUGE[161];
}else{
$printcats .= "";
}
}else{
$printcats .= "<table class='xtable' width='100%' id='AutoNumber15'>
    <tr>
      <td width='60%' class='xtr' align='center'>".$LANGAUGE[162]."</td>
      <td width='30%' class='xtr' align='center'>".$LANGAUGE[149]."</td>
      <td width='10%' class='xtr' align='center'>".$LANGAUGE[93]."</td>
    </tr>";
while ($Row = @mysql_fetch_array($sql))
{
$n = text(3,$Row[name]);
$Row['url'] = text(3,$Row['url']);
$url = explode("[*]", $Row['url']);
$files = count($url);
$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']."&n=".$i."";
}
//$ro .= "<a href='".$url[$i]."'>".typefile($url[$i],$text)."</a>".$fff;
$ro .= "<a href='".$lx."'>".typefile($url[$i],$text)."</a>".$fff;
$rox .= "<a href='".$url[$i]."'><img src='$folder/icons/save.gif' alt='' border='0' /></a>".$fff;
}

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

//onclick=\"NewWindow(this.href,'mywin','400','200','no','center');return false\" onfocus=\"this.blur()\"
$printcats .= "<tr>
<td width='60%' class='xtd'><a href='$lxl'>$n</a></td>
<td width='30%' class='xtd' align='center'>$ro</td>
<td width='10%' class='xtd' align='center'>$Row[vis]</td>
</tr>";
}

$printcats .= "</table>";

$pagesnum = @ceil(mysql_num_rows(mysql_query("select `id` from `mhadrat` where cat='$id' AND active='1'")) / $perpage);

if($pagesnum > 1){
$printcats .= "<div class='multipage'>";
for ($i=1; $i<=$pagesnum; $i++) {
if ($i != $page) {

if ($htmlorphp=="1"){
$z = "<span><a href='m-$id-$i.html'>$i</a></span>";
}else{
$z = "<span><a href='sound.php?action=mhadrat&id=$id&page=$i'>$i</a></span>";
}

} else {
$z = "<span class='act'>$i</span>";
}
$printcats .= "$z";

}
$printcats .= "</div>";
}
}
return $printcats;
}
?>