Page 1 of 1

Help me start multiple streams of a file.

Posted: Fri May 21, 2010 12:49 pm
by rigy73
I am trying to stream a file to a user from rapidshare but, when i do it only one stream opens up or lets say, i only know how to open one stream.
So when the file starts downloading it is not supported by download managers and has no resume functionality
here is the code :

Code: Select all


if (!isset($_POST['_user'])){
header("location: index.html");
/* TODO */
}else{
$url = $_POST['_user'];
if (preg_match('/^http:\/\/rapidshare.com\/files/',$url)){
	$cookie=$accounts[min_key($leftmb)];
	$url_parsed = parse_url($url);
	$host = $url_parsed['host'];
	$path = $url_parsed['path'];

	$out = "GET $path HTTP/1.0\r\nHost: $host\r\nCookie: user=$cookie\r\n\r\n";
	$fp = fsockopen($host, 80, $errno, $errstr, 30) or die("<script>alert('File not Found.')</script>");
	fwrite($fp, $out);

	while (!feof($fp)) {
		$page .= fgets($fp, 128);
	}
	fclose($fp);

	preg_match ('/Location: ([^ ]*)\r\n/',$page, $matches);
	$url = $matches[1];
	$url_parsed = parse_url($url);

	$host = $url_parsed['host'];
	$path = $url_parsed['path'];

	if ($url_parsed['query'] != '') $path .= "?".$url_parsed['query'];
	$out = "GET $path HTTP/1.1\r\nHost: $host\r\nCookie: user=$cookie\r\n\r\n";
	$fp = @fsockopen($host, 80, $errno, $errstr, 30) or die("<script>alert('File not found.')</script>");
	fwrite($fp, $out);

$ok = 0;
while (!feof($fp)) {
$line = fgets($fp, 8192);
if ($ok==1){
echo $line;
}else{
if (preg_match('/(HTTP\/1)|(Date:)|(Connection:)|(Content-Type:)|(Accept-Ranges:)|(Content-Disposition:)|(Content-Length:)/', $line)){
If (preg_match('/Content-Type: text\/html/', $line)){
die ("<script>alert('Over Bandwidth. We are sorry :(')</script>");
}
header ("$line\r\n");
}
if ($line=="\r\n") $ok=1;
}
}

fclose($fp);
//
}
}

?>


can anyone tell me how do i add multiple connections and resume to the file that is to be streamed

any help would be welcome.

Re: Help me start multiple streams of a file.

Posted: Sat May 22, 2010 8:14 am
by rigy73
Can anyone help me here.

Re: Help me start multiple streams of a file.

Posted: Sat May 22, 2010 10:54 pm
by Chalks
I'm fairly certain that rapidshare only allows one connection at a time from a user. It sounds like this might be part of your problem.
rigy73 wrote:can anyone tell me how do i add multiple connections and resume to the file that is to be streamed
I'm confused by this. Do you want multiple connections to rapidshare? Or do you want to allow multiple users to connect to one stream? Those are two very different questions.

As for resuming on a stream... by definition a stream is, well, streaming to the user. To resume for a user who walked off before it finished, you would have to make the stream stop for every user accessing it. It's like someone jumping out of his canoe, swimming to shore, and being surprised when his canoe frolics on down the river.