Файл: CMS/core/admin/users_files.php
Строк: 113
<?php
if (!defined('CMS')) { die('Access Denied!'); }
if (is_admin(array(101, 102))) {
$uz = !empty($_REQUEST['uz']) ? check($_REQUEST['uz']) : $log;
include_once( dirname(__FILE__) . '/loads.inc.php' );
if (!empty($id)) {
$cats = $db->selectRow("SELECT * FROM ?_downs_category WHERE `cats_id` = ? LIMIT 1;", $id);
if (!empty($cats)) {
show_header('Загрузки - ' . $cats['cats_name']);
}
else {
$inSes->addMessage('Ошибка! Категория не найдена или ссылка неверна!');
redirect('?m=users_files&uz=' . $uz . '&' . RND);
}
}
else {
$cats = $db->selectRow("SELECT * FROM ?_downs_category WHERE `cats_user` = ? AND `cats_parent` = '0' LIMIT 1;", $uz);
if (!empty($cats)) {
$id = num($cats['cats_id']);
show_header('Файлы пользователя ' . nickname($uz));
}
else {
$id = (int) $db->query("INSERT INTO ?_downs_category SET `cats_name` = ?, `cats_user` = ?", 'Мои файлы', $uz);
$db->query("UPDATE ?_downs_category SET `cats_parent_all` = ? WHERE `cats_id` = ?", $id, $id);
$cats['cats_name'] = 'Файлы пользователя ' . nickname($uz);
$cats['cats_parent_all'] = $id;
show_header($cats['cats_name']);
}
}
$sub_cats = false;
if (!empty($id)) {
$subs = $db->select("SELECT * FROM ?_downs_category WHERE `cats_user` = ? AND `cats_parent` = ?;", $uz, $id);
if (!empty($subs) && count($subs) > 0 && $page == 1) {
$sub_cats = true;
foreach($subs as $sub) {
echo '<div class="b"><img src="/images/icons/folder.png" class="icon" alt="" /> ';
echo '<a href="?m=users_files&uz=' . $uz . '&id=' . $sub['cats_id'] . '">' . $sub['cats_name'] . '</a></b> (' . $sub['cats_count'] . ')</div>';
}
}
}
$onpage = !empty($config['files_num']) ? num($config['files_num']) : 10;
if ($page > 1) $from = ($page - 1) * $onpage; else $from = 0;
$rows = $db->selectPage( $total, "SELECT * FROM ?_downs
WHERE `downs_user_cat` = ? AND `downs_user` = ?
ORDER BY `downs_time` DESC
LIMIT ?d, ?d", $id, $uz, $from, $onpage );
if (!empty($rows) && $total > 0) {
echo '<div class="b">';
echo '<img src="/images/icons/folder_star.png" class="icon" alt="" /> ';
echo '<b>' . $cats['cats_name'] . '</b></div>';
foreach($rows as $row) {
$filepath = ROOTPATH . DS . $config['files_folder'] . DS . $row['downs_id'] . DS . $row['downs_link'];
$filesize = !empty($row['downs_link']) ? read_file($filepath) : 0;
$file_ext = strtolower(substr(strrchr($row['downs_link'], '.'), 1));
echo '<div class="b" style="min-height: ' . $config['preview_size'] . 'px;">';
if (in_array($file_ext, array('jpg', 'jpeg', 'gif', 'png'))) {
echo '<div class="img">';
echo resize_screen($config['files_folder'] . DS . $row['downs_id'] . DS, $row['downs_link'], $config['preview_size'], $row['downs_title']);
echo '</div>';
}
else if (!empty($row['downs_screen'])) {
echo '<div class="img">';
echo resize_screen($config['files_folder'] . DS . $row['downs_id'] . DS, $row['downs_screen'], $config['preview_size'], $row['downs_title']);
echo '</div>';
}
else {
echo '<div class="img"><img src="/images/no_photos.png" align="center" alt="" /></div>';
}
$sex = ($row['downs_user_sex'] == 1) ? ' <span style="color:red;">(+18)</span>' : '';
if ($row['downs_cats_id'] > 0) {
$zona = '<a href="/load/' . gen_uri('file', $row['downs_id'], RND) . '"><span style="color:grren">Опубликован</span></a>';
} else {
$zona = '<a href="' . gen_users($uz, 'file', $row['downs_id'], RND) . '"><span style="color:red">Не Опубликован</span></a>';
}
echo extensions($file_ext);
echo '<b><a href="' . gen_uri('file', $row['downs_id'], RND) . '">' . $row['downs_title'] . '</a></b>' . $sex;
echo '<div class="right">(' . $filesize . ')</div>';
echo '<br />';
echo format_text($row['downs_text'],0,$config['substr_text'],'UTF-8') . '...<br />' . $zona;
echo ' | <a href="?m=edit_file&id=' . $row['downs_id'] . '&' . RND . '">Редактировать</a> | ';
echo '<a href="?m=users_files&del_file=' . $row['downs_id'] . '&uz=' . $uz . '&rnd=' . $_SESSION['token'] . '">Удалить</a>';
echo '</div>';
}
echo show_pages('?m=users_files&uz=' . $uz . '&' . RND);
}
else if (!$sub_cats) {
show_error('У пользователя ещё нет файлов!');
}
echo '<div class="b">' . icon('return.png');
echo ' <a href="?m=users_files&uz=' . $uz . '&' . RND . '">Файлы ' . $uz . '</a> | ';
echo ' <a href="index.php">В админку</a><br /></div>';
}
else {
redirect('./?' . RND);
}
?>