Файл: explorer.mhos.tk/arhdir.php
Строк: 138
<?php
error_reporting(0);
$k=trim($_GET['k']); include("key.php");
$d=rawurldecode(trim($_GET['d'])); $n=rawurldecode(trim($_GET['n']));
if ($d==NULL) {$d="";} if ($n==NULL) {$n=preg_replace("~.*/([^/]*)~m","\1",$d);
$d=preg_replace("~(.*)/[^/]*~m","\1",$d);}
$rd=rawurlencode($d); $rn=rawurlencode($n);
$d=str_replace(".|htaccess",".htaccess",$d);
$n=str_replace(".|htaccess",".htaccess",$n);
$nm=trim($_POST['nm']); $ch=trim($_GET['ch']);
if ($nm<>NULL) {
$repl=array("\"=>"",":"=>"","*"=>"","?"=>"","""=>"","<"=>"",">"=>"","|"=>"");
$nm=trim(strtr($nm,$repl));
include("repl.php"); $nm=u2t($nm);
if (($nm==".")||($nm=="..")) {$nm="";}
}
if (($nm==NULL)||(strlen($ch)<>3)) {
$num=@file_get_contents("allnumbd.dat"); $nar=NULL;
$num++; $nar=$num; if ($num>99999999) {$num=0;}
$f=@fopen("allnumbd.dat","w"); @fwrite($f,$num); @fclose($f);
if ($d=="/") {$d="";} $n=str_replace("$","$$",$n); $d=str_replace("$","$$",$d);
$vl=$d."/".$n."/".preg_replace("~([^.]*).*~m","\1",$n).".zip";
header("Content-Type: text/vnd.wap.wml; charset=Utf-8");
echo ("<?xml version="1.0" encoding="Utf-8"?><!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" "http://www.wapforum.org/DTD/wml_1.2.xml"><wml>
<head><meta forua="true" http-equiv="Cache-Control" content="no-cache,no-store,must-revalidate"/></head><card title="FTP - ".strtoupper($lg).""><do name="back" type="options" label="Назад"><prev/></do>
<p align="left"><small>
<a href="ftp.php?k=$k&d=$rd&n=$rn">$d/$n</a><br/>
- - -<br/>
Архивировать в:</small><input name="nm".$nar."" type="text" value="$vl" maxlength="250"/><br/>
<small>CHMOD:</small>
<input name="chf" type="text" value="644" size="3" maxlength="3" format="*N"/><br/>
<small>- - -<br/>
<anchor>Архивировать<go href="$dftp/arhdir.php?k=$k&d=$rd&n=$rn&ch=$(chf)" method="post">
<postfield name="nm" value="$(nm".$nar.")"/>
</go></anchor>
</small></p>
</card></wml>");
} else {
if (($ftp=@ftp_connect($sr))&&(@ftp_login($ftp,$lg,$ps))) {
@ftp_pasv($ftp,true); @ftp_chdir($ftp,"$d/$n"); $curr=@ftp_pwd($ftp);
if ((substr($nm,-1)<>"/")&&($curr<>$nm)) {
function scan($dir,$kl=100,$sz=3145728) {
global $ftp; $arr=NULL; $ckl=0; $csz=0; @ftp_chdir($ftp,$dir);
if ($lst=@ftp_nlist($ftp,".")) {
for ($i=0;$i<count($lst);$i++) {$ckl++;
if ($ckl>$kl) {$ckl--; $arr['err']="ck"; break;}
$fnm=trim($lst[$i]);
if (strpos($fnm,$dir)!==0) {$fnm=str_replace('//','/',$dir.'/'.$fnm);}
$fln=preg_replace("~.*/([^/]*)~","\1",$fnm);
if (($fln<>".")&&($fln<>"..")) {
$size=ftp_size($ftp,$fnm); $csz=$csz+$size;
if ($csz>=$sz) {$csz=$csz-$size; $ckl--; $arr['err']="sz"; break;}
if ($size===-1) {
$arr['d'][]=$fnm;
if ($lt=scan($fnm,$kl-$ckl,$sz-$csz)) {
$arr=array_merge_recursive($arr,$lt);
if ($lt['sz']>0) {$csz=$csz+$lt['sz'];} $ckl=$ckl+$lt['ck'];
}
} else {$arr['f'][]=$fnm;}
}
}
$arr['sz']=$csz; $arr['ck']=$ckl;
return $arr;
} else {return false;}
}
$ar=scan($curr);
if (($ar['f']<>NULL)||($ar['d']<>NULL)) {
$tp=strtolower(preg_replace("~.*.([^.]*)~m","\1",$nm));
@mkdir("data/$k",0777);
if ($ar['d']<>NULL) {
for ($i=0;$i<count($ar['d']);$i++) {
@mkdir("data/$k/".preg_replace("~^".$curr."/~","",$ar['d'][$i]),0777);
}
}
if ($ar['f']<>NULL) {
for ($i=0;$i<count($ar['f']);$i++) {
@ftp_get($ftp,"data/$k/".preg_replace("~^".$curr."/~","",$ar['f'][$i]),$ar['f'][$i],FTP_BINARY);
}
}
if (($tp=="zip")||($tp=="jar")) {
include_once('pclzip.php'); $zip=new PclZip("data/$k.zip");
if ($zip->create("data/$k",PCLZIP_OPT_REMOVE_PATH,"data/$k",PCLZIP_OPT_COMMENT,$cmm)<>0) {
@ftp_put($ftp,"$nm","data/$k.zip",FTP_BINARY);
} @unlink("data/$k.zip");
} else {
include_once("tar.php"); $tar=new Archive_Tar("data/$k.tar");
if ($tar->createModify("data/$k","","data/$k")) {
@ftp_put($ftp,"$nm","data/$k.tar",FTP_BINARY);
} @unlink("data/$k.tar");
}
include_once("rmdir.php"); rdir("data/$k");
}
}
@ftp_close($ftp);
header("Location: $dftp/ftp.php?k=$k&d=$rd&n=$rn"); exit;
} else {
header("Content-Type: text/vnd.wap.wml; charset=Utf-8");
echo ("<?xml version="1.0" encoding="Utf-8"?><!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" "http://www.wapforum.org/DTD/wml_1.2.xml"><wml>
<head><meta forua="true" http-equiv="Cache-Control" content="no-cache,no-store,must-revalidate"/></head><card title="FTP - ".strtoupper($lg)."">
<p align="center"><small>
Нет соединения с сервером.<br/>
- - -<br/>
<anchor>Назад<prev/></anchor>
</small></p>
</card></wml>");
}
}
?>