Advertisement
Th3-822

4shared download plugin for Rx08.ii36B.Rv7.4

Sep 12th, 2011
594
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.79 KB | None | 0 0
  1. <?php
  2.  
  3. if (!defined('RAPIDLEECH')) {
  4.     require_once ("404.php");
  5.     exit();
  6. }
  7.  
  8. class d4shared_com extends DownloadClass {
  9.     private $cookie;
  10.     public function Download($link) {
  11.         global $premium_acc;
  12.  
  13.         if (stristr($link, ".com/get/")) {
  14.             $link = str_replace('.com/get/', '.com/file/', $link);
  15.         }
  16.         $page = $this->GetPage($link, "4langcookie=en");
  17.         $this->cookie = GetCookies($page) . "; 4langcookie=en"; //Keep page in english
  18.         is_present($page, "The file link that you requested is not valid.");
  19.         is_present($page, "The file is suspected of illegal or copyrighted content.");
  20.  
  21.         if ($_REQUEST["premium_acc"] == "on" && (($_REQUEST["premium_user"] && $_REQUEST["premium_pass"]) || ($premium_acc["4shared_com"]["user"] && $premium_acc["4shared_com"]["pass"]))) {
  22.             return $this->PremiumDownload($link);
  23.         } else {
  24.             return $this->FreeDownload($page, $link);
  25.         }
  26.     }
  27.  
  28.     private function FreeDownload($page, $link) {
  29.         $page = $this->CheckForPass($page, $link);
  30.  
  31.         preg_match('/.com\/[^\/]+\/([^\/]+)\/?(.*)/i', $link, $L);
  32.         $page = $this->GetPage("http://www.4shared.com/get/{$L[1]}/{$L[2]}", $this->cookie);
  33.  
  34.         if (preg_match('/href=\'(http:\/\/dc[^\']+)\'>Download file now/i', $page, $D)) {
  35.             $this->cookie = $this->cookie."; ".GetCookies($page);
  36.             $dllink = $D[1];
  37.             if (preg_match('/(?:\?|&)dirPwdVerified=(\w+)/i', $link, $pwd)) $dllink .= "&dirPwdVerified=".$pwd[1];
  38.         } else {
  39.             html_error("Download-link not found.");
  40.         }
  41.  
  42.         $url = parse_url($dllink);
  43.         $FileName = basename($url["path"]);
  44.  
  45.         if (!preg_match('/var c = (\d+)/', $page, $count)) html_error("Timer not found.");
  46.  
  47.         if ($count[1] <= 120) $this->CountDown($count[1]);
  48.         else {
  49.             $data = $this->DefaultParamArr($dllink, encrypt($this->cookie));
  50.             $data['filename'] = urlencode($FileName);
  51.             $data['host'] = $url["host"];
  52.             $data['port'] = $url["port"];
  53.             $data['path'] = urlencode($url["path"] . ($url["query"] ? "?" . $url["query"] : ""));
  54.             $data['saveto'] = $_GET["path"];
  55.             $this->JSCountdown($count[1], $data);
  56.         }
  57.  
  58.         $this->RedirectDownload($dllink, $FileName, $this->cookie);
  59.     }
  60.  
  61.     private function JSCountdown($secs, $post = 0, $text='Waiting link timelock') {
  62.         global $PHP_SELF;
  63.         echo "<p><center><span id='dl' class='htmlerror'><b>ERROR: Please enable JavaScript. (Countdown)</b></span><br /><span id='dl2'>Please wait</span></center></p>\n";
  64.         echo "<form action='$PHP_SELF' name='cdwait' method='POST'>\n";
  65.         if ($post) {
  66.             foreach ($post as $name => $input) {
  67.                 echo "<input type='hidden' name='$name' id='$name' value='$input' />\n";
  68.             }
  69.         }?> <script type="text/javascript">
  70.         var c = <?php echo $secs; ?>;var text = "<?php echo $text; ?>";var c2 = 0;var dl = document.getElementById("dl");var a2 = document.getElementById("dl2");fc();fc2();
  71.         function fc() {
  72.             if (c > 0) {
  73.                 if (c > 120) {
  74.                     dl.innerHTML = text+". Please wait <b>"+ Math.round(c/60) +"</b> minutes...";
  75.                 } else {
  76.                     dl.innerHTML = text+". Please wait <b>"+c+"</b> seconds...";
  77.                 }
  78.                 c = c - 1;
  79.                 setTimeout("fc()", 1000);
  80.             } else {
  81.                 dl.style.display="none";
  82.                 void(<?php if ($post) echo 'document.forms.cdwait.submit()';else echo 'location.reload()'; ?>);
  83.             }
  84.         }
  85.         function fc2(){if(c>120){if(c2<=20){a2.innerHTML=a2.innerHTML+".";c2=c2+1}else{c2=10;a2.innerHTML=""}setTimeout("fc2()",100)}else{dl2.style.display="none"}}<?php echo "</script></form></body></html>";
  86.         exit;
  87.     }
  88.  
  89.     private function CheckForPass($page, $link, $predl=false, $pA=false) {
  90.         global $Referer, $PHP_SELF, $gtxt;
  91.         if ($_GET["step"] == "1") {
  92.             $post = array();
  93.             $post["userPass2"] = $_POST['userPass2'];
  94.             $post["dsid"] = $_POST['dsid'];
  95.             $page = $this->GetPage($link, $this->cookie, $post, $link);
  96.             is_present($page, "Please enter a password to access this file", "The password you have entered is not valid.");
  97.             $this->cookie = $this->cookie."; ".GetCookies($page);
  98.             return $page;
  99.         } elseif (stristr($page, 'Please enter a password to access this file')) {
  100.             echo "\n" . '<center><form name="dl_password" action="' . $PHP_SELF . '" method="post" >' . "\n";
  101.             echo '<input type="hidden" name="link" value="' . urlencode($link) . '" />' . "\n";
  102.             echo '<input type="hidden" name="referer" value="' . urlencode($Referer) . '" />' . "\n";
  103.             echo '<input type="hidden" name="step" value="1" />' . "\n";
  104.  
  105.             $defdata = array("comment" => $_GET ["comment"], "email" => $_GET ["email"], "partSize" => $_GET ["partSize"], "method" => $_GET ["method"], "proxy" => $_GET ["proxy"], "proxyuser" => $_GET ["proxyuser"], "proxypass" => $_GET ["proxypass"], "path" => $_GET ["path"]);
  106.             foreach ($defdata as $name => $val) {
  107.                 echo "<input type='hidden' name='$name' id='$name' value='$val' />\n";
  108.             }
  109.             echo '<input type="hidden" name="dsid" value="' . trim(cut_str($page, 'name="dsid" value="', '"')) . '" />' . "\n";
  110.             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;" '.(!$pA?'checked="checked"':'').' />&nbsp;'.$gtxt['use_premix'].'<br /><div id="premiumblock" style="display: none;"><br /><table width="150" border="0"><tr><td>'.$gtxt['_uname'].':&nbsp;</td><td><input type="text" name="premium_user" id="premium_user" size="15" value="" /></td></tr><tr><td>'.$gtxt['_pass'].':&nbsp;</td><td><input type="password" name="premium_pass" id="premium_pass" size="15" value="" /></td></tr></table></div><br />';
  111.             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";
  112.             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";
  113.             echo "\n</form></center>\n</body>\n</html>";
  114.             exit;
  115.         } else {
  116.             return $page;
  117.         }
  118.     }
  119.  
  120.     private function PremiumDownload($link) {
  121.         $pA = ($_REQUEST["premium_user"] && $_REQUEST["premium_pass"] ? true : false);
  122.         $this->cookie = $this->login($pA);
  123.         $page = $this->CheckForPass($this->GetPage($link, $this->cookie), $link, true, $pA);
  124.         $this->cookie = GetCookies($page);
  125.  
  126.         if (stristr($page, "\r\nContent-Length: 0\r\n")) {
  127.             is_notpresent($page, "\r\nLocation:", "Error: Direct link not found.");
  128.             if (!preg_match('@Location: (http://dc\d+.4shared.com/download/[^\r|\n]+)@i', $page, $dl)) html_error("Error: Download-link not found 2.");
  129.         } elseif (!preg_match('@type="text" value="(http://dc\d+.4shared.com/download/[^"]+)"@i', $page, $dl)) {
  130.             html_error("Error: Download-link not found.");
  131.         }
  132.         $dllink = $dl[1];
  133.         if (preg_match('/(?:\?|&)dirPwdVerified=(\w+)/i', $link, $pwd)) $dllink .= "&dirPwdVerified=".$pwd[1];
  134.  
  135.         $url = parse_url($dllink);
  136.         $FileName = basename($url["path"]);
  137.  
  138.         $this->RedirectDownload($dllink, $FileName, $this->cookie);
  139.     }
  140.  
  141.     private function login($pA=false) {
  142.         global $premium_acc, $gtxt;
  143.         $email = ($pA ? $_REQUEST["premium_user"] : $premium_acc["4shared_com"]["user"]);
  144.         $pass = ($pA ? $_REQUEST["premium_pass"] : $premium_acc["4shared_com"]["pass"]);
  145.  
  146.         if (empty($email) || empty($pass)) {
  147.             html_error("Login Failed: EMail or Password is empty. Please check login data.");
  148.         }
  149.  
  150.         $postURL = "http://www.4shared.com/login";
  151.         $post["login"] = $email;
  152.         $post["password"] = $pass;
  153.         $post["remember"] = "false";
  154.         $post["doNotRedirect"] = "true";
  155.         $page = $this->GetPage($postURL, "4langcookie=en", $post, $postURL);
  156.         $cookie = GetCookies($page) . "; 4langcookie=en";
  157.  
  158.         is_present($page, "Invalid e-mail address or password", "Login Failed: Invalid Username/Email or Password.");
  159.         if (stristr($page, '"ok":false') && $err=cut_str($page, '"rejectReason":"', '"')) html_error("Login Failed: 4S says: '$err'.");
  160.         is_notpresent($cookie, "Login=", "Login Failed. Cookie 'Login' not found.");
  161.         is_notpresent($cookie, "Password=", "Login Failed. Cookie 'Password' not found.");
  162.  
  163.         // Chk Acc.
  164.         $redir = cut_str($page, '"loginRedirect":"', '"');
  165.         if (!$redir) html_error("Redirection 1 not found.");
  166.         $page = $this->GetPage($redir, $cookie, 0, "http://www.4shared.com/");
  167.         if (!preg_match('@Location: (http://(www\.)?4shared\.com/[^\r|\n]+)@i', $page, $rloc)) html_error("Redirection 2 not found.");
  168.         $cookie = "$cookie; " . GetCookies($page);
  169.         $page = $this->GetPage($rloc[1], $cookie, 0, $redir);
  170.         is_present($page, "HTTP/1.1 302 Moved Temporarily", "Error: Unknown redirect found.");
  171.         $quota = cut_str($page, 'Bandwidth:', "</div>");
  172.         echo "\n<br /><textarea cols='100' rows='30' readonly='readonly'>".htmlentities($quota, ENT_QUOTES, 'UTF-8')."</textarea><br />\n";
  173.         if (!preg_match('/"quota(?:(?:usagebar" title=")|(?:count">))([\d|\.]+)% of ([\d|\.]+) (\w+)/i', $quota, $qm)) html_error("Cannot get Bandwidth info. Acc. is not premium?");
  174.         $used = floatval($qm[1]);
  175.         $total = floatval($qm[2]);
  176.         // I have to check the BW... I will show it too :)
  177.         $this->changeMesg($gtxt['_retrieving']."<br />4S Premium Download<br />Bandwidth: $used% of $total {$qm[3]}.");
  178.         if ($used >= 95) html_error("Bandwidth limit trigered: Bandwidth: $used% - Limit: 95%");
  179.  
  180.         return $cookie;
  181.     }
  182. }
  183.  
  184. //[21-Nov-2010] Rewritten by Th3-822 & Using some code from the 2shared plugin.
  185. //[26-Jan-2011] Fixed cookies for download pass-protected files. - Th3-822
  186. //[02-Apr-2011] Fixed error when downloading pass-protected files & Added 1 Error Msg. - Th3-822
  187. //[07-May-2011] Some edits to the plugin && Added Premium download support. - Th3-822
  188. //[25-Jul-2011] Using a function for longer link timelock at free download ( I should add it to DownloadClass. :D ). -Th3-822
  189. //[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
  190.  
  191. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement