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

/pluginz/download/uploadstation_com.php

http://rapidleech36b.googlecode.com/
PHP | 201 lines | 175 code | 23 blank | 3 comment | 31 complexity | 1cd5958cf33ced71f44c0afd97d423a3 MD5 | raw file
  1. <?php
  2. if (!defined('RAPIDLEECH')) {
  3. require_once ("index.html");
  4. exit;
  5. }
  6. class uploadstation_com extends DownloadClass {
  7. public function Download($link) {
  8. global $premium_acc;
  9. if (!$_REQUEST["step"]) { // Check link
  10. $this->page = $this->GetPage($link);
  11. is_present($page, "The file could not be found.", "The file could not be found. Please check the download link.");
  12. $this->cookie = GetCookies($this->page);
  13. }
  14. $this->link = $link;
  15. if (($_REQUEST["premium_acc"] == "on" && $_REQUEST["premium_user"] && $_REQUEST["premium_pass"]) ||
  16. ($_REQUEST["premium_acc"] == "on" && $premium_acc["uploadstation_com"]["user"] && $premium_acc["uploadstation_com"]["pass"])) {
  17. return $this->Download_Premium();
  18. } elseif ($_REQUEST['step'] == 1) {
  19. return $this->Check_Captcha();
  20. } else {
  21. return $this->Prepare_Free();
  22. }
  23. }
  24. private function Download_Premium() {
  25. $cookie = $this->Login();
  26. $page = $this->GetPage($this->link, $cookie);
  27. if (stristr($page, "HTTP/1.1 200 OK\r\n")) {
  28. $page = $this->GetPage($this->link, $cookie, array('download'=>'premium'));
  29. }
  30. if (preg_match('/Location: (http:\/\/d\d+.uploadstation.com[^\r\n]+)/i', $page, $D)) {
  31. $dllink = $D[1];
  32. } else {
  33. is_present($page, "You are not able to download", "Error: Account isn't premium. [P6c]");
  34. html_error("Download-link not found. [P7]");
  35. }
  36. $filename = parse_url($dllink);
  37. $filename = urldecode(basename($filename["path"]));
  38. $this->RedirectDownload($dllink, $filename, $cookie);
  39. }
  40. private function Login() {
  41. global $premium_acc;
  42. $pA = ($_REQUEST["premium_user"] && $_REQUEST["premium_pass"] ? true : false);
  43. $user = ($pA ? $_REQUEST["premium_user"] : $premium_acc["uploadstation_com"]["user"]);
  44. $pass = ($pA ? $_REQUEST["premium_pass"] : $premium_acc["uploadstation_com"]["pass"]);
  45. if (empty($user) || empty($pass)) {
  46. html_error("Login Failed: Username or Password is empty. Please check login data. [P1]");
  47. }
  48. $postURL = "http://www.uploadstation.com/login.php";
  49. $post['loginUserName'] = $user;
  50. $post['loginUserPassword'] = $pass;
  51. $post['autoLogin'] = 'on';
  52. $post['loginFormSubmit'] = 'Login';
  53. $page = $this->GetPage($postURL, 0, $post, 'http://www.uploadstation.com/');
  54. is_present($page, "should be larger than or equal to 6", "Username or password too short. [P2]");
  55. is_present($page, "Username doesn't exist.", "Username doesn't exist. [P3]");
  56. is_present($page, "Wrong password.", "Wrong password. [P4]");
  57. is_notpresent($page, "Logging in", "Login error. [P5]");
  58. $cookie = GetCookies($page);
  59. is_notpresent($cookie, "Cookie=", "Login error. Cookie not found. [P5b]");
  60. $page = $this->GetPage("http://www.uploadstation.com/dashboard.php", $cookie, 0, 'http://www.uploadstation.com/');
  61. is_present($page, "acctype_free", "Login error. Account isn't premium. [P6]");
  62. is_notpresent($page, "Expiry date: ", "Login error. Account isn't premium? [P6b]");
  63. return $cookie;
  64. }
  65. private function Prepare_Free() {
  66. $check = $this->GetPage($this->link, $this->cookie, array('checkDownload' => 'check'));
  67. if (!preg_match('/\{"([^"]+)":"([^"]+)"(?:,"([^"]+)":(\d+))?\}/i', $check, $j)) {
  68. is_present($check, "fail404", "Error checking for time/captcha. [F1]");
  69. html_error("Error. [F2]");
  70. }
  71. if ($j[1] == 'success') {
  72. switch ($j[2]) {
  73. case 'showCaptcha':
  74. return $this->showCaptcha();
  75. break;
  76. case 'showTimmer':
  77. return $this->showTimmer();
  78. break;
  79. }
  80. }
  81. is_present($j[2], "timeLimit", "You need to wait 300 seconds to download next file.");
  82. is_present($j[2], "captchaFail", "Your IP has failed the captcha too many times. Please retry later. (~{$j[4]} mins)");
  83. html_error("Error checking for time/captcha. {$j[0]} [F3]");
  84. }
  85. private function showCaptcha() {
  86. if (!preg_match("/reCAPTCHA_publickey='([^\']+)/i", $this->page, $A)) {
  87. html_error("Error: CAPTCHA not found. [F4]");
  88. }
  89. $pid = $A[1];
  90. $data = $this->DefaultParamArr($this->link, $this->cookie);
  91. $data['recaptcha_shortencode_field'] = cut_str($this->page,'name="recaptcha_shortencode_field" value="','"');;
  92. $data['step'] = '1';
  93. $this->Show_reCaptcha($pid, $data);
  94. }
  95. private function Show_reCaptcha($pid, $inputs) {
  96. global $PHP_SELF;
  97. if (!is_array($inputs)) {
  98. html_error("Error parsing captcha data.");
  99. }
  100. // Themes: 'red', 'white', 'blackglass', 'clean'
  101. echo "<script type='text/javascript'>var RecaptchaOptions={theme:'white', lang:'en'};</script>\n";
  102. echo "\n<center><form name='dl' action='$PHP_SELF' method='post' ><br />\n";
  103. echo "<script type='text/javascript' src='http://www.google.com/recaptcha/api/challenge?k=$pid'></script>";
  104. echo "<noscript><iframe src='http://www.google.com/recaptcha/api/noscript?k=$pid' height='300' width='500' frameborder='0'></iframe><br />";
  105. echo "<textarea name='recaptcha_challenge_field' rows='3' cols='40'></textarea><input type='hidden' name='recaptcha_response_field' value='manual_challenge' /></noscript><br />\n";
  106. foreach ($inputs as $name => $input) {
  107. echo "<input type='hidden' name='$name' id='$name' value='$input' />\n";
  108. }
  109. echo "<input type='submit' name='submit' onclick='javascript:return checkc();' value='Download File' />\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. private function showTimmer() {
  115. $check = $this->GetPage($this->link, $this->cookie, array('downloadLink' => 'wait'));
  116. if (!preg_match('/\r\n\r\n(?:\w|\d)+\r\n[^\d]+(\d+)/i', $check, $j)) {
  117. is_present($check, "fail\r\n", "Error checking for time/captcha... Maybe is overloaded, please try again. [F7]");
  118. is_present($check, "fail404\r\n", "Error checking for time/captcha. [F8]");
  119. html_error("Failed to get link time-lock. [F9]");
  120. }
  121. $this->CountDown($j[1] + 2); // Added 2 seconds...
  122. $check = $this->GetPage($this->link, $this->cookie, array('downloadLink' => 'show'));
  123. is_present($check, "fail\r\n", "Error getting download link... Maybe is overloaded, please try again. [F10]");
  124. is_present($check, "fail404\r\n", "Error getting download link. [F11]");
  125. $this->page = $this->GetPage($this->link, $this->cookie, array('download' => 'normal'));
  126. return $this->Download_Free();
  127. }
  128. private function Download_Free() {
  129. if (preg_match('/Location: (http:\/\/d\d+.uploadstation.com[^\r\n]+)/i', $this->page, $D)) {
  130. $dllink = $D[1];
  131. } else {
  132. is_present($this->page, "<h1>You need to wait", "You need to wait 300 seconds to download next file.");
  133. html_error("Download-link not found. [F12]");
  134. }
  135. $filename = parse_url($dllink);
  136. $filename = urldecode(basename($filename["path"]));
  137. $this->RedirectDownload($dllink, $filename);
  138. }
  139. private function Check_Captcha() {
  140. $this->cookie = urldecode($_POST['cookie']);
  141. if (empty($_POST['recaptcha_response_field'])) {
  142. html_error("You didn't enter the image verification code.");
  143. }
  144. $post = array();
  145. $post['recaptcha_challenge_field'] = $_POST['recaptcha_challenge_field'];
  146. $post['recaptcha_response_field'] = $_POST['recaptcha_response_field'];
  147. $post['recaptcha_shortencode_field'] = $_POST['recaptcha_shortencode_field'];
  148. $page = $this->GetPage('http://www.uploadstation.com/checkReCaptcha.php', $this->cookie, $post);
  149. is_present($page, "fail\r\n", "Error checking captcha.... Maybe is overloaded, please try again. [F5]");
  150. is_present($page, "fail404\r\n", "Error checking captcha. [F5b]");
  151. if (!preg_match('/\{"success":(\d)(?:,"([^"]+)":"([^"]+)")?\}/i', $page, $stat)) {
  152. is_present($page, '"error":"captcha-fail"', "Your IP has failed the captcha too many times. Please retry later.");
  153. html_error("Error validating CAPTCHA. [F6]");
  154. }
  155. if ($stat[1] == '1') {
  156. return $this->showTimmer();
  157. } elseif (stristr($stat[3], 'incorrect-captcha-sol')) {
  158. html_error("Entered code was incorrect.");
  159. }
  160. html_error("Error validating CAPTCHA: {$stat[0]}.. Please try again. [F6b]");
  161. }
  162. }
  163. //[08-4-2011] Written by Th3-822 (Free download only).
  164. //[09-4-2011] Added & checked error msgs && 2 more secs to the countdown (no more error F10 (old F9)). - Th3-822.
  165. //[16-4-2011] Added support for download with Premium Account. - Th3-822.
  166. ?>