<?php
define('ROOT','../');
define('GCMS',true);
require_once (ROOT.'system/power.php');
if ($aut == true) {
if ($id) {
$type = $db -> query("SELECT `id`,`login` FROM `users` WHERE `id` = '$id'");
if ($type -> num_rows > 0) $the = $type -> fetch_assoc(); else $the = false;
} else $the = false;
if($type -> num_rows > 0){
$diz -> head("Файлы $the[login]");
require_once (ROOT.'/new_mail.php');
$count = $db -> dbcount('COUNT(`id`)','obmen_files',"`user` = '".$id."'");
$diz -> title("<a href='./'>Обменник файлов</a>/<b>Файлы $the[login] </b>($count)");
if ($count > 0) {
$num = isset($ya['num']) ? $ya['num'] : 10;
$total = intval(($count - 1) / $num) + 1; 
if (!isset($_GET['page']) || !is_numeric($_GET['page']) || $_GET['page'] < 1 )
{
$page = 1;
} elseif($_GET['page'] > $total)
{ $page = $total;
} else $page = (int)$_GET['page'];
$start = $page * $num - $num;
$for = $db -> query("SELECT * FROM `obmen_files` WHERE `user` = '".$id."' ORDER BY `dateupload` DESC LIMIT ".$start.",".$num);
while ($arr = $for -> fetch_assoc()) {
$ext = strtolower(pathinfo($arr['infolder'], PATHINFO_EXTENSION));
if ($ext == 'gif' || $ext == 'jpeg' || $ext == 'jpg' || $ext == 'png') {
$type=''.$diz -> img('obmen/img.gif').'';
}
else if ($ext == 'mp3' || $ext == 'wav') {
$type=''.$diz -> img('obmen/mp3.gif').'';
}
else if ($ext == 'jar') {
$type=''.$diz -> img('obmen/jar.png').'';
}
else if ($ext == 'txt') {
$type=''.$diz -> img('obmen/byb.gif').'';
}
else if ($ext == '3gp' || $ext == 'avi' || $ext == 'mp4' || $ext == 'flv') {
$type=''.$diz -> img('obmen/video.gif').'';
}
else if ($ext == 'rar') {
$type=''.$diz -> img('obmen/rar.png').'';
}
else if ($ext == 'zip') {
$type=''.$diz -> img('obmen/zip.png').'';
}
else {
$type=''.$diz -> img('obmen/other.gif').'';
}
$msg .= '<div class="post">'.$type.' <a href="./view/'.$arr['id'].'/">'.htmlspecialchars($arr['name']).'</a> ('.$func -> size(filesize($arr['infolder'])).')<br/>	</table></div>';
}
$act = 'my_load.php?id='.$id.'';
$msg .= ''.$func -> pagenav($act,$page,$total).'';
} else {
$msg .= '<div class="fon">У '.$the['login'].' ещё нет файлов!</div>';
}
}else{header('location: ./');}
}else {header('location: ../aut.php');}
$msg .= '<div class="levo">'.$diz -> img('home.png').'<a href="/index.php">На главную</a></div>';
#####Копирайт#######
require_once (ROOT.'system/kopy.php');
$diz -> out($msg);
?>