<?
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']);
$d = intval($_GET['dir']);
if (isset($_GET['dir']) && $_GET['dir']!=NULL && isset($_GET['id']) && $_GET['id']!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `comm` WHERE `id` = '".intval($_GET['id'])."'"),0)!=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `comm_obmen` WHERE `id_comm` = '$ID' AND `id` = '$d' AND `type` = '0'"),0)!=0){	
$comm = get_comm($ID);
$moder = mysql_result(mysql_query("SELECT COUNT(*) FROM `comm_user` WHERE `id_user` = '".intval($user['id'])."' AND `id_comm` = '$ID' AND `level` > '0'"),0);
$commuser = mysql_result(mysql_query("SELECT COUNT(*) FROM `comm_user` WHERE `id_user` = '".intval($user['id'])."' AND `id_comm` = '$ID'"),0);
$dir = mysql_fetch_array(mysql_query("SELECT * FROM `comm_obmen` WHERE `id_comm` = '$ID' AND `id` = '$d' AND `type` = '0'"));
$set['title']='Файлы сообщества '.text($comm['name']).' - '.text($dir['name']).''; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
aut();
//======================Начало приватности сообщества===============================//
	if(isset($user) && mysql_result(mysql_query("SELECT COUNT(*) FROM `comm_blacklist` WHERE `id_user` = '$user[id]' AND `id_comm` = '$comm[id]' && (`time_ban` > '$time' OR `navsegda` = '1')"),0)!=0){
	echo'<div class="mess">Вы были забанены ';
	$banned = mysql_fetch_array(mysql_query("SELECT * FROM `comm_blacklist` WHERE `id_user` = '$user[id]' AND `id_comm` = '$comm[id]'"));
	$bancon = mysql_fetch_array(mysql_query("SELECT * FROM `comm_user` WHERE `id_user` = '$banned[id_ban]' AND `id_comm` = '$comm[id]'"));
	if($bancon['level']==1){
		echo 'модератором ';
	}elseif($bancon['level']==2){
		echo 'администратором ';
	}elseif($bancon['level']==3){
		echo 'создателем ';
	}
	echo group($bancon['id_user']);
	echo user::nick($bancon['id_user'],1,1,1);
	if($banned['navsegda']==1){
		echo' навсегда!';
	}else{
		$timefe = $banned['time_ban']-$banned['time'];
		echo ' на ';
		if($timefe>3600){
			$timef = $timefe/3600;
			$timefe = floor($timef);
			
			$timem = $timef-$timefe;
			if($timem==0){
			echo''.$timefe.' часов!';
			}else{
				$timem = round($timem*60);
				echo''.$timefe.' часов '.$timem.' минут!';
			}
		}elseif($timefe<3600){
			$timef = $timefe/60;
			$timefe = round($timef);
			echo''.$timefe.' минут!';
		}
		echo ' <small>';
		echo vremja($banned['time']);
		echo '</small>';
	}
		echo "</div><div class='foot'><img src='/style/icons/str2.gif' alt=''/> <a href='/comm/cat.php?id=$comm[id_category]'>Назад в категорию</a></div>"; 
		include_once '../sys/inc/tfoot.php';
		exit;
	}
	//===========================================//
	if($comm['close']==1 && mysql_result(mysql_query("SELECT COUNT(*) FROM `comm_user` WHERE `id_comm` = '".intval($comm['id'])."' AND `id_user` = '$user[id]'"),0)==0){
		echo'<div class="mess">Сообщество закрыто для чтения!</div>';
		echo "<div class='foot'><img src='/style/icons/str2.gif' alt=''/> <a href='/comm/$comm[id]/'>В сообщество</a></div>";
		include_once '../sys/inc/tfoot.php';
		exit;
	}
	//================Конец приватности сообщества=====================//

	echo "<div class='foot'>";
echo "<img src='/style/icons/up_dir.gif' alt='*'> ".($dir['osn']==1?'Файлы':'')." ".comm_files($dir['id_dires'],$comm['id'])." ".($dir['osn']==1?'':'&gt; '.text($dir['name']))."\n";
echo "</div>";
//============================================================//
if (isset($user) && isset($_GET['delfile']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `comm_obmen` WHERE `id_object` = '".intval($_GET['delfile'])."' AND `type` = '1' AND `id_comm` = '$comm[id]' AND `id_dir` = '$dir[id]'"),0)!=0 && ($moder!=0 || mysql_result(mysql_query("SELECT COUNT(*) FROM `obmennik_files` WHERE `id_user` = '$user[id]' AND `id` = '".intval($_GET['delfile'])."'"),0)!=0)){
	$idfile = intval($_GET['delfile']);
	$files = mysql_fetch_array(mysql_query("SELECT * FROM `obmennik_files`  WHERE `id` = '$idfile'"));
	mysql_query("DELETE FROM `comm_obmen` WHERE `id_object` = '".intval($_GET['delfile'])."' AND `type` = '1' AND `id_comm` = '$comm[id]' AND `id_dir` = '$dir[id]' LIMIT 1");
	$_SESSION['message'] = 'Файл '.$files['name'].' успешно удален из сообщества '.$comm['name'].'!';
	header('Location: ?');
	exit;
}
//===========================================================//
if ($commuser!=0 && isset($user) && $dir['upload']==1 && isset($_GET['trans']) && $_GET['trans']!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `obmennik_files` WHERE `id_user` = '$user[id]' AND `id` = '".intval($_GET['trans'])."'"),0)!=0){
	$idfile = intval($_GET['trans']);
	$file=mysql_fetch_array(mysql_query("SELECT * FROM `obmennik_files`  WHERE `id_user` = '$user[id]' AND `id` = '$idfile'"));
	if (mysql_result(mysql_query("SELECT COUNT(*) FROM `comm_obmen` WHERE `size` = '$file[size]' AND `id_comm` = '$comm[id]'"),0)>0)$err = 'Такой файл уже есть в сообществе';
if ($dir['upload']==1){
$ras=$file['ras'];
$rasss=explode(';', $dir['ras']);
$ras_ok=false;
for($i=0;$i<count($rasss);$i++)
{
	if ($rasss[$i]!=NULL && $ras==$rasss[$i])$ras_ok=true;
}

if (!$ras_ok)$err='Неверное расширение файла';
if ($file['size'] > $dir['max_size'])$err='Размер файла превышает допустимый размер';
	if (!$err)
	{
	if ($dir['id_dires']=='/')
	$id_dires = $dir['id_dires'] . $dir['id'].'/';
	else
	$id_dires = $dir['id_dires'] . $dir['id'].'/';
	
	$upload = $dir['upload'];
	$name = $dir['name'];
	mysql_query("INSERT INTO `comm_obmen` (`id_object` , `id_dir` , `ras` , `size` , `id_dires`, `upload`, `name`, `id_comm`, `time`, `type`) 
	VALUES ('".intval($file['id'])."', '".intval($d)."', '$ras', '$file[size]', '$id_dires', '$upload', '$name','$comm[id]','$time','1')");
	$fileidd = mysql_insert_id();
	//====================Рейтинг и лента===========================//
		$rating = $comm['rating_tmp']+1;
		mysql_query("UPDATE `comm` SET `rating_tmp` = '$rating' WHERE `id` = '$comm[id]' LIMIT 1");
		$user_lenta=mysql_query("SELECT * FROM `comm_user` WHERE `id_comm` = '$comm[id]'");
		while($posts = mysql_fetch_assoc($user_lenta))
		{
		if($posts['id_user']!=$user['id']){
		mysql_query("INSERT INTO `comm_lenta` (`id_object` , `id_comm` , `id_user` , `type` , `time`) 
		VALUES ('".intval($fileidd)."', '".intval($comm['id'])."', '$posts[id_user]', 'obmen', '$time')");
		}
		}
	//==================The End====================================//
	$_SESSION['message'] = 'Файл '.$file['name'].' успешно добавлен в папку '.$dir['name'].' сообщества '.$comm['name'].'';
	header('Location: ?');
	exit;
	}else{
	$_SESSION['message'] = $err;
	header('Location: ?');
	exit;
	}
}else{
echo "<div class='err'>Ошибка! Эта папка не доступна!</div>";
exit;
}
}
	//=================================================================//
	if ($commuser!=0 && isset($user) && $dir['upload']==1 && isset($_GET['act']) && $_GET['act']=='file'){
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `obmennik_files` WHERE `id_user` = '$user[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 '<div class="mess">';
echo "У вас нет файлов!\n";
echo "  </div>\n";
}
//======================================//
$q2=mysql_query("SELECT * FROM `obmennik_files`  WHERE `id_user` = '$user[id]' ORDER BY time DESC LIMIT $start, $set[p_str]");
//echo "<form method='post' action='?move_file'>";

while ($post = mysql_fetch_assoc($q2))
{
$k_p=mysql_result(mysql_query("SELECT COUNT(*) FROM `obmennik_komm` WHERE `id_file` = '$post[id]'"),0);
$dir_id=mysql_fetch_assoc(mysql_query("SELECT * FROM `obmennik_dir` WHERE `id` = '$post[id_dir]' LIMIT 1"));
$ras=$post['ras'];
$file=H."sys/obmen/files/$post[id].dat";
$name=$post['name'];
$size=$post['size'];
/*-----------зебра-----------*/ 
if ($num==0){
echo '<div class="nav1">';
$num=1;
}
elseif ($num==1){
echo '<div class="nav2">';
$num=0;}
/*---------------------------*/
if (is_file(H."obmen/inc/icon48/$ras.php"))
{
include H."obmen/inc/icon48/$ras.php";
}

//echo "<input type='checkbox' name='files_$post[id]' value='1' /> ";

if (is_file(H.'style/themes/'.$set['set_them'].'/loads/14/'.$ras.'.png'))
echo "<img src='/style/themes/$set[set_them]/loads/14/$ras.png' alt='$ras' /> \n";
else 
echo "<img src='/style/themes/$set[set_them]/loads/14/file.png' alt='file' /> \n";

if ($set['echo_rassh']==1)$ras=$post['ras'];else $ras=NULL;

echo '<a href="/user/personalfiles/'.$post['id_user'].'/'.$post['my_dir'].'/?id_file='.$post['id'].'&amp;page='.$page.'"><b>'.text($post['name']).'.'.$ras.'</b></a> ('.size_file($post['size']).') ';
if ($post['metka'] == 1)echo ' <font color=red>(18+)</font>';
if ($user['id']==$post['id_user'] && mysql_result(mysql_query("SELECT COUNT(*) FROM `comm_obmen` WHERE `id_object` = '".intval($post['id'])."' AND `id_comm` = '$comm[id]'"),0)==0)echo '<a href="?trans='.$post['id'].'"><img src="/style/icons/z.gif" alt="*"> в сообщество</a> ';
echo '<br />';
	if ($post['opis']){
	echo rez_text(text($post['opis'])).'<br />';
	}
echo '<a href="/user/personalfiles/'.$post['id_user'].'/'.$post['my_dir'].'/?id_file='.$post['id'].'&amp;page='.$page.'&amp;komm">Комментарии</a> ('.$k_p.')<br />';
echo '</div>';
}
if ($k_page>1)str('?act=file&',$k_page,$page); // Вывод страниц
//======================================//	
if($dir['ras']!=NULL){
 echo"<div class='main'>*Разрешается добавлять файлы форматов: ";
	 
$i5=explode(';', $dir['ras']);
for ($i = 0; $i < count($i5); $i++) 
{
echo $i5[$i].', ';
}
echo" размером до ".size_file($dir['max_size']).".</div>";
}
echo "<div class='foot'><img src='/style/icons/up_dir.gif' alt='*'> ".($dir['osn']==1?'Файлы':'')." ".comm_files($dir['id_dires'],$comm['id'])." ".($dir['osn']==1?'':'&gt; '.text($dir['name']))."\n";
echo "</div>";
	echo "<div class='foot'><img src='/style/icons/str2.gif' alt=''/> <a href='?'>Назад</a></div>";
	include_once '../sys/inc/tfoot.php';
	exit;	
	}
	//==================================================================//
if ($moder!=0 && isset($user) && isset($_GET['act']) && $_GET['act']=='delete' && $dir['osn']==0)
{
	//===================================//
if(isset($_GET['ok'])){
	$q=mysql_query("SELECT * FROM `comm_obmen` WHERE `id_comm` = '$comm[id]' AND `id_dires` like '%/$dir[id_dir]/".intval($dir['id'])."/%'");
	while ($post = mysql_fetch_assoc($q))
{

mysql_query("DELETE FROM `comm_obmen` WHERE `id` = '$post[id]' LIMIT 1");
}
mysql_query("DELETE FROM `comm_obmen` WHERE `id` = '$dir[id]' LIMIT 1");
$_SESSION['message'] = 'Папка '.text($dir['name']).' успешно удалена';
header("Location: /comm/obmen/$comm[id]/$dir[id_dir]/");
}
//=====================================//
echo "<div class='mess'><center>";
echo "Вы действительно желаете удалить папку <b>".htmlspecialchars($dir['name'])."</b><br />";
echo "[<a href='?act=delete&amp;ok'><img src='/style/icons/ok.gif' alt='*'> Да</a>] [<a href='?'><img src='/style/icons/delete.gif' alt='*'> Нет</a>] \n";
echo "</center></div>";
echo "<div class='foot'><img src='/style/icons/up_dir.gif' alt='*'> ".($dir['osn']==1?'Файлы':'')." ".comm_files($dir['id_dires'],$comm['id'])." ".($dir['osn']==1?'':'&gt; '.text($dir['name']))."\n";
echo "</div>";
	include_once '../sys/inc/tfoot.php';
	exit;
}
	//===================================================================//
	if ($moder!=0 && isset($user) && isset($_GET['act']) && $_GET['act']=='edit' && $dir['osn']==0){
		if(isset($_POST['save'])){
		if ($_POST['name']==NULL)$err= "Введите название папки";
elseif( !preg_match("#^([A-zА-я0-9\-\_\(\)\ ])+$#ui", $_POST['name']))$err='В названии присутствуют запрещенные символы';
else{
$newdir=retranslit($_POST['name'],1);


if (isset($_POST['upload']) && $_POST['upload']=='1')$upload=1; else $upload=0;


if (!isset($_POST['ras']) || $_POST['ras']==NULL)
{
$upload=0;
}
$size=0;
if ($upload==1 && isset($_POST['size']) && isset($_POST['mn']))
{
$size=intval($_POST['size'])*intval($_POST['mn']);
if ($upload_max_filesize<$size)$size=$upload_max_filesize;
}
else $upload=0;

// ShaMan
$ras=esc(stripcslashes(htmlspecialchars($_POST['ras'],1)));
$name = my_esc($_POST['name']);

// Тут конец моих дум
if (!isset($err)){
	
	if ($dir['id_dires']=='/')
$id_dires = $dir['id_dires'] . $dir['id'].'/';
else
$id_dires = $dir['id_dires'] . $dir['id'].'/';


mysql_query("UPDATE `comm_obmen` SET `name` = '$name', `ras` = '$ras', `max_size` = '$size', `upload` = '$upload' WHERE `id_comm` = '$comm[id]' AND `id` = '$dir[id]'");
$_SESSION['message'] = 'Папка '.text($_POST['name']).' успешно отредактирована';
header("Location: ?");
}
}
}
err();		
//==================================================//
		echo "<form class=\"foot\" action='?act=edit' method=\"post\">";
	echo "Название папки:<br />\n";
	echo "<input type='text' name='name' value='" . htmlspecialchars($dir['name']) . "' /><br />\n";
if ($dir['upload']==1)$check=' checked="checked"'; else $check=NULL;
	echo "<label><input type=\"checkbox\"$check name=\"upload\" value=\"1\" /> Выгрузка</label><br />\n";
	echo "Расширения через \";\":<br />\n";
	echo "<input type='text' name='ras' value='$dir[ras]' /><br />\n";
	echo "Максимальный размер файлов:<br />\n";
if ($dir['max_size']<1024)$size=$dir['max_size'];
elseif($dir['max_size']>=1024 && $dir['max_size']<1048576)$size=intval($dir['max_size']/1024);
elseif($dir['max_size']>=1048576)$size=intval($dir['max_size']/1048576);

	echo '<input type="text" name="size" size="4" value="'.$size.'" />';
	echo '<select name="mn">';
if ($dir['max_size']<1024)$sel=' selected="selected"';else $sel=NULL;
	echo '<option value="1"'.$sel.'>B</option>';
if ($dir['max_size']>=1024 && $dir['max_size']<1048576)$sel=' selected="selected"';else $sel=NULL;
	echo '<option value="1024"'.$sel.'>KB</option>';
if ($dir['max_size']>=1048576)$sel=' selected="selected"';else $sel=NULL;
	echo '<option value="1048576"'.$sel.'>MB</option>';
	echo '</select><br />';
	echo '*настройки сервера не позволяют выгружать файлы объемом более: '.size_file($upload_max_filesize).'<br />';
	echo '<img src="/style/icons/ok.gif" alt="*"> <input name="save" class="submit" type="submit" value="Принять изменения" /> ';
	echo '[<img src="/style/icons/delete.gif" alt="*"> <a href="?">Отмена</a>]<br />';
	echo '</form>';
	echo "<div class='foot'>";
echo "<img src='/style/icons/up_dir.gif' alt='*'> ".($dir['osn']==1?'Файлы':'')." ".comm_files($dir['id_dires'],$comm['id'])." ".($dir['osn']==1?'':'&gt; '.text($dir['name']))."\n";
echo "</div>";
	include_once '../sys/inc/tfoot.php';
	exit;
	}
	//==================================================================//
	if ($moder!=0 && isset($user) && isset($_GET['act']) && $_GET['act']=='create'){
		if(isset($_POST['create'])){
		if ($_POST['name']==NULL)$err= "Введите название папки";
elseif( !preg_match("#^([A-zА-я0-9\-\_\(\)\ ])+$#ui", $_POST['name']))$err='В названии присутствуют запрещенные символы';
else{
$newdir=retranslit($_POST['name'],1);


if (isset($_POST['upload']) && $_POST['upload']=='1')$upload=1; else $upload=0;


if (!isset($_POST['ras']) || $_POST['ras']==NULL)
{
$upload=0;
}
$size=0;
if ($upload==1 && isset($_POST['size']) && isset($_POST['mn']))
{
$size=intval($_POST['size'])*intval($_POST['mn']);
if ($upload_max_filesize<$size)$size=$upload_max_filesize;
}
else $upload=0;

// ShaMan
$ras=esc(stripcslashes(htmlspecialchars($_POST['ras'],1)));
$name = my_esc($_POST['name']);
// Тут конец моих дум
if (!isset($err)){
	
	if ($dir['id_dires']=='/')
$id_dires = $dir['id_dires'] . $dir['id'].'/';
else
$id_dires = $dir['id_dires'] . $dir['id'].'/';


mysql_query("INSERT INTO `comm_obmen` (`id_dir` , `ras` , `max_size` , `id_dires`, `upload`, `name`, `id_comm`, `time`) 
VALUES ('".intval($d)."', '$ras', '$size', '$id_dires', '$upload', '$name','$comm[id]','$time')");
$_SESSION['message'] = 'Папка '.text($_POST['name']).' успешно создана';
header("Location: ?");
}
}
		}
		err();
		echo "<form method=\"post\" name='folder' action=\"?act=create\">";
	echo "Название папки:<br />\n";
	echo "<input name=\"name\" type=\"text\" maxlength='100' value='' /><br />\n";
	echo '<label><input type="checkbox" name="upload" value="1" /> Выгрузка</label><br />';
	echo 'Расширения через ";":<br />';
	echo '<input type="text" name="ras" value="" /><br />';
	echo 'Максимальный размер файлов:<br />';
	echo '<input type="text" name="size" size="4" value="500" />';
	echo '<select name="mn">';
	echo '<option value="1">B</option>';
	echo '<option value="1024">KB</option>';
	echo '<option value="1048576" selected="selected">MB</option>';
	echo '</select><br />';
	echo '*настройки сервера не позволяют выгружать файлы объемом более: '.size_file($upload_max_filesize).'<br />';
	echo '<img src="/style/icons/ok.gif" alt="*"> <input name="create" class="submit" type="submit" value="Создать папку" /> ';	echo '[<img src="/style/icons/delete.gif" alt="*"> <a href="?">Отмена</a>]<br />';
	echo '</form>';
	echo "<div class='foot'>";
echo "<img src='/style/icons/up_dir.gif' alt='*'> ".($dir['osn']==1?'Файлы':'')." ".comm_files($dir['id_dires'],$comm['id'])." ".($dir['osn']==1?'':'&gt; '.text($dir['name']))."\n";
echo "</div>";
	include_once '../sys/inc/tfoot.php';
	exit;
	}
	
	$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `comm_obmen` WHERE `id_dir` = '$d'"),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 '<div class="mess">';
	echo 'Папка пуста!';
	echo '</div>';
}	


$q=mysql_query("SELECT * FROM `comm_obmen` WHERE `id_dir` = '$d' ORDER BY `type` ASC, `time` DESC  LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_assoc($q))
{
/*-----------зебра-----------*/	
if ($num == 0)	
{			
	echo '<div class="nav1">';		
	$num = 1;	
}	
elseif ($num == 1)	
{		
	echo '<div class="nav2">';		
	$num = 0;	
}	if($post['type']==0){
	$dir_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `comm_obmen` WHERE `id_comm` = '$comm[id]' AND `id_dires` like '%/$post[id_dir]/".intval($post['id'])."/%' AND `type` = '0'"),0);
	$file_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `comm_obmen` WHERE `id_comm` = '$comm[id]' AND `id_dires` like '%/$post[id_dir]/".intval($post['id'])."/%' AND `type` = '1'"),0);
	$new_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `comm_obmen` WHERE `id_comm` = '$comm[id]' AND `id_dires` like '%/$post[id_dir]/".intval($post['id'])."/%' AND `type` = '1' AND `time` > '$ftime'"),0);
	if($new_post==0)$new_post=NULL;
	else $new_post='+'.$new_post;
echo '<img src="/style/themes/' . $set['set_them'] . '/loads/14/dir.png" alt="" /> <a href="/comm/obmen/'.$comm['id'].'/'.$post['id'].'/">'.$post['name'].'</a> ('.$dir_post.'/'.$file_post.') <font color="red">'.$new_post.'</font>';

}elseif (mysql_result(mysql_query("SELECT COUNT(*) FROM `obmennik_files` WHERE `id` = '".intval($post['id_object'])."'"),0)!=0){
	$idfile = intval($post['id_object']);
	$files = mysql_fetch_array(mysql_query("SELECT * FROM `obmennik_files`  WHERE `id` = '$idfile'"));
	$k_p=mysql_result(mysql_query("SELECT COUNT(*) FROM `obmennik_komm` WHERE `id_file` = '$files[id]'"),0);
$dir_id=mysql_fetch_assoc(mysql_query("SELECT * FROM `obmennik_dir` WHERE `id` = '$files[id_dir]' LIMIT 1"));
$ras=$files['ras'];
$file=H."sys/obmen/files/$files[id].dat";
$name=$files['name'];
$size=$files['size'];
/*---------------------------*/
if (is_file(H."obmen/inc/icon48/$ras.php"))
{
include H."obmen/inc/icon48/$ras.php";
}


if (is_file(H.'style/themes/'.$set['set_them'].'/loads/14/'.$ras.'.png'))
echo "<img src='/style/themes/$set[set_them]/loads/14/$ras.png' alt='$ras' /> \n";
else 
echo "<img src='/style/themes/$set[set_them]/loads/14/file.png' alt='file' /> \n";

if ($set['echo_rassh']==1)$ras=$files['ras'];else $ras=NULL;

//echo '<a href="/user/personalfiles/'.$files['id_user'].'/'.$files['my_dir'].'/?id_file='.$files['id'].'&amp;page='.$page.'"><b>'.text($files['name']).'.'.$ras.'</b></a> ('.size_file($files['size']).') ';
echo '<a href="/comm/obmenfiles/'.$files['id'].'/'.$dir['id'].'/?page='.$page.'"><b>'.text($files['name']).'.'.$ras.'</b></a> ('.size_file($files['size']).') ';

if ($files['metka'] == 1)echo ' <font color=red>(18+)</font>';
echo '<br />';
	if ($files['opis']){
	echo rez_text(text($files['opis'])).'<br />';
	}
echo '<a href="/comm/obmenfiles/'.$files['id'].'/'.$dir['id'].'/?page='.$page.'&amp;komm">Комментарии</a> ('.$k_p.')<br />';
	if (isset($user) && ($moder!=0 || $files['id_user']==$user['id'])){
		echo'<div align="right"><a href="?delfile='.$files['id'].'"><img src="/style/icons/delete.gif" alt="delete"></a></div>';
	}

}else{
	echo"<font color='red'>Файл не найден!</font>";
	if (isset($user) && $moder!=0){
		echo'<div align="right"><a href="?delfile='.$post['id_object'].'"><img src="/style/icons/delete.gif" alt="delete"></a></div>';
	}
}
echo'</div>';
}
if ($k_page>1)str("?",$k_page,$page); // Вывод страниц
		echo "<div class='foot'>";
echo "<img src='/style/icons/up_dir.gif' alt='*'> ".($dir['osn']==1?'Файлы':'')." ".comm_files($dir['id_dires'],$comm['id'])." ".($dir['osn']==1?'':'&gt; '.text($dir['name']))."\n";
echo "</div>";
	if ($commuser!=0 && isset($user) && $dir['upload']==1){
	echo "<div class='foot'><img src='/style/icons/str.gif' alt=''/> <a href='?act=file'>Добавить файл</a></div>";
	}
	if ($moder!=0 && isset($user) && $dir['osn']==0){
	echo "<div class='foot'><img src='/style/icons/str.gif' alt=''/> <a href='?act=edit'>Редактировать папку</a></div>";
		echo "<div class='foot'><img src='/style/icons/str.gif' alt=''/> <a href='?act=delete'>Удалить папку</a></div>";
	}
	if ($moder!=0 && isset($user)){
	echo "<div class='foot'><img src='/style/icons/str.gif' alt=''/> <a href='?act=create'>Создать папку</a></div>";
	}
	echo "<div class='foot'><img src='/style/icons/str2.gif' alt=''/> <a href='/comm/$comm[id]/'>В сообщество</a></div>";
}else{
	header("Location: /");
}
include_once '../sys/inc/tfoot.php';
?>