View file ftp_servis/create.php

File size: 5.54Kb
<?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);}
$rd=rawurlencode($d); $rn=rawurlencode($n);
$d=str_replace(".|htaccess",".htaccess",$d);
$n=str_replace(".|htaccess",".htaccess",$n);
$d=str_replace('$','$$',$d); $n=str_replace('$','$$',$n);
$tp=trim($_GET['tp']); $nm=trim($_POST['nm']);
$ch=trim($_GET['ch']); $pn=trim($_GET['pn']);
if ($nm<>NULL) {
 $repl=array("\\"=>"","/"=>"",":"=>"","*"=>"","?"=>"","\""=>"","<"=>"",">"=>"",
 "|"=>"","`"=>""," "=>"_");
 $nm=trim(strtr($nm,$repl));
 include("repl.php"); $nm=u2t($nm);
 if (($nm==".")||($nm=="..")) {$nm="";}
}

if ((($tp=="f")||($tp=="d"))&&($nm<>NULL)) {
 if (($ftp=@ftp_connect($sr))&&(@ftp_login($ftp,$lg,$ps))) {
  @ftp_pasv($ftp,true); $fnm="";
  $d=str_replace('$$','$',$d); $n=str_replace('$$','$',$n);
  if ($tp=="f") {
   $sfnm="free";
   if ($pn==1) {$sfnm="php";}
   elseif ($pn==2) {$sfnm="php_wml";}
   elseif ($pn==3) {$sfnm="php_htm";}
   elseif ($pn==4) {$sfnm="wml";}
   elseif ($pn==5) {$sfnm="htm";}
   if (strlen($ch)<>3) {$ch="644";}
   @ftp_put($ftp,"$d/$n/$nm","patterns/".$sfnm.".ptn",FTP_BINARY);
   $cmd="chmod 0$ch $d/$n/$nm"; @ftp_site($ftp,$cmd);
   @ftp_close($ftp);
   header("Location: $dftp/ftp.php?k=$k&d=$rd&n=$rn"); exit;
  } elseif ($tp=="d") {
   if (strlen($ch)<>3) {$ch="755";}
   @ftp_mkdir($ftp,"$d/$n/$nm");
   $cmd="chmod 0$ch $d/$n/$nm"; @ftp_site($ftp,$cmd);
   @ftp_close($ftp);
   header("Location: $dftp/ftp.php?k=$k&d=$rd&n=$rn"); exit;
  } else {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 - Создать\">
<p align=\"center\"><small>
Нет соединения с сервером.<br/>
- - -<br/>
<anchor>Назад<prev/></anchor>
</small></p>
</card></wml>");
 }
} elseif ($tp=="f") {
$num=@file_get_contents("allnumbd.dat");
$num++; if ($num>9999999) {$num=0;}
$f=@fopen("allnumbd.dat","w"); @fwrite($f,$num); @fclose($f);
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 - Создать\">
<p align=\"left\"><small>
<a href=\"ftp.php?k=$k&amp;d=$rd&amp;n=$rn\">$d/$n</a><br/>
- - -<br/>
Имя:</small><input name=\"nm".$num."\" type=\"text\" value=\"new.php\" maxlength=\"150\"/><br/>
<small>CHMOD:</small>
<input name=\"ch".$num."\" type=\"text\" value=\"644\" size=\"3\" maxlength=\"3\" format=\"*N\"/><br/>
<small>Шаблон:</small>
<select name=\"pn\" value=\"0\">
<option value=\"0\">НЕТ</option>
<option value=\"1\">PHP</option>
<option value=\"2\">PHP_wml</option>
<option value=\"3\">PHP_html</option>
<option value=\"4\">WML</option>
<option value=\"5\">HTML</option>
</select><small>
<br/>- - -<br/>
<anchor>Создать файл
<go href=\"$dftp/create.php?k=$k&amp;d=$rd&amp;n=$rn&amp;ch=$(ch".$num.")&amp;tp=f&amp;pn=$(pn)\" method=\"post\"><postfield name=\"nm\" value=\"$(nm".$num.")\"/>
</go></anchor><br/>
- - -<br/>
<anchor>Назад<prev/></anchor>
</small></p>
</card></wml>");
} elseif ($tp=="d") {
$num=@file_get_contents("allnumbd.dat");
$num++; if ($num>9999999) {$num=0;}
$f=@fopen("allnumbd.dat","w"); @fwrite($f,$num); @fclose($f);
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 - Создать\">
<p align=\"left\"><small>
<a href=\"ftp.php?k=$k&amp;d=$rd&amp;n=$rn\">$d/$n</a><br/>
- - -<br/>
Имя:</small><input name=\"nm".$num."\" type=\"text\" value=\"new\" maxlength=\"150\"/><br/>
<small>CHMOD:</small>
<input name=\"ch".$num."\" type=\"text\" value=\"755\" size=\"3\" maxlength=\"3\" format=\"*N\"/><br/>
<small>- - -<br/>
<anchor>Создать папку
<go href=\"$dftp/create.php?k=$k&amp;d=$rd&amp;n=$rn&amp;ch=$(ch".$num.")&amp;tp=d\" method=\"post\"><postfield name=\"nm\" value=\"$(nm".$num.")\"/>
</go></anchor><br/>
- - -<br/>
<anchor>Назад<prev/></anchor>
</small></p>
</card></wml>");
} 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 - Создать\">
<p align=\"left\"><small>
<a href=\"ftp.php?k=$k&amp;d=$rd&amp;n=$rn\">$d/$n</a><br/>
- - -<br/>
<a href=\"create.php?k=$k&amp;d=$rd&amp;n=$rn&amp;tp=f\">Файл</a><br/>
<a href=\"create.php?k=$k&amp;d=$rd&amp;n=$rn&amp;tp=d\">Папку</a><br/>
- - -<br/>
<anchor>Назад<prev/></anchor>
</small></p>
</card></wml>");
}
?>