Форум АНТИЧАТ

Форум АНТИЧАТ (https://forum.antichat.xyz/index.php)
-   PHP, PERL, MySQL, JavaScript (https://forum.antichat.xyz/forumdisplay.php?f=37)
-   -   PHPDownload (https://forum.antichat.xyz/showthread.php?t=43557)

Ntkiller 02.07.2007 20:37

PHPDownload
 
Начал разработку скрипта на php, который будет эмулировать браузер, основная цель - закачка файлов с докачкой, где докачка не поддерживается(например rapidshare) Также можно использовать для создания всяких web-proxy, скриптов отсылки смс на телефоны без использования iframe, накрутчиков посещений. Сейчас реализовано немного, а именно:
1) User-Agent берется из настроек класса
2) Refer устанавливается автоматически, простые проверки на рефер выдерживает
3) Работает с cookies
4) Пошаговая система интегрирована в ядро.

Также доступен 1 модуль - для закачки с rapidshare, он тоже только начал разрабатываться, пока что не реализовано:
1)Определение имени файла(всегда result.rar)
2)Выбор зеркала

Глючит но работает))

Для работы нужно чтобы был установлен cUrl.

Как думаете есть ли смысл в подобном проекте? Что-бы вы хотели в нем увидеть?

Всем желающим помочь в тестировании исходные коды выкладываю, отписываться в теме, если происходят глюки НЕКАЧАЙТЕ СРАЗУ ДРУГОЙ ФАЙЛ, сначала сохраните файлы res1.htm и res2.htm и потом передайте мне, тогда я смогу постараться решить проблему.

Вот код ядра:
Код:

<?php
        //TODO:CURL_ERRORS
        class CORE
        {

  var $form='';
  var $cookie='';
  var $userAgent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)';
  var $refer='';

  function Init()
  {
          //Init?
  }

  function getStep()
  {
          If((isset($_GET['step'])) && (intval($_GET['step']) != 0))
          {
    return intval($_GET['step'])
          } else {
    return 1;
          }
  }

  function setCookieFile($name)
  {
          $this->cookie=$name;
  }

  function addEdit($name,$value='')
  {
          //TODO:NETXLINE
          //TODO:LABEL
          If($value=='')
          {
    $this->form.='<input type=text name="'.$name.'">';
          } else {
    $this->form.='<input type=text name="'.$name.'" value="'.$value.'">';
          }
  }

  function addElement($element)
  {
          $this->form.=$element;
  }

  function setRefer($refer)
  {
          $this->refer=$refer;
  }

  function doRequest($url,$postfields='',$infile='')
  {
          $curl=curl_init()
          curl_setopt($curl,CURLOPT_URL,$url)
          curl_setopt($curl,CURLOPT_FOLLOWLOCATION,1)
          $cookie=$this->cookie;
          If($cookie!='')
          {
    curl_setopt($curl,CURLOPT_COOKIEJAR,$cookie)
    curl_setopt($curl,CURLOPT_COOKIEFILE,$cookie)
          }
          $userAgent=$this->userAgent;
          If($userAgent != '')
          {
    curl_setopt($curl,CURLOPT_USERAGENT,$userAgent)
          }
          $refer=$this->refer;
          If($refer != '')
          {
    curl_setopt($curl,CURLOPT_REFERER,$refer)
          }
          $this->refer=$url;
          If($postfields!='')
          {
    curl_setopt($curl,CURLOPT_POST,1)
    curl_setopt($curl,CURLOPT_POSTFIELDS,$postfields)
          }
          curl_setopt($curl,CURLOPT_RETURNTRANSFER,1)
          If($infile!='')
          {
    curl_setopt($curl,CURLOPT_FILE,$infile)
    curl_exec($curl)
          } else {
    $result = curl_exec($curl)
    return $result;
          }
  }

  function display($hasNext=1)
  {
          If($hasNext==1)
          {
    $form='<FORM method=GET action="">';
    $form.=$this->form;
    $form.='<input type=hidden name="step" value='.($this->getStep()+1).'>';
                                $form.='<input type=submit value=Next>';
    $form.='</FORM>';
    print $form;
          } else {
    print $this->form;
          }
  }
        }
?>

Вот код Файла, который использует ядро для закачки с rapidshare:

Код:

<?
 include('./core.php')
 $core=new Core()
 $core->Init()
 $core->setCookieFile('./cookie.txt')
 $step=$core->getStep()
 If($step==1)
 {
  $core->addElement('url:')
  $core->addEdit('url')
  $core->display()
 }
 If($step==2)
 {
  $result = $core->doRequest($_GET['url'])
  $file=fopen('res1.htm','w')
  fputs($file,$result)
  fclose($file)
  eregi('<form action="(.*)" method="post">',$result,$action)
  $action=$action[1];
  $result = $core->doRequest($action,'dl.start=Free')
  $file=fopen('res2.htm','w')
  fputs($file,$result)
  fclose($file)
  eregi('You have reached the download-limit for free-users. Want to download more?',$result,$limit)
  If(isset($limit))
  {
  $core->addElement('DownloadLimit Try again Later.')
  $core->displayƐ)
  } else {
  eregi('<h3>No premium user. Please enter<br><img src=http://pro-hack.ru:81/forum/"(.*)"><br>here:',$result,$image)
  $image=$image[1];
  eregi('<form name="dl" action="([^"]*)" method="post">',$result,$action)
  $action=$action[1];
  $file=fopen('./img.jpg','w')
  $core->doRequest($image,'',$file)
  fclose($file)
  $core->addElement('<input type="hidden" name="act" value="'.$action.'">')
  $core->addElement('<img src=http://pro-hack.ru:81/forum/"img.jpg">')
  $core->addElement('<input type="edit" name="code">')
  $core->display()
  }
 }
 If($step==3)
 {
  set_time_limitƐ)
  $action = $_GET['act'];
  $submit = 'Download%20via%20GlobalCrossing';
  $code=$_GET['code'];
  $file=fopen('./result.rar','w')
  $result=$core->doRequest($action,'actionstring='.$submit.'&accesscode='.$code.'',$file)
  fclose($file)
  $core->addElement('<a href="result.rar">Done</a>')
  $core->displayƐ)
 }
?>

Интересно услышать ваше мнение по проекту.

x-demon 01.08.2007 21:23

Развивай, что забросил... А по хорошему - внедри эти функции в rapidget.spb.ru


Время: 21:30