<?
$list=null;
if ($l=='/')
$set['title']='Зона Обмена'; // заголовок страницы
else $set['title']='Зона Обмена - '.$dir_id['name']; // заголовок страницы
$_SESSION['page']=1;
include_once '../sys/inc/thead.php';
title();
include 'inc/upload_act.php';
include 'inc/admin_act.php';

err();

echo "<div class='rekl_main'>";
$k_p=mysql_result(mysql_query("SELECT COUNT(*) FROM `obmennik_files`",$db), 0);
$k_n= mysql_result(mysql_query("SELECT COUNT(*) FROM `obmennik_files` WHERE `time` > '".(time()-60*60*$set['loads_new_file_hour'])."'",$db), 0);
if ($k_n==0)$k_n=NULL;
else $k_n='+'.$k_n;
echo "<img src='/style/obmen/018.png' alt=''/> Bсего файлов <font color='red'>$k_p</font><br/>";
echo "<img src='/style/obmen/084.png' alt=''/>\n";
echo "<a href='/info/rules_obmen.php'> Правила Загрузки</a><br/>\n";
echo "<img src='/style/obmen/083.png' alt=''/>\n";
echo "<a href='/obmen/new.php'> Новые за сутки</a>\n";
$k_p=mysql_result(mysql_query("SELECT COUNT(*) FROM `obmennik_files`",$db), 0);
$k_n= mysql_result(mysql_query("SELECT COUNT(*) FROM `obmennik_files` WHERE `time` > '".(time()-60*60*$set['loads_new_file_hour'])."'",$db), 0);
if ($k_n==0)$k_n=NULL;
else $k_n='+'.$k_n;
echo "<font color='red'>$k_n</font>";

echo "</div>\n";

if ($l!='/'){
}



echo "<table class='post'>\n";


$q=mysql_query("SELECT * FROM `obmennik_dir` WHERE `dir_osn` = '/$l' OR `dir_osn` = '$l/' OR `dir_osn` = '$l' ORDER BY `name`,`num` ASC");
while ($post = mysql_fetch_assoc($q))
{
$list[]=array('dir'=>1,'post'=>$post);
}
$q=mysql_query("SELECT * FROM `obmennik_files` WHERE `id_dir` = '$id_dir' ORDER BY `time` DESC");
while ($post = mysql_fetch_assoc($q))
{
$list[]=array('dir'=>0,'post'=>$post);
}



$set['p_str'] = 15;
$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 "Папка пуста\n";

}

for ($i=$start;$i<$k_post && $i<$set['p_str']*$page;$i++)
{
if ($list[$i]['dir']==1) // папка 
{
$post=$list[$i]['post'];
echo "   <tr>\n";

if($num==1){
echo "  <td class='gmenu'>\n";
$num=0;
}else{
echo "  <td class='gmenu'>\n";
$num=1;}

echo "<img src='/obmen/dir.png' alt='' />\n";

echo "<a href='/obmen$post[dir]'>$post[name]</a>";

$k_f=0;
$k_n=0;
$q3=mysql_query("SELECT * FROM `obmennik_dir` WHERE `dir_osn` like '$post[dir]%'");
while ($post2 = mysql_fetch_assoc($q3))
{
$k_f=$k_f+mysql_result(mysql_query("SELECT COUNT(*) FROM `obmennik_files` WHERE `id_dir` = '$post2[id]'"),0);
$k_n=$k_n+mysql_result(mysql_query("SELECT COUNT(*) FROM `obmennik_files` WHERE `id_dir` = '$post2[id]' AND `time` > '".(time()-60*60*$set['loads_new_file_hour'])."'",$db), 0);
}
$k_f=$k_f+mysql_result(mysql_query("SELECT COUNT(*) FROM `obmennik_files` WHERE `id_dir` = '$post[id]'"),0);
$k_n=$k_n+mysql_result(mysql_query("SELECT COUNT(*) FROM `obmennik_files` WHERE `id_dir` = '$post[id]' AND `time` > '".(time()-60*60*$set['loads_new_file_hour'])."'",$db), 0);

if ($k_n==0)$k_n=NULL;
else $k_n='+'.$k_n;

echo " ($k_f) <font color='red'>$k_n</font><br />\n";

}
else
{
$post=$list[$i]['post'];


$ras=$post['ras'];
$file=H."sys/obmen/files/$post[id].dat";
$name=$post['name'];
$size=$post['size'];


echo "<div class='str'>";

include 'inc/icon48.php';

//include 'inc/icon14.php';




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

echo "<a href='/obmen$dir_id[dir]$post[name].$post[ras]?showinfo'>$post[name]$ras</a><br />\n";


include 'inc/opis.php';

echo "</div>\n";

}
}






echo "</table>\n";
if ($k_page>1)str('?',$k_page,$page); // Вывод страниц
include 'inc/upload_form.php';
echo "<div class='menu_razd'>";
echo "<img src='/style/adm.png'><a href='/obmen/moder.php'>Модераторы</a>\n";
echo "</div>\n";
if ($l!='/'){
echo "<div class='foot'>";
echo "<a href='/obmen/'>Зона Обмена</a> &gt; ".obmen_path($l)."<br />\n";
echo "</div>\n";
}



include 'inc/admin_form.php';


?>