View file ftp_servis/upload.php

File size: 2.32Kb
<?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="";} else {if ($d=="/") {$d="";}}
if ($n==NULL) {$n=preg_replace("~.*/([^/]*)~m","\\1",$d);
$d=preg_replace("~(.*)/[^/]*~m","\\1",$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);

$cnt=count($_FILES['nm']['name']);

header("Content-Type: text/html; charset=utf-8");
echo ("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"><html>
<head><title>FTP - Upload</title>
<meta forua=\"true\" http-equiv=\"Cache-Control\" content=\"no-cache\"></head>
<body bgcolor=\"#e6f5ff\" link=\"#0000aa\" vlink=\"#800000\"><small>
<a href=\"ftp.php?k=$k&amp;d=$rd&amp;n=$rn\">$d/$n</a><br>
- - -<br>\r\n");

if ($cnt<>NULL) {$st="";
 if (($ftp=@ftp_connect($sr))&&(@ftp_login($ftp,$lg,$ps))) {
  @ftp_pasv($ftp,true);
  for ($i=0;$i<$cnt;$i++) {
   if (($_FILES['nm']['name'][$i]<>NULL)&&($_FILES['nm']['size'][$i]<=7340032)&&($_FILES['nm']['size'][$i]>0)) {
    $name=preg_replace("~.*/([^/]*)~m","\\1",$_FILES['nm']['name'][$i]);
    if (ftp_put($ftp,"$d/$n/$name",$_FILES['nm']['tmp_name'][$i],FTP_BINARY)) {
     $sz=$_FILES['nm']['size'][$i];
     $st.="Файл \"".htmlspecialchars($name)."\" размером $sz байт успешно закачан.<br>";
    } else {$st.="Файл \"".htmlspecialchars($name)."\" не закачан.<br>";}
   }
  }
  @ftp_close($ftp);
  if ($st==NULL) {$st="Файлы не закачаны.<br>";}
  echo("$st- - -<br>");
 } else {
echo("Нет соединения с сервером.
</small></body></html>");
exit;
 }
}

echo("<form action=\"$dftp/upload.php?k=$k&amp;d=$rd&amp;n=$rn\" enctype=\"multipart/form-data\" method=\"post\">Файлы:<br>
<input name=\"nm[]\" type=\"file\"><br>
<input name=\"nm[]\" type=\"file\"><br>
<input name=\"nm[]\" type=\"file\"><br>
<input name=\"nm[]\" type=\"file\"><br>
<input name=\"nm[]\" type=\"file\"><br>
<input name=\"nm[]\" type=\"file\"><br>
<input name=\"nm[]\" type=\"file\"><br>- - -<br>
<input type=\"submit\" value=\"Загрузить\">
</form>
</small></body></html>");
?>