blackmanos
Advanced Member | Редактировать | Профиль | Сообщение | ICQ | Цитировать | Сообщить модератору <?php //Зроблено blackmanos //Часть функций взято из PHP rapidget error_reporting(0); #ignore_user_abort(1); set_time_limit(0); error_reporting(7); //собственно пользователь и пароль для авторизации $user=""; $pass=""; @ini_set('memory_limit', '1024M'); @ob_end_clean(); ob_implicit_flush(TRUE); //А здесь путь и имя файла который собираемся заливать $file="wgetgui.exe"; $fieldname=$file; $filename=$file; $fileSize=getfilesize($file); $nn = "\r\n"; $bound="---------------------------".substr(md5(time()),-14); $postdata.="--".$bound.$nn; $postdata.="Content-Disposition: form-data; name=file_p; filename=\"$filename\"".$nn; $postdata.="Content-Type: application/octet-stream".$nn.$nn; if ($user!=="") { $ch = curl_init(); $fp = fopen ("index.html", "w"); $head = fopen ("header.txt", "w"); global $cookiearr; // установка URL и других необходимых параметров curl_setopt($ch, CURLOPT_URL, "http://www.uploading.com/ru/account.php"); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; ru; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_WRITEHEADER,$head); // загрузка страницы и выдача её браузеру curl_exec($ch); curl_close($ch); fclose($fp); fclose($head); $cokl = fopen ("header.txt", "r"); while (!feof($cokl)) { $string = fgets($cokl,4096); if(!strncmp($string, "Set-Cookie:", 11)) { #get the cookie $cookiestr = trim(substr($string, 11, -1)); } } $ch = curl_init(); $poasdata1="login=".$user."&pwd=".$pass; $fp = fopen ("index1.html", "w"); $head = fopen ("header1.txt", "w"); curl_setopt($ch, CURLOPT_URL, "http://www.uploading.com/ru/account.php"); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; ru; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_COOKIE, $cookiestr); curl_setopt($ch, CURLOPT_POSTFIELDS, $poasdata1); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_WRITEHEADER,$head); // загрузка страницы и выдача её браузеру curl_exec($ch); fclose($fp); fclose($head); curl_close($ch); $cookiestr=""; $cokl = fopen ("header1.txt", "r"); while (!feof($cokl)) { $string = fgets($cokl,4096); if(!strncmp($string, "Set-Cookie:", 11)) { #get the cookie $cookiestr = $cookiestr ."; ". trim(substr($string, 11, -1)); } } $ch1 = curl_init(); $fp1 = fopen ("index2.html", "w"); $head1 = fopen ("header2.txt", "w"); curl_setopt($ch1, CURLOPT_URL, "http://www.uploading.com/ru/howto.php"); curl_setopt($ch1, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; ru; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); curl_setopt($ch1, CURLOPT_HEADER, 0); curl_setopt($ch1, CURLOPT_COOKIE, $cookiestr); curl_setopt($ch1, CURLOPT_FILE, $fp1); curl_setopt($ch1, CURLOPT_WRITEHEADER,$head1); // загрузка страницы и выдача её браузеру curl_exec($ch1); fclose($fp1); fclose($head1); curl_close($ch1); // завершение сеанса и освобождение ресурсов } $ch2 = curl_init(); $fp2 = fopen ("index3.html", "w"); $head2 = fopen ("header3.txt", "w"); //echo "zapros /ru/"; curl_setopt($ch2, CURLOPT_URL, "http://www.uploading.com/ru/"); curl_setopt($ch2, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; ru; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); curl_setopt($ch2, CURLOPT_HEADER, 0); curl_setopt($ch2, CURLOPT_COOKIE, $cookiestr); curl_setopt($ch2, CURLOPT_FILE, $fp2); curl_setopt($ch2, CURLOPT_WRITEHEADER,$head2); // загрузка страницы и выдача её браузеру curl_exec($ch2); fclose($fp2); fclose($head2); curl_close($ch2); ///echo "exit /ru/"; $cookiestr=""; $cokl = fopen ("index3.html", "r"); while (!feof($cokl)) { $string = fgets($cokl,4096); if(strstr($string, "updone.php")) { $action_url = cut_str($string,'multipart/form-data','>'); $url = parse_url(cut_str($action_url,'action="','"')); print_r($url); $UPLOAD_METTER_ID = cut_str($action_url,'umid=','"'); } } $host=$url['host']; $port="80"; $full_url=$url['path']."?".$url["query"]; ///echo "zapros... ".$stroka."\n"; /* POST //Accept: * / * Referer: * Accept-Language: * Content-Type: multipart/form-data * User-Agent: * Host: * Content-Length: * Connection: Keep-Alive Cache-Control: no-cache *-дописать. */ $referer="Referer: http://www.uploading.com/ru/"; $zapros= "POST ".str_replace(" ", "%20", $full_url)." HTTP/1.0".$nn. "Host: ".$host.$nn.$cookiestr. "Content-Type: multipart/form-data; boundary=".$bound.$nn."Content-Length: ".(strlen($postdata)+strlen($nn."--".$bound."--".$nn)+$fileSize).$nn. "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; ru; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6".$nn. "Accept: */*".$nn. "Accept-Language: ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3".$nn. "Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7".$nn. "Connection: Keep-Alive".$nn. "Cache-Control: no-cache".$nn. $auth. $referer. $nn. $nn. $postdata; echo $zapros; $fp_streem = fsockopen($host, $port, &$errno, &$errstr, 150); ///stream_set_timeout($fp_streem, 300); if($errno || $errstr) { $lastError = 'err'.$errstr; print "false connect"; } ///echo "File <b>".$filename."</b>, size <b>".bytesToKbOrMb($fileSize)."</b>...<br>"; flush(); $timeStart=getmicrotime(); $len=strlen($zapros); $chunkSize=GetChunkSize($fileSize); fputs($fp_streem,$zapros); fflush($fp_streem); $pac=ceil($fileSize / $chunkSize); $fs=fopen($file,'r'); $i=0; $local_sleep=$sleep_count; while (!feof($fs)) { $data=fread($fs,$chunkSize); if ($data === false) { fclose($fs); fclose($fp_streem); html_error('Error READ Data'); } if (($sleep_count !== false) && ($sleep_time !== false) && is_numeric($sleep_time) && is_numeric($sleep_count) && ($sleep_count > 0) && ($sleep_time > 0)) { $local_sleep--; if ($local_sleep == 0) { usleep($sleep_time); $local_sleep=$sleep_count; } } $sendbyte=fputs($fp_streem,$data); fflush($fp_streem); if ($sendbyte === false) { fclose($fs); fclose($fp_streem); html_error('Error SEND Data'); } $totalsend+=$sendbyte; $time = getmicrotime() - $timeStart; $chunkTime = $time - $lastChunkTime; $chunkTime = $chunkTime ? $chunkTime : 1; $lastChunkTime = $time; $speed = round($sendbyte / 1024 / $chunkTime, 2); $percent = round($totalsend / $fileSize * 100, 2); echo "<script>pr(".$percent.", '".bytesToKbOrMb($totalsend)."', ".$speed.")</script>\n"; flush(); } fclose($fs); fputs($fp_streem,$nn."--".$bound."--".$nn); fflush($fp_streem); while(!feof($fp_streem)) { $data=fgets($fp_streem,1024); if ($data === false) {break;} $page.=$data; }; fclose($fp_streem); $download_link = cut_str($page,"downloadurl = '","'"); echo $download_link."\n"; echo "goto exit"; function getmicrotime(){ list($usec, $sec) = explode(" ",microtime()); return ((float)$usec + (float)$sec); } function GetChunkSize($fsize) { if ($fsize <= 1024*1024) { return 4096; } if ($fsize <= 1024*1024*10) { return 4096*10; } if ($fsize <= 1024*1024*40) { return 4096*30; } if ($fsize <= 1024*1024*80) { return 4096*47; } if ($fsize <= 1024*1024*120) { return 4096*65; } if ($fsize <= 1024*1024*150) { return 4096*70; } if ($fsize <= 1024*1024*200) { return 4096*85; } if ($fsize <= 1024*1024*250) { return 4096*100; } if ($fsize <= 1024*1024*300) { return 4096*115; } if ($fsize <= 1024*1024*400) { return 4096*135; } if ($fsize <= 1024*1024*500) { return 4096*170; } if ($fsize <= 1024*1024*1000) { return 4096*200; } return 4096*210; } function getfilesize($f) { global $is_windows; $stat=stat($f); if ($is_windows) return sprintf("%u", $stat[7]); if (($stat[11] * $stat[12]) < 4*1024*1024*1024) return sprintf("%u", $stat[7]); global $max_4gb; if ($max_4gb === false) { $tmp_=trim(@shell_exec(" ls -Ll ".@escapeshellarg($f))); while (strstr($tmp_,' ')) { $tmp_=@str_replace(' ',' ',$tmp_); } $r=@explode(' ',$tmp_); $size_=$r[4]; } else { $size_=-1; } return $size_; } function bytesToKbOrMb($bytes){ $size = ($bytes >= (1024 * 1024 * 1024 * 1024)) ? round($bytes / (1024 * 1024 * 1024 * 1024), 2)." TB" : (($bytes >= (1024 * 1024 * 1024)) ? round($bytes / (1024 * 1024 * 1024), 2)." GB" : (($bytes >= (1024 * 1024)) ? round($bytes / (1024 * 1024), 2)." MB" : round($bytes / 1024, 2)." KB")); return $size; } function cut_str($str, $left, $right){ $str = substr(stristr($str, $left), strlen($left)); $leftLen = strlen(stristr($str, $right)); $leftLen = $leftLen ? -($leftLen) : strlen($str); $str = substr($str, 0, $leftLen); return $str; } ?> |