Файл: fo/view.php
Строк: 108
<?php
require '../sid.php';
require '../config.php';
$link = connect_db();
if (!empty($_SESSION['us'])) {
list($user, $id, $ps) = check_login($link);
whorm(0, 'fo');
}
include '../head.php';
include '../navigator.php';
$do = (isset($_GET['do'])) ? $_GET['do'] : NULL;
switch($do) {
default:
$r = my_int($_GET['r']);
$test = mysql_query("SELECT * FROM `fo_cat` WHERE `id` = '$r' LIMIT 1");
$_pod = mysql_fetch_array($test);
echo $div_title . 'Зона обмена' . $div_end . $div_left .
$div_menu . '
<img src="../ico/up.gif" alt=""/> <a href="index.php?'.$ref.'">Зона обмена</a>
| <b>' . $_pod['title'] . '</b>
' . $block . '
<a href="search.php?'.$ref.'">Поиск</a><br/>
<a href="pop.php?'.$ref.'">Популярные</a> |
<a href="new.php?'.$ref.'">Новые</a>
' . $div_end;
echo (rat($user['id']) >= 100)
?
$div_menu . '<img src="/ico/z.gif" alt=""/> <a href="load.php?r='.$r.'">Загрузить файл</a>' . $div_end
:
'';
if (mysql_num_rows($test) != FALSE) {
// счетчик подразделов
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `fo_pod` WHERE `cid` = '$r'"), 0);
$n = new navigator($count, 25, '?r='.$r.'&');
$i = 0;
if ($count != FALSE) {
$view = mysql_query("SELECT `fo_pod`.*,
(SELECT COUNT(*) FROM `fo_files` WHERE `fo_files`.`rid` = '$r' AND `fo_files`.`cat` = `fo_pod`.`id` AND `fo_files`.`moder` = '0') AS c,
(SELECT COUNT(*) FROM `fo_files` WHERE `fo_files`.`rid` = '$r' AND `fo_files`.`cat` = `fo_pod`.`id` AND `fo_files`.`moder` = '0' AND `fo_files`.`time` > '" . (time() - 86400) . "') AS t,
(SELECT COUNT(*) FROM `fo_pod` WHERE `fo_pod`.`id` = `fo_pod`.`id`) AS f
FROM `fo_pod` WHERE `cid` = '$r' ORDER BY `id` ASC {$n->limit}");
while($a = mysql_fetch_assoc($view)) {
$new_file = (!empty($a['t'])) ? '<span style="color: #FF0000;">+' . $a['t'] . '</span>' : '';
//--------------------//
if ($a['formats'] == 'pictures') $f = 'gif,jpg,jpeg,jpe,png,bmp,pic,bmp,pco';
elseif ($a['formats'] == 'music') $f = 'mmf,mid,amr,mp3,wav,aac,wma,vox,dxm,imy,emy,pmd,rng';
elseif ($a['formats'] == 'video') $f = '3gp,mp4,avi,mpeg,rm,flv';
elseif ($a['formats'] == 'theme') $f = 'thm,sdt,nth,mtf,col,scs,utz';
elseif ($a['formats'] == 'game') $f = 'sis,sisx,jar,jad,apk';
elseif ($a['formats'] == 'archive') $f = 'zip,rar,tar,cab,gz';
elseif ($a['formats'] == 'flash') $f = 'swf';
elseif ($a['formats'] == 'other') $f = 'doc,docx,pdf,tsk,txt';
else $f = '';
//--------------------//
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo '<img src="../ico/dir.gif" alt=""/>
<a href="view.php?do=look&p='.$a['id'].'&r='.$a['cid'].'">' . $a['title'] . '</a> (' . $a['c'] . ') ' . $new_file . '<br/>
<small><span style="color:#0080a0;">' . $f . '</span></small> ' . $div_end;
}
echo $n->navi();
} else {
echo 'Подразделы не созданы!<br/>';
}
} else {
err('Раздела не существует!');
}
echo $div_end;
break;
case look:
$p = my_int($_GET['p']);
$r = my_int($_GET['r']);
$test_1 = mysql_query("SELECT * FROM `fo_cat` WHERE `id` = '$r' LIMIT 1");
$test_2 = mysql_query("SELECT * FROM `fo_pod` WHERE `id` = '$p' LIMIT 1");
$name_rzd = mysql_fetch_assoc($test_1);
$name_pdf = mysql_fetch_assoc($test_2);
echo $div_title . 'Зона обмена' . $div_end . $div_left .
$div_menu . '
<img src="../ico/up.gif" alt=""/> <a href="index.php?'.$ref.'">Зона обмена</a>
| <a href="view.php?r='.$name_rzd['id'].'">' . $name_rzd['title'] . '</a>
| <b>' . $name_pdf['title'] . '</b>
' . $block . '
<a href="search.php?'.$ref.'">Поиск</a><br/>
<a href="pop.php?'.$ref.'">Популярные</a> |
<a href="new.php?'.$ref.'">Новые</a><br/>' . $div_end;
if (mysql_num_rows($test_1) == FALSE) {
err('Раздела не существует!');
include '../foot.php';
exit();
}
if (mysql_num_rows($test_2) == FALSE) {
err('Подраздела не существует!');
include '../foot.php';
exit();
}
if (isset($_GET['del'])) {
if ($user['level'] != 1 && $user['level'] != 4 && $user['level'] != 5) {
header('Location: index.php?' . $ref);
die();
}
$del = my_int($_GET['del']);
$sql = mysql_query("SELECT * FROM `fo_files` WHERE `id` = '$del' LIMIT 1");
if (mysql_num_rows($sql) != FALSE) {
$info = mysql_fetch_assoc($sql);
mysql_query("DELETE FROM `fo_files` WHERE `id` = '$del' LIMIT 1");
mysql_query("DELETE FROM `fo_komm` WHERE `uid` = '$del'");
mysql_query("DELETE FROM `rating_files` WHERE `uid` = '$del'");
$game = end(explode('.', $info['url']));
// если удаляется игра
if ($game[1] == 'jar') {
// то удаляем файлы к ней
if (file_exists($game[0] . '.jad')) unlink($game[0] . '.jad');
} elseif ($game[1] == 'jad') {
if (file_exists($game[0] . '.jar')) unlink($game[0] . '.jar');
}
// если удаляется тема
if ($game[1] == 'nth') {
// то удаляем скрины к ней
if (file_exists($game[0] . '.nth.gif')) unlink($game[0] . '.nth.gif');
} elseif ($game[1] == 'thm') {
if (file_exists($game[0] . '.thm.gif')) unlink($game[0] . '.thm.gif');
}
if (file_exists($info['url'])) unlink($info['url']);
header('Location: view.php?do=look&p='.$p.'&r='.$r);
} else {
header('Location: view.php?do=look&p='.$p.'&r='.$r);
}
}
$adult = ($user['adult'] == 1) ? '' : "`xxx` = '0' AND";
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `fo_files` WHERE $adult `cat` = '$p' AND `rid` = '$r' AND `moder` = '0'"), 0);
$num_fil = (!empty($_SESSION['us'])) ? $user['onp_files'] : 15;
$n = new navigator($count, $num_fil, '?do=look&p='.$p.'&r='.$r.'&');
$i = 0;
if ($count != FALSE) {
$view = mysql_query("SELECT * FROM `fo_files` WHERE $adult `cat` = '$p' AND `rid` = '$r' AND `moder` = '0' ORDER BY `id` DESC {$n->limit}");
while($a = mysql_fetch_assoc($view)) {
$ext = strtolower(end(explode('.', $a['url'])));
#######################
if ($ext == '3gp') $format = '<img src="img/3gp.gif" alt="*"/>';
elseif ($ext == 'avi') $format = '<img src="img/avi.gif" alt="*"/>';
elseif ($ext == 'gif') $format = '<img src="img/gif.gif" alt="*"/>';
elseif ($ext == 'jpg') $format = '<img src="img/jpg.gif" alt="*"/>';
elseif ($ext == 'mp3') $format = '<img src="img/mp3.gif" alt="*"/>';
elseif ($ext == 'zip') $format = '<img src="img/zip.gif" alt="*"/>';
elseif ($ext == 'jar') $format = '<img src="img/jar.gif" alt="*"/> ';
else $format = '<img src="img/unknown.gif" alt="*"/>';
#######################
$size = filesize($a['url']);
$size = get_size($size);
if ($ext == 'jpg' || $ext == 'gif' || $ext == 'png' || $ext == 'bmp' || $ext == 'jpeg' || $ext == 'ico' || $ext == 'iso' || $ext == 'imy' || $ext == 'wbmp') $prev = '<img src="../resize.php?img=fo/'.$a['url'].'&width=40&height=0&i=0" alt="*"/>';
elseif ($ext == 'avi' || $ext == '3gp' || $ext == 'mp4' || $ext == 'flv' || $ext == 'mpeg' && extension_loaded('ffmpeg')) {
$prev = '<img src="ffmpeg.php?fid='.$a['url'].'" width="40" height="40" alt="preview"/>';
}
elseif ($ext == 'nth' || $ext == 'thm') {
$prev = '<img src="theme.php?i='.$a['id'].'" width="40" height="40" alt=""/>';
} else {
$prev = '';
}
if ($user['level'] == 1 || $user['level'] == 4 || $user['level'] == 5) {
$delete = '<a href="view.php?do=look&p='.$p.'&r='.$r.'&del='.$a['id'].'"><img src="../ico/delete.gif" alt="x"/></a> ';
}
$inf_file = (!empty($a['info'])) ? $a['info'] : 'Без описания';
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo $delete . $prev . '
<br/>
' . $format . '
<a href="info.php?i='.$a['id'].'">' . $a['title'] . '</a> (' . $size . ')
<br/>' . $inf_file . $div_end;
}
echo $n->navi();
} else {
echo 'Файлов нет!<br/>';
}
echo $div_end;
break;
}
include '../foot.php';
?>