Файл: pages/load/index.php
Строк: 44
<?
include '../../system/mysql.php';
include '../../system/sys_func.php';
$dir['id'] = '0';
$dir['name'] = 'Загрузки';
$dir['id_dir'] = '0';
$dir['files'] = '0';
if (isset($_GET['dir'])) {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `load_dir` WHERE `id` = '". intval($_GET['dir']) ."'"), 0) > 0) {
$dir = mysql_fetch_assoc(mysql_query("SELECT * FROM `load_dir` WHERE `id` = '". intval($_GET['dir']) ."' LIMIT 1"));
}
}
$title = $dir['name'];
include '../../system/head.php';
if (isset($dir['url'])) $url = explode('/', $dir['url']);
echo '<div class="title">';
if ($dir['id'] != 0) {
foreach($url as $num => $id) {
if($id != 0) {
$cat = mysql_fetch_assoc(mysql_query("SELECT * FROM `load_dir` WHERE `id` = '". $id ."' LIMIT 1"));
} else {
$cat['id'] = '0';
$cat['name'] = 'Загрузки';
}
if($cat['id'] != 0)
echo ' / ';
echo "<a href='?dir=". $cat['id'] ."'>". $cat['name'] ."</a>";
}
echo ' / '. html($dir['name']);
} else {
echo 'Загрузки';
}
echo '</div>';
if ($dir['files'] == 0) {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `load_dir` WHERE `id_dir` = '". $dir['id'] ."'"), 0) == 0) {
echo '<div class="post">Нет папок</div>';
}
$query = mysql_query("SELECT * FROM `load_dir` WHERE `id_dir` = '". $dir['id'] ."' ORDER BY `id` ASC");
while ($folder = mysql_fetch_assoc($query)) {
echo '<a class="link" href="?dir='. $folder['id'] .'">
<img src="/design/imgs/forum_f.png"/> '. html($folder['name']) .' ('. mysql_result(mysql_query("SELECT COUNT(*) FROM `load_file` WHERE `url` like '%". $folder['id'] ."%'"), 0) .')
</a>';
}
if ($user['position'] == 'admin') {
echo '<a class="link" href="admin.php?act=add_dir&id='. $dir['id'] .'"><img src="/design/imgs/add.png"/> Добавить папку</a>';
if ($dir['id'] != 0) echo '<a class="link" href="admin.php?act=del_dir&id='. $dir['id'] .'"><img src="/design/imgs/delete.png"> Удалить текущую папку</a>';
}
if ($dir['id'] != 0) {
echo '<a class="link" href="?dir='. $dir['id_dir'] .'">← Назад</a>';
}
}
if ($dir['files'] != 0) {
$c_p = mysql_result(mysql_query("SELECT COUNT(*) FROM `load_file` WHERE `id_dir` = '". $dir['id'] ."'"),0);
$k_page = k_page($c_p, 10);
$page = page($k_page);
$start = 10*$page-10;
if($c_p == 0) {
echo '<div class="post">Нет файлов</div>';
}
$query = mysql_query("SELECT * FROM `load_file` WHERE `id_dir` = '". $dir['id'] ."' ORDER BY `id` DESC LIMIT $start, 10");
while ($file = mysql_fetch_assoc($query)) {
echo '<a class="link" href="file.php?id='. $file['id'] .'">
<span class="c_date">'. ptime($file['time']) .'</span>
<img src="/design/imgs/file.png"/> '. html($file['name']).$file['ext'] .'
</a>';
}
if($k_page > 1) str('?dir='. $dir['id'] .'&', $k_page, $page);
if (isset($user)) echo '<a class="link" href="upload.php?id='. $dir['id'] .'"><img src="/design/imgs/add.png"/> Добавить файл</a>';
if ($dir['id'] != 0 && $user['position'] == 'admin') echo '<a class="link" href="admin.php?act=del_dir&id='. $dir['id'] .'"><img src="/design/imgs/delete.png"> Удалить текущую папку</a>';
if($dir['id'] != 0) {
echo '<a class="link" href="?dir='. $dir['id_dir'] .'">← Назад</a>';
}
}
foot();
?>