Файл: user/files/dir.php
Строк: 63
<?php
/*
* Файлы
* DCMS Special
* Модифицировал densnet
* Файл dir.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 "<div class = 'buttons razd'><div class = 'tiptip'>";
echo "<a href = 'upload.php?id=$dir' class = 'button' title = 'Кабинет'><span class = 'icon icon189' />Добавить файл</a>";
echo "<a href = 'edit.php?id=$dir&act=new' class = 'button' title = 'Кабинет'><span class = 'icon icon92' />Создать папку</a>";
echo "</div></div>";
}
$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 "<div class = 'razd'>";
echo "<img src = '/style/img/error.png' /> Нет результатов";
echo "</div>";
}
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 "<div class = 'razd'>";
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/img/pencil.png' /></a> ";
echo "<a href = 'edit.php?id=$post[id]&act=delete'><img src = '/style/img/delete.png' /></a>";
echo "</div>";
}
echo "<img src = '/style/img/folder.png' /> <a href = 'dir.php?id=$id&dir=$post[id]'>" . htmlentities($post['name'], ENT_QUOTES, 'UTF-8') . "</a> ($k_f)";
echo "</div>";
} else {
$post = $list[$i]['post'];
$ras = $post['ras'];
$name = $post['name'];
$size = $post['size'];
echo "<div class = 'razd'>";
if (is_file(H . 'style/img/files/' . $ras . '.png')) {
echo "<img src = '/style/img/files/$ras.png' alt = '$ras' />";
} else {
echo "<img src = '/style/img/file.png' alt = 'file' />";
}
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/img/pencil.png' /></a> ";
echo "<a href = 'edit_file.php?id=$post[id]&act=delete' title = 'Удалить'><img src = '/style/img/delete.png' /></a> ";
echo "<a href = 'edit_file.php?id=$post[id]&act=obmen' title = 'В обменник'><img src = '/style/img/arrow_undo.png' /></a>";
echo "</div>";
}
echo "</div>";
}
}
if ($k_page > 1) {
str('?', $k_page, $page);
}
require_once '../../sys/inc/tfoot.php';