Advertisement
Th3-822

[rapidleech][d] filecloud_io.php

Oct 27th, 2012
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.72 KB | None | 0 0
  1. <?php
  2.  
  3. if (!defined('RAPIDLEECH')) {
  4.     require_once('index.html');
  5.     exit;
  6. }
  7.  
  8. class filecloud_io extends DownloadClass {
  9.     private $page, $cookie, $redir, $_url, $_ukey, $dlreq, $dlurl, $ab1, $captcha;
  10.     public function Download($link) {
  11.         global $premium_acc;
  12.         $this->cookie = array();
  13.  
  14.         if (empty($_POST['skip']) || $_POST['skip'] != 'true') {
  15.             global $Referer;
  16.             $this->page = $this->GetPage($link, $this->cookie);
  17.             if (substr($this->page, 9, 3) == '404') html_error('File not Found or Deleted');
  18.             $this->cookie = GetCookiesArr($this->page, $this->cookie);
  19.             if (preg_match('@\r\nLocation: ((https?://(?:www\.)?filecloud\.io)?/[^\r\n]+)@i', $this->page, $redir)) {
  20.                 $this->redir = (empty($redir[2])) ? 'http://filecloud.io'.$redir[1] : $redir[1];
  21.                 $this->page = $this->GetPage($this->redir, $this->cookie, 0, $link);
  22.                 $this->cookie = GetCookiesArr($this->page, $this->cookie);
  23.                 $Referer = $this->redir;
  24.             } else $Referer = $link;
  25.             if (preg_match('@\nLocation: (https?://s\d+\.filecloud\.io/[^\r\n]+)@i', $this->page, $dllink)) {
  26.                 $filename = urldecode(basename(parse_url($dllink[1], PHP_URL_PATH)));
  27.                 return $this->RedirectDownload($dllink[1], $filename);
  28.             }
  29.         }
  30.  
  31.         // Check https support for login.
  32.         $cantlogin = false;
  33.         if (!extension_loaded('openssl')) {
  34.             if (extension_loaded('curl')) {
  35.                 $cV = curl_version();
  36.                 if (!in_array('https', $cV['protocols'], true)) $cantlogin = true;
  37.             } else $cantlogin = true;
  38.             if ($cantlogin) $this->changeMesg(lang(300).'<br /><br />Https support: NO<br />Login disabled.');
  39.         }
  40.  
  41.         if ($_REQUEST['premium_acc'] == 'on' && (((!empty($_REQUEST['premium_user']) && !empty($_REQUEST['premium_pass'])) || (!empty($premium_acc['filecloud_io']['user']) && !empty($premium_acc['filecloud_io']['pass']))) || !empty($premium_acc['filecloud_io']['apikey']))) $this->Login($cantlogin);
  42.         elseif (!empty($_POST['skip']) && $_POST['skip'] == 'true') {
  43.             $this->_ukey = urldecode($_POST['_ukey']);
  44.             $this->ab1 = urldecode($_POST['_ab1']);
  45.             $this->chkcaptcha($link, true);
  46.         } else $this->Prepare($link);
  47.     }
  48.  
  49.     private function Prepare($link) {
  50.         $_s = '[\s\t]'; //Still lazy XD
  51.  
  52.         if (!preg_match("@$_s'ukey'$_s*:$_s*'([^']+)'@i", $this->page, $_ukey)) html_error('Error: File ID not found.');
  53.         $this->_ukey = $_ukey[1];
  54.  
  55.         if (!preg_match("@var$_s+__requestUrl$_s*=$_s*'([^']+)'@i", $this->page, $_url)) html_error('Error: Url for posting data not found.');
  56.         $this->_url = $_url[1];
  57.  
  58.         if (!preg_match("@var$_s+__downloadUrl$_s*=$_s*'([^']+)'@i", $this->page, $dlreq)) $dlreq = array(1=>false);
  59.         $this->dlreq = $dlreq[1];
  60.  
  61.         if (!preg_match("@var$_s+__recaptcha_public$_s*=$_s*'([^']+)'@i", $this->page, $this->captcha)) $this->captcha = false;
  62.         $this->captcha = $this->captcha[1];
  63.  
  64.         $ab_js = $this->GetPage('http://filecloud.io/ads/adframe.js', $this->cookie);
  65.         if (!preg_match("@var$_s+__ab1$_s*=$_s*[\'\"]([^\'\"]+)[\'\"]@i", $ab_js, $ab1)) html_error('Error: "Session" code not found.');
  66.         $this->ab1 = $ab1[1];
  67.  
  68.         $this->chkcaptcha($link);
  69.     }
  70.  
  71.     private function FreeDL($rply) {
  72.         if ($rply['dl'] != '1') {
  73.             $err = (!empty($rply['message'])) ? ': '.htmlentities($rply['message']) : '.';
  74.             html_error("Error getting download-link$err");
  75.         }
  76.  
  77.         $page = $this->GetPage($this->dlreq, $this->cookie);
  78.  
  79.         if (!preg_match('@https?://s\d+\.filecloud\.io/'.$this->_ukey.'/[^\r\n\s\t<>\'\"]+@i', $page, $dllink)) html_error('Error: Download-link not found.');
  80.  
  81.         $filename = urldecode(basename(parse_url($dllink[0], PHP_URL_PATH)));
  82.         return $this->RedirectDownload($dllink[0], $filename, $this->cookie);
  83.     }
  84.  
  85.     private function Get_Reply($page) {
  86.         if (!function_exists('json_decode')) html_error('Error: Please enable JSON in php.');
  87.         // First time using json_decode in plugins. :)
  88.         $json = substr($page, strpos($page, "\r\n\r\n") + 4);
  89.         $json = substr($json, strpos($json, '{'));$json = substr($json, 0, strrpos($json, '}') + 1);
  90.         $rply = json_decode($json, true);
  91.         if (!$rply || count($rply) == 0) html_error('Error getting json data.');
  92.         return $rply;
  93.     }
  94.  
  95.     private function chkcaptcha($link, $send = false) {
  96.         $post = array();
  97.         $post['ukey'] = $this->_ukey;
  98.         $post['__ab1'] = $this->ab1; // More annoying ad-block trap.
  99.         if ($send) {
  100.             if (empty($_POST['captcha'])) html_error('You didn\'t enter the image verification code.');
  101.             $post['ctype'] = 'recaptcha';
  102.             $post['recaptcha_response'] = $_POST['captcha'];
  103.             $post['recaptcha_challenge'] = $_POST['challenge'];
  104.  
  105.             $this->_url = urldecode($_POST['_url']);
  106.             $this->dlreq = urldecode($_POST['_dlreq']);
  107.             $this->cookie = urldecode($_POST['cookie']);
  108.  
  109.             $page = $this->GetPage($this->_url, $this->cookie, $post);
  110.             $rply = $this->Get_Reply($page);
  111.  
  112.             if ($rply['captcha'] == 0) $this->FreeDL($rply);
  113.             elseif ($rply['retry'] == 1) html_error('Error: Wrong Captcha Entered.');
  114.             else html_error('Error Sending Captcha.');
  115.         } else {
  116.             $page = $this->GetPage($this->_url, $this->cookie, $post);
  117.             $rply = $this->Get_Reply($page);
  118.  
  119.             if ($rply['status'] == 'ok') {
  120.                 if ($rply['captcha'] == 0) {
  121.                     $this->FreeDL($rply);
  122.                 } else {
  123.                     if (!$this->captcha || empty($this->captcha)) html_error('Error: Captcha not found.');
  124.                     $data = $this->DefaultParamArr($link, $this->cookie);
  125.                     $data['_ukey'] = urlencode($this->_ukey);
  126.                     $data['_url'] = urlencode($this->_url);
  127.                     $data['_dlreq'] = urlencode($this->dlreq);
  128.                     $data['_ab1'] = urlencode($this->ab1);
  129.                     $data['skip'] = 'true';
  130.                     $this->DL_reCaptcha($this->captcha, $data);
  131.                 }
  132.             } else html_error("Error getting download data ('{$rply['status']}' => '{$rply['message']}').");
  133.         }
  134.         return false;
  135.     }
  136.  
  137.     private function DL_reCaptcha($pid, $data) {
  138.         $page = $this->GetPage('http://www.google.com/recaptcha/api/challenge?k=' . $pid);
  139.         if (!preg_match('/challenge \: \'([^\']+)/i', $page, $ch)) html_error('Error getting CAPTCHA data.');
  140.         $challenge = $ch[1];
  141.  
  142.         $data['challenge'] = $challenge;
  143.  
  144.         //Download captcha img.
  145.         $page = $this->GetPage('http://www.google.com/recaptcha/api/image?c=' . $challenge);
  146.         $capt_img = substr($page, strpos($page, "\r\n\r\n") + 4);
  147.         $imgfile = DOWNLOAD_DIR . 'filecloud_captcha.jpg';
  148.  
  149.         if (file_exists($imgfile)) unlink($imgfile);
  150.         if (!write_file($imgfile, $capt_img)) html_error('Error getting CAPTCHA image.');
  151.  
  152.         $this->EnterCaptcha($imgfile.'?'.time(), $data, 20);
  153.         exit;
  154.     }
  155.  
  156.     private function Login($cantlogin) {
  157.         global $premium_acc;
  158.         if ($cantlogin && empty($premium_acc['filecloud_io']['apikey'])) html_error('Login Error: Empty apikey.');
  159.  
  160.         // Ping api
  161.         $page = $this->GetPage('http://api.filecloud.io/api-ping.api');
  162.         is_notpresent($page, '"message":"pong"', 'Error: filecloud.io api is down?.');
  163.  
  164.         if (!empty($_REQUEST['premium_user']) && !empty($_REQUEST['premium_pass'])) $pA = true;
  165.         else $pA = false;
  166.         if (empty($premium_acc['filecloud_io']['apikey']) || $pA) {
  167.             $user = ($pA ? $_REQUEST['premium_user'] : $premium_acc['filecloud_io']['user']);
  168.             $pass = ($pA ? $_REQUEST['premium_pass'] : $premium_acc['filecloud_io']['pass']);
  169.             if (empty($user) || empty($pass)) html_error('Login Failed: Username or Password are empty. Please check login data.');
  170.  
  171.             $post = array();
  172.             $post['username'] = urlencode(strtolower($user));
  173.             $post['password'] = urlencode($pass);
  174.             $page = $this->GetPage('https://secure.filecloud.io/api-fetch_apikey.api', 0, $post);
  175.             $rply = $this->Get_Reply($page);
  176.  
  177.             if ($rply['status'] != 'ok') html_error('Login Failed: '.htmlentities($rply['message']));
  178.             if (empty($rply['akey'])) html_error('Login Failed: Akey not found.');
  179.         } else $rply = array('akey' => urldecode($premium_acc['filecloud_io']['apikey']));
  180.  
  181.         $this->cookie = array('auth' => urlencode($rply['akey']));
  182.         return $this->PremiumDL();
  183.     }
  184.  
  185.     private function PremiumDL() {
  186.         if (!preg_match('@\nLocation: (https?://s\d+\.filecloud\.io/[^\r\n]+)@i', $this->page, $dllink)) {
  187.             if (!preg_match("@[\s\t]'ukey'[\s\t]*:[\s\t]*'([^']+)'@i", $this->page, $_ukey)) html_error('Error: FileID not found.');
  188.             $page = $this->GetPage('http://api.filecloud.io/api-fetch_download_url.api', 0, array('akey' => $this->cookie['auth'], 'ukey' => $_ukey[1]));
  189.             $rply = $this->Get_Reply($page);
  190.  
  191.             if ($rply['status'] != 'ok') html_error('Error getting premium dlink: '.htmlentities($rply['message']));
  192.             if (empty($rply['download_url'])) html_error('Error getting premium dlink... Empty?');
  193.         } else $rply = array('download_url' => $dllink[1]);
  194.  
  195.         $filename = urldecode(basename(parse_url($rply['download_url'], PHP_URL_PATH)));
  196.         return $this->RedirectDownload($rply['download_url'], $filename);
  197.     }
  198. }
  199.  
  200. //[26-Oct-2012] (Re)Written by Th3-822.
  201. //[17-Feb-2013] Login Fixes. - Th3-822
  202. //[16-Oct-2013] Fixed support for direct-links. - Th3-822
  203.  
  204. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement