Advertisement
Th3-822

[rapidleech][d] minhateca_com_br

Apr 22nd, 2016
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.47 KB | None | 0 0
  1. <?php
  2.  
  3. if (!defined('RAPIDLEECH')) {
  4.     require_once('index.html');
  5.     exit;
  6. }
  7.  
  8. class minhateca_com_br extends DownloadClass {
  9.     private $page, $cookie = array(), $pA, $DLRegexp = '@https?://s\d+\.minhateca\.com\.br/File\.aspx\?[^\t\r\n\'\"<>]+@i';
  10.     public function Download($link) {
  11.         if (!preg_match('@(https?://minhateca\.com\.br)/(?:[^/]+/)+[^\r\n\t/<>\"]+,(\d+)[^\r\n\t/<>\"]*@i', str_ireplace('://www.minhateca.com.br', '://minhateca.com.br', $link), $fid)) html_error('Invalid link?.');
  12.         $this->link = str_ireplace('https://', 'http://', $fid[0]);
  13.         $this->baseurl = $fid[1];
  14.         $this->fid = $fid[2];
  15.  
  16.         $this->pA = (empty($_REQUEST['premium_user']) || empty($_REQUEST['premium_pass']) ? false : true);
  17.         if (($_REQUEST['premium_acc'] == 'on' && ($this->pA || (!empty($GLOBALS['premium_acc']['minhateca_com_br']['user']) && !empty($GLOBALS['premium_acc']['minhateca_com_br']['pass']))))) {
  18.             $user = ($this->pA ? $_REQUEST['premium_user'] : $GLOBALS['premium_acc']['minhateca_com_br']['user']);
  19.             $pass = ($this->pA ? $_REQUEST['premium_pass'] : $GLOBALS['premium_acc']['minhateca_com_br']['pass']);
  20.             return $this->Login($user, $pass);
  21.         } else return $this->TryDL();
  22.     }
  23.  
  24.     private function TryDL() {
  25.         $this->page = $this->GetPage($this->link, $this->cookie);
  26.         $this->cookie = GetCookiesArr($this->page, $this->cookie);
  27.  
  28.         if (!preg_match($this->DLRegexp, $this->page, $DL)) {
  29.             if (substr($this->page, 9, 3) != '200') html_error('File Not Found or Private.');
  30.             $download = $this->reqAction('License/Download', array('fileId' => $this->fid, '__RequestVerificationToken' => $this->getCSRFToken($this->page)));
  31.             if (empty($download['redirectUrl']) || !preg_match($this->DLRegexp, $download['redirectUrl'], $DL)) {
  32.                 if (empty($this->cookie['RememberMe']) && $download['Type'] == 'Window') html_error('Login is Required to Download This File.');
  33.                 html_error('Download-Link Not Found.');
  34.             }
  35.         }
  36.         return $this->RedirectDownload($DL[0], 'minhateca_placeholder_fname');
  37.     }
  38.  
  39.     private function getCSRFToken($page, $errorPrefix = 'Error') {
  40.         if (!preg_match('@name="__RequestVerificationToken"\s+type="hidden"\s+value="([\w\-+/=]+)"@i', $page, $token)) return html_error("[$errorPrefix]: Request Token Not Found.");
  41.         return $token[1];
  42.     }
  43.  
  44.     private function Login($user, $pass) {
  45.         $page = $this->GetPage($this->baseurl . '/', $this->cookie);
  46.         $this->cookie = GetCookiesArr($page, $this->cookie);
  47.  
  48.         $login = $this->reqAction('login/login', array('Login' => $user, 'Password' => $pass, 'FileId' => 0, '__RequestVerificationToken' => $this->getCSRFToken($page, 'Login Error')));
  49.         if (empty($login['IsSuccess'])) html_error('Login Error: IsSuccess is false.');
  50.         is_present($login['Content'], 'Connta com este nome n&#227;o existe.', 'Login Error: Wrong Username/Email.');
  51.         is_present($login['Content'], 'A senha indicada n&#227;o &#233; a senha correcta do propriet&#225;rio desta conta.', 'Login Error: Wrong Password.');
  52.         if (empty($this->cookie['RememberMe'])) html_error('Login Error: "RememberMe" cookie not found.');
  53.  
  54.         return $this->TryDL();
  55.     }
  56.  
  57.     private function reqAction($path, $post = array()) {
  58.         $page = $this->GetPage("{$this->baseurl}/action/$path", $this->cookie, array_map('urlencode', $post), "{$this->baseurl}/\r\nX-Requested-With: XMLHttpRequest");
  59.         $reply = $this->json2array($page, "reqAction($path) Error");
  60.         if (empty($reply)) html_error("[reqAction($path) Error] Empty Response.");
  61.         $this->cookie = GetCookiesArr($page, $this->cookie);
  62.  
  63.         return $reply;
  64.     }
  65.  
  66.     private function json2array($content, $errorPrefix = 'Error') {
  67.         if (!function_exists('json_decode')) html_error('Error: Please enable JSON in php.');
  68.         if (empty($content)) return NULL;
  69.         $content = ltrim($content);
  70.         if (($pos = strpos($content, "\r\n\r\n")) > 0) $content = trim(substr($content, $pos + 4));
  71.         $cb_pos = strpos($content, '{');
  72.         $sb_pos = strpos($content, '[');
  73.         if ($cb_pos === false && $sb_pos === false) html_error("[$errorPrefix]: JSON start braces not found.");
  74.         $sb = ($cb_pos === false || $sb_pos < $cb_pos) ? true : false;
  75.         $content = substr($content, strpos($content, ($sb ? '[' : '{')));$content = substr($content, 0, strrpos($content, ($sb ? ']' : '}')) + 1);
  76.         if (empty($content)) html_error("[$errorPrefix]: No JSON content.");
  77.         $rply = json_decode($content, true);
  78.         if ($rply === NULL) html_error("[$errorPrefix]: Error reading JSON.");
  79.         return $rply;
  80.     }
  81. }
  82.  
  83. // [20-3-2016] Written by Th3-822.
  84. // [22-4-2016] Renamed to minhateca_com_br. - Th3-822
  85.  
  86. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement