<?
Error_Reporting(E_ALL & ~E_NOTICE);
Error_Reporting (ERROR | WARNING);
include("func.php");
include("set.php");
include("start.php");
include("modul/head.php");
if(is_dir("$dir_load/$did"))
{
include("clear.php");
if($ver=='wml') print "<b>Загрузки</b><br/>"; else print "<div class=\"c\">Загрузки<br/></div>";
if($set_reklama>0)
{
if($ver!="wml") print "<div class=\"d\">";
include("reklama.php");
if($ver!="wml") print "</div><br/>"; else print "<br/>";
}
if($admin_ok!=true);
if($mode=="del_file" && $admin_ok)
{
if($ver!='wml') print "<div class=\"d\">";
print "<b>Удалить?</b><br/><a href=\"index.php?did=$did&file=$file&pg=$pg&mode=del_file_ok\">Да</a>|<a href=\"index.php?did=$did&pg=$pg\">Нет</a><br/>";
if($ver!='wml') print "</div><br/>";
}
elseif($mode=="del_file_ok")
{
if(file_exists("$dir_load/$did/$file")) unlink("$dir_load/$did/$file");
}
if($mode=="del_dir" && $admin_ok)
{
if($ver!='wml') print "<div class=\"d\">";
print "<b>Удалить?</b><br/><a href=\"index.php?did=$did&dir=$dir&pg=$pg&mode=del_dir_ok\">Да</a>|<a href=\"index.php?did=$did&pg=$pg\">Нет</a><br/>";
if($ver!='wml') print "</div><br/>";
}
elseif($mode=="del_dir_ok")
{
if(is_dir("$dir_load/$did/$dir"))
{
$nd=del_files("$dir_load/$did/$dir/");
if($nd==0) {} else print "Не удалено файлов $nd.<br/>Папка не удалена.<br/>Возможно в нем есть файлы у которых нет прав доступа. поставьте к папке CHMOD 777.<br/><br/>";
if($nd==0) if(@rmdir("$dir_load/$did/$dir")) print "Папка удалена.<br/><br/>"; else print "Не удалось удалить папку.<br/><br/>";
}
}
elseif($mode=="ren_file")
{
if($ver!='wml') print "<div class=\"d\">";
print "Файл: $file_rename<br/><br/>
<form action=\"index.php\">
<input name=\"mode\" type=\"hidden\" value=\"rename\"/>
<input name=\"file_rename\" type=\"hidden\" value=\"$file_rename\"/>
<input name=\"did\" type=\"hidden\" value=\"$did\"/>
<input name=\"pg\" type=\"hidden\" value=\"$pg\"/>
Сохранить как:<br/><input name=\"nname\" value=\"$file_rename\"/><br/>
Label:<br/><input name=\"label\"/><br/>
Описание:<br/><input name=\"info\"/><br/>
<input type=\"submit\" value=\"Изменить\"/><br/>
</form>";
if($ver!='wml') print "</div><br/>";
}
elseif($mode=="rename")
{
if(file_exists("$dir_load/$did/$file_rename"))
{
chmod("$dir_load/$did/$file_rename",0777);
@rename("$dir_load/$did/$file_rename","$dir_load/$did/$nname");
@rename("$dir_load/$did/$file_rename.info","$dir_load/$did/$nname.info");
if($label!="" && $info!="" && $fi=fopen("$dir_load/$did/$nname.info","w+"))
{
chmod("$dir_load/$did/$nname.info",0777);
fwrite($fi,"|$label|$info|");
fclose($fi);
}
}
$file_rename=''; $label=''; $info='';
}
elseif($mode=="mkdir_q")
{
if($ver!='wml') print "<div class=\"d\">";
print "Новая папка<br/><br/>
<form action=\"index.php\">
<input name=\"mode\" type=\"hidden\" value=\"mkdir\"/>
<input name=\"did\" type=\"hidden\" value=\"$did\"/>
<input name=\"pg\" type=\"hidden\" value=\"$pg\"/>
Сохранить как:<br/><input name=\"ndir\" value=\"papka\"/><br/>
Label:<br/><input name=\"label\" value=\"Папка\"/><br/>
<input type=\"submit\" value=\"Создать\"/><br/>
</form>";
if($ver!='wml') print "</div><br/>";
}
elseif($mode=="mkdir" && $ndir!="")
{
if(!is_dir("$dir_load/$did/$ndir/"))
{
if(mkdir("$dir_load/$did/$ndir",0777))
{
if($fdn=fopen("$dir_load/$did/$ndir/name.dat","w+"))
{
fwrite($fdn,"$label");
fclose($fdn);
@chmod("$dir_load/$did/$ndir/name.dat",0777);
}
}
} else print "<big>Такая папка уже существует.</big><br/><br/>";
}
elseif($mode=="ren_dir_q")
{
if($ver!='wml') print "<div class=\"d\">";
print "Переимновать папку: $dir<br/><br/>
<form action=\"index.php\">
<input name=\"mode\" type=\"hidden\" value=\"ren_dir\"/>
<input name=\"did\" type=\"hidden\" value=\"$did\"/>
<input name=\"dir\" type=\"hidden\" value=\"$dir\"/>
<input name=\"pg\" type=\"hidden\" value=\"$pg\"/>
Label:<br/><input name=\"label\" value=\"Папка\"/><br/>
Описание:<br/><input name=\"directory_info\" value=\"\"/><br/>
<input type=\"submit\" value=\"OK\"/><br/>
</form>";
if($ver!='wml') print "</div><br/>";
}
elseif($mode=="ren_dir" && $label!="")
{
@chmod("$dir_load/$did/$dir/",0777);
if($fdr=fopen("$dir_load/$did/$dir/name.dat","w+"))
{
fwrite($fdr,"$label\r\n$directory_info");
fclose($fdr);
}
@chmod("$dir_load/$did/$dir/name.dat",0777);
}
elseif($mode=="add_screen")
{
if($ver!='wml') print "<div class=\"d\">
Upload скрина файлу $file_screen<br/><br/>
<form action=\"index.php\" method=\"post\" enctype=\"multipart/form-data\">
<input name=\"mode\" type=\"hidden\" value=\"upload_screen\"/>
<input name=\"did\" type=\"hidden\" value=\"$did\"/>
<input name=\"file_screen\" type=\"hidden\" value=\"$file_screen\"/>
<input name=\"pg\" type=\"hidden\" value=\"$pg\"/>
Файл:<br/><input name=\"up_file\" type=\"file\"/><br/>
<input type=\"submit\" value=\"OK\"/><br/>
</form></div><br/>";
else print "<big>В WML Upload не поддерживается.<br/><br/></big>";
}
elseif($mode=="upload_screen")
{
if(is_uploaded_file($_FILES['up_file']['tmp_name']))
{
if(!is_dir("$dir_screen/$did/")) mkdir("$dir_screen/$did/",0777);
$rsh=rsh($_FILES['up_file']['name']);
$nam=($_FILES['up_file']['name']);
if(!in_array($rsh,$set_format)) print "<big>Не поддерживаемый формат.<br/><br/></big>";
elseif(file_exists("$dir_load/$did/$nam")) print "<big>Такой файл уже существует.<br/><br/></big>";
elseif(@copy($_FILES['up_file']['tmp_name'],"$dir_screen/$did/$file_screen.$rsh")) @chmod("$dir_load/$did/".$_FILES['up_file']['name'],0777); else print "Ошибка UPLOAD. Не сохранен. возможно неь доступа.<br/><br/>";
} else print "Ошибка!<br/><br/>";
}
elseif($mode=="upload_form")
{
if($ver!='wml') print "<div class=\"d\">
Upload в папку $dir<br/><br/>
<form action=\"index.php\" method=\"post\" enctype=\"multipart/form-data\">
<input name=\"mode\" type=\"hidden\" value=\"upload\"/>
<input name=\"did\" type=\"hidden\" value=\"$did\"/>
<input name=\"pg\" type=\"hidden\" value=\"$pg\"/>
Файл:<br/><input name=\"up_file\" type=\"file\"/><br/>
Label:<br/><input name=\"label\" value=\"\"/><br/>
<input type=\"submit\" value=\"OK\"/><br/>
</form></div><br/>";
else print "<big>В WML Upload не поддерживается.<br/><br/></big>";
}
elseif($mode=="upload")
{
if(is_uploaded_file($_FILES['up_file']['tmp_name']))
{
$rsh=rsh($_FILES['up_file']['name']);
$nam=($_FILES['up_file']['name']);
if(!in_array($rsh,$set_format)) print "<big>Не поддерживаемый формат.<br/><br/></big>";
elseif(file_exists("$dir_load/$did/$nam")) print "<big>Такой файл уже существует.<br/><br/></big>";
elseif(@copy($_FILES['up_file']['tmp_name'],"$dir_load/$did/".$_FILES['up_file']['name'])) @chmod("$dir_load/$did/".$_FILES['up_file']['name'],0777); else print "Ошибка UPLOAD. Не сохранен. возможно неь доступа.<br/><br/>";
} else print "Ошибка!<br/><br/>";
}
if($ver!="wml") print "<div class=\"b\">";
$dirs=scan_dirs("$dir_load/$did");
$d_c=count($dirs);
if($ver!="wml" && $dirs>0) print "<div class=\"f\"></div>";
$files=scan_files("$dir_load/$did",$set_format);
$f_c=count($files);
//@sort($files);
if(($sort=='name' || $sort=='') && $f_c>0)
{
for($i=0;$i<$f_c;$i++)
{
}
}
if($sort=='date' && $f_c>0)
{
for($c=0;$c<$f_c;$c++)
{
$infodate = date("YnjHis",filectime("$dir_load/$did/$files[$c]")).rand(123456,999999);
$dm["$infodate"]=$files[$c];
}
$list=array_keys($dm);
@natsort($list);
for($c=0;$c<$f_c;$c++)
{
$value=$list[$c];
$files[$f_c-$c-1]=$dm[$value];
}
}
if($sort=='top' && $f_c>0)
{
for($c=0;$c<$f_c;$c++)
{
$load=ld($dir_system,$did,$files[$c]);
$j='';
for($i=1;$i<strlen($files[$c]);$i++)
{
$z=ord(strtoupper(substr($files[$c],0,1)));
$z=255-$z;
$j=$j.$z;
}
if(strlen($j)>24) $j=substr($j,0,24);
if(strlen($j)<24)
{
$l=strlen($j);
$nado=24-$l;
$j=$j.rand_id($nado,2);
}
$infodate = $load.$j.rand_id(6,2);
$dm["$infodate"]=$files[$c];
}
$list=array_keys($dm);
@sort($list);
for($c=0;$c<$f_c;$c++)
{
$value=$list[$c];
$files[$f_c-$c-1]=$dm[$value];
}
}
$bases=mas_plus($dirs,$files);
$b_c=count($bases);
for($i=$pg_b;$i<$pg_e && $b_c>0;$i++)
{
if(!isSet($bases[$i])) continue;
if($ver!="wml") print "<div class=\"f\">";
$type=filetype("$dir_load/$did/$bases[$i]");
if($type=="file")
{
$size=real_size(filesize("$dir_load/$did/$bases[$i]"));
$rsh=rsh($bases[$i]);
if($on_rename_z) $filename=rename_z($bases[$i]); else $filename=ext_rsh($bases[$i]);
if($on_img_screen && ($rsh=="png" || $rsh=="jpg" || $rsh=="gif") && $uset_pw!="net") print "<img src=\"picture.php?did=$did&fid=$bases[$i]&x=$uset_pw&y=$uset_pw&screen=1\" alt=\"Screen\"/><br/>";
if($on_vid_screen && ($rsh=="3gp" || $rsh=="mp4") && $uset_pw!="net") print "<img src=\"screen.php?did=$did&fid=$bases[$i]\" alt=\"Screen\" width=\"$uset_pw\" height=\"$uset_pw\"/><br/>";
if($on_ch_symbol) $filename=str_replace("_"," ",$filename);
if(file_exists("$dir_load/$did/$bases[$i].info"))
{
$fb=file("$dir_load/$did/$bases[$i].info");
$msv=explode("|",$fb[0]);
if($msv[1]!="") $filename=$msv[1];
}
if($rsh=='jpg' || $rsh=='png' || $rsh=='gif') $img="<img src=\"img/picture.png\"/>"; else $img="";
if($rsh=='mp3' || $mp3=='wav' || $rsh=='amr' || $rsh=='midi' || $rsh=='mid' || $rsh=='mmf') $img="<img src=\"img/sound.png\"/>";
if($rsh=='3gp' || $rsh=='mp4') $img="<img src=\"img/video.png\"/>";
if($rsh=='jar') $img="<img src=\"img/java.png\"/>";
if($rsh=='zip' || $rsh=='rar' || $rsh=='gz') $img="<img src=\"img/arhiv.png\"/>";
if($rsh=='swf') $img="<img src=\"img/flash.png\"/>";
if($rsh=='exe' || $rsh=="bat" || $rsh=="com") $img="<img src=\"img/exe.png\"/>";
if($admin_ok) $link_del=" [<a href=\"index.php?did=$did&file=$bases[$i]&mode=del_file&pg=$pg\">У</a>] "; else $link_del="";
if($admin_ok) $link_ren="[<a href=\"index.php?did=$did&file_rename=$bases[$i]&mode=ren_file&pg=$pg\">П</a>] "; else $link_ren="";
if($admin_ok) $link_scr="[<a href=\"index.php?did=$did&file_screen=$bases[$i]&mode=add_screen&pg=$pg\">S</a>] "; else $link_scr="";
print "$img $link_del$link_ren$link_scr<a href=\"info.php?did=$did&fid=$bases[$i]&pg=$pg\">$filename</a> ($size)<br/>";
}
if($type=="dir")
{
$dir_name=$bases[$i];
$dir_info="";
if(file_exists("$dir_load/$did/$bases[$i]/name.dat"))
{
$dn_m=@file("$dir_load/$did/$bases[$i]/name.dat");
$dn_c=@count($dn_m);
if(isSet($dn_m[0]) && $dn_m[0]!="") $dir_name=mytrim($dn_m[0]);
if(isSet($dn_m[1]) && $dn_m[1]!="") $dir_info=mytrim($dn_m[1]);
}
elseif($on_rename_z) $dir_name=rename_z($bases[$i]);
if($dir_name=="") $dir_name=$bases[$i];
$file_count=count_files("$dir_load/$did/$bases[$i]",$set_format);
if($on_ch_symbol) $dir_name=str_replace("_"," ",$dir_name);
if($dir_info!="") if($ver!="wml") $dir_info="<div class=\"nc\">> $dir_info<br/></div>"; else $dir_info="> $dir_info<br/>";
if($admin_ok) $link_del=" [<a href=\"index.php?did=$did&dir=$bases[$i]&mode=del_dir&pg=$pg\">У</a>]"; else $link_del="";
if($admin_ok) $link_ren="[<a href=\"index.php?did=$did&dir=$bases[$i]&mode=ren_dir_q&pg=$pg\">П</a>] "; else $link_ren="";
print "<img src=\"img/folder.png\"/> $link_del$link_ren<a href=\"index.php?did=$did/$bases[$i]\">$dir_name</a> [$file_count]<br/>$dir_info";
}
if($ver!="wml") print "</div>";
}
if($ver!="wml") print "</div>";
print "<br/>";
$p_all=ceil($b_c/$set_files_page);
for($i=1;$i<=$p_all;$i++) $p_m[count($p_m)]=$i;
if($pg>1) print "<a href=\"index.php?did=$did&pg=$pg_p\"><< Назад</a><br/>";
if($b_c>$pg_e) print "<a href=\"index.php?did=$did&pg=$pg_n\">Далее >></a><br/>";
if($pg>1 || $b_c>$pg_e) print '<br/>';
/*print "<br/>";
if($pg>1) print "<a href=\"index.php?did=$did&pg=$pg_p\"><< Назад</a>";
$p_all=ceil($b_c/$set_files_page);
for($i=1;$i<=$p_all;$i++) $p_m[count($p_m)]=$i;
if($pg>3 && $p_all>3) print "[<a href=\"index.php?did=$did&pg=1\">1</a>].."; elseif($pg==1 && $pg_all>1) print "[1]..";
for($i=$pg-3;$i<$pg+2;$i++) { $p_t=$p_m[$i]; if(isSet($p_m[$i]) && $pg!=$p_t && $pg>1) print "[<a href=\"index.php?did=$did&pg=$p_t\">$p_t</a>]"; elseif($pg==$p_t && $pg>1) print "[$pg]"; }
if($pg+2<$p_all) print "..[<a href=\"index.php?did=$did&pg=$p_all\">$p_all</a>]";
if($b_c>$pg_e) print "<a href=\"index.php?did=$did&pg=$pg_n\">Далее >></a>";
if($b_c>0 || $d_c>$set_dirs_page) print "<br/>";*/
print "Навигация:<br/>";
print dirs_links("$did")."<br/>";
print "<a href=\"search.php?did=$did&pg=$pg\">Поиск в папке</a><br/>";
if($admin_ok) print "<a href=\"index.php?did=$did&pg=$pg&mode=mkdir_q\">Создать папку</a><br/>";
if($admin_ok) print "<a href=\"index.php?did=$did&pg=$pg&mode=upload_form\">Upload</a><br/>";
//print "Страниц: $p_all<br/>";
} else print "Каталог не найден.<br/>";
if($set_reklama2>0)
{
if($ver!="wml") print "<div class=\"reklama\">";
include("reklama2.php");
if($ver!="wml") print "</div>"; else print "";
}
include("modul/foot.php");
?>