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

/hosts/download/rapidshare_com.php

https://github.com/gartz/RapidLeetch
PHP | 234 lines | 212 code | 19 blank | 3 comment | 27 complexity | 74c4fd038bc4c6ba1336edd38f63e254 MD5 | raw file
  1. <?php
  2. if (! defined ( 'RAPIDLEECH' ))
  3. {
  4. require_once ("index.html");
  5. exit ();
  6. }
  7. class rapidshare_com extends DownloadClass
  8. {
  9. public function Download($link)
  10. {
  11. global $premium_acc;
  12. if (($_REQUEST ["premium_acc"] == "on" && $_REQUEST ["premium_user"] && $_REQUEST ["premium_pass"]) ||
  13. ($_REQUEST ["premium_acc"] == "on" && $premium_acc ["rapidshare_com"]))
  14. {
  15. $this->DownloadPremium($link);
  16. }
  17. else
  18. {
  19. $this->DownloadFree($link);
  20. }
  21. }
  22. private function DownloadFree($link)
  23. {
  24. global $nn, $PHP_SELF, $pauth;
  25. $page = $this->GetPage($link);
  26. is_present ( $page, "Due to a violation of our terms of use, the file has been removed from the server." );
  27. is_present ( $page, "This limit is reached", "This file is neither allocated to a Premium Account, or a Collector's Account, and can therefore only be downloaded 10 times. This limit is reached." );
  28. is_present ( $page, "This file is suspected to contain illegal content and has been blocked." );
  29. is_present ( $page, "The file could not be found.", "The file could not be found. Please check the download link." );
  30. is_present ( $page, "The uploader has removed this file from the server." );
  31. is_present ( $page, "This file has been removed from the server, because the file has not been accessed in a long time." );
  32. is_present ( $page, "is momentarily not available", "This server is momentarily not available. We are aware of this and are working to get this resolved." );
  33. is_present ( $page, "unavailable due to hardware-problems", "Server unavailable due to hardware-problems" );
  34. is_present ( $page, "is already downloading a file", "Your IP-address is already downloading a file, Please wait until the download is completed." );
  35. $post = array ();
  36. $post ["dl.start"] = "Free";
  37. $Href = trim ( cut_str ( $page, '<form action="', '"' ) );
  38. $Url = parse_url ( $Href );
  39. global $Referer;
  40. $Referer = $link;
  41. $page = $this->GetPage($Href,0,$post);
  42. is_present ( $page, "is not allowed to use the free-service anymore today", "No more free downloads from this IP today" );
  43. is_present ( $page, "This limit is reached", "This file is neither allocated to a Premium Account, or a Collector's Account, and can therefore only be downloaded 10 times. This limit is reached." );
  44. is_present ( $page, "This file exceeds your download-limit", "Download limit exceeded" );
  45. is_present ( $page, "is already downloading a file", "Your IP-address is already downloading a file, Please wait until the download is completed." );
  46. if (stristr ( $page, "This file can only be downloaded by becoming a" ))
  47. {
  48. html_error ( "This file can only be downloaded by becoming a Premium member", 0 );
  49. }
  50. if (stristr ( $page, "lot of users are downloading files" ))
  51. {
  52. $minutes = trim ( cut_str ( $page, "Please try again in ", " minutes" ) );
  53. html_error ( "Currently a lot of users are downloading files. Please try again in <font color=black><span id='waitTime'>$minutes</span></font> minutes or become a Premium member", 0 );
  54. }
  55. if (stristr ( $page, "try again in" ))
  56. {
  57. $minutes = trim ( cut_str ( $page, "Or try again in about ", " minutes." ) );
  58. if ($minutes)
  59. {
  60. echo('<script type="text/javascript">');
  61. echo('wait_time = '.(($minutes + 1) * 60000).';');
  62. echo('function waitLoop() {');
  63. echo('if (wait_time == 0) {');
  64. echo('location.reload();');
  65. echo('}');
  66. echo('wait_time = wait_time - 60000;');
  67. echo('document.getElementById("waitTime").innerHTML = wait_time / 60000;');
  68. echo('setTimeout("waitLoop()",60000);');
  69. echo('}');
  70. echo('</script>');
  71. html_error ( "Download limit exceeded. You have to wait <font color=black><span id='waitTime'>$minutes</span></font> minute(s) until the next download.<script>waitLoop();</script>", 0 );
  72. }
  73. else
  74. {
  75. html_error ( "Download limit exceeded.", 0 );
  76. }
  77. }
  78. if (stristr ( $page, "Too many users downloading right now" ) || stristr ( $page, "Too many connections" ))
  79. {
  80. html_error ( "Too many users downloading right now", 0 );
  81. }
  82. $countDown = trim ( cut_str ( $page, "var c=", ";" ) );
  83. $form_content = "";
  84. preg_match ( '%<form name="dlf?".*</form>%s', $page, $form_content );
  85. $form_content [0] = trim ( cut_str ( $form_content [0], '<form name="dlf"', '</form>' ) );
  86. $form_content [0] = '<form name="dlf" '.$form_content[0].'</form>';
  87. $middle_str = str_replace ( "\\", "", preg_replace ( '/(\' *\+.*?(\r\n)*.*?\'|display:none;)/s', '', $form_content [0] ) );
  88. $code = '<center>' . trim ( $middle_str );
  89. $FileAddr = trim ( cut_str ( $code, '<form name="dlf" action="', '"' ) );
  90. $Href = parse_url ( $FileAddr );
  91. $FileName = basename ( $Href ["path"] );
  92. if (! $FileAddr)
  93. {
  94. html_error ( "Error getting download link", 0 );
  95. }
  96. $code = str_replace ( $FileAddr, $PHP_SELF, $code );
  97. $code = preg_replace ( '/<input type=image.*?".*?>/', '<input type=submit value=Download onclick="return check()">', $code );
  98. $code = preg_replace ( '%<div><img.*Advanced download settings</div>%s', '', $code );
  99. $matches = "";
  100. preg_match_all ( "/http:\/\/rs(.*).rapidshare.com\/(.*)" . $FileName . "/iU", $code, $matches );
  101. if (! $matches)
  102. {
  103. html_error ( "Error getting available server's list", 0 );
  104. }
  105. for($i = 0; $i < count ( $matches [0] ); $i ++)
  106. {
  107. $Url = parse_url ( $matches [0] [$i] );
  108. $code = str_replace ( "document.dlf.action='" . $matches [0] [$i], "document.dlf.host.value='" . $Url ["host"], $code );
  109. }
  110. $code = str_replace('checked','',$code);
  111. $temp = explode('<br />',$code);
  112. global $RSHost;
  113. foreach ($temp as $k=>$temp2)
  114. {
  115. if (stristr($temp2,$RSHost))
  116. {
  117. $temp[$k] = str_replace('<input type="radio"','<input checked="checked" type="radio"',$temp2);
  118. }
  119. }
  120. $temp = implode('<br />',$temp);
  121. $code = $temp;
  122. $code = str_replace ( "</form>", $nn, $code );
  123. $code .= "<input type=\"hidden\" name=\"filename\" value=\"" . urlencode ( $FileName ) . "\">$nn<input type=\"hidden\" name=\"link\" value=\"" . urlencode ( $link ) . "\">$nn<input type=\"hidden\" name=\"referer\" value=\"" . urlencode ( $Referer ) . "\">$nn<input type=\"hidden\" name=\"saveto\" value=\"" . $_GET ["path"] . "\">$nn<input type=\"hidden\" name=\"host\" value=\"" . $Href ["host"] . "\">$nn<input type=\"hidden\" name=\"path\" value=\"" . urlencode ( $Href ["path"] ) . "\">$nn";
  124. $code .= ($_GET ["add_comment"] == "on" ? "<input type=\"hidden\" name=\"comment\" value=\"" . urlencode ( $_GET ["comment"] ) . "\">$nn" : "") . "<input type=\"hidden\" name=\"email\" value=\"" . ($_GET ["domail"] ? $_GET ["email"] : "") . "\">$nn<input type=\"hidden\" name=\"partSize\" value=\"" . ($_GET ["split"] ? $_GET ["partSize"] : "") . "\">$nn";
  125. $code .= "<input type=\"hidden\" name=\"method\" value=\"" . $_GET ["method"] . "\">$nn<input type=\"hidden\" name=\"proxy\" value=\"" . ($_GET ["useproxy"] ? $_GET ["proxy"] : "") . "\">$nn" . ($pauth ? "<input type=\"hidden\" name=\"pauth\" value=\"" . $pauth . "\">$nn" : "");
  126. $code .= "</form></center>";
  127. $js_code = "<script language=\"JavaScript\">" . $nn . "function check() {" . $nn . "var imagecode=document.dlf.accesscode.value;" . $nn . "var path=document.dlf.path.value;" . $nn;
  128. $js_code .= 'if (imagecode == "") { window.alert("You didn\'t enter the image verification code"); return false; }' . $nn . 'else {' . $nn . 'document.dlf.path.value=path+escape("?accesscode="+imagecode);' . $nn . 'return true; }' . $nn . '}' . $nn . '</script>' . $nn;
  129. $js_code .= "<script type=\"text/javascript\">setTimeout(\"document.dlf.submit()\", 5000);</script>";
  130. if (! $countDown)
  131. {
  132. print $code . $nn . $nn . $js_code . "$nn</body>$nn</html>";
  133. }
  134. else
  135. {
  136. insert_new_timer ( $countDown, rawurlencode ( $code ), "Download-Ticket reserved.", $js_code );
  137. }
  138. }
  139. private function DownloadPremium($link)
  140. {
  141. global $premium_acc;
  142. $page = $this->GetPage($link);
  143. is_present ( $page, "The file could not be found.", "The file could not be found. Please check the download link." );
  144. is_present ( $page, "This limit is reached", "This file is neither allocated to a Premium Account, or a Collector's Account, and can therefore only be downloaded 10 times. This limit is reached." );
  145. is_present ( $page, "Due to a violation of our terms of use, the file has been removed from the server." );
  146. is_present ( $page, "This file is suspected to contain illegal content and has been blocked." );
  147. is_present ( $page, "The uploader has removed this file from the server." );
  148. is_present ( $page, "This file has been removed from the server, because the file has not been accessed in a long time." );
  149. is_present ( $page, "is momentarily not available", "This server is momentarily not available. We are aware of this and are working to get this resolved." );
  150. is_present ( $page, "unavailable due to hardware-problems", "Server unavailable due to hardware-problems" );
  151. $FileName = basename ( trim ( cut_str ( $page, '<form action="', '"' ) ) );
  152. $Url = parse_url($link);
  153. ! $FileName ? $FileName = basename ( $Url ["path"] ) : "";
  154. if (isset ( $premium_acc ["rapidshare_com"] ['user'] ) || ($_REQUEST["premium_user"] && $_REQUEST['premium_pass']))
  155. {
  156. $auth = $_REQUEST ["premium_user"] ? base64_encode ( $_REQUEST ["premium_user"] . ":" . $_REQUEST ["premium_pass"] ) : base64_encode ( $premium_acc ["rapidshare_com"] ["user"] . ":" . $premium_acc ["rapidshare_com"] ["pass"] );
  157. $page = $this->GetPage($link,0,0,0,$auth);
  158. is_present ( $page, "password is incorrect" );
  159. is_present ( $page, "Account not found" );
  160. if (stristr ( $page, "Location:" ))
  161. {
  162. $Href = trim ( cut_str ( $page, "Location:", "\n" ) );
  163. $Url = parse_url ( $Href );
  164. $sendauth = ($_REQUEST ["premium_user"] && $_REQUEST ["premium_pass"]) ? encrypt($auth) : 1;
  165. $this->RedirectDownload($Href,$FileName, 0, 0, 0, 0, $sendauth);
  166. }
  167. else
  168. {
  169. html_error ( "Cannot use premium account", 0 );
  170. }
  171. }
  172. else
  173. {
  174. $totalpremium = count ( $premium_acc ["rapidshare_com"] );
  175. $success = 0;
  176. for($i = 0; $i < $totalpremium; $i++)
  177. {
  178. $acc = $premium_acc ["rapidshare_com"] [$i] ['user'];
  179. $pass = $premium_acc ["rapidshare_com"] [$i] ['pass'];
  180. $auth = base64_encode ( $acc . ":" . $pass );
  181. $page = $this->GetPage($link,0,0,0,$auth);
  182. if (stristr($page,"Account found, but password is incorrect")) continue;
  183. if (stristr($page,"Account not found")) continue;
  184. if (stristr($page,"You have exceeded the download limit.")) continue;
  185. if (stristr ( $page, "Location:" ))
  186. {
  187. $Href = trim ( cut_str ( $page, "Location:", "\n" ) );
  188. $Url = parse_url ( $Href );
  189. $success = 1;
  190. $this->RedirectDownload($Href,$FileName, 0, 0, 0, 0, encrypt($auth));
  191. break;
  192. }
  193. }
  194. if (! $success)
  195. {
  196. html_error ( "No usable premium account", 0 );
  197. }
  198. }
  199. }
  200. }
  201. // updated by rajmalhotra on 17 Dec 09 : added some error messages
  202. // Fixed by rajmalhotra on 28 Dec 09
  203. //updated 08-jun-2010 for standard auth system (szal)
  204. ?>