Guest
Public paste!

Untitled

By: a guest | Sep 14th, 2009 | Syntax: PHP | Size: 1.95 KB | Hits: 341 | Expires: Never
Copy text to clipboard
  1. <?
  2. // invoke like http://example.com/rscp.php?f=http://rapidshare.com/files/12345678/wtfwarez.rar
  3. // if enough kb left on premium account and the file exists, script will download file and pass thru.
  4. // if not, script will break and display error.
  5. $rsc_acc="1234567";
  6. $rsc_pass="pass";
  7. if(isset($_GET["f"]))
  8.         $file=$_GET["f"];
  9. else
  10.         die("no file given");
  11.  
  12. $r="@(http.?\:\/\/)?(.*)?rapidshare\.com\/files\/(.*)\/(.*)$@isU";
  13. if(preg_match($r,$file,$hit)) {
  14.         $fid=$hit[3];
  15.         $fn=$hit[4];
  16. } else
  17.         die("incorrect url");
  18. $pa_stats=file("http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=getaccountdetails_v1&type=prem&login=$rsc_acc&password=$rsc_pass&withcookie=1");
  19. foreach($pa_stats as $line) {
  20.         $pair=split("=",$line);
  21.         $pa[trim($pair[0])]=trim($pair[1]);
  22. }
  23. if( !($pa["premkbleft"]>0) || !(strlen($pa["cookie"])>0) )
  24.         die("can not access account data. report to author!");
  25. else {
  26.         $kbleft=$pa["premkbleft"];
  27.         $cookie=$pa["cookie"];
  28. }
  29. $fstats=file("http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=checkfiles_v1&files=$fid&filenames=$fn");
  30. $fstats=split(",",trim($fstats[0]));
  31. $fs=$fstats[2]/1024;    //convert to KB
  32. if($fs>$kbleft)
  33.         die("premium account is empty or has not enough KB left (available: $kbleft KB, filesize $fs KB). wait 24 hrs or contact account owner.");
  34. switch((int)trim($fstats[4])){
  35.         case 0:
  36.         case 4:
  37.         case 5:
  38.                 die("file not available (deleted or locked)");
  39.         case 1:
  40.         case 2:
  41.         case 6:
  42.                 $url="http://rs".$fstats[3].$fstats[5].".rapidshare.com/files/".$fstats[0]."/".$fstats[1]."";
  43.                 break;
  44.         case 3:
  45.                 die("rapidshare server down, retry later");
  46. }
  47. $user_agent = ini_get("user_agent");
  48. ini_set("user_agent",$user_agent . "\r\nCookie: enc=$cookie");
  49. $httphandle = fopen($url,"r");
  50.  
  51. header('Content-type: application/octet-stream');
  52. header('Content-Disposition: attachment; filename="'.$fn.'"');
  53. header('Content-Length: '.$fstats[2]);
  54. fpassthru($httphandle);
  55.  
  56. fclose($httphandle);
  57. ini_set("user_agent",$user_agent);
  58.  
  59.  
  60. ?>