<?
include('../core/core.php');
include(BASEDIR.INC.'func.php');
include(BASEDIR.INC.'session.php');
include(BASEDIR.INC.'session_user.php');
$mode = htmlspecialchars($_GET['mode']);
include(BASEDIR.INC.'head.php');
show_title('Зона обмена');
echo '<div class="razdel">Зона обмена</div>';
switch ($mode):
case 'index':
$count=(count(scandir('../obmen/files'))-3);
echo'<div class="menu"><img src="/images/zone/crown_silver_9078.png"> <a href="?mode=best">Лучшие файлы</a><br />
<img src="/images/zone/bookmarks_list_add_6465.png"> <a href="?mode=new">Новые файлы</a><br />
<img src="/images/zone/search.png"> <a href="search.php">Поиск файлов</a>';
echo'</div><div class="menu">';
echo'<img src="/images/zone/folder_green_4326.png"> <a href="?mode=applications">Приложения</a> ['.catalog('apli').']<br />
<img src="/images/zone/folder_green_4326.png"> <a href="?mode=music">Музыка</a> ['.catalog('music').']<br />
<img src="/images/zone/folder_green_4326.png"> <a href="?mode=video">Видео</a> ['.catalog('video').']<br />
<img src="/images/zone/folder_green_4326.png"> <a href="?mode=images">Изображения</a> ['.catalog('images').']<br />
<img src="/images/zone/folder_green_4326.png"> <a href="?mode=documents">Документы</a> ['.catalog('doc').']<br />
<img src="/images/zone/folder_green_4326.png"> <a href="?mode=archives">Архивы</a> ['.catalog('arhiv').']<br />
<img src="/images/zone/folder_green_4326.png"> <a href="?mode=other">Прочее</a> ['.other().']<br />
<img src="/images/zone/folder_green_4326.png"> <a href="?mode=all">Все файлы</a> ['.$count.']
</div><div class="menu">
<img src="/images/act.png"> Файлов: '.$count.'<br />
<img src="/images/act.png"> Общий вес: '.formatsize(read_dir('../obmen/files/') - 19).'<br />';
if(is_user()){ echo'<img src="/images/act.png"> <a href="upload.php">Загрузить файл</a>'; }
echo'</div>';
break;
case 'applications':
$catalog = htmlspecialchars($_GET['catalog']);
if($catalog == NULL){
echo'<div class="menu"><img src="/images/zone/crown_silver_9078.png"> <a href="?mode=best">Лучшие файлы</a><br />
<img src="/images/zone/bookmarks_list_add_6465.png"> <a href="?mode=new">Новые файлы</a><br />
<img src="/images/zone/search.png"> <a href="search.php">Поиск файлов</a>';
echo'</div><div class="menu">';
echo'<img src="/images/zone/folder_green_4326.png"> <a href="?mode=applications&catalog=java">Java</a> ['.catalog('java').']<br />
<img src="/images/zone/folder_green_4326.png"> <a href="?mode=applications&catalog=symbian">Symbian</a> ['.catalog('symbian').']<br />
<img src="/images/zone/folder_green_4326.png"> <a href="?mode=applications&catalog=android">Android</a> ['.catalog('android').']<br />
<img src="/images/zone/folder_green_4326.png"> <a href="?mode=applications&catalog=windows">Windows</a> ['.catalog('windows').']</div>';
}
if($catalog == 'java'){
define('TOPAGE',10);
$page=(int)$_GET['page'];
$q=mysql_result(mysql_query("SELECT COUNT(*) FROM `files` WHERE type='jar' OR type='jad'"),0);
$total = intval(($q - 1) / TOPAGE) + 1;
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * TOPAGE -TOPAGE;
$g=mysql_query("SELECT * FROM `files` WHERE type='jar' OR type='jad' ORDER BY `id` DESC LIMIT $start,".TOPAGE."");
while($u=mysql_fetch_array($g)){
echo'<div class="menu"><img src="/images/catalog/java.png"> '.$u['link'].''; if(is_admin(array(101,102,103))){echo'[<a href="?mode=del_file&id='.$u['id'].'">X</a>]';}echo'</div>';
}
if($q == 0){ echo'<div class="menu">В данной категории файлов нету!</div>'; }
if ($page != $total) $nextpage = '<a href="?mode=applications&catalog=java&'. ($page + 1) .'">Далее</a>';
if($page - 1 > 0) $pageback = '<a href="?mode=applications&catalog=java&'. ($page - 1) .'">Назад</a>';
echo''.$pageback.' '.$nextpage.'';
}
if($catalog == 'symbian'){
define('TOPAGE',10);
$page=(int)$_GET['page'];
$q=mysql_result(mysql_query("SELECT COUNT(*) FROM `files` WHERE type='sis' OR type='sisx'"),0);
$total = intval(($q - 1) / TOPAGE) + 1;
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * TOPAGE -TOPAGE;
$g=mysql_query("SELECT * FROM `files` WHERE type='sis' OR type='sisx' ORDER BY `id` DESC LIMIT $start,".TOPAGE."");
while($u=mysql_fetch_array($g)){
echo'<div class="menu"><img src="/images/catalog/simbian1.png"> '.$u['link'].''; if(is_admin(array(101,102,103))){echo'[<a href="?mode=del_file&id='.$u['id'].'">X</a>]';}echo'</div>';
}
if($q == 0){ echo'<div class="menu">В данной категории файлов нету!</div>'; }
if ($page != $total) $nextpage = '<a href="?mode=applications&catalog=symbian&'. ($page + 1) .'">Далее</a>';
if($page - 1 > 0) $pageback = '<a href="?mode=applications&catalog=symbian&'. ($page - 1) .'">Назад</a>';
echo''.$pageback.' '.$nextpage.'';
}
if($catalog == 'android'){
define('TOPAGE',10);
$page=(int)$_GET['page'];
$q=mysql_result(mysql_query("SELECT COUNT(*) FROM `files` WHERE type='apk'"),0);
$total = intval(($q - 1) / TOPAGE) + 1;
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * TOPAGE -TOPAGE;
$g=mysql_query("SELECT * FROM `files` WHERE type='apk' ORDER BY `id` DESC LIMIT $start,".TOPAGE."");
while($u=mysql_fetch_array($g)){
echo'<div class="menu"><img src="/images/catalog/android.png"> '.$u['link'].''; if(is_admin(array(101,102,103))){echo'[<a href="?mode=del_file&id='.$u['id'].'">X</a>]';}echo'</div>';
}
if($q == 0){ echo'<div class="menu">В данной категории файлов нету!</div>'; }
if ($page != $total) $nextpage = '<a href="?mode=applications&catalog=android&'. ($page + 1) .'">Далее</a>';
if($page - 1 > 0) $pageback = '<a href="?mode=applications&catalog=android&'. ($page - 1) .'">Назад</a>';
echo''.$pageback.' '.$nextpage.'';
}
if($catalog == 'windows'){
define('TOPAGE',10);
$page=(int)$_GET['page'];
$q=mysql_result(mysql_query("SELECT COUNT(*) FROM `files` WHERE type='exe'"),0);
$total = intval(($q - 1) / TOPAGE) + 1;
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * TOPAGE -TOPAGE;
$g=mysql_query("SELECT * FROM `files` WHERE type='exe' ORDER BY `id` DESC LIMIT $start,".TOPAGE."");
while($u=mysql_fetch_array($g)){
echo'<div class="menu"><img src="/images/catalog/windows.png"> '.$u['link'].''; if(is_admin(array(101,102,103))){echo'[<a href="?mode=del_file&id='.$u['id'].'">X</a>]';}echo'</div>';
}
if($q == 0){ echo'<div class="menu">В данной категории файлов нету!</div>'; }
if ($page != $total) $nextpage = '<a href="?mode=applications&catalog=windows&'. ($page + 1) .'">Далее</a>';
if($page - 1 > 0) $pageback = '<a href="?mode=applications&catalog=windows&'. ($page - 1) .'">Назад</a>';
echo''.$pageback.' '.$nextpage.'';
}
break;
////-------------------------//
case 'music':
define('TOPAGE',10);
$page=(int)$_GET['page'];
$q=mysql_result(mysql_query("SELECT COUNT(*) FROM `files` WHERE type='mp3' OR type='wma' OR type='flac' OR type='aac' OR type='mmf' OR type='amr' OR type='m4a' OR type='m4r' OR type='ogg' OR type='mp2' OR type='wav'"),0);
$total = intval(($q - 1) / TOPAGE) + 1;
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * TOPAGE -TOPAGE;
$g=mysql_query("SELECT * FROM `files` WHERE type='mp3' OR type='wma' OR type='flac' OR type='aac' OR type='mmf' OR type='amr' OR type='m4a' OR type='m4r' OR type='ogg' OR type='mp2' OR type='wav' ORDER BY `id` DESC LIMIT $start,".TOPAGE."");
while($u=mysql_fetch_array($g)){
echo'<div class="menu"><img src="/images/catalog/muzyka.png"> '.$u['link'].''; if(is_admin(array(101,102,103))){echo'[<a href="?mode=del_file&id='.$u['id'].'">X</a>]';}echo'</div>';
}
if($q == 0){ echo'<div class="menu">В данной категории файлов нету!</div>'; }
if ($page != $total) $nextpage = '<a href="?mode=music&'. ($page + 1) .'">Далее</a>';
if($page - 1 > 0) $pageback = '<a href="?mode=music&'. ($page - 1) .'">Назад</a>';
echo''.$pageback.' '.$nextpage.'';
break;
case 'video':
define('TOPAGE',10);
$page=(int)$_GET['page'];
$q=mysql_result(mysql_query("SELECT COUNT(*) FROM `files` WHERE type='mp4' OR type='avi' OR type='3gp' OR type='rmvb' OR type='wmv' OR type='mkv' OR type='mpg' OR type='mov' OR type='vob' OR type='flv'"),0);
$total = intval(($q - 1) / TOPAGE) + 1;
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * TOPAGE -TOPAGE;
$g=mysql_query("SELECT * FROM `files` WHERE type='mp4' OR type='avi' OR type='3gp' OR type='rmvb' OR type='wmv' OR type='mkv' OR type='mpg' OR type='mov' OR type='vob' OR type='flv' ORDER BY `id` DESC LIMIT $start,".TOPAGE."");
while($u=mysql_fetch_array($g)){
echo'<div class="menu"><img src="/images/catalog/video.png"> '.$u['link'].''; if(is_admin(array(101,102,103))){echo'[<a href="?mode=del_file&id='.$u['id'].'">X</a>]';}echo'</div>';
}
if($q == 0){ echo'<div class="menu">В данной категории файлов нету!</div>'; }
if ($page != $total) $nextpage = '<a href="?mode=video&'. ($page + 1) .'">Далее</a>';
if($page - 1 > 0) $pageback = '<a href="?mode=video&'. ($page - 1) .'">Назад</a>';
echo''.$pageback.' '.$nextpage.'';
break;
case 'images':
define('TOPAGE',10);
$page=(int)$_GET['page'];
$q=mysql_result(mysql_query("SELECT COUNT(*) FROM `files` WHERE type='jpg' OR type='jpeg' OR type='swf' OR type='png' OR type='ico' OR type='bmp' OR type='gif' OR type='tif' OR type='pcx' OR type='tga'"),0);
$total = intval(($q - 1) / TOPAGE) + 1;
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * TOPAGE -TOPAGE;
$g=mysql_query("SELECT * FROM `files` WHERE type='jpg' OR type='jpeg' OR type='swf' OR type='png' OR type='ico' OR type='bmp' OR type='gif' OR type='tif' OR type='pcx' OR type='tga' ORDER BY `id` DESC LIMIT $start,".TOPAGE."");
while($u=mysql_fetch_array($g)){
echo'<div class="menu"><img src="/images/catalog/kartinki.png"> '.$u['link'].''; if(is_admin(array(101,102,103))){echo'[<a href="?mode=del_file&id='.$u['id'].'">X</a>]';}echo'</div>';
}
if($q == 0){ echo'<div class="menu">В данной категории файлов нету!</div>'; }
if ($page != $total) $nextpage = '<a href="?mode=images&'. ($page + 1) .'">Далее</a>';
if($page - 1 > 0) $pageback = '<a href="?mode=images&'. ($page - 1) .'">Назад</a>';
echo''.$pageback.' '.$nextpage.'';
break;
case 'documents':
define('TOPAGE',10);
$page=(int)$_GET['page'];
$q=mysql_result(mysql_query("SELECT COUNT(*) FROM `files` WHERE type='txt' OR type='doc' OR type='docx' OR type='pdf'"),0);
$total = intval(($q - 1) / TOPAGE) + 1;
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * TOPAGE -TOPAGE;
$g=mysql_query("SELECT * FROM `files` WHERE type='txt' OR type='docx' OR type='doc' OR type='pdf' ORDER BY `id` DESC LIMIT $start,".TOPAGE."");
while($u=mysql_fetch_array($g)){
echo'<div class="menu"><img src="/images/catalog/dokumenty.png"> '.$u['link'].''; if(is_admin(array(101,102,103))){echo'[<a href="?mode=del_file&id='.$u['id'].'">X</a>]';}echo'</div>';
}
if($q == 0){ echo'<div class="menu">В данной категории файлов нету!</div>'; }
if ($page != $total) $nextpage = '<a href="?mode=documents&'. ($page + 1) .'">Далее</a>';
if($page - 1 > 0) $pageback = '<a href="?mode=documents&'. ($page - 1) .'">Назад</a>';
echo''.$pageback.' '.$nextpage.'';
break;
case 'archives':
define('TOPAGE',10);
$page=(int)$_GET['page'];
$q=mysql_result(mysql_query("SELECT COUNT(*) FROM `files` WHERE type='zip' OR type='7z' OR type='rar'"),0);
$total = intval(($q - 1) / TOPAGE) + 1;
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * TOPAGE -TOPAGE;
$g=mysql_query("SELECT * FROM `files` WHERE type='zip' OR type='7z' OR type='rar' ORDER BY `id` DESC LIMIT $start,".TOPAGE."");
while($u=mysql_fetch_array($g)){
echo'<div class="menu"><img src="/images/catalog/arhivy.png"> '.$u['link'].''; if(is_admin(array(101,102,103))){echo'[<a href="?mode=del_file&id='.$u['id'].'">X</a>]';}echo'</div>';
}
if($q == 0){ echo'<div class="menu">В данной категории файлов нету!</div>'; }
if ($page != $total) $nextpage = '<a href="?mode=archives&'. ($page + 1) .'">Далее</a>';
if($page - 1 > 0) $pageback = '<a href="?mode=archives&'. ($page - 1) .'">Назад</a>';
echo''.$pageback.' '.$nextpage.'';
break;
case 'other':
$file = explode(",", file_get_contents('../moduls/obmen/other.txt'));
$where = ''; // это будущее условие
$all = count($file)-1; // всего форматов
$i = 0; // счетчик
foreach($file as $value){ // разбираем масси
$value = trim($value);
if($value != ''){ // да бы не попалась пустота
$where .= "`type` = '{$value}' "; // Дополняем переменную
if($i != $all) $where .= 'OR '; // если это не последняя запись добавляем OR
}
$i++;
}
define('TOPAGE',10);
$page=(int)$_GET['page'];
$q=mysql_result(mysql_query("SELECT COUNT(*) FROM `files` WHERE $where"),0);
$total = intval(($q - 1) / TOPAGE) + 1;
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * TOPAGE -TOPAGE;
$g=mysql_query("SELECT * FROM `files` WHERE $where ORDER BY `id` DESC LIMIT $start,".TOPAGE."");
while($u=mysql_fetch_array($g)){
echo'<div class="menu"><img src="/images/catalog/prilozeenija.png"> '.$u['link'].''; if(is_admin(array(101,102,103))){echo'[<a href="?mode=del_file&id='.$u['id'].'">X</a>]';}echo'</div>';
}
if($q == 0){ echo'<div class="menu">В данной категории файлов нету!</div>'; }
if ($page != $total) $nextpage = '<a href="?mode=other&'. ($page + 1) .'">Далее</a>';
if($page - 1 > 0) $pageback = '<a href="?mode=other&'. ($page - 1) .'">Назад</a>';
echo''.$pageback.' '.$nextpage.'';
case 'all':
define('TOPAGE',10);
$page=(int)$_GET['page'];
$q=mysql_result(mysql_query("SELECT COUNT(*) FROM `files`"),0);
$total = intval(($q - 1) / TOPAGE) + 1;
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * TOPAGE -TOPAGE;
$g=mysql_query("SELECT * FROM `files` ORDER BY `id` DESC LIMIT $start,".TOPAGE."");
while($u=mysql_fetch_array($g)){
# ----------------------- #
$tf = $u['type'];
$tf = regist($tf);
if($tf == 'jar' || $tf == 'jad' || $tf == 'sis' || $tf == 'sisx' || $tf == 'apk' || $tf == 'exe' || $tf == 'mp3' || $tf == 'wma' || $tf == 'flac' || $tf == 'aac' || $tf == 'mmf' || $tf == 'amr' || $tf == 'm4a' || $tf == 'm4r' || $tf == 'ogg' || $tf == 'mp2' || $tf == 'wav' || $tf == 'mpeg' || $tf == 'mp4' || $tf == 'avi' || $tf == '3gp' || $tf == 'rmvb' || $tf == 'wmv' || $tf == 'mkv' || $tf == 'mpg' || $tf == 'mov' || $tf == 'vob' || $tf == 'flv' || $tf == 'jpg' || $tf == 'jpeg' || $tf == 'gif' || $tf == 'png' || $tf == 'txt' || $tf == 'pdf' || $tf == 'docs' || $tf == 'doc' || $tf == 'rar' || $tf == 'zip' || $tf == '7z'){
if($tf == 'jar' || $tf == 'jad'){ $img = '<img src="/images/catalog/java.png">'; }
if($tf == 'sis' || $tf == 'sisx'){ $img = '<img src="/images/catalog/simbian1.png">'; }
if($tf == 'apk'){ $img = '<img src="/images/catalog/android.png">'; }
if($tf == 'exe'){ $img = '<img src="/images/catalog/windows.png">'; }
if($tf == 'mp3' || $tf == 'wma' || $tf == 'flac' || $tf == 'aac' || $tf == 'mmf' || $tf == 'amr' || $tf == 'm4a' || $tf == 'm4r' || $tf == 'ogg' || $tf == 'mp2' || $tf == 'wav' || $tf == 'mpeg'){$img = '<img src="/images/catalog/muzyka.png">'; }
if($tf == 'mp4' || $tf == 'avi' || $tf == '3gp' || $tf == 'rmvb' || $tf == 'wmv' || $tf == 'mkv' || $tf == 'mpg' || $tf == 'mov' || $tf == 'vob' || $tf == 'flv' ){$img = '<img src="/images/catalog/video.png">'; }
if($tf == 'jpg' || $tf == 'jpeg' || $tf == 'gif' || $tf == 'png') { $img = '<img src="/images/catalog/kartinki.png">'; }
if($tf == 'txt' || $tf == 'pdf' || $tf == 'docs' || $tf == 'doc'){ $img = '<img src="/images/catalog/dokumenty.png">'; }
if($tf == 'rar' || $tf == 'zip' || $tf == '7z'){ $img = '<img src="/images/catalog/arhivy.png">'; }
} else {$img = '<img src="/images/catalog/prilozeenija.png">'; }
# ----------------------- #
echo'<div class="menu">'.$img.' '.$u['link'].''; if(is_admin(array(101,102,103))){echo'[<a href="?mode=del_file&id='.$u['id'].'">X</a>]';}echo'</div>';
}
if($q == 0){ echo'<div class="menu">В данной категории файлов нету!</div>'; }
if ($page != $total) $nextpage = '<a href="?mode=all&'. ($page + 1) .'">Далее</a>';
if($page - 1 > 0) $pageback = '<a href="?mode=all&'. ($page - 1) .'">Назад</a>';
echo''.$pageback.' '.$nextpage.'';
break;
break;
case 'new':
echo'<div class="menu">10 новых файлов!</div>';
echo'</div>';
$g=mysql_query("SELECT * FROM `files` ORDER BY `id` DESC LIMIT 10");
while($u=mysql_fetch_array($g)){
echo'<div class="menu"><img src="/images/act.png"> '.$u['link'].' </div>';
}
break;
case 'best':
echo'<div class="menu">Топ 10 файлов!';
echo'</div>';
$g=mysql_query("SELECT * FROM `files` ORDER BY `count` DESC LIMIT 10"); //
while($u=mysql_fetch_array($g)){
echo'<div class="menu"><img src="/images/act.png"> '.$u['link'].' </div>';
}
break;
default:
header ('location: ?mode=index');
endswitch;
echo'<div class="menu"><a href="/">На главную</a></div>';
include(BASEDIR.INC.'foot.php');
?>