<?
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_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'].''; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
aut(); // форма авторизации
$file=H."files/user_files/$file_id[id].dat";
$name=$file_id['name'];
$ras=$file_id['ras'];
echo'<div class="p_m"><center><b>'.$file_id['name'].'.'.$file_id['ras'].'</b></center></div>';
echo '<div class="pa">';
if(is_file("file/".$file_id['ras'].".php")){include "file/".$file_id['ras'].".php";
echo '</div>';
}else{
if ($file_id['opis']!=NULL){
echo '<div class="pa">';
echo trim(br(links($file_id['opis'])));
echo "</div>";}
}
echo "<div class='pa'><img src='img/download.png' alt='' /> <a href='dl.php?id=".$file_id['id']."'>Скачать (".size_file($file_id['size']).")</a></div>";
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$file_id[id_user]' LIMIT 1"));
echo "<div class='p_m'>";
echo'<b>Закачек:</b> '.$file_id['k_loads'].'<br/>';
echo "<b>Добавил:</b> <a href='/info.php?id=$ank[id]'>".GradientText("$ank[nick]", "$ank[ncolor]", "$ank[ncolor2]")."</a> ";
echo "".online($ank['id'])." (".vremja($file_id['time']).")<br />\n";
echo'</div>';
### Комментарии к файлам
echo'<div class="p_m">';
echo'Комментариев: '.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` = '$_GET[post]'");
msg('Сообщение успешно удалено!');
}else{
$err[]='Вам не доступно удаление сообщений';
}
}
if (isset($_POST['msg']) && isset($user)){
$msg=$_POST['msg'];
if (isset($_POST['translit']) && $_POST['translit']==1)$msg=translit($msg);
$mat=antimat($msg);
if ($mat)$err[]='В тексте сообщения обнаружен мат: '.$mat;
if (strlen2($msg)>1024){$err='Сообщение слишком длинное';}
elseif (strlen2($msg)<2){$err='Короткое сообщение';}
elseif (mysql_result(mysql_query("SELECT COUNT(*) FROM `user_files_komm` WHERE `id_user` = '$user[id]' AND `msg` = '".my_esc($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', '".my_esc($msg)."')");
if($file_id['id_user']!=$user['id']){
$msg2="[b]$user[nick][/b] прокомментировал ваш [url=/file/file.php?id=$id]файл[/url]";
mysql_query("INSERT INTO `lenta` (`id_user`, `id_kont`, `msg`, `time`) values('0', '$file_id[id_user]', '$msg2', '$time')");
}
msg('Сообщение успешно добавлено');
}
}
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'];
echo "<table class='post'>\n";
if ($k_post==0){
echo "   <tr>\n";
echo "  <td class='p_t'>\n";
echo "Оставь первый комментарий!\n";
echo "  </td>\n";
echo "   </tr>\n";
}
$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 "   <tr>\n";
if ($set['set_show_icon']==2){
echo "  <td class='icon48' rowspan='2'>\n";
avatar($ank['id']);
echo "  </td>\n";
}
elseif ($set['set_show_icon']==1){
echo "  <td class='icon14'>\n";
echo "<img src='/style/themes/$set[set_them]/user/$ank[pol].png' alt='' />";
echo "  </td>\n";}
echo " <td class='p_t'>\n";
echo "<a href='/info.php?id=$ank[id]'>".GradientText("$ank[nick]", "$ank[ncolor]", "$ank[ncolor2]")."</a>".online($ank['id'])." (".vremja($post['time']).")";
echo "  </td>\n";
echo "   </tr>\n";
echo "   <tr>\n";
if ($set['set_show_icon']==1)echo "  <td class='p_m' colspan='2'>\n"; else echo "  <td class='p_m'>\n";
echo output_text($post['text'])."<br />\n";
if (user_access('guest_delete'))
echo "<a href='file.php?id=$id&amp;post=$post[id]'>Удалить</a><br />\n";
echo "  </td>\n";
echo "   </tr>\n";
}
echo "</table>\n";
if ($k_page>1)str('?id='.$id.'&',$k_page,$page); // Вывод страниц
if (isset($user)){
echo '<form method="post" name="message" action="file.php?id='.$id.'">';
if ($set['web'] && is_file(H.'style/themes/'.$set['set_them'].'/altername_post_form.php'))
include_once H.'style/themes/'.$set['set_them'].'/altername_post_form.php';
else
include_once '../panel_bb/bb.php';
echo "<textarea name=\"msg\"></textarea><br />\n";
echo "<input value=\"Отправить\" type=\"submit\" />\n";
echo "</form>\n";
}
include_once '../sys/inc/tfoot.php';
?>