Файл: user/files/file.php
Строк: 80
<?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';
$id = intval($_GET['id']);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user_files` WHERE `id` = '$id' LIMIT 1"), 0) == 0) {
header("Location: /index.php?");
exit;
}
$file_id = mysql_fetch_array(mysql_query("SELECT * FROM `user_files` WHERE `id` = '$id' LIMIT 1"));
$set['title'] = '' . $file_id['name'] . ''; // заголовок страницы
require_once '../../sys/inc/thead.php';
aut();
$file = H . "sys/files/$file_id[id].dat";
$name = $file_id['name'];
$ras = $file_id['ras'];
echo "<div class='foot'><center><b>$file_id[name].$file_id[ras]</b></center></div>";
if (is_file("file/" . $file_id['ras'] . ".php")) {
include "file/" . $file_id['ras'] . ".php";
} else {
if ($file_id['opis'] != NULL) {
echo "<div class = 'foot'>";
echo trim(br(links($file_id['opis'])));
echo "</div>";
}
}
if ($file_id['k_loads'] == 1 || $file_id['k_loads'] >= 5 && $file_id['k_loads'] <= 21 || $file_id['k_loads'] >= 25 && $file_id['k_loads'] <= 1111111111) {
$kol = "раз";
} elseif ($file_id['k_loads'] >= 2 && $file_id['k_loads'] <= 4 || $file_id['k_loads'] >= 22 && $file_id['k_loads'] <= 24) {
$kol = "раза";
} elseif ($file_id['k_loads'] == 0) {
$kol = "раз";
}
echo "<div class='dowloads'>";
echo "<img src = '/style/icons/upload.png' /> <a href='dl.php?id=$file_id[id]'>Скачать (" . size_file($file_id['size']) . ")</a>";
echo "<br /><small> Скачано $file_id[k_loads] $kol</small></div>";
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$file_id[id_user]' LIMIT 1"));
echo "<div class='foot'>";
echo "<img src = '/style/icons/time.png' /> " . vremja($file_id['time']);
echo "</div><div class='foot'>";
echo "<img src = '/style/icons/comment_white.png' /> Комментариев: " . mysql_result(mysql_query("SELECT COUNT(*) FROM `user_files_komm` WHERE `id_file` = '$id'"), 0);
echo'</div>';
if (isset($_GET['post']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `user_files_komm` WHERE `id` = '" . intval($_GET['post']) . "'"), 0) == 1) {
if (user_access('guest_delete')) {
mysql_query("DELETE FROM `user_files_komm` WHERE `id` = '".mysql_real_escape_string($_GET[post])."'");
header("Location: file.php?id=$id" . SID);
} else {
$err[] = 'Вам не доступно удаление сообщений';
}
}
if (isset($_POST['msg']) && isset($user)) {
$msg = $_POST['msg'];
$mat = antimat($msg);
if ($mat) {
$err[] = 'В тексте сообщения обнаружен мат: ' . $mat;
}
if (utf8_strlen($msg) > 10024) {
$err = 'Сообщение слишком длинное';
} elseif (utf8_strlen($msg) < 2) {
$err = 'Короткое сообщение';
} elseif (mysql_result(mysql_query("SELECT COUNT(*) FROM `user_files_komm` WHERE `id_user` = '$user[id]' AND `text` = '" . mysql_real_escape_string($msg) . "' LIMIT 1"), 0) != 0) {
$err = 'Ваше сообщение повторяет предыдущее';
} elseif (!isset($err)) {
mysql_query("INSERT INTO `user_files_komm` (id_file, id_user, time, text) values('$id', '$user[id]', '$time', '" . mysql_real_escape_string($msg) . "')");
if ($file_id['id_user'] != $user['id']) {
$msg2 = "[b]$user[nick][/b] прокомментирова" . ($user['sex'] ? 'л' : 'ла') . " ваш [url=/user/files/file.php?id=$id]файл[/url]";
mysql_query("INSERT INTO `tape` (`id_user`, `id_kont`, `msg`, `time`) values('0', '$file_id[id_user]', '$msg2', '$time')");
}
header("Location: file.php?id=$id" . SID);
}
}
err();
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `user_files_komm` WHERE `id_file` = '$id'"), 0);
$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>";
}
$q = mysql_query("SELECT * FROM `user_files_komm` WHERE `id_file` = '$id' ORDER BY `id` DESC LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_array($q)) {
$ank = get_user($post['id_user']);
echo "<table class = 'foot'><tr><td class = 'icon14'>";
avatar($ank['id'], '48');
echo "</td><td class='null'>n";
echo user($ank['id']);
echo "<br />";
echo "<img src = '/style/icons/time.png' /> " . vremja($post['time']) . "<br />";
if (($user['group_access'] >= 7 || $user['id'] == $ank['id']) && isset($user)) {
echo "<div class = 'right' id = 'hide'>";
echo "<a href = 'file.php?id=$id&post=$post[id]' title = 'Удалить'><img src = '/style/icons/cross.png' /></a>";
echo "</div>";
}
echo output_text($post['text']) . "<br />n";
echo "</td></tr></table>n";
}
if ($k_page > 1) {
str('?id=' . $id . '&', $k_page, $page);
}
if (isset($user)) {
echo "<form method='post' class = 'foot' name='message' action='file.php?id=$id'>";
echo "Сообщение<br />";
echo text::auto_bb('message', 'msg');
echo L . "<textarea name="msg"></textarea><br />n";
echo "<button class = 'btn'>";
echo "<img src = '/style/icons/add.png' /> Добавить";
echo "</button></form>";
}
require_once '../../sys/inc/tfoot.php';