Location: PHPKode > projects > FREE WAP PHP SCRIPTS CENTER > free_wap_ftp_client/actn.php
<?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="";} elseif ($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);
$ac=trim($_GET['ac']); $t=trim($_GET['t']); $go=trim($_GET['go']); $nm=trim($_POST['nm']);
if ($nm<>NULL) {
 $repl=array("\\"=>"",":"=>"","*"=>"","?"=>"","\""=>"","<"=>"",">"=>"","|"=>"");
 $nm=trim(strtr($nm,$repl));
 if ($ac<>"mv") {$nm=str_replace("/","",$nm);}
 include("repl.php"); $nm=u2t($nm);
}

if ($go<>1) {
 $n=str_replace('$','$$',$n); $d=str_replace('$','$$',$d);
 if (($ac=="del")&&($t=="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 - ".strtoupper($lg)."\">
<p align=\"center\"><small>
$d/$n<br/>
- - -<br/>
delete file?<br/>
<a href=\"actn.php?k=$k&amp;d=$rd&amp;n=$rn&amp;ac=del&amp;t=f&amp;go=1\">yes</a> <anchor>no<prev/></anchor>
</small></p>
</card></wml>");
 } elseif ($ac=="delf") {
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 - ".strtoupper($lg)."\">
<p align=\"center\"><small>
$d/$n<br/>
- - -<br/>
delete folder with all files?<br/>
<a href=\"actn.php?k=$k&amp;d=$rd&amp;n=$rn&amp;ac=delf&amp;t=d&amp;go=1\">yes</a> <anchor>no<prev/></anchor>
</small></p>
</card></wml>");
 } elseif (($ac=="ren")||($ac=="mv")) {
if ($n==NULL) {
 $n=preg_replace("~.*/([^/]*)~m","\\1",$d); $d=preg_replace("~(.*)/[^/]*~m","\\1",$d);
 $rn=str_replace(".htaccess",".|htaccess",$n);
 $rd=str_replace(".htaccess",".|htaccess",$d);
}
$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 ($ac=="ren") {$sn="new name"; $vl=$n;}
else {$sn="move to"; $vl=$d."/".$n;}
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 - ".strtoupper($lg)."\">
<p align=\"left\"><small>
$d/$n<br/>
- - -<br/>
$sn:</small><input name=\"nm".$nar."\" type=\"text\" value=\"$vl\" maxlength=\"150\"/><br/><small>- - -<br/><anchor>ok
<go href=\"$dftp/actn.php?k=$k&amp;d=$rd&amp;n=$rn&amp;ac=$ac&amp;t=$t&amp;go=1\" method=\"post\">
<postfield name=\"nm\" value=\"$(nm".$nar.")\"/>
</go></anchor><br/>
<anchor>undo<prev/></anchor>
</small></p>
</card></wml>");
 } elseif (($ac=="at")&&($t=="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 - ".strtoupper($lg)."\">
<p align=\"left\"><small>
<a href=\"ftp.php?k=$k&amp;d=$rd\">$d/</a><a href=\"file.php?k=$k&amp;d=$rd&amp;n=$rn\">$n</a><br/>
- - -<br/>
format:</small>
<select name=\"fmt\" value=\"at2\">
<option value=\"at1\">TAR</option>
<option value=\"at2\">TGZ</option>
<option value=\"at3\">TGZ2</option>
<option value=\"at4\">TBZ</option>
<option value=\"at5\">TBZ2</option>
</select><br/><small>
<a href=\"actn.php?k=$k&amp;d=$rd&amp;n=$rn&amp;ac=$(fmt)&amp;t=f&amp;go=1\">add</a><br/>- - -<br/>
<anchor>undo<prev/></anchor>
</small></p>
</card></wml>");
 }
} else {$stb="";
 if (($ftp=@ftp_connect($sr))&&(@ftp_login($ftp,$lg,$ps))) {
  @ftp_pasv($ftp,true);
  $st="error.";
  if (($ac=="del")&&($t=="f")) {//del file
   if (@ftp_delete($ftp,"$d/$n")) {
    @ftp_close($ftp);
    header("Location: $dftp/ftp.php?k=$k&d=$rd"); exit;
   } else {$st="Файл не удалён.";}
  } elseif (($ac=="delf")&&($t=="d")) {//del all dir
   function rdir($conn,$dir) {ftp_chdir($conn,$dir);
    $arr=ftp_nlist($conn,"."); $ctns=count($arr); if ($ctns>700) {$ctns=700;}
    for ($i=0;$i<$ctns;$i++) {$fl=$dir."/".$arr[$i];
     if ((ftp_size($conn,$fl)==-1)&&(preg_replace("~.*/([^/]*)~m","\\1",$fl)<>".")&&
     (preg_replace("~.*/([^/]*)~m","\\1",$fl)<>"..")) {rdir($conn,$fl);}
     else {@ftp_delete($conn,$fl);}
    } ftp_chdir($conn,"/");
    @ftp_delete($conn,$dir."/".".htaccess");
    if (ftp_rmdir($conn,$dir)) {return true;} else {return false;}
   }
   if ($n==NULL) {
    $n=preg_replace("~.*/([^/]*)~m","\\1",$d); $d=preg_replace("~(.*)/[^/]*~m","\\1",$d);
    $rn=str_replace(".htaccess",".|htaccess",$n);
    $rd=str_replace(".htaccess",".|htaccess",$d);
   }
   if (@rdir($ftp,"$d/$n")) {
    @ftp_close($ftp);
    header("Location: $dftp/ftp.php?k=$k&d=$rd"); exit;
   } else {$st="error.";}
   @ftp_close($ftp);
  } elseif (($ac=="mv")&&($t=="d")) {//move dir
   if (@ftp_rename($ftp,$d."/".$n,$nm)) {
    @ftp_close($ftp);
    $nm=str_replace(".htaccess",".|htaccess",$nm);
    $nm=rawurlencode($nm);
    header("Location: $dftp/ftp.php?k=$k&d=$nm"); exit;
   } else {$st="error.";}
  } elseif (($ac=="ren")&&($t=="d")) {//rename dir
   if (@ftp_rename($ftp,$d."/".$n,$d."/".$nm)) {
    @ftp_close($ftp);
    $nm=str_replace(".htaccess",".|htaccess",$nm);
    $nm=rawurlencode($nm);
    header("Location: $dftp/ftp.php?k=$k&d=$rd&n=$nm"); exit;
   } else {$st="error.";}
  } elseif (($ac=="ren")&&($t=="f")) {//rename file
   if (@ftp_rename($ftp,$d."/".$n,$d."/".$nm)) {
    @ftp_close($ftp);
    header("Location: $dftp/ftp.php?k=$k&d=$rd"); exit;
   } else {$st="error.";}
  } elseif (($ac=="copy")||($ac=="cut")||($ac=="arh")||($ac=="at1")||
   ($ac=="at2")||($ac=="at3")||($ac=="at4")||($ac=="at5")) {//add act
   $flist=@file("data/$k.act");
   $n=str_replace('$','$$',$n); $d=str_replace('$','$$',$d);
   if ($n[strlen($n)-1]=="/") {$n[strlen($n)-1]="";}
   $str="$d/$n|$t|$ac\r\n";
   if ($flist<>NULL) {
    for ($i=0;$i<count($flist);$i++) {if ($i==100) {break;} $str.=$flist[$i];}
   }
   $f=@fopen("data/$k.act","w"); @fwrite($f,$str); @fclose($f);
   if ($t=="d") {$st="Папка \"".htmlspecialchars($d."/".$n)."\" добавлена в список.";}
   else {$stb="<br/><a href=\"ftp.php?k=$k&amp;d=$rd\">$d/</a><a href=\"file.php?k=$k&amp;d=$rd&amp;n=$rn\">$n</a>"; $st="Файл \"".htmlspecialchars($d."/".$n)."\" added to file list.";}
  } elseif ($ac=="rm") {//list; remove
   $lnm=rawurldecode(trim(str_replace(".|htaccess",".htaccess",$_GET['lnm'])));
   $lnm=str_replace('$','$$',$lnm);
   if ($flist=@file("data/$k.act")) {$str="";
    for ($i=0;$i<count($flist);$i++) {
     list($p1,$p2,$p3)=split('[|]',$flist[$i]); $p1=trim($p1);
     if ($p1<>$lnm) {$str.=$flist[$i];}
    }
    $f=@fopen("data/$k.act","w"); @fwrite($f,$str); @fclose($f);
    header("Location: $dftp/list.php?k=$k&d=$rd&n=$rn"); exit;
   } else {$st="error.";}
  } elseif ($ac=="rmall") {//list; remove all
   if (unlink("data/$k.act")) {
    header("Location: $dftp/list.php?k=$k&d=$rd&n=$rn"); exit;
   } else {$st="error";}
  }
  @ftp_close($ftp);
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 - ".strtoupper($lg)."\">
<p align=\"center\"><small>
$st<br/>
- - -$stb<br/>
<anchor>back<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 - ".strtoupper($lg)."\">
<p align=\"center\"><small>
no connection.<br/>
- - -<br/>
<anchor>back<prev/></anchor>
</small></p>
</card></wml>");
 }
}
?>
Return current item: FREE WAP PHP SCRIPTS CENTER