PageRenderTime 48ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/hosts/download/netload_in.php

https://gitlab.com/billyprice1/rapidleech
PHP | 164 lines | 138 code | 19 blank | 7 comment | 37 complexity | fd2b18e7ba6922d55b8327b473462284 MD5 | raw file
  1. <?php
  2. if (!defined('RAPIDLEECH')) {
  3. require_once("index.html");
  4. exit;
  5. }
  6. class netload_in extends DownloadClass {
  7. public function Download($link) {
  8. global $premium_acc, $Referer;
  9. $this->link = $link;
  10. //check the link
  11. if (!$_REQUEST['step']) {
  12. $this->page = $this->GetPage($this->link);
  13. if (preg_match('/Location: (\/[^|\r|\n]+)/i', $this->page, $temp)) {
  14. $this->link = 'http://netload.in' . $temp[1];
  15. $this->page = $this->GetPage($this->link);
  16. }
  17. is_present($this->page, 'Code: ER_NFF', 'Error[File not found]!');
  18. }
  19. if ($_REQUEST['premium_acc'] == 'on' && (($_REQUEST['premium_user'] && $_REQUEST['premium_pass']) || ($premium_acc['netload_in']['user'] && $premium_acc['netload_in']['pass']))) {
  20. return $this->Login();
  21. } elseif ($_REQUEST['step'] == 'password') {
  22. $post['file_id'] = $_POST['file_id'];
  23. $post['password'] = $_POST['password'];
  24. $post['submit'] = $_POST['submit'];
  25. $this->link = urldecode($_POST['link']);
  26. if (!empty($_POST['cookie'])) {
  27. $this->cookie = decrypt(urldecode($_POST['cookie']));
  28. $this->page = $this->GetPage($this->link, $this->cookie, $post, $Referer);
  29. return $this->Premium();
  30. } else {
  31. $this->page = $this->GetPage($this->link, 0, $post, $Referer);
  32. return $this->Retrieve();
  33. }
  34. } elseif ($_REQUEST['step'] == 'captcha') {
  35. return $this->Free();
  36. } else {
  37. return $this->Retrieve();
  38. }
  39. }
  40. private function Retrieve() {
  41. global $Referer;
  42. if (stristr($this->page, 'This file is password-protected!')) {
  43. $form = cut_str($this->page, '<form name="form" method="post"', '</form>');
  44. if (!preg_match('%action="([^"]+)"%', $form, $pw)) html_error("Error[getFreePassLink]");
  45. $this->link = 'http://netload.in/' . $pw[1];
  46. if (!preg_match_all('%<input type="(hidden|submit)" value="([^"]+)?" name="([^"]+)" \/>%', $form, $match)) html_error("Error[getFreePostPass]");
  47. $data = array_merge($this->DefaultParamArr('http://netload.in/' . $pw[1]), array_combine($match[3], $match[2]));
  48. $data['step'] = 'password';
  49. $this->EnterPassword($data);
  50. exit();
  51. }
  52. $this->cookie = GetCookies($this->page);
  53. if (!preg_match('%<div class="Free_dl"><a href="([^"]+)">%', $this->page, $temp)) html_error('Error[getFreeLink]');
  54. $this->link = 'http://netload.in/' . html_entity_decode($temp[1], ENT_QUOTES, 'UTF-8');
  55. $this->page = $this->GetPage($this->link, $this->cookie, 0, $Referer);
  56. if (!preg_match('@countdown\(([0-9]+),\'change\(\)\'\)@', $this->page, $wait)) html_error('Error[getFreeTimer1]!');
  57. $this->CountDown($wait[1] / 100);
  58. if (stripos($this->page, 'Please enter the security code')) {
  59. $form = cut_str($this->page, '<form method="post"', '</form>');
  60. if (!preg_match('%action="([^"]+)">%', $form, $temp) || !preg_match('%src="([^"]+)" alt="Sicherheitsbild" \/>%', $form, $cap)) html_error("Error[getCaptchaLink/Image]");
  61. if (!preg_match_all('@name="([^"]+)" type="(hidden|submit)" value="([^"]+)?"@', $form, $match)) html_error("Error[getCaptchaPostData]");
  62. $capt = $this->GetPage('http://netload.in/' . $cap[1], $this->cookie);
  63. $capt_img = substr($capt, strpos($capt, "\r\n\r\n") + 4);
  64. $imgfile = DOWNLOAD_DIR . "netload_captcha.png";
  65. if (file_exists($imgfile)) unlink($imgfile);
  66. if (empty($capt_img) || !write_file($imgfile, $capt_img)) html_error("Error getting CAPTCHA image.");
  67. $data = array_merge($this->DefaultParamArr('http://netload.in/' . $temp[1], $this->cookie), array_combine($match[1], $match[3]));
  68. $data['step'] = 'captcha';
  69. $this->EnterCaptcha($imgfile, $data);
  70. exit();
  71. }
  72. }
  73. private function Free() {
  74. global $Referer;
  75. $post['file_id'] = $_POST['file_id'];
  76. $post['captcha_check'] = $_POST['captcha'];
  77. $post['start'] = $_POST['start'];
  78. $this->link = urldecode($_POST['link']);
  79. $this->cookie = urldecode($_POST['cookie']);
  80. $this->page = $this->GetPage($this->link, $this->cookie, $post, $Referer);
  81. if (!preg_match('#countdown\(([0-9]+),\'change\(\)\'\)#', $this->page, $wait)) html_error('Error[getFreeTimer2]!');
  82. $timer = trim($wait[1]) / 100;
  83. if ($timer > 20) html_error("Error[Limit reach, you can download your next file in " . round($timer / 60) . " minute]!");
  84. $this->CountDown($timer);
  85. if (!preg_match('@http:\/\/[\d.]+\/[^|\r|\n|"]+@', $this->page, $dl)) html_error('Error[getFreeDownloadLink]');
  86. $dlink = trim($dl[0]);
  87. $filename = basename(parse_url($dlink, PHP_URL_PATH));
  88. $this->RedirectDownload($dlink, $filename, $this->cookie, 0, $Referer);
  89. exit();
  90. }
  91. private function Login() {
  92. global $premium_acc;
  93. $user = ($_REQUEST["premium_user"] ? trim($_REQUEST["premium_user"]) : $premium_acc["netload_in"]["user"]);
  94. $pass = ($_REQUEST["premium_pass"] ? trim($_REQUEST["premium_pass"]) : $premium_acc["netload_in"]["pass"]);
  95. if (empty($user) || empty($pass)) html_error("Login Failed: User [$user] or Password [$pass] is empty. Please check login data.");
  96. $posturl = 'http://netload.in/';
  97. $post['txtuser'] = $user;
  98. $post['txtpass'] = $pass;
  99. $post['txtcheck'] = 'login';
  100. $post['txtlogin'] = 'Login';
  101. $this->page = $this->GetPage($posturl . 'index.php', 0, $post, $posturl);
  102. is_present($this->page, '/index.php?id=15', 'Login failed, invalid username or password???');
  103. $this->cookie = GetCookies($this->page);
  104. //check the premium account (IMPORTANT!)
  105. $this->page = $this->GetPage($posturl . 'index.php?id=2', $this->cookie);
  106. is_present($this->page, 'Order Premium Account now', 'Account Status : FREE!');
  107. //start download the link
  108. $this->page = $this->GetPage($this->link, $this->cookie, 0, $this->link);
  109. return $this->Premium();
  110. }
  111. private function Premium() {
  112. if (stristr($this->page, 'This file is password-protected!')) {
  113. $form = cut_str($this->page, '<form name="form" method="post"', '</form>');
  114. if (!preg_match('%action="([^"]+)"%', $form, $pw)) html_error("Error[getPrePassLink]");
  115. if (!preg_match_all('%<input type="(hidden|submit)" value="([^"]+)?" name="([^"]+)" \/>%', $form, $match)) html_error("Error[getPrePostPass]");
  116. $data = array_merge($this->DefaultParamArr('http://netload.in/' . $pw[1], encrypt($this->cookie)), array_combine($match[3], $match[2]));
  117. $data['step'] = 'password';
  118. $this->EnterPassword($data);
  119. exit();
  120. }
  121. if (!preg_match('@http:\/\/[\d.]+\/[^|\r|\n|\'"]+@i', $this->page, $dl)) html_error('Error[getPremiumDownloadLink]');
  122. $dlink = trim($dl[0]);
  123. $filename = basename(parse_url($dlink, PHP_URL_PATH));
  124. $this->RedirectDownload($dlink, $filename, $this->cookie);
  125. }
  126. private function EnterPassword($inputs) {
  127. global $PHP_SELF;
  128. if (!is_array($inputs)) {
  129. html_error("Error parsing password data!");
  130. }
  131. echo "\n" . '<center><form action="' . $PHP_SELF . '" method="post" >' . "\n";
  132. foreach ($inputs as $name => $val) {
  133. echo "<input type='hidden' name='$name' id='$name' value='$val' />\n";
  134. }
  135. echo '<h4>Enter password here: <input type="text" name="password" id="filepass" size="13" />&nbsp;&nbsp;<input type="submit" onclick="return check()" value="Continue" /></h4>' . "\n";
  136. 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";
  137. echo "\n</form></center>\n</body>\n</html>";
  138. exit();
  139. }
  140. }
  141. //updated 05-jun-2010 for standard auth system (szal)
  142. //updated 05-Okt-2011 for premium & free, password protected files by Ruud v.Tony
  143. //small fix in checkin' link 10-Okt-2011 by Ruud v.Tony
  144. //fix password & captcha form layout by Ruud v.Tony 02-02-2012
  145. ?>