PageRenderTime 34ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/hosts/download/hotfile_com.php

http://rapidleech.googlecode.com/
PHP | 216 lines | 186 code | 24 blank | 6 comment | 42 complexity | 03f3f2dfdf348c37f4b85a7bfe55d258 MD5 | raw file
  1. <?php
  2. if (!defined('RAPIDLEECH')) {
  3. require_once ("index.html");
  4. exit();
  5. }
  6. class hotfile_com extends DownloadClass {
  7. public function Download($link) {
  8. global $premium_acc;
  9. if (!$_GET["step"]) { // Check link
  10. if (preg_match("/hotfile\.com\/dl\/(\d+\/\w+)\/(.+)?/i", $link, $l)) {
  11. $link = "http://hotfile.com/dl/{$l[1]}/{$l[2]}";
  12. } else {
  13. html_error("Error: Malformed link?. Please check the download link.");
  14. }
  15. $page = $this->GetPage($link);
  16. is_present($page, "<td>This file is either removed due", "Error: This file is either removed due to copyright claim or is deleted by the uploader.");
  17. is_present($page, "<td>File is removed", "Error: File is removed due to copyright claim.");
  18. if (stristr($page, "\r\nContent-Length: 0\r\n")) {
  19. is_notpresent($page, "\r\nLocation:", "Error: Invalid link. Please check the download link.");
  20. // Check if file has enabled Hot/Direct linking.
  21. if (!preg_match("/(s\d+)\.hotfile\.com\/get\/(\w+\/\w+\/\w+\/\w+\/\w+)\/([^\r|\n]+)/i", $page, $l)) {
  22. html_error("Error: Invalid link?. Please check the download link.");
  23. }
  24. $dllink = "http://{$l[1]}.hotfile.com/get/{$l[2]}/{$l[3]}";
  25. $filename = parse_url($dllink);
  26. $filename = urldecode(basename($filename["path"]));
  27. return $this->RedirectDownload($dllink, $filename, GetCookies($page));
  28. }
  29. unset($page);
  30. }
  31. if (($_REQUEST["cookieuse"] == "on" && preg_match("/auth\s?=\s?(\w{64})/i", $_REQUEST["cookie"], $c)) || ($_REQUEST["premium_acc"] == "on" && $premium_acc["hotfile_com"]["cookie"])) {
  32. $cookie = (empty($c[1]) ? $premium_acc["hotfile_com"]["cookie"] : $c[1]);
  33. $this->DownloadPremium($link, $cookie);
  34. } elseif (($_REQUEST["premium_acc"] == "on" && $_REQUEST["premium_user"] && $_REQUEST["premium_pass"]) ||
  35. ($_REQUEST["premium_acc"] == "on" && $premium_acc["hotfile_com"]["user"] && $premium_acc["hotfile_com"]["pass"])) {
  36. $this->DownloadPremium($link);
  37. } else {
  38. $this->DownloadFree($link);
  39. }
  40. }
  41. private function DownloadFree($link) {
  42. $page = $this->GetPage($link);
  43. if ($_GET["step"] != "1") {
  44. if (!preg_match_all('/timerend=d\.getTime\(\)\+(\d+)/i', $page, $t)) {
  45. html_error("Error getting timer.");
  46. }
  47. $t = $t[1];
  48. $hl = ($t[1] > 0 ? $t[1]/1000 : 0);
  49. if ($hl > 0) {
  50. $data = $this->DefaultParamArr($link);
  51. $data['step'] = '2';
  52. $this->JSCountdown($hl, $data, 'You reached your hourly traffic limit');
  53. } else {
  54. insert_timer(($t[0]/1000)+1, "Waiting captcha/link timelock:");
  55. }
  56. $post['action'] = cut_str($page, "action value=", ">");
  57. $post['tm'] = cut_str($page, "tm value=", ">");
  58. $post['tmhash'] = cut_str($page, "tmhash value=", ">");
  59. $post['wait'] = cut_str($page, "wait value=", ">");
  60. $post['waithash'] = cut_str($page, "waithash value=", ">");
  61. $post['upidhash'] = cut_str($page, "upidhash value=", ">");
  62. $page = $this->GetPage($link, 0, $post);
  63. }
  64. $lfound = (stristr($page, "hotfile.com/get/") ? true : false);
  65. $cfound = (stristr($page, "api.recaptcha.net/challenge?k=") ? true : false);
  66. if (!$lfound && !$cfound) {
  67. /* No captcha or link found?. Let's try resending the post */
  68. $post['action'] = cut_str($page, "action value=", ">");
  69. $post['tm'] = cut_str($page, "tm value=", ">");
  70. $post['tmhash'] = cut_str($page, "tmhash value=", ">");
  71. $post['wait'] = cut_str($page, "wait value=", ">");
  72. $post['waithash'] = cut_str($page, "waithash value=", ">");
  73. $post['upidhash'] = cut_str($page, "upidhash value=", ">");
  74. $page = $this->GetPage($link, 0, $post);
  75. $lfound = (stristr($page, "hotfile.com/get/") ? true : false);
  76. $cfound = (stristr($page, "api.recaptcha.net/challenge?k=") ? true : false);
  77. }
  78. if($_GET["step"] == "1" && !$lfound) {
  79. //Send captcha
  80. $post['action'] = $_POST['action'];
  81. $post['recaptcha_challenge_field'] = $_POST['challenge'];
  82. $post['recaptcha_response_field'] = $_POST['captcha'];
  83. $post['recaptcha_shortencode_field'] = $_POST['shortencode'];
  84. $page = $this->GetPage($link, 0, $post);
  85. is_present($page, "Wrong Code. Please try again.", "Error: Entered CAPTCHA was incorrect.");
  86. is_notpresent($page, 'hotfile.com/get/', 'Error: Download-link not found [2].');
  87. } elseif (!$lfound && $cfound) {
  88. //Get captcha
  89. $pid = cut_str($page, 'recaptcha.net/challenge?k=', '"');
  90. $page = $this->GetPage("http://www.google.com/recaptcha/api/challenge?k=" . $pid);
  91. if (preg_match('/challenge \: \'([^\']+)/i', $page, $ch)) {
  92. $challenge = $ch[1];
  93. } else {
  94. html_error("Error getting CAPTCHA data.");
  95. }
  96. $data = $this->DefaultParamArr($link);
  97. $data['challenge'] = $challenge;
  98. $data['shortencode'] = 'undefined';
  99. $data['action'] = 'checkcaptcha';
  100. $data['step'] = '1';
  101. //Download captcha img.
  102. $page = $this->GetPage("http://www.google.com/recaptcha/api/image?c=" . $challenge);
  103. $capt_img = substr($page, strpos($page, "\r\n\r\n") + 4);
  104. $imgfile = DOWNLOAD_DIR . "hotfile_captcha.jpg";
  105. if (file_exists($imgfile)) {
  106. unlink($imgfile);
  107. }
  108. if (! write_file($imgfile, $capt_img)) {
  109. html_error("Error getting CAPTCHA image.", 0);
  110. }
  111. $this->EnterCaptcha($imgfile, $data, 20);
  112. exit;
  113. } elseif (!$lfound) {
  114. html_error("Error getting CAPTCHA");
  115. }
  116. if (preg_match('/\/get\/(\d+\/\w+\/\w+)\/([^\'|\"]+)/i', $page, $dl)) {
  117. $cookie = GetCookies($page);
  118. $page = $this->GetPage("http://hotfile.com/get/{$dl[1]}/{$dl[2]}", $cookie);
  119. } else {
  120. html_error("Error: Download-link not found.");
  121. }
  122. is_notpresent($page, "\r\nLocation:", "Error: Direct link not found.");
  123. if (!preg_match("/(s\d+)\.hotfile\.com\/get\/(\w+\/\w+\/\w+\/\w+\/\w+)\/([^\r|\n]+)/i", $page, $l)) {
  124. is_present(cut_str($page, "\r\nLocation: ", "\r\n"), "?expire=1", "Error: Your download expired, try again.");
  125. html_error("Error: Direct link not found [2].");
  126. }
  127. $dllink = "http://{$l[1]}.hotfile.com/get/{$l[2]}/{$l[3]}";
  128. $filename = parse_url($dllink);
  129. $filename = urldecode(basename($filename["path"]));
  130. $this->RedirectDownload($dllink, $filename, $cookie);
  131. }
  132. private function DownloadPremium($link, $cookie = false) {
  133. $cookie = $this->login($cookie);
  134. $page = $this->GetPage($link, $cookie);
  135. if (stristr($page, "\r\nContent-Length: 0\r\n")) {
  136. is_notpresent($page, "\r\nLocation:", "Error: Direct link not found.");
  137. } elseif (preg_match('/\/get\/(\d+\/\w+\/\w+)\/([^\'|\"]+)/i', $page, $dl)) {
  138. $page = $this->GetPage("http://hotfile.com/get/{$dl[1]}/{$dl[2]}", $cookie);
  139. } else {
  140. is_notpresent($page, '<span>Premium</span>', "Error: The account isn't premium?.");
  141. html_error("Error: Download-link not found.");
  142. }
  143. $cookie = $cookie . "; " . GetCookies($page);
  144. if (!preg_match("/(s\d+)\.hotfile\.com\/get\/(\w+\/\w+\/\w+\/\w+\/\w+)\/([^\r|\n]+)/i", $page, $l)) {
  145. html_error("Error: Direct link not found [2].");
  146. }
  147. $dllink = "http://{$l[1]}.hotfile.com/get/{$l[2]}/{$l[3]}";
  148. $filename = parse_url($dllink);
  149. $filename = urldecode(basename($filename["path"]));
  150. $this->RedirectDownload($dllink, $filename, $cookie);
  151. }
  152. private function login($authc = false) {
  153. global $premium_acc;
  154. if (!$authc) {
  155. $user = ($_REQUEST["premium_user"] ? $_REQUEST["premium_user"] : $premium_acc["hotfile_com"]["user"]);
  156. $pass = ($_REQUEST["premium_pass"] ? $_REQUEST["premium_pass"] : $premium_acc["hotfile_com"]["pass"]);
  157. if (empty($user) || empty($pass)) {
  158. html_error("Login Failed: Username or Password is empty. Please check login data.");
  159. }
  160. $postURL = "http://hotfile.com/login.php";
  161. $post["returnto"] = "/";
  162. $post["user"] = $user;
  163. $post["pass"] = $pass;
  164. $page = $this->GetPage($postURL, 0, $post, 'http://hotfile.com/');
  165. $cookie = GetCookies($page);
  166. is_present($page, '/suspended.html', "Login failed: Your account has been suspended.");
  167. is_notpresent($page, "Location: /?cookiecheck=1", "Login failed: Username or Password is incorrect.");
  168. is_notpresent($cookie, "auth=", "Login Failed: Cannot get cookie.");
  169. } elseif (strlen($authc) == 64) {
  170. $cookie = "auth=" . $authc;
  171. } else {
  172. html_error("[Cookie] Invalid cookie (" . strlen($authc) . " != 64).");
  173. }
  174. $page = $this->GetPage("http://hotfile.com/?cookiecheck=1", $cookie);
  175. is_present($page, '<span>Free</span>', "Login Failed: The account isn't premium.");
  176. is_present($page, '/howtocookies.html', "Error: Login Failed.");
  177. is_present($page, '/login.php', "[Cookie] Invalid cookie.");
  178. return $cookie;
  179. }
  180. }
  181. //[06-Feb-2011] Plugin rewritten & added cookie support by Th3-822.
  182. //[13-Feb-2011] Removed old code & Fixed captcha in free download. - Th3-822
  183. //[15-May-2011] Added 3 error msg; 1 edited & Fixed error in 'hfwait' form & Added 1 seg to free dl Timelock & Added code to try again if captcha isn't found. - Th3-822
  184. //[11-Jul-2011] Using a function for the countdown & Added code for use DefaultParamArr(). -Th3-822
  185. ?>