Файл: user/files/dir.php
Строк: 71
<?php
require_once '../../sys/inc/start.php';
require_once '../../sys/inc/compress.php';
require_once '../../sys/inc/sess.php';
require_once '../../sys/inc/settings.php';
require_once '../../sys/inc/db_connect.php';
require_once '../../sys/inc/ipua.php';
require_once '../../sys/inc/fnc.php';
require_once '../../sys/inc/user.php';
$set['title'] = 'Файлы';
require_once '../../sys/inc/thead.php';
aut();
if (isset($_GET['id'])) {
$id = intval($_GET['id']);
} else {
$id = $user['id'];
}
if (isset($_GET['dir'])) {
$dir = intval($_GET['dir']);
}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user_dir` WHERE `id` = '$dir' AND `id_user` = '$id' LIMIT 1"), 0) == 0) {
header("Location: /index.php?");
exit;
}
if ($id == $user['id']) {
echo "<a href='upload.php?id=$dir'><div class='foot'><img src='/style/icons/folder-import.png' /> Добавить файл</div></a>";
echo "<a href='edit.php?id=$dir&act=new'><div class='foot'><img src='/style/icons/folder--plus.png' /> Создать папку</div></a>";
}
$q = mysql_query("SELECT * FROM `user_dir` WHERE `id_user` = '$id' AND `dir` = '$dir' ORDER BY `name` ASC");
while ($post = mysql_fetch_array($q)) {
$set['p_str'] = 15;
$list[] = array('dir' => 1, 'post' => $post);
}
$q = mysql_query("SELECT * FROM `user_files` WHERE `dir` = '$dir' ORDER BY `time` DESC");
while ($post = mysql_fetch_array($q)) {
$set['p_str'] = 8;
$list[] = array('dir' => 0, 'post' => $post);
}
$k_post = @sizeof($list);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
if ($k_post == 0) {
echo "<table class = 'foot'><tr><td class = 'null'>";
echo "<img src = '/style/icons/bullet_error.png' /> Папка пуста";
echo "</td></tr></table>";
}
for ($i = $start; $i < $k_post && $i < $set['p_str'] * $page; $i++) {
if ($list[$i]['dir'] == 1) {
$post = $list[$i]['post'];
$k_f = 0;
$q3 = mysql_query("SELECT * FROM `user_dir` WHERE `dir` = '$post[id]'");
while ($post2 = mysql_fetch_array($q3)) {
$k_f = $k_f + mysql_result(mysql_query("SELECT COUNT(*) FROM `user_files` WHERE `dir` = '$post2[id]'"), 0);
}
$k_f = $k_f + mysql_result(mysql_query("SELECT COUNT(*) FROM `user_files` WHERE `dir` = '$post[id]'"), 0);
echo "<table class = 'foot'><tr><td class = 'null'>";
if ($post['id_user'] == $user['id']) {
echo "<div class = 'right' id = 'hide'>";
echo "<a href='edit.php?id=$post[id]&act=rename'><img src='/style/icons/pencil.png' /></a> ";
echo "<a href='edit.php?id=$post[id]&act=delete'><img src='/style/icons/cross.png' /></a>";
echo "</div>";
}
echo'<img src="img/folder_open.png" alt=""/> <a href="dir.php?id=' . $id . '&dir=' . $post['id'] . '">' . htmlentities($post['name'], ENT_QUOTES, 'UTF-8') . '</a> (' . $k_f . ')';
echo "</td></tr></table>";
} else {
$post = $list[$i]['post'];
$ras = $post['ras'];
$name = $post['name'];
$size = $post['size'];
echo "<table class = 'foot'><tr><td class = 'null'>";
if (is_file(H . 'style/icons/files/' . $ras . '.png')) {
echo "<img src='/style/icons/files/$ras.png' alt='$ras' />n";
} else {
echo "<img src='/style/icons/file.png' alt='file' />n";
}
echo "<a href='file.php?id=" . $post['id'] . "'>$post[name]</a> (" . size_file($size) . ")";
if ($post['id_user'] == $user['id']) {
echo "<div class = 'right' id = 'hide'>";
echo "<a href='edit_file.php?id=$post[id]&act=rename' title = 'Изменить'><img src='/style/icons/pencil.png' /></a> ";
echo "<a href='edit_file.php?id=$post[id]&act=delete' title = 'Удалить'><img src='/style/icons/cross.png' /></a> ";
echo "<a href='edit_file.php?id=$post[id]&act=obmen' title = 'В обменник'><img src='/style/icons/zona.png' /></a>";
echo "</div>";
}
echo "</td></tr></table>";
}
}
if ($k_page > 1) {
str('?', $k_page, $page);
}
require_once '../../sys/inc/tfoot.php';