Location: PHPKode > projects > FREE WAP PHP SCRIPTS CENTER > free_wap_ftp_client/openarh.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="";} if ($n==NULL) {$n=preg_replace("~.*/([^/]*)~m","\\1",$d);
$d=preg_replace("~(.*)/[^/]*~m","\\1",$d);}
$rd=rawurlencode($d); $rn=rawurlencode($n); $tp=trim($_GET['tp']);
$d=str_replace(".|htaccess",".htaccess",$d);
$n=str_replace(".|htaccess",".htaccess",$n);
$nm=trim($_POST['nm']); $chf=trim($_POST['chf']); $chd=trim($_POST['chd']);
if ($nm<>NULL) {
 $repl=array("\\"=>"",":"=>"","*"=>"","?"=>"","\""=>"","<"=>"",">"=>"","|"=>"");
 $nm=trim(strtr($nm,$repl));
 include("repl.php"); $nm=u2t($nm);
 if ($nm=="..") {$nm="";}
}

if (($nm==NULL)||(strlen($chf)<>3)||(strlen($chd)<>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);
$vl=$d."/".preg_replace("~([^.]*).*~m","\\1",$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)."\"><do name=\"back\" type=\"options\" label=\"back\"><prev/></do>
<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/>
extract to:</small><input name=\"nm".$nar."\" type=\"text\" value=\"$vl\" maxlength=\"250\"/><br/>
<small>file CHMOD:</small>
<input name=\"chf".$nar."\" type=\"text\" value=\"644\" size=\"3\" maxlength=\"3\" format=\"*N\"/><br/>
<small>folder CHMOD:</small>
<input name=\"chd".$nar."\" type=\"text\" value=\"755\" size=\"3\" maxlength=\"3\" format=\"*N\"/><br/>
<small>- - -<br/>
<anchor>open<go href=\"$dftp/openarh.php?k=$k&amp;d=$rd&amp;n=$rn&amp;tp=$tp\" method=\"post\">
<postfield name=\"nm\" value=\"$(nm".$nar.")\"/>
<postfield name=\"chd\" value=\"$(chd".$nar.")\"/>
<postfield name=\"chf\" value=\"$(chf".$nar.")\"/>
</go></anchor>
</small></p>
</card></wml>");
} else {
if (($ftp=@ftp_connect($sr))&&(@ftp_login($ftp,$lg,$ps))) {
 @ftp_pasv($ftp,true); $sz=ftp_size($ftp,"$d/$n");
 if (($sz==-1)||($sz>716800)) {header("Location: $dftp/ftp.php?k=$k&d=$rd"); exit;}
 if ($nm[0]<>"/") {if ($nm==".") {$nm="";} $nm=$d."/".$nm;}
 $nm=preg_replace("~(^/)|(/$)|(//)~","",$nm);
 $nm=str_replace('$','$$',$nm);
 if (($tp=="zip")||($tp=="jar")) {
  @ftp_get($ftp,"data/$k.zip","$d/$n",FTP_BINARY);
  include_once('pclzip.php'); $zip=new PclZip("data/$k.zip");
  if (($lst=$zip->listContent())==0) {$st="corrupted archive or server error.";}
  $f=@fopen("data/$k.aopen","w");
  @fwrite($f,$nm."::".$chf."::".$chd."::zip\r\n");
  for ($i=0;$i<count($lst);$i++) {
   $fnm=trim($lst[$i]['stored_filename']);
   $fd=trim($lst[$i]['folder']); if ($fd<>1) {$fd=0;}
   if ($fd==1) {$fnm=preg_replace("~(^/)|(/$)~","",$fnm);}
   @fwrite($f,$i."::".$fnm."::".$fd."::".trim($lst[$i]['size'])."::".trim($lst[$i]['compressed_size'])."\r\n");
  }
  @fclose($f);
 } else {
  @ftp_get($ftp,"data/$k.tar","$d/$n",FTP_BINARY);
  include_once("tar.php"); $tar=new Archive_Tar("data/$k.tar");
  if (($lst=$tar->listContent())==0) {$st="corrupted archive or server error.";}
  $f=@fopen("data/$k.aopen","w");
  @fwrite($f,$nm."::".$chf."::".$chd."::tar\r\n");
  for ($i=0;$i<count($lst);$i++) {
   $fnm=trim($lst[$i]['filename']);
   $fd=trim($lst[$i]['typeflag']); if ($fd==5) {$fd=1;} else {$fd=0;}
   if ($fd==1) {$fnm=preg_replace("~(^/)|(/$)~","",$fnm);}
   @fwrite($f,$i."::".$fnm."::".$fd."::".trim($lst[$i]['size'])."::0\r\n");
  }
  @fclose($f);
 }
 @ftp_close($ftp);
 header("Location: $dftp/shopen.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 - ".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