<?
include '../config.php';
include '../func.php';

head();
aut();
ban();
////////////////////////////////////////
mysql_query("UPDATE `profile` SET `online` = 'fo' WHERE `id` = '".$id_session."'");

if ( isset($_GET['addcyes']) ) echo katalog . 'Подкаталог успешно создан' . div;

$id = num($_GET['pcat']);
$pcat = mysql_fetch_assoc(mysql_query("SELECT * FROM `fo_pcat` WHERE `id` = '".$id."'"));
$cat = mysql_fetch_assoc(mysql_query("SELECT * FROM `fo_cat` WHERE `id` = '".$pcat['cat']."'"));

if ( empty($pcat['id']) ) {
    
    echo head . "Обменник файлов / <b>NULL</b>" . div; 
    
    echo link1;
    
    echo 'Подраздел не найден';
    
    echo div;
    navig();
    foot();
    exit();
    
}

echo head . "<b>Обменник файлов / ".$cat['name']." / ".$pcat['name']."</b>" . div;   


$all = mysql_result(mysql_query("SELECT count(*) FROM fo_fil WHERE `pcat` = '".$pcat['id']."'"), 0);

if ( $all == 0 ) {
    
    echo link1 . 'Файлы еще не загружены' . div;
} else {

if($all){
$onpage = 5;
$allpage = ceil($all/$onpage);
$this_page = (isset($_GET['p'])) ? intval($_GET['p']) : 1 ;
if($this_page < 1 || $this_page > $allpage)$this_page = 1;
$start = $this_page*$onpage - $onpage;

$result = mysql_query("SELECT * FROM fo_fil WHERE `pcat` = '".$pcat['id']."' order by id desc limit ".num($start).",".num($onpage)."");
while($file = mysql_fetch_assoc($result)){

if ( $cat['tip'] == 1 ) {
    echo link2 . "<img src=\"../pict.php?file=newobmen/files/".$file['file']."\" alt=\".\" /><br/>";
} else {

if ( !empty($file['screen']) ) {
    
    echo "<img src=\"../pict.php?file=newobmen/screen/".$file['screen']."\" alt=\".\" /><br/>";
} else {
    echo link2 . 'Без скриншота<br/ >';
}

}
$f = 'files/'.$file['file'];
echo '<a href="view.php?file='.$file['id'].'">'.$file['name'].'</a> ('.size(filesize($f)).')</div>';
}

echo link1 . '<b>Страницы:</b> ';
navigation($allpage,"pcat.php?pcat=".$pcat['id']."&p={p}",1,1);
}

}




echo div;
/////////////////////////////////////////

navig();
foot();
?>