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

/hosts/download/bitshare_com.php

https://gitlab.com/dkiller1/rapidleech
PHP | 144 lines | 122 code | 18 blank | 4 comment | 36 complexity | 5685ef785e115bf9a600d6440006905c MD5 | raw file
  1. <?php
  2. if (!defined('RAPIDLEECH')) {
  3. require_once ("index.html");
  4. exit();
  5. }
  6. class bitshare_com extends DownloadClass {
  7. public function Download($link) {
  8. global $premium_acc;
  9. if (!$_REQUEST['step']) {
  10. $this->page = $this->GetPage($link, "language_selection=EN"); //keep page in english
  11. is_present($this->page, "Error - File not available");
  12. $this->cookie = GetCookies($this->page). "; language_selection=EN";
  13. }
  14. if ($_REQUEST ["premium_acc"] == "on" && (($_REQUEST ["premium_user"] && $_REQUEST ["premium_pass"]) || ($premium_acc ["bitshare_com"] ["user"] && $premium_acc ["bitshare_com"] ["pass"]))) {
  15. $this->DownloadPremium($link);
  16. } else {
  17. $this->DownloadFree($link);
  18. }
  19. }
  20. private function DownloadFree($link) {
  21. if ($_REQUEST['step'] == '1') {
  22. $Url = urldecode($_POST['link']);
  23. $this->cookie = urldecode($_POST['cookie']);
  24. $recap = $_POST['recap']; //to be called when we failed to enter captcha code
  25. $ajaxid = $_POST['ajaxid'];
  26. $post['request'] = 'validateCaptcha';
  27. $post['ajaxid'] = $ajaxid;
  28. $post['recaptcha_challenge_field'] = $_POST['challenge'];
  29. $post['recaptcha_response_field'] = $_POST['captcha'];
  30. $check = $this->GetPage($Url, $this->cookie, $post, $link , 0, 1);
  31. } else {
  32. is_present($this->page, "Your Traffic is used up for today. Upgrade to premium to continue!");
  33. if (preg_match('@<span id="blocktimecounter">(\d+) seconds<\/span>@', $this->page, $wait) && !strpos($this->page, "var blocktime = 0;")) {
  34. echo ("<center><font color='red'><b>You reached your hourly traffic limit.</b></font></center>");
  35. $this->JSCountdown($wait[1]);
  36. }
  37. if (!preg_match('@url: "([^"]+)",@', $this->page, $rd)) html_error("Error: Post Link [FREE] not found!");
  38. if (!preg_match('@var ajaxdl = "([^"]+)";@i', $this->page, $ajax)) html_error("Error: Ajax ID [FREE] not found!");
  39. $post['request'] = 'generateID';
  40. $post['ajaxid'] = $ajax[1];
  41. $check = $this->GetPage($rd[1], $this->cookie, $post, $link , 0, 1);
  42. if (!preg_match('@file:(\d+)\:[0-1]+@', $check, $wait)) html_error("Error: Timer not found!");
  43. $this->CountDown($wait[1]);
  44. if (!preg_match('@\/challenge\?k=([^"]+)"@', $this->page, $cap) && !stristr($this->page, "var captcha = 1;")) html_error("Error getting CAPTCHA Data!");
  45. $ch = cut_str($this->GetPage("http://www.google.com/recaptcha/api/challenge?k=$cap[1]"), "challenge : '", "'");
  46. $capt = $this->GetPage("http://www.google.com/recaptcha/api/image?c=" . $ch);
  47. $capt_img = substr($capt, strpos($capt, "\r\n\r\n") + 4);
  48. $imgfile = DOWNLOAD_DIR . "bitshare_captcha.jpg";
  49. if (file_exists($imgfile)) unlink($imgfile);
  50. if (empty($capt_img) || !write_file($imgfile, $capt_img)) html_error("Error getting CAPTCHA image.");
  51. $data = $this->DefaultParamArr($rd[1], $this->cookie);
  52. $data['step'] = '1';
  53. $data['challenge'] = $ch;
  54. $data['ajaxid'] = $ajax[1];
  55. $data['recap'] = $cap[1];
  56. $this->EnterCaptcha($imgfile, $data, 20);
  57. exit();
  58. }
  59. is_present($check, "We are sorry, but an error occured.");
  60. if (strpos($check, "SUCCESS") && !strpos($check, 'ERROR')) {
  61. unset($post);
  62. $post['request'] = 'getDownloadURL';
  63. $post['ajaxid'] = $ajaxid;
  64. $this->page = $this->GetPage($Url, $this->cookie, $post, $link, 0, 1);
  65. is_present($this->page, "ERROR#SESSION ERROR!");
  66. if (!preg_match('@(http(s)?:\/\/\w+\.bitshare\.com(:\d+)?\/[^\r\n]+)@i', $this->page, $dl)) html_error("Error: Download Link [FREE] not found!");
  67. $dlink = trim($dl[1]);
  68. $filename = basename(parse_url($dlink, PHP_URL_PATH));
  69. $this->RedirectDownload($dlink, $filename, $this->cookie, 0, $link);
  70. exit();
  71. } else {
  72. echo ("<center><font color='red'><b>". cut_str($check, 'ERROR:', '\r\n')."</b></font></center>");
  73. $this->changeMesg("<font color='red'><b>". cut_str($check, 'ERROR:', '\r\n')."</b></font>");
  74. $ch = cut_str($this->GetPage("http://www.google.com/recaptcha/api/challenge?k=$recap"), "challenge : '", "'");
  75. $capt = $this->GetPage("http://www.google.com/recaptcha/api/image?c=" . $ch);
  76. $capt_img = substr($capt, strpos($capt, "\r\n\r\n") + 4);
  77. $imgfile = DOWNLOAD_DIR . "bitshare_captcha.jpg";
  78. if (file_exists($imgfile)) unlink($imgfile);
  79. if (empty($capt_img) || !write_file($imgfile, $capt_img)) html_error("Error getting CAPTCHA image.");
  80. $data = $this->DefaultParamArr($Url, $this->cookie);
  81. $data['challenge'] = $ch;
  82. $data['step'] = '1';
  83. $data['ajaxid'] = $ajaxid;
  84. $data['recap'] = $recap;
  85. $this->EnterCaptcha($imgfile, $data, 20);
  86. exit();
  87. }
  88. }
  89. private function DownloadPremium($link) {
  90. global $premium_acc;
  91. $user = ($_REQUEST["premium_user"] ? trim($_REQUEST["premium_user"]) : $premium_acc ["bitshare_com"] ["user"]);
  92. $pass = ($_REQUEST["premium_pass"] ? trim($_REQUEST["premium_pass"]) : $premium_acc ["bitshare_com"] ["pass"]);
  93. if (empty($user) || empty($pass)) html_error("Login failed, $user [user] or $pass [password] is empty!");
  94. $Url = 'http://bitshare.com/';
  95. $post['user'] = $user;
  96. $post['password'] = $pass;
  97. $post['rememberlogin'] = '';
  98. $post['submit'] = 'Login';
  99. $check = $this->GetPage($Url."login.html", $this->cookie, $post, $Url);
  100. $this->cookie = $this->cookie. ";". GetCookies($check);
  101. is_notpresent($this->cookie, 'login=', "Wrong Username or Password!");
  102. is_present($check, "<a href=\"http://bitshare.com/myupgrade.html\">Free</a>", "Account type : FREE");
  103. $this->page = $this->GetPage($link, $this->cookie, 0, $link);
  104. if (!preg_match('@Location: (http(s)?:\/\/[^\r\n]+)@i', $this->page, $dl)) { // non direct link
  105. if (!preg_match('@url: "([^"]+)",@i', $this->page, $rd)) html_error("Error: Post Link [PREMIUM] not found!");
  106. if (!preg_match('@var ajaxdl = "([^"]+)";@i', $this->page, $ajax)) html_error("Error: Post Data [PREMIUM] not found!");
  107. unset($post);
  108. $post['request'] = 'generateID';
  109. $post['ajaxid'] = $ajax[1];
  110. $check = $this->GetPage($rd[1], $this->cookie, $post, $link, 0, 1);
  111. unset($post);
  112. $post['request'] = 'getDownloadURL';
  113. $post['ajaxid'] = $ajax[1];
  114. $this->page = $this->GetPage($rd[1], $this->cookie, $post, $link, 0, 1);
  115. if (!preg_match('@(http(s)?:\/\/\w+\.bitshare\.com(:\d+)?\/[^\r\n]+)@i', $this->page, $dl)) html_error("Error: Download Link [PREMIUM] not found!");
  116. }
  117. $dlink = trim($dl[1]);
  118. $filename = basename(parse_url($dlink, PHP_URL_PATH));
  119. $this->RedirectDownload($dlink, $filename, $this->cookie);
  120. }
  121. }
  122. /*
  123. * by vdhdevil Dec-11-2010
  124. * fixed by Ruud v.Tony 25-01-2012
  125. */
  126. ?>