Th3-822

[rapidleech][d] filefactory_com.php

Mar 11th, 2012 (edited)
1,579
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.30 KB | None | 0 0
  1. <?php
  2. if (!defined('RAPIDLEECH')) {
  3.     require_once('index.html');
  4.     exit();
  5. }
  6.  
  7. class filefactory_com extends DownloadClass {
  8.     private $page, $cookie = array('ff_locale' => 'en_US.utf8'), $lpass = '';
  9.     public function Download($link) {
  10.         global $premium_acc;
  11.  
  12.         $arr = explode('|', str_replace('%7C', '|', $link), 2);
  13.         if (count($arr) >= 2) {
  14.             $this->lpass = (strpos($link, '|') === false) ? rawurldecode($arr[1]) : $arr[1];
  15.             $link = $arr[0];
  16.         }
  17.         unset($arr);
  18.  
  19.         $this->link = $GLOBALS['Referer'] = str_ireplace(array('http://', '://filefactory.com/'), array('https://', '://www.filefactory.com/'), $link);
  20.  
  21.         $post = empty($this->lpass) ? 0 : array('password' => urlencode($this->lpass), 'Submit' => 'Continue');
  22.         $this->page = $this->GetPage($this->link, $this->cookie, $post);
  23.         $this->cookie = GetCookiesArr($this->page, $this->cookie);
  24.  
  25.         $this->CheckPass();
  26.  
  27.         $X = 0;
  28.         while ($X < 3 && preg_match('@\nLocation: .*(/(?:file|preview)/[^\r\n]+)@i', $this->page, $RD)) {
  29.             $this->link = 'https://www.filefactory.com' . $RD[1];
  30.             $this->page = $this->GetPage($this->link, $this->cookie);
  31.             $this->cookie = GetCookiesArr($this->page, $this->cookie);
  32.             $X++;
  33.         }
  34.  
  35.         if (preg_match('@/error\.php\?code=(\d+)@i', $this->page, $this->redir) && !in_array($this->redir[1], array('257', '258')) /*Forcing PPS is not fair...*/) {
  36.             if ($this->redir[1] == '160') html_error('IP banned by FF.');
  37.             $page = $this->GetPage('https://www.filefactory.com'.$this->redir[0], $this->cookie);
  38.             if (preg_match('@class="alert alert-error">\s*<h2>\s*([\w\-\s]+)\s*</h2>@i', $page, $err)) html_error("[FF:{$this->redir[1]}] ".htmlspecialchars($err[1]));
  39.             html_error("Link is not available [{$this->redir[1]}]");
  40.         }
  41.         if (stripos($this->page, 'error.php?code=') === false && $this->CheckTS()) return; // insert_location doesn't do exit()... So i must to stop the plugin if it's a trafficshare link.
  42.  
  43.         if (stripos($this->link, '/preview/') === false && $_REQUEST['premium_acc'] == 'on' && ((!empty($_REQUEST['premium_user']) && !empty($_REQUEST['premium_pass'])) || (!empty($premium_acc['filefactory_com']['user']) && !empty($premium_acc['filefactory_com']['pass'])))) $this->Login();
  44.         else $this->FreeDL();
  45.     }
  46.  
  47.     private function CheckTS() {
  48.         if (preg_match('@https?://(?:[a-zA-Z\d\-]+\.)*filefactory\.com/get/t/[^\r\n\"\'<>\s\t]+@i', $this->page, $dl)) {
  49.             $filename = urldecode(basename(parse_url($dl[0], PHP_URL_PATH)));
  50.             if (stripos($dl[0], ';') !== false) $dl[0] = str_replace(array('&',';'), '', $dl[0]);
  51.             $this->RedirectDownload($dl[0], $filename, $this->cookie, 0, 0, $filename);
  52.             return true;
  53.         }
  54.         return false;
  55.     }
  56.  
  57.     private function CheckPass() {
  58.         if (stripos($this->page, 'This File has been password protected by the uploader.') !== false || stripos($this->page, '>Please enter the password</') !== false) {
  59.             if (empty($this->lpass)) html_error('File is password protected, please send the password in this format: link|pass');
  60.             else html_error('The link\'s password you have sent is not valid.');
  61.         }
  62.     }
  63.  
  64.     private function FreeDL() {
  65.         if (!empty($this->redir)) {
  66.             $page = $this->GetPage('https://www.filefactory.com'.$this->redir[0], $this->cookie);
  67.             if (preg_match('@class="alert alert-error">\s*<h2>\s*([\w\-\s]+)\s*</h2>@i', $page, $err)) html_error("[FF:{$this->redir[1]}] ".htmlspecialchars($err[1]));
  68.             html_error("Link is not available [{$this->redir[1]}]");
  69.         }
  70.  
  71.         if (!preg_match('@https?://(?:[a-zA-Z\d\-]+\.)*filefactory\.com/get/f/[^\r\n\"\'<>\s\t]+@i', $this->page, $dllink)) html_error('Download Link Not Found.');
  72.         $dllink = $dllink[0];
  73.  
  74.         if (!preg_match('@data-delay\s*=\s*"(\d+)"@i', $this->page, $C) && stripos($this->link, '/preview/') === false) html_error('Failed to Get Link Time-lock.');
  75.         if (!empty($C[1])) $this->CountDown($C[1]);
  76.  
  77.         $filename = urldecode(basename(parse_url($dllink, PHP_URL_PATH)));
  78.         if (stripos($dllink, ';') !== false) $dllink = str_replace(array('&',';'), '', $dllink);
  79.         $this->RedirectDownload($dllink, $filename, $this->cookie, 0, 0, $filename);
  80.     }
  81.  
  82.     private function PremiumDL() {
  83.         $this->page = $this->GetPage($this->link, $this->cookie);
  84.         $this->cookie = GetCookiesArr($this->page, $this->cookie);
  85.  
  86.         $X = 0;
  87.         while ($X < 3 && preg_match('@\nLocation: .*(/(?:file|preview)/[^\r\n]+)@i', $this->page, $RD)) {
  88.             $this->link = 'https://www.filefactory.com' . $RD[1];
  89.             $this->page = $this->GetPage($this->link, $this->cookie);
  90.             $this->cookie = GetCookiesArr($this->page, $this->cookie);
  91.             $X++;
  92.         }
  93.  
  94.         if (preg_match('@/error\.php\?code=(\d+)@i', $this->page, $this->redir)) {
  95.             $this->page = $this->GetPage('https://www.filefactory.com'.$this->redir[0], $this->cookie);
  96.             if (preg_match('@class="alert alert-error">\s*<h2>\s*([\w\-\s]+)\s*</h2>@i', $this->page, $err)) html_error("[FF:{$this->redir[1]}]-".htmlspecialchars($err[1]));
  97.             html_error("Link is not available. [{$this->redir[1]}]");
  98.         }
  99.  
  100.         if (!preg_match('@https?://(?:[a-zA-Z\d\-]+\.)*filefactory\.com/get/p/[^\r\n\"\'<>\s\t]+@i', $this->page, $dl)) html_error('Download-Link Not Found.');
  101.  
  102.         $filename = urldecode(basename(parse_url($dl[0], PHP_URL_PATH)));
  103.         if (stripos($dl[0], ';') !== false) $dl[0] = str_replace(array('&',';'), '', $dl[0]);
  104.         $this->RedirectDownload($dl[0], $filename, $this->cookie, 0, 0, $filename);
  105.     }
  106.  
  107.     private function Login() {
  108.         global $premium_acc;
  109.         $pA = !empty($_REQUEST['premium_user']) && !empty($_REQUEST['premium_pass']) ? true : false;
  110.         $email = $pA ? $_REQUEST['premium_user'] : $premium_acc['filefactory_com']['user'];
  111.         $password = $pA ? $_REQUEST['premium_pass'] : $premium_acc['filefactory_com']['pass'];
  112.  
  113.         if (empty($email) || empty($password)) html_error('Login Failed: Email or Password is empty. Please check login data.');
  114.  
  115.         $postURL = 'https://www.filefactory.com/member/signin.php';
  116.         $post = array();
  117.         $post['loginEmail'] = urlencode($email);
  118.         $post['loginPassword'] = urlencode($password);
  119.         $post['Submit'] = 'Sign+In';
  120.         $page = $this->GetPage($postURL, 0, $post, $postURL);
  121.         is_present($page, 'The Email Address submitted was invalid', 'Login Failed: Invalid email address.');
  122.         is_present($page, 'The email address or password you have entered is incorrect.', 'Login Failed: The Email/Password you have entered is incorrect.');
  123.  
  124.         $this->cookie = GetCookiesArr($page, $this->cookie);
  125.         if (empty($this->cookie['auth'])) html_error('Login Failed, auth cookie not found.');
  126.  
  127.         $page = $this->GetPage('https://www.filefactory.com/account/', $this->cookie, 0, $postURL);
  128.         is_present($page, "\nLocation: /member/settos.php", 'TOS have changed and need to be approved at the site.');
  129.         is_present($page, "\nLocation: /member/setpwd.php", 'Your password has expired, please change it.');
  130.         if (stripos($page, '>Free Member<') !== false) {
  131.             $this->changeMesg(lang(300).'<br /><b>Account isn\'t premium</b><br />Using it as member.');
  132.             $this->page = $this->GetPage($this->link, $this->cookie);
  133.             preg_match('@/error\.php\?code=(\d+)@i', $this->page, $this->redir);
  134.             return $this->FreeDL();
  135.         }
  136.         return $this->PremiumDL();
  137.     }
  138. }
  139.  
  140. //[26-Nov-2010] Written by Th3-822.
  141. //[20-Feb-2011] Fixed regex for redirect & Fixed errors in filename & Changed captcha funtion for show reCaptcha. - Th3-822
  142. //[10-Feb-2012] Added error msg at freedl & 2 Regexps edited. -Th3-822
  143. //[11-Mar-2012] Fixed getting dlink in premium account (Sometimes the request it's redirected to freedl error page) && Fixed login function. - Th3-822
  144. //[23-Mar-2012] Fixed free dl regexps. - Th3-822
  145. //[22-May-2012] Added support for files with Traffic Share on freedl. - Th3-822
  146. //[11-Jul-2012] Fixed regexp for files with Traffic Share on freedl && fixed regexp at premiumdl && minor changes. - Th3-822
  147. //[10-Aug-2012] Added cookie support & fixed free acc check. - Th3-822
  148. //[22-Aug-2012] Fixed Traffic Share support (Again) & added error msg. - Th3-822
  149. //[14-May-2013] Fixed freedl (ff removed the captcha... But the code still at page, so i will let it on the plugin too). - Th3-822
  150. //[17-Sep-2013] Rewritten for make it work with the new site & Cookie support removed & Added password protected links support. - Th3-822
  151. //[24-Oct-2013] Added a error at login & fixed redirect on premium download. - Th3-822
  152. //[18-Nov-2013] Fixed premium-dl error msgs. - Th3-822
  153. //[02-Dec-2016] Fixed login error msgs. - Th3-822
  154. //[14-May-2021] Switched links to https. - Th3-822
Add Comment
Please, Sign In to add comment