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

/hosts/download/filepost_com.php

https://gitlab.com/billyprice1/rapidleech
PHP | 269 lines | 246 code | 11 blank | 12 comment | 36 complexity | 30a1acd371d6f4c2dcd70d4d1714daed MD5 | raw file
  1. <?php
  2. if (!defined('RAPIDLEECH')) {
  3. require_once ("index.html");
  4. exit();
  5. }
  6. class filepost_com extends DownloadClass {
  7. public function Download($link) {
  8. global $premium_acc;
  9. if (strstr($link, "fp.io/")) {
  10. $link = str_replace("fp.io/", "filepost.com/files/", $link);
  11. }
  12. $this->link = $link;
  13. if (!$_REQUEST['step']) {
  14. $this->page = $this->GetPage($this->link);
  15. if (preg_match('@Location: (http(s)?:\/\/[^\r\n]+)@i', $this->page, $rd)) {
  16. $this->link = trim($rd[1]);
  17. $this->page = $this->GetPage($this->link);
  18. }
  19. is_present($this->page, "File not found");
  20. is_present($this->page, "This IP address has been blocked on our service due to some fraudulent activity.");
  21. $this->Cookies = GetCookiesArr($this->page);
  22. if ($this->Cookies['SID'] == '') html_error("Error Cookie [SID] not found!");
  23. }
  24. if ($_REQUEST ["premium_acc"] == "on" && (($_REQUEST ["premium_user"] && $_REQUEST ["premium_pass"]) || ($premium_acc ["filepost_com"] ["user"] && $premium_acc ["filepost_com"] ["pass"]))) {
  25. return $this->Login();
  26. } elseif ($_REQUEST['step'] == 'Recaptcha') {
  27. return $this->Login(true);
  28. } elseif ($_REQUEST['step'] == 'Passpre') {
  29. return $this->Premium(true);
  30. } else {
  31. return $this->Free();
  32. }
  33. }
  34. private function Free() {
  35. switch ($_REQUEST['step']) {
  36. case 'Captcha':
  37. $post['code'] = $_POST['code'];
  38. $post['file_pass'] = '';
  39. $post['recaptcha_challenge_field'] = $_POST['recaptcha_challenge_field'];
  40. $post['recaptcha_response_field'] = $_POST['recaptcha_response_field'];
  41. $post['token'] = $_POST['token'];
  42. $Url = urldecode($_POST['link']);
  43. $this->Cookies = urldecode($_POST['cookie']);
  44. $recap = $_POST['recap'];
  45. $check = $this->GetPage($Url, $this->Cookies, $post, $this->link);
  46. break;
  47. case 'password':
  48. $post['code'] = $_POST['code'];
  49. $post['file_pass'] = $_POST['password'];
  50. $post['token'] = $_POST['token'];
  51. $Url = urldecode($_POST['link']);
  52. $this->Cookies = urldecode($_POST['cookie']);
  53. $check = $this->GetPage($Url, $this->Cookies, $post, $this->link);
  54. break;
  55. default:
  56. is_present($this->page, "Files over 1024MB can be downloaded by premium<br/ >members only. Please upgrade to premium");
  57. if (!preg_match("@code: '([^']+)',@", $this->page, $code) || !preg_match("@[({]token: '([^']+)',@", $this->page, $token)) html_error('Error: Post Data [FREE] not found!');
  58. $code = $code[1];
  59. $token = $token[1];
  60. $Url = "http://filepost.com/files/get/?SID={$this->Cookies['SID']}&JsHttpRequest=" . jstime() . "-xml";
  61. $post = array('action' => 'set_download', 'code' => $code, 'token' => $token);
  62. $check = $this->GetPage($Url, $this->Cookies, $post, $this->link);
  63. $this->Cookies = GetCookiesArr($check, $this->Cookies);
  64. if (preg_match('@"js":\{"(\w+)":\{?"([a-z|\_]+)"?:?"?(\d+)"?@i', $check, $match)) $this->CountDown($match[3]);
  65. if (strpos($this->page, 'var is_pass_exists = true') || strpos($this->page, 'var show_captcha = true')) {
  66. $data = $this->DefaultParamArr($Url, $this->Cookies);
  67. $data['code'] = $code;
  68. $data['token'] = $token;
  69. if (strpos($this->page, 'var is_pass_exists = true')) {
  70. $data['step'] = 'password';
  71. $this->EnterPassword($data);
  72. exit();
  73. } else {
  74. if (!preg_match('@key: \'([^\']+)@i', $this->page, $cap)) html_error('Error: Captcha Data [FREE] not found!');
  75. $data['step'] = 'Captcha';
  76. $data['recap'] = $cap[1]; // incase we need to load the captcha image again
  77. $this->Show_reCaptcha($cap[1], $data);
  78. exit();
  79. }
  80. } else { // no captcha or password required, skip the form process
  81. $post = array('code' => $code, 'file_pass' => '', 'token' => $token);
  82. $check = $this->GetPage($Url, $this->Cookies, $post, $this->link);
  83. }
  84. break;
  85. }
  86. // Let's play with the regex
  87. if (!preg_match('@"js":\{"(\w+)":\{?"([^"]+)"?:?"?([^|\r|\n|"]+)?"\}@i', $check, $match)) html_error("Error: Unknown Post Data [FREE] page response!");
  88. switch ($match[1]) {
  89. case 'error':
  90. echo ("<center><font color='red'><b>$match[2]</b></font></center>");
  91. $data = $this->DefaultParamArr($Url, $this->Cookies);
  92. $data['code'] = $_POST['code'];
  93. $data['token'] = $_POST['token'];
  94. switch ($match[2]) {
  95. case 'Wrong file password':
  96. $data['step'] = 'password';
  97. $this->EnterPassword($data);
  98. break;
  99. case 'You entered a wrong CAPTCHA code. Please try again.':
  100. $data['step'] = 'Captcha';
  101. $data['recap'] = $recap;
  102. $this->Show_reCaptcha($recap, $data);
  103. break;
  104. }
  105. break;
  106. case 'answer':
  107. switch ($match[2]) {
  108. case 'link':
  109. $dlink = str_replace('\\', '', $match[3]);
  110. $filename = basename(parse_url($dlink, PHP_URL_PATH));
  111. $this->RedirectDownload($dlink, $filename, $this->Cookies, 0, $this->link);
  112. break;
  113. }
  114. break;
  115. default:
  116. html_error("$match[1], $match[2]");
  117. break;
  118. }
  119. }
  120. private function Login($captcha = false) {
  121. global $premium_acc;
  122. $email = ($_REQUEST["premium_user"] ? trim($_REQUEST["premium_user"]) : $premium_acc ["filepost_com"] ["user"]);
  123. $password = ($_REQUEST["premium_pass"] ? trim($_REQUEST["premium_pass"]) : $premium_acc ["filepost_com"] ["pass"]);
  124. if (empty($email) || empty($password)) html_error("Login failed, username or password is empty!");
  125. $post = array();
  126. $post['email'] = $email;
  127. $post['password'] = $password;
  128. $post['remember'] = 'on';
  129. if ($captcha == true) {
  130. $post['recaptcha_challenge_field'] = $_POST['recaptcha_challenge_field'];
  131. $post['recaptcha_response_field'] = $_POST['recaptcha_response_field'];
  132. $posturl = urldecode($_POST['link']);
  133. $this->Cookies = StrToCookies(urldecode($_POST['cookie']));
  134. $check = $this->GetPage($posturl, $this->Cookies, $post, "http://filepost.com/");
  135. } else {
  136. $posturl = "http://filepost.com/general/login_form/?SID={$this->Cookies['SID']}&JsHttpRequest=" . jstime() . "-xml";
  137. $check = $this->GetPage($posturl, $this->Cookies, $post, "http://filepost.com/");
  138. }
  139. if (!preg_match('@"js":\{"(\w+)":\{?"([^"]+)"?:?(\w+)?\}?,?"?(\w+)?"?:?"?([^"]+)?"?\}@i', $check, $match)) html_error("Error: Unknown Login Page Response, Plugin need to be updated!");
  140. if ($match[1] == 'answer' && $match[4] !== 'error') {
  141. switch ($match[2]) {
  142. case 'captcha':
  143. if (!preg_match('@key: \'([^\']+)@i', $this->page, $cap)) html_error('Error: Captcha Data [Premium] not found!');
  144. $data = $this->DefaultParamArr($posturl, $this->Cookies);
  145. $data['step'] = 'Recaptcha';
  146. $this->Show_reCaptcha($cap[1], $data);
  147. break;
  148. case 'success':
  149. //check account, we need to convert to array since we have pass the captcha, I also made mistake, should be array_merge, not array_replace, stupid...
  150. $this->Cookies = GetCookiesArr($check, $this->Cookies);
  151. $check = $this->GetPage("http://filepost.com/partners/", $this->Cookies, 0, 'http://filepost.com/');
  152. is_present($check, "Account type: <span>Free</span>");
  153. break;
  154. }
  155. }
  156. is_present($match[1], 'error', str_replace('\\', '', $match[2]));
  157. is_present($match[4], 'error', $match[5]);
  158. return $this->Premium();
  159. }
  160. private function Premium($password = false) {
  161. if ($password == true) {
  162. $post['code'] = $_POST['code'];
  163. $post['file_pass'] = $_POST['password'];
  164. $post['token'] = $_POST['token'];
  165. $Url = urldecode($_POST['link']);
  166. $this->Cookies = decrypt(urldecode($_POST['cookie']));
  167. $this->page = $this->GetPage($Url, $this->Cookies, $post, $this->link);
  168. if (!preg_match('@"js":\{"(\w+)":\{?"([^"]+)"?:?"?([^|\r|\n|"]+)?"\}@i', $this->page, $match)) html_error("Error: Unknown Password Link [PREMIUM] page response, plugin need to be updated!");
  169. switch ($match[1]) {
  170. case 'error':
  171. echo ("<center><font color='red'><b>$match[2]</b></font></center>");
  172. $data = $this->DefaultParamArr($Url, encrypt($this->Cookies), $this->link);
  173. $data['step'] = 'Passpre';
  174. $data['code'] = $_POST['code'];
  175. $data['token'] = $_POST['token'];
  176. $this->EnterPassword($data);
  177. break;
  178. case 'answer':
  179. switch ($match[2]) {
  180. case 'link':
  181. $dlink = str_replace('\\', '', $match[3]);
  182. $filename = basename(parse_url($dlink, PHP_URL_PATH));
  183. $this->RedirectDownload($dlink, $filename, $this->Cookies);
  184. break;
  185. }
  186. break;
  187. }
  188. } else {
  189. $this->page = $this->GetPage($this->link, $this->Cookies, 0, $this->link);
  190. is_present($this->page, "You can only download 50GB a day");
  191. if (strpos($this->page, 'var is_pass_exists = true')) {
  192. if (!preg_match("@code: '([^']+)',@", $this->page, $code) || !preg_match("@[({]token: '([^']+)',@", $this->page, $token)) html_error('Error: Post Password Data [Premium] not found!');
  193. $Url = "http://filepost.com/files/get/?SID={$this->Cookies['SID']}&JsHttpRequest=" . jstime() . "-xml";
  194. $data = $this->DefaultParamArr($Url, encrypt(CookiesToStr($this->Cookies)), $this->link);
  195. $data['code'] = $code[1];
  196. $data['token'] = $token[1];
  197. $data['step'] = 'Passpre';
  198. $this->EnterPassword($data);
  199. exit();
  200. }
  201. if (!preg_match('@http(s)?:\/\/fs\d+\.filepost\.com\/get_file\/[^|\r|\n|\']+@i', $this->page, $dl)) html_error("Error: Download Link [PREMIUM] non password not found!");
  202. $dlink = trim($dl[0]);
  203. $filename = basename(parse_url($dlink, PHP_URL_PATH));
  204. $this->RedirectDownload($dlink, $filename, $this->Cookies);
  205. }
  206. }
  207. private function Show_reCaptcha($pid, $inputs) {
  208. global $PHP_SELF;
  209. if (!is_array($inputs)) {
  210. html_error("Error parsing captcha data.");
  211. }
  212. // Themes: 'red', 'white', 'blackglass', 'clean'
  213. echo "<script language='JavaScript'>var RecaptchaOptions={theme:'white', lang:'en'};</script>\n";
  214. echo "\n<center><form name='dl' action='$PHP_SELF' method='post' ><br />\n";
  215. foreach ($inputs as $name => $input) {
  216. echo "<input type='hidden' name='$name' id='$name' value='$input' />\n";
  217. }
  218. echo "<script type='text/javascript' src='http://www.google.com/recaptcha/api/challenge?k=$pid'></script>";
  219. echo "<noscript><iframe src='http://www.google.com/recaptcha/api/noscript?k=$pid' height='300' width='500' frameborder='0'></iframe><br />";
  220. echo "<textarea name='recaptcha_challenge_field' rows='3' cols='40'></textarea><input type='hidden' name='recaptcha_response_field' value='manual_challenge' /></noscript><br />";
  221. echo "<input type='submit' name='submit' onclick='javascript:return checkc();' value='Enter Captcha' />\n";
  222. 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";
  223. echo "</form></center>\n</body>\n</html>";
  224. exit;
  225. }
  226. private function EnterPassword($inputs) {
  227. global $PHP_SELF;
  228. if (!is_array($inputs)) {
  229. html_error("Error parsing password data.");
  230. }
  231. echo "\n" . '<center><form action="' . $PHP_SELF . '" method="post" >' . "\n";
  232. foreach ($inputs as $name => $input) {
  233. echo "<input type='hidden' name='$name' id='$name' value='$input' />\n";
  234. }
  235. echo '<h4>Enter password here: <input type="text" name="password" id="filepass" size="13" />&nbsp;&nbsp;<input type="submit" onclick="return check()" value="Submit" /></h4>' . "\n";
  236. 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";
  237. echo "\n</form></center>\n</body>\n</html>";
  238. exit();
  239. }
  240. }
  241. /*
  242. * Filepost.com free download plugin by Ruud v.Tony 29-09-2011
  243. * Updated to support premium by vdhdevil 12-10-2011
  244. * Updated the free download code by Ruud v.Tony 02-11-2011 for multiple option error
  245. * Small regex fix in free download by Ruud v.Tony 10-01-2012
  246. * Updated for including short link (fp.io) in check link by Ruud v.Tony 13-01-2012
  247. * Updated to support captcha also password protected files in premium by Ruud v.Tony 21-01-2012
  248. * Small fix in checking account also free download code by Ruud v.Tony 01-02-2012
  249. * Implement new function for an example by Ruud v.Tony 04-02-2012
  250. */
  251. ?>