Автор Тема: file download  (Прочитано 1554 раз)

Оффлайн xalyavshik

  • Sr. Member
  • ****
  • Сообщений: 405
  • Linux Registred User #472973
    • ICQ клиент - 757487
    • Просмотр профиля
    • GNU in Armenia
    • Email
file download
« : Июль 29, 2008, 05:58:41 »
իմաստը
իմ ինետ-ը հայկական սայտերի համար ձրի ա իսկ դրսի սերվերներից դովն անելը 1 մբ --- xxx դրամ

այս սկրիպտը կոնկրետ ֆայլը դովն ա անում և ուղարկում ֆրինետի ֆտպ-ի վրա որից դե իհարկե ես կարամ ձրի քաշեմ

եսօր եմ գրե շատ կիսատ բաներ ունի բայց ում պետք ա կարա որոշ բաներ փոփոխի և իր համար օգտագործի  ;)

Цитировать
<?php

//______________ Start ______________ //

  print("start<br>");
  print(date("h:i:s"));
  print("<br>");
 
   // down file
     $v=file_get_contents ('http://www.slo.ru/download/daemon_tools/daemon_tools_4301_(SLO.ru).zip') or die("error 1");


  print("file get is ok<br>");

   //open file or if not exist touch it
     $file='123/1.zip';

     $x=fopen($file, "w+") or die("error open file");

   //write in opened file
     fwrite($x, $v) or die("error file write");

   //connect to ftp
     $conn_id = ftp_connect("users.freenet.am");

   //login to ftp
     $login_result = ftp_login($conn_id, 'XXXX', 'XXXXX');
    printf("ftp connected");
   //put file to ftp
     if (ftp_fput($conn_id, file, $x, FTP_BINARY)) {
       echo "Загружен файл $file\n";
     } else {
       echo "Проблема закачивания $file\n";
     }

   //close ftp connection
     ftp_close($conn_id);

   //close file
     fclose($x);

  print("all is ok");

//______________ E N D ______________ //

?>


բարի վայելում  ;D
# killall -9 "win PC"

Оффлайн xalyavshik

  • Sr. Member
  • ****
  • Сообщений: 405
  • Linux Registred User #472973
    • ICQ клиент - 757487
    • Просмотр профиля
    • GNU in Armenia
    • Email
Re: file download
« Ответ #1 : Июль 30, 2008, 11:28:43 »
ետ նույն ծրագիրը ավելի սիրուն ու մի քիչ փոփոխված  ;)
ես մեկը մաիլ ա ուղարկում ;D


Цитировать
<?php

 set_time_limit(0);
 ini_set("memory_limit","500M");

  class mime_mail {
  var $parts;
  var $to;
  var $from;
  var $headers;
  var $subject;
  var $body;

  function mime_mail() {
   $this->parts = array();
   $this->to =  "";
   $this->from =  "";
   $this->subject =  "";
   $this->body =  "";
   $this->headers =  "";
  }

  function add_attachment($message, $name = "", $ctype = "application/octet-stream") {
   $this->parts [] = array (
    "ctype" => $ctype,
    "message" => $message,
    "encode" => $encode,
    "name" => $name
   );
  }

  function build_message($part) {
   $message = $part["message"];
   $message = chunk_split(base64_encode($message));
   $encoding = "base64";
   return "Content-Type: ".$part["ctype"].($part["name"]? "; name = \"".$part["name"]."\"" : "")."\nContent-Transfer-Encoding: $encoding\n\n$message\n";
  }

  function build_multipart() {
   $boundary = "b".md5(uniqid(time()));
   $multipart = "Content-Type: multipart/mixed; boundary = $boundary\n\nThis  is a MIME encoded message.\n\n--$boundary";
   for($i = sizeof($this->parts)-1; $i>=0; $i--) $multipart .= "\n".$this->build_message($this->parts[$i]). "--$boundary";
   return $multipart.=  "--\n";
  }

  function send() {
   $mime = "";
   if (!empty($this->from)) $mime .= "From: ".$this->from. "\n";
   if (!empty($this->headers)) $mime .= $this->headers. "\n";
   if (!empty($this->body)) $this->add_attachment($this->body, "", "text/plain");   
   $mime .= "MIME-Version: 1.0\n".$this->build_multipart();
    mail($this->to, $this->subject, "", $mime);
  }
 }

?>

<html>

 <head>
  <title>Link</title>
 </head>

 <body>
  <center>

   <form action="index.php" method='post'>

    <table width="200" cellspacing="0" cellpadding="2" border="0" bgcolor="#2d3851"><tr><td>
    <table width="200" cellspacing="0" cellpadding="1" border="0" bgcolor="#ffffff"><tr><td>
    <table width="200" cellspacing="2" cellpadding="2" border="0" bgcolor="#5f7797">
     
     <tr align="center">
      <td bgcolor="#5f7797"><b>Линк для скачки .:</b></td>
     </tr>
     
     <tr align="center">
      <td  bgcolor="#a7aeb8"><input  name="link" type="text"></td>
     </tr>
     
     <tr align="center">
      <td bgcolor="#a7aeb8" ><input type="submit" value="Submit" name="sub2">
     </tr>

     <tr>
      <td bgcolor="#a7aeb8" align="center">
       <?php

        if (isset($_POST['sub2'])) {
         $link=$_POST['link'];
     
         print("start<br>");
         print(date("h:i:s"));
         print("<br>");

         if ($link!="") {
   
          // down file
          $v=file_get_contents ("$link") or die("error 1");

          print("file get is ok<br>");

          //open file or if not exist touch it
          $file='1.rar';

          $x=fopen($file, "w+") or die("error open file");

          //write in opened file
          fwrite($x, $v) or die("error file write");

          fclose($x);

          print(date("h:i:s"));
          print("<br>");

          $data=date("h:i:s");

          $FILE_ = "$file";
          $FROM_ = "from@mail.am";
          $TO_ = "to@mail.am";
          $SUBJECT_ = "mail with file $data";
          $TEXT_ = "cetch you file $link ;)";

          $attachment = fread(fopen($FILE_, "r"), filesize($FILE_));
          $mail = new mime_mail();
          $mail->from = $FROM_;
          $mail->headers = "Errors-To: ".$FROM_."";
          $mail->to = $TO_;
          $mail->subject = $SUBJECT_ ;
          $mail->body = $TEXT_;
          $mail->add_attachment("$attachment", $FILE_, "Content-Transfer-Encoding: base64  /9j/4AAQSkZJRgABAgEASABIAAD/7QT+UGhvdG9zaG");
          $mail->send();

          print(date("h:i:s"));
          print("<br>");
         }
      }
 
       ?>
      </td>
     </tr>
 
    </table>
    </table>   
    </table>

   </form>
   
 </center>
 </body>

</html>
# killall -9 "win PC"