<?php
function signatures_cats() {
global  $htmlorphp,$signatures_catsloop,$LANGAUGE;

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

$sql = @mysql_query("SELECT * FROM  signatures_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 * FROM signatures where cat='".$Row2['id']."' AND active='1'")  or die ("Query failed");
$nu = mysql_num_rows($sql2);

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

return $printcats;
}

function signaturess() {
global $id,$htmlorphp,$folder,$name_path,$signatures_loop,$LANGAUGE;

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

$sqlz = @mysql_query("SELECT * FROM signatures_cat where sub='".$id."' AND active='1' order by order_cat");
$nuz = mysql_num_rows($sqlz);
if($nuz == 0){
$printcats = "";
}else{
$printcats = "<table border='0' width='100%' id='mber2' style='border-collapse: collapse'>";
$tslsls = '0';
while ($Row2 = @mysql_fetch_array($sqlz))
{
$sql2 = @mysql_query("SELECT * FROM signatures where cat='".$Row2['id']."' AND active='1'")  or die ("Query failed");
$nu = mysql_num_rows($sql2);

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

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

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

if($nu == 0){
if($nuz == 0){
$printcats .= $LANGAUGE[153];
}else{
$printcats .= "";
}
}else{
$printcats .= "";
$c = 0;
while ($Row = @mysql_fetch_array($sql))
{
++$c;
if($c == $nu){
$smbol = "";
}else{
$smbol = "<br />";
}
$Row[name] = text(3,$Row[name]);
$Row[name_image] = text(3,$Row[name_image]);
$Row[desin_image] = text(3,$Row[desin_image]);
$Row[keywords] = text(3,$Row[keywords]);
$Row[description] = text(3,$Row[description]);

if($Row[desin_image] == ""){
$x = "";
}else{
$x = "<tr>
      <td width='25%' class='xtr'>".$LANGAUGE[154]."</td>
      <td width='75%' class='xtd'>".$Row[desin_image]."</td>
    </tr>";
}

$z2 = '<img border="0" src="'.$name_path.'/'.$Row[name_image].'" alt="'.$Row[name].'" />';

$printcats .= "<div class='signatures'>
<div align='center'><img border='0' src='$Row[name_image]' alt='".$Row[description]."' /></div>";
$printcats .= "<table class='xtable' width='100%' id='umsber".$c."'>
    <tr>
      <td width='25%' class='xtr'>".$LANGAUGE[155]."</td>
      <td width='75%' class='xtd'>".$Row[name]."</td>
    </tr>
    ".$x."
    <tr>
      <td width='25%' class='xtr'>".$LANGAUGE[156]."</td>
      <td width='75%' class='xtd'>".$Row[description]."</td>
    </tr>
    <tr>
      <td width='25%' class='xtr'>".$LANGAUGE[157]."</td>
      <td width='75%' class='xtd'>".$Row[keywords]."</td>
    </tr>
    <tr>
      <td width='25%' class='xtr'>".$LANGAUGE[158]."</td>
      <td width='75%' class='xtd'><input dir='ltr' name='name1' type='text' value='[IMG]$name_path/$Row[name_image][/IMG]' /></td>
    </tr>
    <tr>
      <td width='25%' class='xtr'>".$LANGAUGE[159]."</td>
      <td width='75%' class='xtd'><input dir='ltr' name='name2' type='text' value='".htmlspecialchars($z2)."' /></td>
    </tr>
    <tr>
      <td width='25%' class='xtr'>".$LANGAUGE[160]."</td>
      <td width='75%' class='xtd'><input dir='ltr' name='name3' type='text' value='$name_path/$Row[name_image]' /></td>
    </tr>
  </table></div>";
$printcats .= "$smbol".$m;

}

$pagesnum = @ceil(mysql_num_rows(mysql_query("select `id` from `signatures` 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='signaturespage-$id-$i.html'>$i</a></span>";
}else{
$z = "<span><a href='signatures.php?action=signatures&id=$id&page=$i'>$i</a></span>";
}

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

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

return $printcats;
}
?>