Файл: ftp/ecopy.php
Строк: 131
<?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);
require_once '../api_core/apicms_system.php';
require_once '../api_core/head.php';
echo'<div class="headmenu" style="padding: 8px; color:#fff;" >
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<td><img src="icons/cldir.png" width="16" height="16" alt=">"/>
<a style="color:#fff;" href="ftp.php?k='.$k.'&d='.$rd.'">'.$d.'/</a><a style="color:#fff;" href="file.php?k='.$k.'&d='.$rd.'&n='.$rn.'">'.$n.'</a>
</td>
<td align = "right">
<a class="headbut" href = "/ftp/">На главную</a>
<a class="headbut" href = "javascript:history.back(1)">Назад</a></td>
</div></div></table></div>';
$d=str_replace(".|htaccess",".htaccess",$d);
$n=str_replace(".|htaccess",".htaccess",$n);
require_once 'moduls/per.php';
$tp=trim($_GET['tp']); $nm=trim($_GET['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 (($tp<>NULL)&&($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);
if ($tp=="c") {
$vl=$d."/~".$n; $v1="Копировать в"; $v2="Копировать";
} elseif ($tp=="m") {
$vl=$d."/".$n; $v1="Переместить в"; $v2="Переместить";
} elseif ($tp=="a") {
$vl=$d."/".preg_replace("~([^.]*).*~m","\1",$n).".zip";
$v1="Архивировать в"; $v2="Архивировать";
} elseif ($tp=="t") {
$vl=$d."/".preg_replace("~([^.]*).*~m","\1",$n).".tgz";
$v1="Архивировать в"; $v2="Архивировать";
} else {header("Location: $dftp/ftp.php?k=$k&d=$rd"); exit;}
echo '
<div class="subhead">
<form action="ecopy.php" method="get">
'.$v1.':<br/>
<input name="nm" type="text" value="'.$vl.'" maxlength="250"/><br/>
CHMOD:
<input name="ch" type="text" value="644" size="3" maxlength="3" format="*N"/><br/>
<input type="hidden" name="k" value="'.$k.'"/>
<input type="hidden" name="d" value="'.$rd.'"/>
<input type="hidden" name="n" value="'.$rn.'"/>
<input type="hidden" name="tp" value="'.$tp.'"/>
<input type="hidden" name="go" value="1"/>
<input type="submit" value="'.$v2.'"><br/>
</div>';
} else {
if (($ftp=@ftp_connect($sr))&&(@ftp_login($ftp,$lg,$ps))) {
@ftp_pasv($ftp,true);
if ((substr($nm,-1)<>"/")&&($d."/".$n<>$nm)) {
if ($tp=="c") {
@ftp_get($ftp,"data/$k.bk","$d/$n",FTP_BINARY);
@ftp_put($ftp,"$nm","data/$k.bk",FTP_BINARY);
@unlink("data/$k.bk");
$cmd="chmod 0$ch $nm"; @ftp_site($ftp,$cmd);
} elseif ($tp=="m") {
@ftp_rename($ftp,"$d/$n","$nm");
$cmd="chmod 0$ch $nm"; @ftp_site($ftp,$cmd);
} elseif (($tp=="a")&&(@ftp_size($ftp,"$d/$n")<=3145728)) {
include('pclzip.php'); $zip=new PclZip("data/$k.zip");
mkdir("data/$k",0777);
ftp_get($ftp,"data/$k/$n","$d/$n",FTP_BINARY);
if ($zip->create("data/$k/$n",PCLZIP_OPT_REMOVE_ALL_PATH,PCLZIP_OPT_COMMENT,$cmm)<>0) {
@ftp_put($ftp,"$nm","data/$k.zip",FTP_BINARY);
}
@unlink("data/$k.zip");
@unlink("data/$k/$n"); @rmdir("data/$k");
} elseif (($tp=="t")&&(@ftp_size($ftp,"$d/$n")<=3145728)) {mkdir("data/$k",0777);
$name=preg_replace("~.*/([^/]*)~m","\1",$nm);
include('tar.php'); $tar=new Archive_Tar("data/$k/$name");
ftp_get($ftp,"data/$k/$n","$d/$n",FTP_BINARY);
if ($tar->createModify("data/$k/$n","","data/$k")) {
@ftp_put($ftp,"$nm","data/$k/$name",FTP_BINARY);
}
@unlink("data/$k/$name");
@unlink("data/$k/$n"); @rmdir("data/$k");
}
}
@ftp_close($ftp);
header("Location: $dftp/ftp.php?k=$k&d=$rd"); exit;
} else {
echo '<div class="subhead">
Нет соединения с сервером</div>
<div class="subhead"><a href="index.php">Главная</a></div>';
}
}
apicms_foot();
?>