Untitled
By: a guest | Nov 25th, 2009 | Syntax:
PHP | Size: 3.32 KB | Hits: 489 | Expires: Never
<?
// (c) marco "harddisk" schuster
// marco @ vmsoft-gbr.de
// rapidshare account data here
$rsc_acc="123456789";
$rsc_pass="blublub";
//sanity check
$file=$_GET["f"];
else
//is it a valid rs link?
$r="@(http.?\:\/\/)?(.*)?rapidshare\.com\/files\/(.*)\/(.*)$@isU";
$fid=$hit[3]; //file identifier
$fn=$hit[4]; //file name
} else
//check if the premium account has enough traffic for the file
$pa_stats=file("http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=getaccountdetails_v1&type=prem&login=$rsc_acc&password=$rsc_pass&withcookie=1");
foreach($pa_stats as $line) {
}
if( !($pa["premkbleft"]>0
) || !(strlen($pa["cookie"])>0
) )
die("can not access account data. report to author!");
else {
$kbleft=$pa["premkbleft"];
$cookie=$pa["cookie"];
}
//let's get some file data and check the file itself
$fstats=file("http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=checkfiles_v1&files=$fid&filenames=$fn");
$fs=$fstats[2]/1024; //convert to KB
if($fs>$kbleft)
die("premium account is empty or has not enough KB left (available: $kbleft KB, filesize $fs KB). wait 24 hrs or contact account owner.");
//check if the file is accessible
switch((int
)trim($fstats[4
])){
case 0:
case 4:
case 5:
header("HTTP/1.1 404 Not Found");
die("file not available (deleted or locked)");
break;
case 1:
case 2:
case 6:
$url="http://rs".$fstats[3].$fstats[5].".rapidshare.com/files/".$fstats[0]."/".$fstats[1]."";
break;
case 3:
header("HTTP/1.1 503 Service Unavailable");
die("rapidshare server down, retry later");
break;
}
$multipart=false;
//was a part of the file requested? (partial download)
$range=$_SERVER["HTTP_RANGE"];
if($range) {
//pass client Range header to rapidshare
$cookie.="\r\nRange: $range";
$multipart=true;
header("X-UR-RANGE-Range: $range");
}
//octet-stream + attachment => client always stores file
header('Content-type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.$fn.'"');
//always included so clients know this script supports resuming
header("Accept-Ranges: bytes");
//awful hack to pass rapidshare the premium cookie
$user_agent = ini_get("user_agent");
ini_set("user_agent",$user_agent . "\r\nCookie: enc=$cookie");
$httphandle = fopen($url,"r");
//let's check the return header of rapidshare for range / length indicators
//we'll just pass these to the client
foreach($headers["wrapper_data"] as $header) {
header("X-RS-RANGE-".$header);
$multipart=true; //content-range indicates partial download
}
}
//now show the client he has a partial download
if($multipart)
header('HTTP/1.1 206 Partial Content');
fpassthru($httphandle); //simply proxy the file content
fclose($httphandle); //free up resources
ini_set("user_agent",$user_agent); //restore old user agent to revert the hack
?>