Location: PHPKode > projects > FREE WAP PHP SCRIPTS CENTER > free_wap_ftp_client/import.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="";} 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);}
$url=trim(stripslashes($_POST['url'])); if ($url=="<http://>") {$url=NULL;}
$rd=rawurlencode($d); $rn=rawurlencode($n);
$d=str_replace('$','$$',$d); $n=str_replace('$','$$',$n);
$d=str_replace(".|htaccess",".htaccess",$d);
$n=str_replace(".|htaccess",".htaccess",$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 - import\"><do name=\"faq\" type=\"options\" label=\"FAQ\"><go href=\"$dftp/faq.php?p=7\"/></do>");

if ($url<>NULL) {
 if (($ftp=@ftp_connect($sr))&&(@ftp_login($ftp,$lg,$ps))) {
  @ftp_pasv($ftp,true);
  @preg_match_all("~<([^*>]*)[*]?([^*>]*)[*]?([acm]{1})?>~m",$url,$arr);
  if ($arr<>NULL) {include("repl.php");
   $cn=count($arr[0]); $str=""; $pp=""; $imp=0; $addl=0;
   if ($cn>25) {$cn=25;}
   for ($i=0;$i<$cn;$i++) {
    $curl=$arr[1][$i];
    if (strpos($curl,'"')!==false) {
     if (substr_count($curl,'"')==1) {
      $pp=preg_replace("~^([^\"]*).*~","\\1",$curl);
      if ($pp[strlen($pp)-1]=="/") {$pp[strlen($pp)-1]="";}
     }
     $curl=str_replace('"','',$curl);

    } elseif ($pp<>NULL) {
     if ((strlen($curl)<5)||(@substr($curl,0,5)<>"http:")) {
      if ($curl[0]=="/") {$curl=substr($curl,1);} $curl=trim($pp)."/".trim($curl);
     }
    }
    if ($arr[2][$i]==NULL) {
     $sv=preg_replace("~.*/([^/]*)~m","\\1",$curl);
     if ($sv==NULL) {$sv="index.wml";}
    } else {$sv=$arr[2][$i];}
    $repl=array("\\"=>"",":"=>"","*"=>"","?"=>"","\""=>"","<"=>"",">"=>"","|"=>"");
    $sv=trim(strtr($sv,$repl));
    $sv=u2t($sv);

    if ($n[strlen($n)-1]=="/") {$n[strlen($n)-1]="";}
    if ($sv[0]=="/") {$svf=$sv;} else {$svf=$d."/".$n."/".$sv;}
    if (strpos($curl,"http://")===0) {$fsz=NULL;
     $host=preg_replace("~.*://([^/]*).*~","\\1",$curl,1);
     $path=preg_replace("~.*://[^/]*(/.*)~","\\1",$curl,1);
     if (($host<>$curl)&&($path<>$curl)) {
      $f=@fsockopen($host,80,$e,$e,7);
      @fputs($f,"HEAD $path HTTP/1.1\r\nHost: $host\r\nConnection: close\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n");
      $header="";
      while (!feof($f)) {$header.=@fgets($f,1024);}
      @fclose($f);
      if (strpos($header,"Content-Length:")!==false) {
       eregi("Content-Length: ([0-9]*)",$header,$mss);
       $fsz=trim($mss[1]);
      }
     }
     if (($fsz==NULL)||($fsz<=5242880)) {
      if (copy($curl,"data/$k.bk")) {
       if (filesize("data/$k.bk")<=5242880) {
        if (ftp_put($ftp,$svf,"data/$k.bk",FTP_BINARY)) {
         $imp++;
         $ac=NULL;
         if ($arr[3][$i]<>NULL) {
          if ($arr[3][$i]=="m") {$ac="cut";}
          else if ($arr[3][$i]=="c") {$ac="copy";}
          else if ($arr[3][$i]=="a") {$ac="arh";}
         }
         if ($ac<>NULL) {$addl++; $str.="$svf|f|$ac\r\n";}
        }
       } else {$st.="file ".htmlspecialchars(str_replace('$','$$',$curl),ENT_QUOTES)." too big.<br/>\r\n";}
      } else {$st.="file ".htmlspecialchars(str_replace('$','$$',$curl),ENT_QUOTES)." not imported.<br/>\r\n";}
     } else {$st.="file ".htmlspecialchars(str_replace('$','$$',$curl),ENT_QUOTES)." too big.<br/>\r\n";}
    } else {$st.="Файл ".htmlspecialchars(str_replace('$','$$',$curl),ENT_QUOTES)." не импортирован.<br/>\r\n";}
    @unlink("data/$k.bk");
   }
   if ($str<>NULL) {
    $flist=@file("data/$k.act");
    if ($flist<>NULL) {
     for ($j=0;$j<count($flist);$j++) {if ($j==100) {break;} $str.=$flist[$j];}
    }
    $f=@fopen("data/$k.act","w"); @fwrite($f,$str); @fclose($f);
   }
   if ($cn<>NULL) {
    if ($st<>NULL) {$st.="- - -<br/>\r\n";}
    $st.="imported files: $imp/$cn<br/>\r\n";
    if ($addl<>NULL) {$st.="files added to file list: $addl<br/><a href=\"list.php?k=$k&amp;d=$rd&amp;n=$rn\"list</a><br/>\r\n";}
    $st.="- - -<br/>";
   }
  } else {$st="error.";}
  @ftp_close($ftp);
$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 ($pp<>NULL) {$purl="&lt;".htmlspecialchars(trim($pp))."&gt;";} else {$purl="&lt;http://&gt;";}
echo("<p align=\"left\"><small>$st
<a href=\"ftp.php?k=$k&amp;d=$rd&amp;n=$rn\">$d/$n</a><br/>
- - -<br/>
URL's:</small><input name=\"url".$nar."\" type=\"text\" value=\"$purl\"/><br/>
<small><anchor>import file!
<go href=\"$dftp/import.php?k=$k&amp;d=$rd&amp;n=$rn\" method=\"post\">
<postfield name=\"url\" value=\"$(url".$nar.")\"/>
</go></anchor><br/>
<anchor>back<prev/></anchor>
</small></p>
</card></wml>");
 } else {
echo("<p align=\"center\"><small>
no connection.<br/>
- - -<br/>
<anchor>back<prev/></anchor>
</small></p>
</card></wml>");
 }
} else {
$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);
echo ("<p align=\"left\"><small>
<a href=\"ftp.php?k=$k&amp;d=$rd&amp;n=$rn\">$d/$n</a><br/>
- - -<br/>
URL's:</small><input name=\"url".$nar."\" type=\"text\" value=\"&lt;http://&gt;\"/><br/>
<small><anchor>import file!
<go href=\"$dftp/import.php?k=$k&amp;d=$rd&amp;n=$rn\" method=\"post\">
<postfield name=\"url\" value=\"$(url".$nar.")\"/>
</go></anchor><br/>
<anchor>back<prev/></anchor>
</small></p>
</card></wml>");
}
?>
Return current item: FREE WAP PHP SCRIPTS CENTER