<?php
function aldleel_cats() {
global  $htmlorphp,$aldleel_catsloop,$LANGAUGE;

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

$sql = @mysql_query("SELECT * FROM  dlil_cat where sub='0' AND active='1' order by order_cat");
$nuxx = mysql_num_rows($sql);

if($nuxx==0){
$printcats = $LANGAUGE[91];
}else{
$printcats = "<table border='0' width='100%' id='AutoNumber2'>";

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

++$tslsls;
if($tslsls=="$aldleel_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='aldlel_cat-$Row2[id].html'>$Row2[name_cat]</a></div></td>
$tslslats";
}else{
$printcats .= "<td width='$width' class='category'><div><a href='links.php?action=islam_dlil&id=$Row2[id]'>$Row2[name_cat]</a></div></td>
$tslslats";
}
}
$printcats .= "</table>";
}
return $printcats;
}




function aldleel_sitesx () {
global $id,$htmlorphp,$folder,$aldleel_catsloop,$aldleel_sitesloop,$LANGAUGE;


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

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

if($nuxx==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 * FROM islam_dlil where cat='".$Row2['id']."' AND active='1'") or die ("Query failed");
$nu = mysql_num_rows($sql2);
@mysql_free_result($sql2);

++$tslsls;
if($tslsls=="$aldleel_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='aldlel_cat-$Row2[id].html'>$Row2[name_cat]</a></div></td>
$tslslats";
}else{
$printcats .= "<td width='$width' class='category'><div><a href='links.php?action=islam_dlil&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 = $aldleel_sitesloop;
$startpoint = ($page * $perpage) - $perpage;

$sql = @mysql_query("SELECT * FROM islam_dlil where cat='$id' AND active='1' order by id desc limit $startpoint,$perpage");
$nue = mysql_num_rows($sql);
if($nue == 0){
if($nuxx==0){
$printcats .= $LANGAUGE[139];
}else{
$printcats .= "";
}
}else{
$printcats .= "<table class='xtable' width='100%' id='AutoNumber15'>
    <tr>
      <td width='85%' class='xtr' align='center'>".$LANGAUGE[138]."</td>
      <td width='15%' class='xtr' align='center'>".$LANGAUGE[93]."</td>
    </tr>";
while ($Row = @mysql_fetch_array($sql))
{
$Row['name_site'] = text(3,$Row['name_site']);
$Row['url_site'] = text(3,$Row['url_site']);
$Row['text_site'] = text(3,$Row['text_site']);

if($Row['text_site'] == ""){
$t = "";
}else{
$t = "<br />".$Row['text_site'];
}

if ($htmlorphp=="1"){
$pl = "<a href='aldlel_show-$Row[id].html'>".$Row['name_site']."</a>";
}else{
$pl = "<a href='links.php?action=show&id=$Row[id]'>".$Row['name_site']."</a>";
}

$printcats .= "<tr>
<td width='85%' class='xtd'>".$pl."</td>
<td width='15%' class='xtd' align='center'>$Row[vis]</td>
</tr>";
}

$printcats .= "</table>";

$pagesnum = @ceil(mysql_num_rows(mysql_query("select id from islam_dlil where cat='$id'")) / $perpage);

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

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

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

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

return $printcats;
}


function aldleel_sites () {
global $id,$htmlorphp,$folder,$aldleel_catsloop,$aldleel_sitesloop,$LANGAUGE;


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

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

if($nuxx==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 * FROM islam_dlil where cat='".$Row2['id']."' AND active='1'") or die ("Query failed");
$nu = mysql_num_rows($sql2);

++$tslsls;
if($tslsls=="$aldleel_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='aldlel_cat-$Row2[id].html'>$Row2[name_cat]</a></div></td>
$tslslats";
}else{
$printcats .= "<td width='$width' class='category'><div><a href='links.php?action=islam_dlil&id=$Row2[id]'>$Row2[name_cat]</a></div></td>
$tslslats";
}
}
$printcats .= "</table>";
}

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

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

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

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

if($nue == 0){
if($nuxx==0){
$printcats .= $LANGAUGE[139];
}else{
$printcats .= "";
}

}else{
$printcats .= "<table border='0' width='100%' id='AutoNumber2' style='border-collapse: collapse'>";
$tslslsx = '0';
while ($Row = @mysql_fetch_array($sql))
{
$Row['name_site'] = text(3,$Row['name_site']);
$Row['url_site'] = text(3,$Row['url_site']);
$Row['text_site'] = text(3,$Row['text_site']);

if ($htmlorphp=="1"){
$pr = "aldlel_gosite-$Row[id].html";
}else{
$pr = "links.php?action=islam_dlil_go&id=$Row[id]";
}

if($Row['text_site'] == ""){
$t = "";
}else{
$t = "<br />".$Row['text_site'];
}

if ($htmlorphp=="1"){
$pl = "<a target='_blank' href='".$pr."'><img src='$folder/icons/web.png' alt='".$Row['name_site']."' border='0' /></a> <a href='aldlel_show-$Row[id].html'>".$Row['name_site']."</a>";
}else{
$pl = "<a target='_blank' href='".$pr."'><img src='$folder/icons/web.png' alt='".$Row['name_site']."' border='0' /></a> <a href='links.php?action=show&id=$Row[id]'>".$Row['name_site']."</a>";
}

++$tslslsx;
if($tslslsx=="$aldleel_catsloopx"){
$tslslatsx = "</tr><tr>";
$tslslsx="0";
}else{
$tslslatsx = "";
}

$printcats .= "<td width='$width' class='category'><div>".$pl."</div></td>
$tslslatsx";
}

$printcats .= "</table>";

$pagesnum = @ceil(mysql_num_rows(mysql_query("select id from islam_dlil where cat='$id'")) / $perpage);

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

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

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

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

return $printcats;
}
?>