Advertisement
Th3-822

[rapidleech][d] rapidu_net

Feb 21st, 2016
385
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.70 KB | None | 0 0
  1. <?php
  2.  
  3. if (!defined('RAPIDLEECH')) {
  4.     require_once('index.html');
  5.     exit;
  6. }
  7.  
  8. class rapidu_net extends DownloadClass {
  9.     private $page, $cookie = array(), $pA, $login, $DLRegexp = '@https?://\w+\d+\.rapiduservers\.net/download/[^\t\r\n\'\"<>]+@i';
  10.     public function Download($link) {
  11.         if (!preg_match('@(https?://rapidu.net/)(\d+)@i', str_ireplace('://www.rapidu.net', '://rapidu.net', $link), $fid)) html_error('Invalid link?.');
  12.         $this->link = $GLOBALS['Referer'] = str_ireplace('http://', 'https://', $fid[0]);
  13.         $this->baseurl = $fid[1];
  14.         $this->fid = $fid[2];
  15.  
  16.         if (empty($_POST['step'])) {
  17.             $this->page = $this->GetPage($this->link, $this->cookie);
  18.             is_present($this->page, '404 - File not found', 'File Not Found.');
  19.             $this->cookie = GetCookiesArr($this->page, $this->cookie);
  20.         }
  21.  
  22.         $this->pA = (empty($_REQUEST['premium_user']) || empty($_REQUEST['premium_pass']) ? false : true);
  23.         if (($_REQUEST['premium_acc'] == 'on' && ($this->pA || (!empty($GLOBALS['premium_acc']['rapidu_net']['user']) && !empty($GLOBALS['premium_acc']['rapidu_net']['pass']))))) {
  24.             $user = ($this->pA ? $_REQUEST['premium_user'] : $GLOBALS['premium_acc']['rapidu_net']['user']);
  25.             $pass = ($this->pA ? $_REQUEST['premium_pass'] : $GLOBALS['premium_acc']['rapidu_net']['pass']);
  26.             if ($this->pA && !empty($_POST['pA_encrypted'])) {
  27.                 $user = decrypt(urldecode($user));
  28.                 $pass = decrypt(urldecode($pass));
  29.                 unset($_POST['pA_encrypted']);
  30.             }
  31.             return $this->Login($user, $pass);
  32.         } else return $this->AnonDL();
  33.     }
  34.  
  35.     private function AnonDL() {
  36.         if (empty($_POST['step']) || $_POST['step'] != '1') {
  37.             $page = $this->GetPage($this->baseurl . 'ajax.php?a=getLoadTimeToDownload', $this->cookie, '_go=', $this->link . "\r\nX-Requested-With: XMLHttpRequest");
  38.             $this->cookie = GetCookiesArr($page, $this->cookie);
  39.             $start_timer = $this->json2array($page, 'getLoadTimeToDownload Error');
  40.  
  41.             if (!isset($start_timer['timeToDownload']) || !is_numeric($start_timer['timeToDownload'])) {
  42.                 if (!empty($start_timer['timeToDownload']) && $start_timer['timeToDownload'] == 'stop') html_error('Your daily transfer limit has been reached');
  43.                 textarea($start_timer);
  44.                 html_error('Unknown error @ getLoadTimeToDownload');
  45.             }
  46.             $start_timer['timeToDownload'] -= time();
  47.  
  48.             $js = $this->GetPage($this->baseurl . 'js/global.engine.js', $this->cookie);
  49.             if (!preg_match('@Recaptcha\.create\s*\(\s*\'([\w\.\-]+)\'@i', $js, $recaptcha)) html_error('Captcha Not Found.');
  50.  
  51.             if (!empty($start_timer['timeToDownload']) && $start_timer['timeToDownload'] > 0) {
  52.                 if ($start_timer['timeToDownload'] > 100) {
  53.                     return $this->JSCountdown($start_timer['timeToDownload'], $this->DefaultParamArr($this->link), 'AnonDL limit reached.');
  54.                 } else $this->CountDown($start_timer['timeToDownload']);
  55.             }
  56.  
  57.             $data = $this->DefaultParamArr($this->link, $this->cookie, 1, true);
  58.             $data['step'] = '1';
  59.             return $this->reCAPTCHA($recaptcha[1], $data);
  60.         } else {
  61.             if (empty($_POST['recaptcha_response_field'])) html_error('You didn\'t enter the image verification code.');
  62.             if (empty($_POST['recaptcha_challenge_field'])) html_error('Empty reCAPTCHA challenge.');
  63.             $this->cookie = StrToCookies(decrypt(urldecode($_POST['cookie'])));
  64.  
  65.             $post = array();
  66.             $post['captcha1'] = $_POST['recaptcha_challenge_field'];
  67.             $post['captcha2'] = $_POST['recaptcha_response_field'];
  68.             $post['fileId'] = $this->fid;
  69.             $post['_go'] = '';
  70.  
  71.             $page = $this->GetPage($this->baseurl . 'ajax.php?a=getCheckCaptcha', $this->cookie, array_map('urlencode', $post));
  72.             $chkCaptcha = $this->json2array($page, 'getCheckCaptcha Error');
  73.  
  74.             if (empty($chkCaptcha['message']) || $chkCaptcha['message'] != 'success') html_error('Wrong captcha entered.');
  75.             if (empty($chkCaptcha['url'])) html_error('Download Link Not Found.');
  76.  
  77.             return $this->RedirectDownload($chkCaptcha['url'], urldecode(parse_url($chkCaptcha['url'], PHP_URL_PATH)));
  78.         }
  79.     }
  80.  
  81.     private function ApiDL() {
  82.         $DL = $this->ApiReq('getFileDownload', array('id' => $this->fid));
  83.         if (!empty($DL['message'])) {
  84.             if (!empty($DL['message']['errorDateNextDownload'])) {
  85.                 $data = $this->DefaultParamArr($this->link);
  86.                 $data['premium_acc'] = 'on';
  87.                 if ($this->pA) {
  88.                     $data['pA_encrypted'] = 'true';
  89.                     $data['premium_user'] = urlencode($_REQUEST['premium_user']); // encrypt() will keep this safe.
  90.                     $data['premium_pass'] = urlencode($_REQUEST['premium_pass']); // And this too.
  91.                 }
  92.                 $waitTime = strtotime($DL['message']['errorDateNextDownload'] . ' UTC') - time();
  93.                 return $this->JSCountdown($waitTime, $data, 'FreeDL limit reached.');
  94.             } else if ($DL['message']['error'] == 'errorAccountNotHaveDayTransfer') html_error('Your daily transfer limit has been reached.');
  95.             else html_error('[ApiDL Error] ' . htmlspecialchars($DL['message']['error'], ENT_QUOTES));
  96.         }
  97.  
  98.         if (empty($DL['fileLocation'])) html_error('Download-Link Not Found.');
  99.         return $this->RedirectDownload($DL['fileLocation'], urldecode(basename(parse_url($DL['fileLocation'], PHP_URL_PATH))));
  100.     }
  101.  
  102.     private function Login($user, $pass) {
  103.         $this->login = array('login' => $user, 'password' => $pass);
  104.         $reply = $this->ApiReq('getAccountDetails');
  105.  
  106.         if (!empty($reply['message'])) html_error('[Login Error] ' . htmlspecialchars($reply['message']['error'], ENT_QUOTES));
  107.         if (empty($reply['userPremium'])) $this->changeMesg('<br /><b>Account isn\'t premium</b>', true);
  108.  
  109.         return $this->ApiDL();
  110.     }
  111.  
  112.     private function ApiReq($path, $post = array()) {
  113.         if (!is_array($post)) $post = array();
  114.         if ($path != 'getFileDetails') $post = array_merge($this->login, $post);
  115.  
  116.         $page = $this->GetPage("https://rapidu.net/api/$path/", 0, array_map('urlencode', $post), 'https://rapidu.net/');
  117.         return $this->json2array($page, "ApiReq($path) Error");
  118.     }
  119.  
  120.     private function json2array($content, $errorPrefix = 'Error') {
  121.         if (!function_exists('json_decode')) html_error('Error: Please enable JSON in php.');
  122.         if (empty($content)) return NULL;
  123.         $content = ltrim($content);
  124.         if (($pos = strpos($content, "\r\n\r\n")) > 0) $content = trim(substr($content, $pos + 4));
  125.         $cb_pos = strpos($content, '{');
  126.         $sb_pos = strpos($content, '[');
  127.         if ($cb_pos === false && $sb_pos === false) html_error("[$errorPrefix]: JSON start braces not found.");
  128.         $sb = ($cb_pos === false || $sb_pos < $cb_pos) ? true : false;
  129.         $content = substr($content, strpos($content, ($sb ? '[' : '{')));$content = substr($content, 0, strrpos($content, ($sb ? ']' : '}')) + 1);
  130.         if (empty($content)) html_error("[$errorPrefix]: No JSON content.");
  131.         $rply = json_decode($content, true);
  132.         if ($rply === NULL) html_error("[$errorPrefix]: Error reading JSON.");
  133.         return $rply;
  134.     }
  135. }
  136.  
  137. //[21-2-2016]  Written by Th3-822.
  138.  
  139. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement