PageRenderTime 24ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/hosts/download/filejungle_com.php

http://rapidleech.googlecode.com/
PHP | 136 lines | 123 code | 9 blank | 4 comment | 31 complexity | d3ce73fb4ef8e85e68135a6b18dc8768 MD5 | raw file
  1. <?php
  2. if (!defined('RAPIDLEECH')) {
  3. require_once ("index.html");
  4. exit();
  5. }
  6. class filejungle_com extends DownloadClass {
  7. public function Download($link) {
  8. global $premium_acc;
  9. // check link
  10. if (preg_match('@http:\/\/filejungle\.com\/l\/[^|\r|\n]+@i', $link, $dir)) {
  11. if (!$dir[0]) html_error('Filejungle folder link can\'t be found!');
  12. $check = $this->GetPage($link);
  13. preg_match_all('@http:\/\/www\.filejungle\.com\/f\/[^"]+@i', $check, $fj, PREG_SET_ORDER);
  14. $arr_link = array();
  15. foreach ($fj as $match) {
  16. $arr_link[] = $match[0];
  17. }
  18. if (!$arr_link) html_error('Can\'t find filejungle single link, probably folder is empty?');
  19. $this->moveToAutoDownloader($arr_link);
  20. }
  21. if (($_REQUEST['premium_acc'] == 'on' && $_REQUEST['premium_user'] && $_REQUEST['premium_pass']) || ($_REQUEST['premium_acc'] == 'on' && $premium_acc['filejungle_com']['user'] && $premium_acc['filejungle_com']['pass'])) {
  22. return $this->Premium($link);
  23. } else {
  24. return $this->Free($link);
  25. }
  26. }
  27. private function Premium($link) {
  28. $pA = ($_REQUEST["premium_user"] && $_REQUEST["premium_pass"] ? true : false);
  29. $cookie = $this->Login($pA);
  30. $page = $this->GetPage($link, $cookie);
  31. is_present($page, 'This file is no longer available.');
  32. if (!stristr($page, 'Location:')) {
  33. $page = $this->GetPage($link, $cookie, array('download' => 'premium'), $link);
  34. }
  35. $dlink = trim(cut_str($page, "Location: ", "\r\n"));
  36. if (empty($dlink)) html_error('Error: Premium download link not found, plugin need to be updated!');
  37. $FileName = urldecode(basename(parse_url($dlink, PHP_URL_PATH)));
  38. $this->RedirectDownload($dlink, $FileName, $cookie);
  39. }
  40. private function Login($pA = false) {
  41. global $premium_acc;
  42. $user = ($pA ? $_REQUEST["premium_user"] : $premium_acc["filejungle_com"]["user"]);
  43. $pass = ($pA ? $_REQUEST["premium_pass"] : $premium_acc["filejungle_com"]["pass"]);
  44. if (empty($user) || empty($pass)) {
  45. html_error("Login Failed: Username or Password is empty!");
  46. }
  47. $posturl = "http://filejungle.com/";
  48. $post['autoLogin'] = 'on';
  49. $post['loginUserName'] = $user;
  50. $post['loginUserPassword'] = $pass;
  51. $post['loginFormSubmit'] = 'Login';
  52. $page = $this->GetPage($posturl . "login.php", 0, $post, $posturl);
  53. is_present($page, "The length of user name should be larger than or equal to 6");
  54. is_present($page, "Username doesn't exist.");
  55. is_present($page, "Wrong password.");
  56. $cookie = GetCookies($page);
  57. is_notpresent($cookie, "cookie=", "Login error. Problem with cookie cache?");
  58. $page = $this->GetPage($posturl . 'dashboard.php', $cookie, 0, $posturl);
  59. is_present($page, "FREE<span>", "Account Free! What do you expect from that?");
  60. return $cookie;
  61. }
  62. private function Free($link) {
  63. if ($_REQUEST['step'] == 'Captcha') {
  64. $post['recaptcha_challenge_field'] = $_POST['recaptcha_challenge_field'];
  65. $post['recaptcha_response_field'] = $_POST['captcha'];
  66. $post['recaptcha_shortencode_field'] = $_POST['recaptcha_shortencode_field'];
  67. $cookie = urldecode($_POST['cookie']);
  68. $link = urldecode($_POST['link']);
  69. $check = $this->GetPage('http://www.filejungle.com/checkReCaptcha.php', $cookie, $post, $link . "\r\nX-Requested-With: XMLHttpRequest");
  70. } else {
  71. $this->page = $this->GetPage($link);
  72. is_present($this->page, 'This file is no longer available.');
  73. $cookie = GetCookies($this->page);
  74. $check = $this->GetPage($link, $cookie, array('checkDownload' => 'check'), $link . "\r\nX-Requested-With: XMLHttpRequest");
  75. }
  76. if (preg_match('@\{"(\w+)":"?([a-zA-Z0-9]+)"?(,"(\w+)":"?([a-zA-Z0-9\-]+)"?)?@i', $check, $match)) {
  77. if ($match[1] == 'success' && $match[4] !== 'error') {
  78. switch ($match[2]) {
  79. case 'showCaptcha':
  80. if (!preg_match('@reCAPTCHA_publickey=\'([^\']+)@i', $this->page, $cap)) html_error('Captcha not found!');
  81. if (!preg_match('@shortencode_field" value="([^"]+)@i', $this->page, $rsc)) html_error('Link id not found!');
  82. $ch = cut_str($this->GetPage("http://www.google.com/recaptcha/api/challenge?k=$cap[1]&ajax=1"), "challenge : '", "'");
  83. if ($ch) {
  84. $page = $this->GetPage("http://www.google.com/recaptcha/api/image?c=" . $ch);
  85. $pass_img = substr($page, strpos($page, "\r\n\r\n") + 4);
  86. $imgfile = DOWNLOAD_DIR . "filejungle_captcha.jpg";
  87. if (file_exists($imgfile)) unlink($imgfile);
  88. write_file($imgfile, $pass_img);
  89. } else {
  90. html_error('Can\'t find captcha image?');
  91. }
  92. $data = $this->DefaultParamArr($link, $cookie);
  93. $data['recaptcha_shortencode_field'] = $rsc[1];
  94. $data['recaptcha_challenge_field'] = $ch;
  95. $data['step'] = 'Captcha';
  96. $this->EnterCaptcha("$imgfile?" . time(), $data, 20);
  97. exit();
  98. break;
  99. case 'showTimmer': case '1':
  100. $check = $this->GetPage($link, $cookie, array('downloadLink' => 'wait'), $link . "\r\nX-Requested-With: XMLHttpRequest");
  101. if (!preg_match('@waitTime":(\d+),@', $check, $wait)) html_error('Timer not found?');
  102. $this->CountDown($wait[1]);
  103. $check = $this->GetPage($link, $cookie, array('downloadLink' => 'show'), $link . "\r\nX-Requested-With: XMLHttpRequest");
  104. is_present($check, 'forcePremiumDownload_exceed_4', 'You have reach download size limit for free user!');
  105. $this->page = $this->GetPage($link, $cookie, array('download' => 'normal'), $link . "\r\nX-Requested-With: XMLHttpRequest");
  106. break;
  107. }
  108. }
  109. is_present($match[2], 'timeLimit', 'Please wait for 1200 seconds to download the next file.');
  110. is_present($match[2], "captchaFail", "Your IP has failed the captcha too many times. Please retry again in $match[5] mins");
  111. is_present($match[5], "incorrect-captcha-sol", "Entered captcha was incorrect.");
  112. }
  113. if (!preg_match('@Location: (http:\/\/[a-zA-Z0-9]+\.filejungle\.com\/[^|\r|\n]+)@i', $this->page, $dl)) html_error('Error: Free download link not found, plugin need to be updated!');
  114. $dlink = trim($dl[1]);
  115. $FileName = urldecode(basename(parse_url($dlink, PHP_URL_PATH)));
  116. $this->RedirectDownload($dlink, $FileName, $cookie, 0, $link);
  117. exit();
  118. }
  119. }
  120. /*
  121. * filejungle download plugin by Ruud v.Tony 01/11/2011
  122. */
  123. ?>