Advertisement
Th3-822

[rapidleech][d] moyapidbirka_com_ua

Apr 22nd, 2016
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.33 KB | None | 0 0
  1. <?php
  2.  
  3. if (!defined('RAPIDLEECH')) {
  4.     require_once('index.html');
  5.     exit;
  6. }
  7.  
  8. class moyapidbirka_com_ua extends DownloadClass {
  9.     private $page, $cookie = array(), $pA, $DLRegexp = '@https?://s\d+\.moyapidbirka\.com\.ua/download\?[^\t\r\n\'\"<>]+@i';
  10.     public function Download($link) {
  11.         if (!preg_match('@(https?://moyapidbirka\.com\.ua)/(?:[^/]+/)+[^\r\n\t/<>\"]+?,(\d+)[^\r\n\t/<>\"]*@i', preg_replace('@^(http)s?(://)(?:www\.)?mo[yi](apidbirka\.com)(?:\.ua)?(?=/)@i', '$1$2moy$3.ua', $link), $fid)) html_error('Invalid link?.');
  12.         $this->link = $GLOBALS['Referer'] = $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']['moyapidbirka_com_ua']['user']) && !empty($GLOBALS['premium_acc']['moyapidbirka_com_ua']['pass']))))) {
  18.             $user = ($this->pA ? $_REQUEST['premium_user'] : $GLOBALS['premium_acc']['moyapidbirka_com_ua']['user']);
  19.             $pass = ($this->pA ? $_REQUEST['premium_pass'] : $GLOBALS['premium_acc']['moyapidbirka_com_ua']['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('DownloadFile', array('fileId' => $this->fid, '__RequestVerificationToken' => $this->getCSRFToken($this->page)));
  31.             if (empty($download['DownloadUrl']) || !preg_match($this->DLRegexp, $download['DownloadUrl'], $DL)) {
  32.                 if (empty($this->cookie['.ASPXAUTH_v2']) && $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], 'moyapidbirka_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('Account/Login', array('UserName' => $user, 'Password' => $pass, '__RequestVerificationToken' => $this->getCSRFToken($page, 'Login Error')));
  49.         if (!empty($login['Content'])) is_present($login['Content'], 'Логін або пароль неправильний.', 'Login Error: Wrong Login/Password.');
  50.         if (empty($this->cookie['.ASPXAUTH_v2'])) html_error('Login Error: Cookie ".ASPXAUTH_v2" not Found.');
  51.  
  52.         return $this->TryDL();
  53.     }
  54.  
  55.     private function reqAction($path, $post = array()) {
  56.         $page = $this->GetPage("{$this->baseurl}/action/$path", $this->cookie, array_map('urlencode', $post), "{$this->baseurl}/\r\nX-Requested-With: XMLHttpRequest");
  57.         $reply = $this->json2array($page, "reqAction($path) Error");
  58.         if (empty($reply)) html_error("[reqAction($path) Error] Empty Response.");
  59.         $this->cookie = GetCookiesArr($page, $this->cookie);
  60.  
  61.         return $reply;
  62.     }
  63.  
  64.     private function json2array($content, $errorPrefix = 'Error') {
  65.         if (!function_exists('json_decode')) html_error('Error: Please enable JSON in php.');
  66.         if (empty($content)) return NULL;
  67.         $content = ltrim($content);
  68.         if (($pos = strpos($content, "\r\n\r\n")) > 0) $content = trim(substr($content, $pos + 4));
  69.         $cb_pos = strpos($content, '{');
  70.         $sb_pos = strpos($content, '[');
  71.         if ($cb_pos === false && $sb_pos === false) html_error("[$errorPrefix]: JSON start braces not found.");
  72.         $sb = ($cb_pos === false || $sb_pos < $cb_pos) ? true : false;
  73.         $content = substr($content, strpos($content, ($sb ? '[' : '{')));$content = substr($content, 0, strrpos($content, ($sb ? ']' : '}')) + 1);
  74.         if (empty($content)) html_error("[$errorPrefix]: No JSON content.");
  75.         $rply = json_decode($content, true);
  76.         if ($rply === NULL) html_error("[$errorPrefix]: Error reading JSON.");
  77.         return $rply;
  78.     }
  79. }
  80.  
  81. // [20-3-2016] Written by Th3-822.
  82. // [22-4-2016] Renamed to moyapidbirka_com_ua and fixed. - Th3-822
  83.  
  84. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement