Advertisement
Th3-822

[rapidleech][d] letitbit_net.php

Oct 16th, 2012
1,021
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 14.20 KB | None | 0 0
  1. <?php
  2. if (!defined('RAPIDLEECH')) {
  3.     require_once('index.html');
  4.     exit();
  5. }
  6.  
  7. class letitbit_net extends DownloadClass {
  8.     private $page, $cookie;
  9.     public $link;
  10.     public function Download($link) {
  11.         global $premium_acc;
  12.         $this->cookie = array('lang' => 'en');
  13.         // Check link
  14.         if (empty($_REQUEST['step']) || $_REQUEST['step'] != '1') {
  15.             $this->page = $this->GetPage($link, $this->cookie);
  16.             $headers = substr($this->page, 0, strpos($this->page, "\r\n\r\n"));
  17.             $this->cookie = GetCookiesArr($this->page, $this->cookie);
  18.             if (preg_match('@\nLocation: ((https?://(?:[a-zA-Z\d\-]+\.)*letitbit\.net)?/[^\r\n]+)@i', $headers, $redir)) {
  19.                 $link = (empty($redir[2])) ? 'http://letitbit.net'.$redir[1] : $redir[1];
  20.                 $this->page = $this->GetPage($link, $this->cookie);
  21.                 $this->cookie = GetCookiesArr($this->page, $this->cookie);
  22.             } elseif (preg_match('@\nLocation: https?://[^/\r\n]+/[^\r\n]+@i', $headers)) html_error('Error: Non Acceptable Redirect.');
  23.             if (stripos($this->page, 'File not found') !== false) {
  24.                 if ($this->cookie['country'] == 'US') html_error('The requested file was not found or isn\'t downloadable in your server\'s country.'); // It seems that lib blocks downloads from usa... I will check this later and add the error msg if it's true. - T8
  25.                 html_error('The requested file was not found.');
  26.             }
  27.         }
  28.         $this->link = $link;
  29.         if ($_REQUEST ['premium_acc'] == 'on' && (($_REQUEST['premium_user'] && $_REQUEST ['premium_pass']) || (!empty($premium_acc ['letitbit_net'] ['user']) && !empty($premium_acc ['letitbit_net'] ['pass'])))) {
  30.             $user = $_REQUEST ["premium_user"] ? $_REQUEST ["premium_user"] : $premium_acc ["letitbit_net"] ["user"];
  31.             $pass = $_REQUEST ["premium_pass"] ? $_REQUEST ["premium_pass"] : $premium_acc ["letitbit_net"] ["pass"];
  32.             if (empty($user) || empty($pass)) html_error("Login Failed: Username or Password is empty. Please check login data.");
  33.             return $this->SkipLoginC($user, $pass);
  34.         } elseif ($_REQUEST['premium_acc'] == 'on' && (($_REQUEST['premium_pass'])||(!empty($premium_acc['letitbit_net']['pass'])))) {
  35.             $key = ($_REQUEST ["premium_pass"] ? trim($_REQUEST ["premium_pass"]) : $premium_acc["letitbit_net"]["pass"]);
  36.             return $this->Premium($key);
  37.         } elseif (!empty($_REQUEST['step']) && $_REQUEST['step'] == '1') {
  38.             return $this->Free();
  39.         } else {
  40.             return $this->Retrieve();
  41.         }
  42.     }
  43.  
  44.     private function Retrieve() {
  45.         if (!preg_match("@<form (?:[^<>]*)[\s\t]*id=\"ifree_form\"(?:[^<>]*)>@i", $this->page, $form_tag)) html_error('Error: Free Form 1 Tag Not Found!');
  46.         $form_action = trim(cut_str($form_tag[0], 'action="', '"'));
  47.         if (!preg_match("@<form (?:[^<>]*)[\s\t]*id=\"enter_premium_form\"(?:[^<>]*)>@i", $this->page, $form_tag)) html_error('Error: Free Form 1 Tag Not Found!');
  48.         $form = trim(cut_str($this->page, $form_tag[0], '</form>'));
  49.         if (empty($form)) html_error('Error: Empty Free Form 1!');
  50.         $post = $this->AutomatePost($form);
  51.         if (stripos($form_action, 'born_iframe') !== false) {
  52.             $page = $this->GetPage("http://letitbit.net$form_action", $this->cookie, $post);
  53.             if (!preg_match("@<form (?:[^<>]*)[\s\t]*id=\"d3_form\"(?:[^<>]*)>@i", $page, $form_tag)) html_error('Error: Free Form 2 Tag Not Found!');
  54.             $form = trim(cut_str($page, $form_tag[0], '</form>'));
  55.             if (empty($form)) html_error('Error: Empty Free Form 2!');
  56.             $post = $this->AutomatePost($form);
  57.             $form_action = trim(cut_str($form_tag[0], 'action="', '"'));
  58.         }
  59.         $this->link = "http://letitbit.net$form_action";
  60.         $page = $this->GetPage($this->link, $this->cookie, $post);
  61.         $this->cookie = GetCookiesArr($page, $this->cookie);
  62.         unset($post, $form_tag, $form_action);
  63.         if (!preg_match("/ajax_check_url = '((http:\/\/[a-z0-9]+\.[\w.]+)\/[^\r\n']+)';/", $page, $check)) html_error("Error: Redirect link [Free] not found!");
  64.         $this->link = $check[1];
  65.         $this->server = $check[2];
  66.         // If you want, you can skip the countdown...
  67.         if (preg_match('@(\d+)<\/span> seconds@', $page, $wait)) $this->CountDown($wait[1]);
  68.         // end countdown timer...
  69.         $this->GetPage($this->link, $this->cookie, array(), 0, 0, 1); //empty array in post variable needed...
  70.  
  71.         if (!preg_match('@https?://(?:[^/]+\.)?(?:(?:google\.com/recaptcha/api)|(?:recaptcha\.net))/(?:(?:challenge)|(?:noscript))\?k=([\w|\-]+)@i', $page, $pid)) html_error('reCAPTCHA not found.');
  72.         if (!preg_match('@var[\s\t]+recaptcha_control_field[\s\t]*=[\s\t]*\'([^\'\;]+)\'@i', $page, $ctrl)) html_error('Captcha control field not found.');
  73.  
  74.         $data = $this->DefaultParamArr($this->server . "/ajax/check_recaptcha.php", $this->cookie);
  75.         $data['step'] = '1';
  76.         $data['recaptcha_control_field'] = rawurlencode($ctrl[1]);
  77.         $this->Show_reCaptcha($pid[1], $data);
  78.     }
  79.  
  80.     private function Free() {
  81.         if (empty($_POST['recaptcha_response_field'])) html_error('You didn\'t enter the image verification code.');
  82.         $post = array();
  83.         $post['recaptcha_challenge_field'] = $_POST['recaptcha_challenge_field'];
  84.         $post['recaptcha_response_field'] = $_POST['recaptcha_response_field'];
  85.         $post['recaptcha_control_field'] = rawurlencode(rawurldecode($_POST['recaptcha_control_field']));
  86.  
  87.         $this->cookie = urldecode($_POST['cookie']);
  88.         $page = $this->GetPage($this->link, $this->cookie, $post, 0, 0, 1); //too many XML request needed so I used default http.php function in geturl...
  89.         is_present($page, 'error_wrong_captcha', 'Error: Wrong Captcha Entered.');
  90.         is_present($page, 'error_free_download_blocked', 'Error: FreeDL limit reached.');
  91.         if (!preg_match_all('/"(https?:[^\|\r\n\"\']+)"?/', $page, $dl)) html_error('Error: Download link [Free] not found.');
  92.         $dlink = str_replace('\\', '', trim($dl[1][array_rand($dl[1])]));
  93.         $FileName = urldecode(basename(parse_url($dlink, PHP_URL_PATH)));
  94.         $this->RedirectDownload($dlink, $FileName, $this->cookie, 0);
  95.         exit();
  96.     }
  97.  
  98.     private function Show_reCaptcha($pid, $inputs, $sname = 'Download File') {
  99.         global $PHP_SELF;
  100.         if (!is_array($inputs)) html_error('Error parsing captcha data.');
  101.  
  102.         // Themes: 'red', 'white', 'blackglass', 'clean'
  103.         echo "<script language='JavaScript'>var RecaptchaOptions = {theme:'red', lang:'en'};</script>\n";
  104.  
  105.         echo "\n<center><form name='recaptcha' action='$PHP_SELF' method='post'><br />\n";
  106.         foreach ($inputs as $name => $input) echo "<input type='hidden' name='$name' id='$name' value='$input' />\n";
  107.         echo "<script type='text/javascript' src='http://www.google.com/recaptcha/api/challenge?k=$pid'></script>";
  108.         echo "<noscript><iframe src='http://www.google.com/recaptcha/api/noscript?k=$pid' height='300' width='500' frameborder='0'></iframe><br /><textarea name='recaptcha_challenge_field' rows='3' cols='40'></textarea><input type='hidden' name='recaptcha_response_field' value='manual_challenge' /></noscript><br />";
  109.         echo "<input type='submit' name='submit' onclick='javascript:return checkc();' value='$sname' />\n";
  110.         echo "<script type='text/javascript'>/*<![CDATA[*/\nfunction checkc(){\nvar capt=document.getElementById('recaptcha_response_field');\nif (capt.value == '') { window.alert('You didn\'t enter the image verification code.'); return false; }\nelse { return true; }\n}\n/*]]>*/</script>\n";
  111.         echo "</form></center>\n</body>\n</html>";
  112.         exit;
  113.     }
  114.  
  115.     private function Premium($premiumkey = false) {
  116.         if ($premiumkey) {
  117.             $form = cut_str($this->page, '<div class="hide-block password_area">', '<div class="column label" style="width:200px">');
  118.             if (empty($form)) html_error("Error: Empty Premium Key Form!");
  119.             $post = $this->AutomatePost($form);
  120.             $post['pass'] = $premiumkey;
  121.             $post['submit_sms_ways_have_pass'] = 'Download file';
  122.             $this->link = "http://letitbit.net" . cut_str($form, '<form action="', '"');
  123.             $this->page = $this->GetPage($this->link, $this->cookie, $post);
  124.         } else $this->page = $this->GetPage($this->link, $this->cookie, 0, $this->link);
  125.         $this->cookie = GetCookiesArr($this->page, $this->cookie);
  126.  
  127.         $x = 0;
  128.         $ref = $this->link;
  129.         while ($x < 5 && preg_match('@\nLocation: ((https?://(?:[a-zA-Z\d\-]+\.)*letitbit\.net)?/[^\r\n]*)@i', $this->page, $redir)) {
  130.             $redir = (empty($redir[2])) ? (!empty($ref['scheme']) && strtolower($ref['scheme']) == 'https' ? 'https' : 'http').'://'.parse_url($ref, PHP_URL_HOST).$redir[1] : $redir[1];
  131.             $this->page = $this->GetPage($redir, $this->cookie, 0, $ref);
  132.             $ref = $redir;
  133.             $this->cookie = GetCookiesArr($this->page, $this->cookie);
  134.             $x++;
  135.         }
  136.  
  137.         is_present($this->page, 'The premium key has been banned for sharing with other people.');
  138.         is_present($this->page, 'This premium key is attached to a registered account', 'You need to use your username and password not the premium key!');
  139.         is_present($this->page, 'callback_no_pass', 'This premium key does not exist.');
  140.         if (!preg_match_all('@"(https?://[^/]+/[^\"]+)"\s*\:\s*"direct\_link\_\d+"@', $this->page, $dl)) html_error('Error: Download Link [Premium] not found!');
  141.         $dlink = trim($dl[1][array_rand($dl[1])]);
  142.         $FileName = urldecode(basename(parse_url($dlink, PHP_URL_PATH)));
  143.         $this->RedirectDownload($dlink, $FileName, $this->cookie, 0, $this->link);
  144.     }
  145.  
  146.     private function login($user, $pass) {
  147.         $post = array();
  148.         $post['act'] = 'login';
  149.         $post['login'] = $user;
  150.         $post['password'] = $pass;
  151.         $check = $this->GetPage("http://letitbit.net/ajax/auth.php", $this->cookie, $post, "http://letitbit.net/");
  152.         is_present($check, 'Authorization data is invalid');
  153.         is_present($check, 'Your login attempts have been made more than 100 times in 24 hours, the next attempt will be available only tomorrow.');
  154.         $this->cookie = GetCookiesArr($check, array('lang' => 'en'));
  155.         if (empty($this->cookie['log']) || empty($this->cookie['pas'])) html_error('Error [log/pass cookie not found!]');
  156.  
  157.         $check = $this->GetPage('http://letitbit.net/ajax/get_attached_passwords.php', $this->cookie, 0, 'http://letitbit.net/');
  158.         is_present($check, 'Authorization data is invalid!', 'Unknown login error.');
  159.         $this->SaveCookies($user, $pass); // Update cookies file
  160.         is_present($check, 'There are no attached premium', 'No premium codes attached');
  161.  
  162.         return $this->Premium();
  163.     }
  164.  
  165.     private function IWillNameItLater($cookie, $decrypt=true) {
  166.         if (!is_array($cookie)) {
  167.             if (!empty($cookie)) return $decrypt ? decrypt(urldecode($cookie)) : urlencode(encrypt($cookie));
  168.             return '';
  169.         }
  170.         if (count($cookie) < 1) return $cookie;
  171.         $keys = array_keys($cookie);
  172.         $values = array_values($cookie);
  173.         $keys = $decrypt ? array_map('decrypt', array_map('urldecode', $keys)) : array_map('urlencode', array_map('encrypt', $keys));
  174.         $values = $decrypt ? array_map('decrypt', array_map('urldecode', $values)) : array_map('urlencode', array_map('encrypt', $values));
  175.         return array_combine($keys, $values);
  176.     }
  177.  
  178.     private function SkipLoginC($user, $pass, $filename = 'letitbit_dl.php') {
  179.         global $secretkey;
  180.         $filename = DOWNLOAD_DIR . basename($filename);
  181.         if (!file_exists($filename)) return $this->login($user, $pass);
  182.  
  183.         $file = file($filename);
  184.         $savedcookies = unserialize($file[1]);
  185.         unset($file);
  186.  
  187.         $hash = hash('crc32b', $user . ':' . $pass);
  188.         if (array_key_exists($hash, $savedcookies)) {
  189.             $_secretkey = $secretkey;
  190.             $secretkey = sha1($user . ':' . $pass);
  191.             $this->cookie = (decrypt(urldecode($savedcookies[$hash]['enc'])) == 'OK') ? $this->IWillNameItLater($savedcookies[$hash]['cookie']) : '';
  192.             $secretkey = $_secretkey;
  193.             if (is_array($this->cookie)) unset($this->cookie['PHPSESSID']);
  194.             if ((is_array($this->cookie) && count($this->cookie) < 1) || empty($this->cookie)) return $this->login($user, $pass);
  195.  
  196.             $check = $this->GetPage('http://letitbit.net/ajax/get_attached_passwords.php', $this->cookie, 0, 'http://letitbit.net/');
  197.             if (stripos($check, 'Authorization data is invalid!') !== false) return $this->login($user, $pass);
  198.             $this->SaveCookies($user, $pass); // Update cookies file
  199.             is_present($check, 'There are no attached premium', 'No premium codes attached');
  200.  
  201.             return $this->Premium();
  202.         }
  203.         return $this->login($user, $pass);
  204.     }
  205.  
  206.     private function SaveCookies($user, $pass, $filename = 'letitbit_dl.php') {
  207.         global $secretkey;
  208.         $maxdays = 7; // Max days to keep cookies saved
  209.         $filename = DOWNLOAD_DIR . basename($filename);
  210.         if (file_exists($filename)) {
  211.             $file = file($filename);
  212.             $savedcookies = unserialize($file[1]);
  213.             unset($file);
  214.  
  215.             // Remove old cookies
  216.             foreach ($savedcookies as $k => $v) if (time() - $v['time'] >= ($maxdays * 24 * 60 * 60)) unset($savedcookies[$k]);
  217.         } else $savedcookies = array();
  218.         $hash = hash('crc32b', $user . ':' . $pass);
  219.         $_secretkey = $secretkey;
  220.         $secretkey = sha1($user . ':' . $pass);
  221.         $savedcookies[$hash] = array('time' => time(), 'enc' => urlencode(encrypt('OK')), 'cookie' => $this->IWillNameItLater($this->cookie, false));
  222.         $secretkey = $_secretkey;
  223.  
  224.         write_file($filename, "<?php exit(); ?>\r\n" . serialize($savedcookies));
  225.     }
  226.  
  227.     private function AutomatePost($form) {
  228.         if (!preg_match_all('@<input type="hidden" name="([^"]+)" value="([^"]+)" \/>@i', $form, $match)) html_error("Error: Post Data not found!");
  229.         $post = array();
  230.         $match = array_combine($match[1], $match[2]);
  231.         foreach ($match as $k => $v) $post[$k] = ($v == "") ? 1 : $v;
  232.         return $post;
  233.     }
  234.  
  235. }
  236.  
  237. /***********************************************************************************************\
  238.   WRITTEN BY VinhNhaTrang 15-11-2010
  239.   Fix the premium code by code by vdhdevil
  240.   Fix the free download code by vdhdevil & Ruud v.Tony 25-3-2011
  241.   Updated the premium code by Ruud v.Tony 19-5-2011
  242.   Updated for site layout change by Ruud v.Tony 24-7-2011
  243.   Updated for joining between premium user & pass with only single key by Ruud v.Tony 13-10-2011
  244.   Small fix in post form by Ruud v.Tony 16-12-2011 (sorry for the delay, I'm busy with my real life)
  245.   Fix free code by Ruud v.Tony & Th3-822 for letitbit new layout 31-12-2011 (Happy new year everyone)
  246.   Fix new login policy & free download code from letitbit by Ruud v.Tony & Th3-822 18-02-2012
  247.   Fixed free download code by Ruud v.Tony 16-04-2012
  248.   Fixed for redirects in download links by Th3-822 16-10-2012
  249.   reCaptcha support added at freedl by Th3-822 24-11-2012
  250.   Fixed free dl for extra form on some locations. - Th3-822
  251.   FreeDl & PremiumKeyDl fixed. - Th3-822 | [19-4-2013]
  252. \***********************************************************************************************/
  253.  
  254. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement