<?php session_start(); ?>
<?php
include("stop.php");
?>
<?php
$cat = $_GET["cat"];
$cid = $_GET["cat"];

if($cat=="$cid"){
    
include("config.php");
include("uploads.html");
?>
<table width='950' cellspacing='0' cellpadding='0' align='center'>
<?php
include ("right.html");
?>
<td width='720' valign='top' class='continut'>

<table cellspacing='0' cellpadding='10'  width='100%'>
<tr>
<td>

<!-- CONTINUTUL !!!! -->

<div class='hl'>Categories</div><center>

</center>
<table width='100%'>
<tr>
<td align='50%'><h2>

<?php
$cat = $cid;
if ($cat=='') {} else {
 if($cat=='35'){echo 'Script';}
 if($cat=='34'){echo 'Subtitles';}
 if($cat=='33'){echo 'Symbian S60v4/5 Games';}
 if($cat=='32'){echo 'Symbian S60v4/5 Apps';}
 if($cat=='31'){echo 'Blackberry';}
 if($cat=='30'){echo 'iPhone';}
 if($cat=='29'){echo 'Avatare';}
 if($cat=='28'){echo 'Manele';}
 if($cat=='21'){echo 'Serials/Keygen';}
 if($cat=='27'){echo 'Android';}
 if($cat=='26'){echo 'Linux';}
 if($cat=='25'){echo 'Flash Video (FLV)';}
 if($cat=='24'){echo 'Firmware Base';}
 if($cat=='23'){echo 'Siemens Themes';}
 if($cat=='22'){echo 'Motorola Themes';}
 if($cat=='20'){echo 'Nokia Themes';}
 if($cat=='19'){echo 'Sony Themes';}
 if($cat=='18'){echo 'Symbian S60v2 Apps';}
 if($cat=='17'){echo 'PC Misc';}
 if($cat=='16'){echo 'PC Phone Tools';}
 if($cat=='15'){echo 'Tutorials';}
 if($cat=='14'){echo 'Funny pics';}
 if($cat=='13'){echo 'Photos/Images';}
 if($cat=='12'){echo 'Symbian S60v3 Apps';}
 if($cat=='11'){echo 'Symbian S60v3 Games';}
 if($cat=='10'){echo 'Symbian S60v2 Games';}
 if($cat=='9'){echo 'Symbian UIQ';}
 if($cat=='8'){echo 'PocketPC';}
 if($cat=='7'){echo 'Windows Smartphone';}
 if($cat=='6'){echo 'Java Games';}
 if($cat=='5'){echo 'Java Applications';} 
 if($cat=='4'){echo 'Mobile Video';}
 if($cat=='3'){echo 'VideoClips';} 
 if($cat=='2'){echo 'Ringtones';} 
 if($cat=='1'){echo 'Audio';} 
 if($cat=='0'){echo 'none';} 

echo "</h2><br/><small><small>   </small></small>
</td>
<td align='right' style='text-align: right;'>
</td>
</tr>
</table>";


if(!isset($_GET['p'])){
$page = 1;
} else {
$page = $_GET['p'];
}

$max_results = 30;

$from = (($page * $max_results) - $max_results);
$sql = mysql_query("SELECT * FROM fisiere ORDER BY id desc LIMIT $from,$max_results");

// Define the number of results per page 
echo "<table width='100%'  cellspacing='0' cellpadding='4'  class='tbnail border'><tr>";

$rezultate_maxime_in_linie = 5;
$rezultate_maxime_in_jos = 6;
$from = (($page * $max_results) - $max_results); 
$result = mysql_query('SELECT * FROM `fisiere` LIMIT 30');
$totale = mysql_num_rows($result);


if($totale == 0) echo 'Nu exista intrari ...';
elseif(!isset($_GET['pagina'])) $pagina = 1;
else $pagina = $_GET['pagina'];

	$sql = mysql_query("SELECT * FROM `fisiere` WHERE categorie='$cid' ORDER by `id` DESC LIMIT ".(($page * ($rezultate_maxime_in_jos*$rezultate_maxime_in_linie)) - ($rezultate_maxime_in_jos*$rezultate_maxime_in_linie)).', '.($rezultate_maxime_in_jos*$rezultate_maxime_in_linie).' ');

	$pagini_totale = ceil($totale / ($rezultate_maxime_in_jos*$rezultate_maxime_in_linie));

	if($pagina > $pagini_totale);
	elseif($pagini_totale > 0) {

			$seteaza = 0;
			$numar = ($pagina - 1) * ($rezultate_maxime_in_jos*$rezultate_maxime_in_linie);
		
			while($rand = mysql_fetch_array($sql)) {
				$numar++;

				if($seteaza == $rezultate_maxime_in_linie) {
				echo "</tr><tr>\n";
				$seteaza = 1;
				} else $seteaza++;

$lol = substr($rand['file'],0,16);
$sz = $rand['size'];
 if ($sz<1024) {$sz="$sz bytes";}
 elseif (($sz>=1024)&&($sz<1048576)) {$sz=strtr(round($sz/1024,2),".",",")." KB";}
 elseif ($sz>=1048576) {$sz=strtr(round($sz/1024/1024,2),".",",")." MB";}

$filename = $rand['file'];
$filename=str_replace("_"," ",$filename);
$filename=str_replace("."," ",$filename);
$filename = substr($filename,0,35);
$file = $rand['file'];
$ftype = $rand['ftype'];
$pid = $rand['id'];
echo "<td width='20%'  id='". $rand["id"] ."'> ";
echo "<a href='file.php?id=". $rand["id"] ."' title='". $rand["file"] .", $sz, ". $rand["download"] ." downloads by ". $rand["user"] ."' style='height:115'>";
if(in_array($ftype,array("gif","jpg","jpeg","png")))
	  {
		echo "<img src='thumb/".$rand['file']."' align='absmiddle' />";
	   }else{
		 echo "<img src='interfata/res/". $rand["ftype"] .".gif' alt=\"thumb\" align='absmiddle' />";
		} 
echo "<br/>$filename</a><div class='hl abuseL normalfont'> $sz | <a href='report.php?id=". $rand["id"] ."' title='Report abuse/bad file' />!</a></div>
";
echo "</td>";

			}

}
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as id FROM fisiere WHERE categorie='$cid'"),0);
$total_pages = ceil($total_results / $max_results);

echo "</td></tr><tr></tr></table>
 <br/><div class='hl'>Navigation</div>
<table width='100%' cellpadding=''3'><tr><td bgcolor='#E2EDF6'>";
if($page > 1){
$prev = ($page - 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?cat=$cid&p=$prev\">&#171;Prev </a> | ";
}
if($page < $total_pages){
$next = ($page + 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?cat=$cid&p=$next\"> Next&#187;</a>";
}
$i = 1; $i <= $total_pages; $i++ ;
if ($total_pages>2)
{
echo "<br/>Jump To Page: ($page/$total_pages):
<br/>";
echo "<form action=\"cat.php?cat=$cid&\" method=\"get\">
<input type=\"text\" name=\"cat=$cid&p\" style='-wap-input-format: \"5N\"' value=\"$page\" />
<input type=\"submit\"  value=\"Dute!\"/>
</form>";
}
echo "</td></tr></table>
</div>";

}}
?>
<!-- SFARSIT CONTINUT!!! -->
</br>
</td></tr></table>
<tr>
<td width='180'>&nbsp;
</td>
<?
include ("flooter.html");
?>