Файл: ftp/create.php
Строк: 176
<?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);
require_once '../api_core/apicms_system.php';
require_once '../api_core/head.php';
require_once 'moduls/per.php';
$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($_GET['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="";}
}
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.'&n='.$rn.'">'.$d.'/'.$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>';
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);
echo'
<script type="text/javascript">
document.location.href="'.$dftp.'/ftp.php?k='.$k.'&d='.$rd.'&n='.$rn.'";
</script>';
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);
echo'
<script type="text/javascript">
document.location.href="'.$dftp.'/ftp.php?k='.$k.'&d='.$rd.'&n='.$rn.'";
</script>';
header("Location: $dftp/ftp.php?k=$k&d=$rd&n=$rn"); exit;
} else {
echo'
<script type="text/javascript">
document.location.href="'.$dftp.'/ftp.php?k='.$k.'&d='.$rd.'&n='.$rn.'";
</script>';
header("Location: $dftp/ftp.php?k=$k&d=$rd&n=$rn"); exit;}
} else {
echo '<div class="subhead">
Нет соединения с сервером</div>
<div class="title_page"><a href="index.php">Главная</a></div>';
}
} 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);
echo '
<div class="subhead">
<form action="create.php" method="get">
<b>Имя:</b>:<br/>
<input name="nm" type="text" value="new.php" maxlength="250"/><br/>
<b>CHMOD</b>:
<input name="ch" type="text" value="755" size="3" maxlength="3" format="*N"/><br/>
<b>Шаблон:</b><br/>
<select name="pn" value="0">
<option value="0">НЕТ</option>
<option value="1">PHP</option>
<option value="4">WML</option>
<option value="5">HTML</option>
</select>
<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="f"/>
<input type="submit" value="Создать"><br/>
</form>
</div>';
} 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);
echo '
<div class="subhead">
<form action="create.php" method="get">
<b>Имя</b>:<br/>
<input name="nm" type="text" value="new" maxlength="250"/><br/>
<b>CHMOD</b>:
<input name="ch" type="text" value="755" 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="d"/>
<input type="submit" value="Создать"><br/>
</form>
</div>';
} else {
echo '
<div class="subhead">» <a href="create.php?k='.$k.'&d='.$rd.'&n='.$rn.'&tp=f">Файл</a></div>
<div class="subhead">» <a href="create.php?k='.$k.'&d='.$rd.'&n='.$rn.'&tp=d">Папку</a></div>';
}
apicms_foot();
?>