<?
error_reporting(7);
if (dir_name($dir_loads)!=NULL)
$set['title']='ZonaSmart - '.dir_name($dir_loads);
else $set['title']='ZonaSmart';
include_once '../sys/inc/thead.php';
title();
include 'inc/admin_act.php';
err();
aut();
if(isset($_GET['sort'])) $_SESSION['sort']=$_GET['sort'];
if($_SESSION['sort']=="") $_SESSION['sort']=0;
if($_SESSION['sort']==1) $order="loads";
elseif($_SESSION['sort']==2) $order="rate";
elseif($_SESSION['sort']==4) $order="size";
elseif($_SESSION['sort']==3) $order="name";
else $order="time";
$dirlist_t=NULL;
$opendir=opendir($dir_loads);
while ($readdir=readdir($opendir))
$dirlist=scandir($dir_loads);
$offsetarray=0;
foreach($dirlist as $readdir)
{
if (!eregi("^\.|\.php|\.name$|\.txt$|\.opis$|\.html?$|\.sql$|\.ini$|\.db$|\.dat$|\.jad$|\.dirname$",$readdir) && !ereg("\.JPG$|\.PNG$|\.GIF$",$readdir))
{
$offsetarray++;
if(is_file($dir_loads.'/'.$readdir)) $filesqlinfo=mysql_fetch_assoc(mysql_query("SELECT * FROM `loads_list` WHERE(`name`='$readdir' && `path`='/".$l."/' && `size`='".filesize($dir_loads.'/'.$readdir)."') LIMIT 1"));
$dirlist_t[]=is_dir($dir_loads.'/'.$readdir)?array('dir'=>1,'name'=>'000'.$readdir.'','size'=>1000*1024*1024*1024*1024,'loads'=>'999999','rate'=>'999999','time'=>'9999999999'):array('dir'=>0,'name'=>$readdir,'size'=>$filesqlinfo['size'],'loads'=>$filesqlinfo['loads'],'rate'=>$filesqlinfo['rate'],'time'=>$filesqlinfo['time']);
//if(is_file($dir_loads.'/'.$readdir)) $dirlist_t[$offsetarray]=array('dir'=>0,'name'=>$readdir,'size'=>$filesqlinfo['size'],'loads'=>$filesqlinfo['loads'],'rate'=>$filesqlinfo['rate'],'time'=>$filesqlinfo['time']);
//if(is_dir($dir_loads.'/'.$readdir)) $dirlist_d[$offsetarray]=array('dir'=>1,'name'=>$readdir,'size'=>'-1','loads'=>'-1','rate'=>'-1','time'=>'-1');
}
}
//closedir($opendir);
//natsort($dirlist_t);
function cmp_name($a2, $b2)
{
return ($a2['name']>=$b2['name'])?1:0;
}
function cmp_dir($a2, $b2)
{
return ($a2['dir']<$b2['dir'])?1:0;
}
function cmp_size($a2, $b2)
{
return ($a2['size']<=$b2['size'])?1:0;
}
function cmp_loads($a2, $b2)
{
return ($a2['loads']<=$b2['loads'])?1:0;
}
function cmp_rate($a2, $b2)
{
return ($a2['rate']<=$b2['rate'])?1:0;
}
function cmp_time($a2, $b2)
{
return ($a2['time']<=$b2['time'])?1:0;
}
//shuffle($dirlist_t);
if (count($dirlist_t)!=0) usort($dirlist_t, "cmp_".$order."");
//if (count($dirlist_d)!=0)usort($dirlist_d, "cmp_".$order."");
//if (count($dirlist_t)!=0)usort($dirlist_t, "cmp_dir");
//if (count($dirlist_t)!=0)usort($dirlist_t, "cmp_dir");
//print_r($dirlist_t);
//print_r($dirlist_d);
$k_post=count($dirlist_t);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$end=$set['p_str']*$page;
if ($l!=NULL){
echo "<div class='foot'>";
echo "<a href='?'>ZonaSmart</a> > ".rupath($l,'../sys/loads/files')."<br />\n";
echo "</div>\n";
}
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";
}
for ($i=$start;$i<$end && $i<$k_post;$i++)
{
$dirlist[$i]=$dirlist_t[$i]['name'];
if ($dirlist_t[$i]['dir']==1) // папка
{
$dirlist[$i]=substr($dirlist[$i],3,strlen($dirlist[$i]));
echo " <tr>\n";
if ($set['set_show_icon']==2){
echo " <td rowspan='2' class='icon48'>\n";
echo "<img src='/style/themes/$set[set_them]/loads/48/dir.png' alt='' />\n";
echo " </td>\n";
}
elseif ($set['set_show_icon']==1){
echo " <td class='icon14'>\n";
echo "<img src='/style/themes/$set[set_them]/loads/14/dir.png' alt='' />\n";
echo " </td>\n";
}
echo " <td class='p_t'>\n";
echo "<a href='?d=".urlencode("$l/$dirlist[$i]")."'><b>".dir_name($dir_loads.'/'.$dirlist[$i])."</b></a> (".k_files($l.'/'.$dirlist[$i]).")\n";
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 "Файлов: ".k_files($l.'/'.$dirlist[$i])."<br />\n";
echo " </td>\n";
echo " </tr>\n";
}
else // файл
{
echo " <tr>\n";
$ras=strtolower(eregi_replace('^.*\.', NULL, $dirlist[$i]));
$name=eregi_replace('\.[^\.]*$', NULL, $dirlist[$i]);
if (is_file($dir_loads.'/'.$dirlist[$i].'.name'))
$name2=trim(esc(file_get_contents($dir_loads.'/'.$dirlist[$i].'.name')));
elseif (function_exists('iconv'))
$name2=iconv('windows-1251', 'utf-8', $name);
else $name2=$name;
$name2=htmlspecialchars($name2);
$size=filesize($dir_loads.'/'.$dirlist[$i]);
if ($set['set_show_icon']==2){
echo " <td rowspan='2' class='icon48'>\n";
include 'inc/icon48.php';
echo " </td>\n";
}
elseif ($set['set_show_icon']==1){
echo " <td class='icon14'>\n";
include 'inc/icon14.php';
echo " </td>\n";
}
echo " <td class='p_t'>\n";
if ($set['echo_rassh']==1)$ras2=".$ras";else $ras2=NULL;
echo "<b>$name2$ras2</b>".file_new($dir_loads.'/'.$dirlist[$i])."\n";
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";
if (is_file($dir_loads.'/'.$dirlist[$i].''.$file.'.GIF'))
echo "<img src=\"resize.php?".url("f=$l/$dirlist[$i]$file.GIF")."&w=59&h=59\" alt=\"Скрин...\" /><br />\n";
elseif (is_file($dir_loads.'/'.$dirlist[$i].''.$file.'.JPG'))
echo "<img src=\"resize.php?".url("f=$l/$dirlist[$i]$file.JPG")."&w=59&h=59\" alt=\"Скрин...\" /><br />\n";
elseif (is_file($dir_loads.'/'.$dirlist[$i].''.$file.'.PNG'))
echo "<img src=\"resize.php?".url("f=$l/$dirlist[$i]$file.PNG")."&w=59&h=59\" alt=\"Скрин...\" /><br />\n";
if (is_file($dir_loads.'/'.$dirlist[$i].'.opis')) // проверка описания
{
$tmp = output_text(file_get_contents($dir_loads.'/'.$dirlist[$i].'.opis'));
$tmp = vyvod_text($tmp);
echo $tmp."...\n";
}
elseif (is_file($dir_loads.'/'.$dirlist[$i].'.txt')) // проверка описания в txt файле
{
$tmp = output_text(file_get_contents($dir_loads.'/'.$dirlist[$i].'.txt'));
$tmp = vyvod_text($tmp);
echo $tmp."...\n";
}
if ($set['echo_rassh']==1)$ras2=".$ras";else $ras2=NULL;
echo "<a href='?d=".urlencode("$l")."&f=".urlencode("$dirlist[$i]")."&page=$page'><b>Полное описание</b></a><br />\n";
include 'inc/opis.php';
echo " </td>\n";
echo " </tr>\n";
}
}
echo "</table>\n";
if ($k_page>1)str("?d=".urlencode("$l")."&",$k_page,$page); // Вывод страниц
echo "<div class='foot'>Сорт: ";
if($_SESSION['sort']==0) echo'Дата | '; else echo'<a href="/loads/?d='.$l.'&page='.$_GET['page'].'&sort=0">Дата</a> | ';
if($_SESSION['sort']==3) echo'Имя | '; else echo'<a href="/loads/?d='.$l.'&page='.$_GET['page'].'&sort=3">Имя</a> | ';
if($_SESSION['sort']==1) echo'Скачивания | '; else echo'<a href="/loads/?d='.$l.'&page='.$_GET['page'].'&sort=1">Скачивания</a> | ';
if($_SESSION['sort']==2) echo'Рейтинг | '; else echo'<a href="/loads/?d='.$l.'&page='.$_GET['page'].'&sort=2">Рейтинг</a> | ';
if($_SESSION['sort']==4) echo'Размер'; else echo'<a href="/loads/?d='.$l.'&page='.$_GET['page'].'&sort=4">Размер</a>';
echo'</div>';
if ($l!=NULL){
echo "<div class='foot'>";
echo "<a href='?'>ZonaSmart</a> > ".rupath($l,'../sys/loads/files')."<br />\n";
echo "</div>\n";
}
include 'inc/admin_form.php';
if ($l==NULL){
echo "<div class='foot'>";
echo "»<a href='/loads/new_komm.php'>Новые комментарии</a> (".mysql_result(mysql_query("SELECT COUNT(*) FROM `loads_komm` LEFT JOIN `loads_list` ON `loads_komm`.`file` = `loads_list`.`name` AND `loads_komm`.`size` = `loads_list`.`size` WHERE `loads_komm`.`time` > '".($time-60*60*24)."'"), 0).")<br />\n";
echo "»<a href='/loads/search.php'>Поиск файлов</a><br />\n";
echo "»<a href='/loads/top.php'>Топ 20 файлов</a><br />\n";
echo "</div>\n";
}
include_once '../sys/inc/tfoot.php';
?>