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

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

if ( isset($_GET['upload']) ) echo katalog . 'Файл загружен' . div;

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


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


echo link2;

echo 'Файл: <b>'.$file['name'].'</b><br/ >';


if ( $cat['tip'] == 1 ) {
    echo "<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 null;
}

}


echo div . link2 . 'Описание: <b>'.$file['info'].'</b><br/ >';
echo 'Загрузил(а): <b>'.user($file['user']).'</b><br/ >';

$f = 'files/'.$file['file'];
echo 'Размер: <b>'.size(filesize($f)).'</b><br/ >';

if ( $cat['tip'] == 1 ) {
    
    $razr = getimagesize("files/".$file['file']."");
    echo 'Разрешение: <b>'.$razr['0'].'x'.$razr['1'].'</b><br/ >';
    
}

if ( $cat['tip'] == 2 ) {

    echo '<object type="application/x-shockwave-flash" data="../mp3/dewplayer-rect.swf" width="240" height="20" id="dewplayermultirect" name="dewplayermultirect">
					<param name="movie" value="dewplayer-rect.swf" />
					<param name="flashvars" value="mp3=http://'.$_SERVER['HTTP_HOST'].'/newobmen/files/'.html($file['file']).'" /></object><br/ >';
    
}

if (empty($file['downs'])) $file['downs'] = '0';
echo '<a href="down.php?file='.$file['id'].'">Скачать</a> [Скачиваний: '.$file['downs'].']<br/ >';
echo '<a href="usfiles.php?user='.$file['user'].'">Все файлы '.user($file['user']).'</a><br/ ><br/>';

if ($file['user'] == $id_session OR $level_session >= 3) {
    echo '<a href="userf.php?file='.$file['id'].'&mod=edit">Редактировать</a><br/ >';
    echo '<a href="userf.php?file='.$file['id'].'&mod=del">Удалить</a><br/ >';
}
// предыдущий/следующий файл

    $count = mysql_result(mysql_query('SELECT COUNT(*) FROM `fo_fil` WHERE `cat` = "' . $cat['id'] . '" AND `pcat` = "'.$pcat['id'].'"'), 0);
   
    if ($count > 1) {
        $next = mysql_fetch_row(mysql_query("SELECT MIN(`id`), COUNT(`id`) FROM `fo_fil` WHERE `cat` = '" . $cat['id'] . "' AND `pcat` = '".$pcat['id']."' AND `id` > '" . $id . "'"));
    
        $prev = mysql_fetch_row(mysql_query('SELECT MIN(`id`), COUNT(`id`) FROM `fo_fil` WHERE `cat` = "' . $cat['id'] . '" AND `pcat` = "'.$pcat['id'].'" AND `id` < ' . $id . ' '));
    
        
       
        
                if ($prev[0]) {
           echo div . link1 . '[' . $prev[1] . '] <a href="view.php?file=' . $prev[0] . '"> << Предыдущий</a>';
        }
        
        echo ' ['.$file['name'].'] ';
        
        if ($next[0]) {
            echo '<a href="view.php?file=' . $next[0] . '">Следующий >> </a> [' . $next[1] . ']' . div;
        }
        
        
        
       
        
        
        
    }



        

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

navig();
foot();
?>