Файл: fo/view.php
Строк: 95
<?php
require '../system/sid.php';
require '../system/config.php';
if (!empty($_SESSION['us']))
{
include '../system/user.php';
whorm(0, 'fo');
}
include '../system/head.php';
include '../system/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_menu . '
<img src="../ico/up.gif" alt=""/> <a href="index.php">Обменник</a>
| <b>' . $_pod['title'] . '</b>
' . $block . '
<a href="search.php?">Поиск</a><br/>
<a href="pop.php?">Популярные</a> |
<a href="new.php?">Новые</a>
' . $div_end;
if (isset($_SESSION['us'])) echo $div_menu . '<img src="/ico/z.gif" alt=""/> <a href="load-'.$r.'">Загрузить файл</a>' . $div_end;
if (mysql_num_rows($test) != FALSE) {
// счетчик подразделов
$count = mysql_result(mysql_query("SELECT COUNT(id) FROM `fo_pod` WHERE `cid` = '$r'"), 0);
$n = new navigator($count, 10, '?r='.$r.'&');
$i = 0;
if ($count != FALSE) {
$view = mysql_query("SELECT `fo_pod`.*,
(SELECT COUNT(id) FROM `fo_files` WHERE `fo_files`.`rid` = '$r' AND `fo_files`.`cat` = `fo_pod`.`id` AND `fo_files`.`moder` = '0') AS c,
(SELECT COUNT(id) 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(id) 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>' : '';
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo '<img src="../ico/dir.gif" alt=""/>
<a href="p-look-'.$a['id'].'-'.$a['cid'].'">' . $a['title'] . '</a> (' . $a['c'] . ') ' . $new_file . $div_end;
}
echo $n->navi();
} else {
echo 'Подразделы не созданы!<br/>';
}
} else {
err('Раздела не существует!');
}
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_menu . '
<img src="../ico/up.gif" alt=""/> <a href="index.php?">Обменник</a>
| <a href="view.php?r='.$name_rzd['id'].'">' . $name_rzd['title'] . '</a>
| <b>' . $name_pdf['title'] . '</b>
' . $block . '
<a href="search.php?">Поиск</a><br/>
<a href="pop.php?">Популярные</a> |
<a href="new.php?">Новые</a><br/>' . $div_end;
if (mysql_num_rows($test_1) == FALSE) {
err('Раздела не существует!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($test_2) == FALSE) {
err('Подраздела не существует!');
include '../system/foot.php';
exit();
}
if (isset($_GET['del']))
{
if ($user['level'] != 4 && $user['level'] != 5) {
header('Location: index.php?');
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);
$SizeF = filesize($info['url']);
$TXT = '<small>(' . date('d-m-y в H:i:s') . ')</small><br/>' . elite($user['id']) . ' ' . $user['user'] . ' удалил файл <b>' . $info['title'] . '</b> из обменника.';
mysql_query("INSERT INTO admin_logs SET text = '$TXT'");
mysql_query("DELETE FROM `fo_komm` WHERE `uid` = '$del'");
mysql_query("DELETE FROM `rating_files` WHERE `uid` = '$del'");
mysql_query("UPDATE `users` SET `fo_size` = '" . (minus(user_inf($info['author'], 'fo_size') - $SizeF)) . "' WHERE id = '$info[author]' LIMIT 1");
if (file_exists($info['url'])) unlink($info['url']);
if (file_exists($info['screen'])) unlink($info['screen']);
mysql_query("DELETE FROM `fo_files` WHERE `id` = '$del' LIMIT 1");
header('Location: p-look-'.$p.'-'.$r);
} else {
header('Location: p-look-'.$p.'-'.$r);
}
}
$count = mysql_result(mysql_query("SELECT COUNT(id) FROM `fo_files` WHERE `cat` = '$p' AND `rid` = '$r' AND `moder` = '0'"), 0);
$n = new navigator($count, 10, 'p-look-'.$p.'-'.$r.'&');
$i = 0;
if ($count != FALSE) {
$view = mysql_query("SELECT * FROM `fo_files` WHERE `cat` = '$p' AND `rid` = '$r' AND `moder` = '0' ORDER BY `id` DESC {$n->limit}");
while($a = mysql_fetch_assoc($view)) {
$ext = strtolower(strrchr($a['url'], '.'));
if ($ext == '.zip') $format = '<img src="img/zip.gif" alt="*"/> ';
elseif ($ext == '.rar') $format = '<img src="img/rar.gif" alt="*"/> ';
elseif ($ext == '.gz') $format = '<img src="img/gz.gif" alt="*"/> ';
elseif ($ext == '.tar') $format = '<img src="img/tar.gif" alt="*"/> ';
else $format = '<img src="img/unknown.gif" alt="*"/> ';
#######################
$size = filesize($a['url']);
$size = get_size($size);
if ($user['level'] == 4 || $user['level'] == 5) {
$delete = '<a href="delfile-look-'.$p.'-'.$r.'-'.$a['id'].'"><img src="../ico/delete.png" alt="x"/></a> ';
}
$inf_file = (!empty($a['info'])) ? $a['info'] : 'Без описания';
$cont = (mb_strlen($inf_file, 'UTF8') > 100)
? mb_substr($inf_file, 0, 100, 'UTF8') . '...'
: $inf_file;
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo $delete . ' ' . $format . '
<a href="info-'.$a['id'].'">' . $a['title'] . '</a> (' . $size . ')
<br/>' . bb_code($cont) . $div_end;
}
echo $n->navi();
} else {
echo 'Файлов нет!<br/>';
}
break;
}
include '../system/foot.php';
?>