Advertisement
Th3-822

[rapidleech][d] 4shared_com.php

Mar 23rd, 2012
2,026
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.85 KB | None | 0 0
  1. <?php
  2.  
  3. if (!defined('RAPIDLEECH')) {
  4.     require_once('index.html');
  5.     exit();
  6. }
  7.  
  8. class d4shared_com extends DownloadClass {
  9.     private $page, $cookie, $pA, $DL_regexp, $noTrafficFreeDl;
  10.     public $link;
  11.     public function Download($link) {
  12.         global $premium_acc;
  13.         $this->DL_regexp = '@https?://dc\d+\.4shared\.com/download/[^/\"\'\s<>]+/(?:tsid[^/\"\'\s<>]+/)?[^/\"\'\s<>]+@i';
  14.         $this->cookie = array('4langcookie' => 'en');
  15.         $this->noTrafficFreeDl = true; // Set to true to switch to free download when premium traffic used is over the limit.
  16.  
  17.         $this->link = str_ireplace('.com/get/', '.com/file/', $link);
  18.         $this->page = $this->GetPage($this->link, $this->cookie);
  19.         $this->cookie = GetCookiesArr($this->page, $this->cookie);
  20.         is_present($this->page, 'The file link that you requested is not valid.');
  21.         is_present($this->page, 'The file is suspected of illegal or copyrighted content.');
  22.         is_present($this->page, 'This file is no longer available because it\'s identical to file banned because of claim.'); // MD5 banned
  23.  
  24.         if ($_REQUEST['premium_acc'] == 'on' && ((!empty($_REQUEST['premium_user']) && !empty($_REQUEST['premium_pass'])) || (!empty($premium_acc['4shared_com']['user']) && !empty($premium_acc['4shared_com']['pass'])))) {
  25.             $this->pA = (!empty($_REQUEST['premium_user']) && !empty($_REQUEST['premium_pass']) ? true : false);
  26.             return $this->login();
  27.         } else return $this->FreeDownload();
  28.     }
  29.  
  30.     private function FreeDownload() {
  31.         $this->CheckForPass();
  32.  
  33.         // Direct link downloadable without login or countdown...
  34.         if (preg_match($this->DL_regexp, $this->page, $DL)) {
  35.             if (preg_match('/[\?&]dirPwdVerified=(\w+)/i', $this->link, $pwd)) $DL[0] .= '&dirPwdVerified='.$pwd[1];
  36.             return $this->RedirectDownload($DL[0], urldecode(basename(parse_url($DL[0], PHP_URL_PATH))), $this->cookie);
  37.         }
  38.  
  39.         if (!preg_match('@\.com/[^/]+/([^/]+)/?(.*)@i', $this->link, $L)) html_error('Invalid link?');
  40.         $getLink = "http://www.4shared.com/get/{$L[1]}/{$L[2]}";
  41.         $page = $this->GetPage("http://www.4shared.com/get/{$L[1]}/{$L[2]}", $this->cookie);
  42.         $GLOBALS['Referer'] = $getLink;
  43.  
  44.         if (!preg_match($this->DL_regexp, $page, $DL)) html_error('Download-link not found.');
  45.         $this->cookie = GetCookiesArr($page, $this->cookie);
  46.         $dllink = $DL[0];
  47.         if (preg_match('/[\?&]dirPwdVerified=(\w+)/i', $this->link, $pwd)) $dllink .= '&dirPwdVerified='.$pwd[1];
  48.  
  49.         if (!preg_match('@id="secondsLeft"[\s\t]+value="(\d+)"@i', $page, $count) && !preg_match('@id="downloadDelayTimeSec"[^<>/]*>(\d+)<@i', $page, $count)) html_error('Timer not found.');
  50.  
  51.         $FileName = urldecode(basename(parse_url($dllink, PHP_URL_PATH)));
  52.         if ($count[1] <= 120) $this->CountDown($count[1]);
  53.         else {
  54.             $data = $this->DefaultParamArr($dllink, encrypt($this->cookie));
  55.             $data['filename'] = urlencode($FileName);
  56.             $data['host'] = $url['host'];
  57.             $data['port'] = $url['port'];
  58.             $data['path'] = urlencode($url['path'] . ($url['query'] ? '?' . $url['query'] : ''));
  59.             $data['saveto'] = $_GET['path'];
  60.             $this->JSCountdown($count[1], $data);
  61.         }
  62.  
  63.         $this->RedirectDownload($dllink, $FileName, $this->cookie);
  64.     }
  65.  
  66.     private function CheckForPass($predl=false) {
  67.         global $PHP_SELF;
  68.         if (isset($_GET['step']) && $_GET['step'] == '1') {
  69.             $post = array();
  70.             $post['userPass2'] = $_POST['userPass2'];
  71.             $post['dsid'] = trim($_POST['dsid']);
  72.             $this->page = $this->GetPage($this->link, $this->cookie, $post, $this->link);
  73.             is_present($this->page, 'Please enter a password to access this file', 'The password you have entered is not valid.');
  74.         } elseif (stristr($this->page, 'Please enter a password to access this file')) {
  75.             echo "\n<center><form name='dl_password' action='$PHP_SELF' method='POST'>\n";
  76.             $data = $this->DefaultParamArr($this->link);
  77.             $data['step'] = 1;
  78.             $data['dsid'] = cut_str($this->page, 'name="dsid" value="', '"');
  79.             foreach ($data as $name => $val) echo "<input type='hidden' name='$name' id='$name' value='$val' />\n";
  80.             if ($predl) echo '<br /><input type="checkbox" name="premium_acc" id="premium_acc" onclick="javascript:var displ=this.checked?\'\':\'none\';document.getElementById(\'premiumblock\').style.display=displ;" '.(!$this->pA?'checked="checked"':'').' />&nbsp;'.lang(249).'<br /><div id="premiumblock" style="display: none;"><br /><table width="150" border="0"><tr><td>'.lang(250).':&nbsp;</td><td><input type="text" name="premium_user" id="premium_user" size="15" value="" /></td></tr><tr><td>'.lang(251).':&nbsp;</td><td><input type="password" name="premium_pass" id="premium_pass" size="15" value="" /></td></tr></table></div><br />';
  81.             echo '<h4>Enter password here: <input type="text" name="userPass2" id="filepass" size="13" />&nbsp;&nbsp;<input type="submit" onclick="return check()" value="Download File" /></h4>' . "\n";
  82.             echo "<script type='text/javascript'>\nfunction check() {\nvar pass=document.getElementById('filepass');\nif (pass.value == '') { window.alert('You didn\'t enter the password'); return false; }\nelse { return true; }\n}\n</script>\n";
  83.             echo "\n</form></center>\n</body>\n</html>";
  84.             exit;
  85.         }
  86.         $this->cookie = GetCookiesArr($this->page, $this->cookie, true, array('','deleted','""'));
  87.     }
  88.  
  89.     private function PremiumDownload() {
  90.         $page = $this->GetPage($this->link, $this->cookie);
  91.         $this->CheckForPass(true);
  92.         $this->cookie = GetCookiesArr($page, $this->cookie);
  93.  
  94.         if (stripos($page, "\nContent-Length: 0\n") !== false) is_notpresent($page, "\nLocation: ", 'Error: Direct link not found.');
  95.         if (!preg_match($this->DL_regexp, $page, $DL)) html_error('Error: Download link not found.');
  96.         $dllink = $DL[0];
  97.         if (preg_match('/[\?&]dirPwdVerified=(\w+)/i', $this->link, $pwd)) $dllink .= '&dirPwdVerified='.$pwd[1];
  98.  
  99.         $FileName = urldecode(basename(parse_url($dllink, PHP_URL_PATH)));
  100.         $this->RedirectDownload($dllink, $FileName, $this->cookie);
  101.     }
  102.  
  103.     private function login() {
  104.         global $premium_acc;
  105.         $email = ($this->pA ? $_REQUEST['premium_user'] : $premium_acc['4shared_com']['user']);
  106.         $pass = ($this->pA ? $_REQUEST['premium_pass'] : $premium_acc['4shared_com']['pass']);
  107.         if (empty($email) || empty($pass)) html_error('Login Failed: EMail or Password is empty. Please check login data.');
  108.  
  109.         $postURL = 'http://www.4shared.com/web/login';
  110.         $post['login'] = urlencode($email);
  111.         $post['password'] = urlencode($pass);
  112.         $post['remember'] = 'false';
  113.         $post['doNotRedirect'] = 'true';
  114.         $page = $this->GetPage($postURL, $this->cookie, $post, $postURL);
  115.  
  116.         is_present($page, 'Invalid e-mail address or password', 'Login Failed: Invalid Username/Email or Password.');
  117.         if (stripos($page, '"ok":false') !== false) {
  118.             if ($err=cut_str($page, '"rejectReason":"', '"')) html_error("Login Failed: 4S says: '$err'.");
  119.             else html_error('Login Failed.');
  120.         }
  121.         $this->cookie = GetCookiesArr($page, $this->cookie, true, array('','deleted','""'));
  122.         if (empty($this->cookie['Login'])) html_error('Login Error: Cannot find session cookie.');
  123.         $this->cookie['WWW_JSESSIONID'] = $this->cookie['JSESSIONID'];
  124.  
  125.         $this->GetPage('http://www.4shared.com/web/user/language', $this->cookie, array('code' => 'en'), 0, 0, 1);
  126.  
  127.         // Chk Acc.
  128.         $page = $this->GetPage('http://www.4shared.com/account/home.jsp', $this->cookie);
  129.         if (substr($page, 9, 3) != '200') html_error('Login Error.');
  130.         $this->cookie = GetCookiesArr($page, $this->cookie, true, array('','deleted','""'));
  131.  
  132.         $quota = cut_str($page, 'Premium Traffic:</div>', '</div>');
  133.         $Mesg = lang(300);
  134.  
  135.         if (empty($quota) || !preg_match('@>([\d|\.]+)\s?(%|(?:\wB)) of ([\d|\.]+)\s?(\wB)@i', $quota, $qm)) {
  136.             $Mesg .= "<br /><b>Account isn't premium?</b><br />Using it as member.";
  137.             $this->changeMesg($Mesg);
  138.  
  139.             $this->page = $this->GetPage($this->link, $this->cookie);
  140.             return $this->FreeDownload();
  141.         }
  142.  
  143.         $used = floatval($qm[1]);
  144.         $total = floatval($qm[3]);
  145.  
  146.         // I have to check the BW... I will show it too :)
  147.         $Mesg .= "<br />4S Premium Download<br />Bandwidth: $used {$qm[2]} of $total {$qm[4]}.";
  148.         $this->changeMesg($Mesg);
  149.         if ($qm[2] != '%' && $total != 100) $used = ($used * 100)/$total;
  150.         if ($used >= 95) {
  151.             if ($this->noTrafficFreeDl) {
  152.                 $Mesg .= "<br /><b>Bandwidth limit trigered: $used% - Limit: 95%</b><br />Switching to FreeDL.";
  153.                 $this->changeMesg($Mesg);
  154.                 $this->page = $this->GetPage($this->link, $this->cookie);
  155.                 $this->cookie = GetCookiesArr($page, $this->cookie);
  156.                 return $this->FreeDownload();
  157.             }
  158.             html_error("Bandwidth limit trigered: Bandwidth: $used% - Limit: 95%");
  159.         }
  160.  
  161.         return $this->PremiumDownload();
  162.     }
  163.  
  164.     public function CheckBack($header) {
  165.         is_present($header, 'cau2=dow-lim', '[4S] The download limit has been reached.');
  166.         is_present($header, 'cau2=0759nousr', '[4S] You need to be logged in for download this file.');
  167.     }
  168. }
  169.  
  170. //[21-Nov-2010] Rewritten by Th3-822 & Using some code from the 2shared plugin.
  171. //[26-Jan-2011] Fixed cookies for download pass-protected files. - Th3-822
  172. //[02-Apr-2011] Fixed error when downloading pass-protected files & Added 1 Error Msg. - Th3-822
  173. //[07-May-2011] Some edits to the plugin && Added Premium download support. - Th3-822
  174. //[25-Jul-2011] Using a function for longer link timelock at free download ( I should add it to DownloadClass. :D ). -Th3-822
  175. //[12-Sep-2011] Fixed regex for get BW usage in Premium && Password in files can be skiped with '?dirPwdVerified=xxxxxxxx' in the url. -Th3-822
  176. //[15-Oct-2011] JSCountdown was added in DownloadClass.php... Removed declaration from plugin. - Th3-822
  177. //[21-Nov-2011] Fixed regexp for get dlink in FreeDL. - Th3-822
  178. //[23-Mar-2012] Added support for member (its needed for some links) & some changes & small fixes. - Th3-822
  179. //[18-Apr-2012] Fixed login needed msg, direct download link regexp (freedl) && removed 2 error msgs from login function. - Th3-822
  180. //[01-Aug-2012] Fixed for changes at 4S. - Th3-822
  181. //[20-Feb-2014] Fixed Login/FreeDL. - Th3-822
  182. //[10-Sep-2016] Fixed FreeDL of Direct-Link Files. - Th3-822
  183.  
  184. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement