Файл: shopen.php
Строк: 176
<?php
error_reporting(0);
$sid=trim($_GET['sid']);
$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);
$ac=trim($_GET['ac']); $id=trim($_GET['id']); $p=trim($_GET['p']);
$d=str_replace(".|htaccess",".htaccess",$d); $n=str_replace(".|htaccess",".htaccess",$n);
if ($ac==NULL) {
$fls=@file("data/$k.aopen"); $links=""; $bl=""; $cnt=count($fls);
if (($cnt<>NULL)&&($cnt<>1)) {$bln=true;
$cnt--; $v=15; $allp=ceil($cnt/$v);
if (($p==NULL)||($p==0)) {$p=1;} elseif ($p>$allp) {$p=$allp;}
$begin=$p*$v-$v; if ($begin>$cnt) {$begin=0;}
$end=$begin+$v; if ($end>$cnt) {$end=$cnt;}
list($p1,$p2,$p3,$p4)=split("::",$fls[0]); $tp=trim($p4);
for ($i=$begin;$i<$end;$i++) {
list($p1,$p2,$p3,$p4,$p5)=split("::",$fls[$i+1]);
$p1=trim($p1); $p2=str_replace('$','$$',$p2); $p5=trim($p5); $sz="";
if ($p3==1) {
$sz="(DIR)"; $fd=">"; $remd="<a href="shopen.php?k=$k&d=$rd&n=$rn&ac=rmd&id=$p1">R</a> ";
} else {$fd=""; $remd="";
$sz="(".str_replace(".",",",round($p4/1024,2));
if ($tp=="zip") {$sz.="/".str_replace(".",",",round($p5/1024,2)).")";} else {$sz.=")";}
}
$links.="[$fd<a href="shopen.php?k=$k&d=$rd&n=$rn&ac=ex&id=$p1" title="$sz">$p2</a> $remd<a href="shopen.php?k=$k&d=$rd&n=$rn&ac=rm&id=$p1">del</a>]<br/>rn";
}
if ($p>1) {$v=$p-1; $bl.="<a style="color:red" href="shopen.php?k=$k&d=$rd&n=$rn&p=$v"><b><<</b></a> | ";} elseif ($allp>$p) {$bl.="<< | ";}
if ($allp>$p) {$v=$p+1; $bl.="<a style="color:red" href="shopen.php?k=$k&d=$rd&n=$rn&p=$v"><b>>></b></a><br/>rn";} elseif ($p>1) {$bl.=">><br/>rn";}
if ($bl<>NULL) {$bl="$bl<br/>$p/$allp
<form action="shopen.php?" method="get"><input type="hidden" name="sid" value="$sid"/><input type="hidden" name="k" value="$k"/><input type="hidden" name="d" value="$rd"/><input type="hidden" name="n" value="$rn"/><input type="text" name="p" value="$p" size="3" format="*N"/><input type="submit" value="GO"/></form><br/>";}
} else {
$bln=false;
if ($cnt==1) {header("Location:ftp.php?k=$k&d=$rd&act=pm"); exit;}
else {header("Location:ftp.php?k=$k&d=$rd"); exit;}
}
if ($d=="/") {$d="";} $n=str_replace("$","$",$n); $d=str_replace("$","$",$d);
$title="Show open";
include("inc/head.php");
echo("<div class="gmenu" align="left">
<a href="ftp.php?k=$k&d=$rd">$d/</a><a href="file.php?k=$k&d=$rd&n=$rn">$n</a></div><div class="bmenu"><b>$title</b></div><div class="menu">
$links<br/>$bl
");
if ($bln<>false) {echo("opened: $cnt<br/><a href="shopen.php?k=$k&d=$rd&n=$rn&ac=all">extract all</a><br/>");}echo("<br/></div>");
include("inc/foot.php");
} else {
if (($ac=="rm")||($ac=="rmd")) {
if ($fls=@file("data/$k.aopen")) {$cnt=count($fls);
$f=@fopen("data/$k.aopen","w");
@fwrite($f,$fls[0]); $rmd=NULL;
for ($i=1;$i<$cnt;$i++) {
list($p1,$p2,$p3,$p4,$p5)=split("::",$fls[$i]); $p1=trim($p1);
if ($id<>$p1) {
if ($p3==1) {$rmd==NULL;}
if (($rmd==NULL)||(strpos($p2,$rmd."/")!==0)) {@fwrite($f,$fls[$i]);}
} elseif (($ac=="rmd")&&($p3==1)) {$rmd=$p2;}
}
@fclose($f);
}
header("Location: $dftp/shopen.php?k=$k&d=$rd&n=$rn&p=$p"); exit;
} elseif (($ac=="ex")||($ac=="all")) {
if (($ftp=@ftp_connect($sr))&&(@ftp_login($ftp,$lg,$ps))) {
@ftp_pasv($ftp,true); $lst=NULL; $rmd="";
if ($fls=@file("data/$k.aopen")) {$cnt=count($fls);
list($p1,$p2,$p3,$p4)=split("::",trim($fls[0]));
$dir=$p1; $chf=$p2; $chd=$p3; $tp=$p4;
$f=@fopen("data/$k.aopen","w");
@fwrite($f,$fls[0]); $rmd=NULL;
for ($i=1;$i<$cnt;$i++) {
list($p1,$p2,$p3,$p4,$p5)=split("::",trim($fls[$i]));
if ($ac=="all") {
$lst[]=$p2;
} elseif ($id<>$p1) {
if ($p3==1) {$rmd==NULL;}
if (($rmd==NULL)||(strpos($p2,$rmd."/")!==0)) {@fwrite($f,$fls[$i]);}
else {$lst[]=$p2;}
} else {if ($p3==1) {$rmd=$p2; $lst[]=$p2;} else {$lst[]=$p2;}}
}
@fclose($f);
}
if ($lst<>NULL) {
function scan($dir) {$arr=NULL;
$handle=@opendir($dir);
while (($file=readdir($handle))<>false) {
if (is_file($dir."/".$file)) {$arr['f'][]=$dir."/".$file;}
elseif (is_dir($dir."/".$file)&&($file<>".")&&($file<>"..")) {
$arr['d'][]=$dir."/".$file;
if ($lt=scan($dir."/".$file)) {$arr=array_merge_recursive($arr,$lt);}
}
}
closedir($handle);
if ($arr<>NULL) {return $arr;} else {return false;}
}
if ($tp=="tar") {
include_once('tar.php'); $tar=new Archive_Tar("data/$k.tar");
mkdir("data/$k",0777);
if ($tar->extractList($lst,"data/$k")) {
ftp_mkdir($ftp,$dir);
if ($lt=scan("data/$k")) {
if ($lt['d']<>NULL) {
for ($i=0;$i<count($lt['d']);$i++) {
$name=preg_replace("~^data/".$k."/~","",$lt['d'][$i]);
ftp_mkdir($ftp,$dir."/".$name);
$cmd="chmod 0$chd ".$dir."/".$name; @ftp_site($ftp,$cmd);
}
}
if ($lt['f']<>NULL) {
for ($i=0;$i<count($lt['f']);$i++) {
$name=preg_replace("~^data/".$k."/~","",$lt['f'][$i]);
ftp_put($ftp,$dir."/".$name,$lt['f'][$i],FTP_BINARY);
$cmd="chmod 0$chf ".$dir."/".$name; @ftp_site($ftp,$cmd);
}
}
}
}
include_once("rmdir.php"); rdir("data/$k");
} else {
include_once('pclzip.php'); $zip=new PclZip("data/$k.zip");
mkdir("data/$k",0777);
if ($zip->extract(PCLZIP_OPT_BY_NAME,$lst,PCLZIP_OPT_PATH,"data/$k")<>0) {
ftp_mkdir($ftp,$dir);
if ($lt=scan("data/$k")) {
if ($lt['d']<>NULL) {
for ($i=0;$i<count($lt['d']);$i++) {
$name=preg_replace("~^data/".$k."/~","",$lt['d'][$i]);
ftp_mkdir($ftp,$dir."/".$name);
$cmd="chmod 0$chd ".$dir."/".$name; @ftp_site($ftp,$cmd);
}
}
if ($lt['f']<>NULL) {
for ($i=0;$i<count($lt['f']);$i++) {
$name=preg_replace("~^data/".$k."/~","",$lt['f'][$i]);
ftp_put($ftp,$dir."/".$name,$lt['f'][$i],FTP_BINARY);
$cmd="chmod 0$chf ".$dir."/".$name; @ftp_site($ftp,$cmd);
}
}
}
}
include_once("rmdir.php"); rdir("data/$k");
}
}
@ftp_close($ftp);
header("Location:shopen.php?k=$k&d=$rd&n=$rn&p=$p"); exit;
} else {
$title="No Connection...";
include("inc/in_head.php");
echo ("<p class="rmenu" align="center">
no connection...</p>");
include("inc/foot.php");
}
}
}
?>