All pastes #406804 Raw Edit

Untitled

public text v1 · immutable
·published 2007-03-22 18:21 UTC
rendered paste body
<?php

//Clearing Cache 
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 

// always modified 
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); 

// HTTP/1.1 
header("Cache-Control: no-store, no-cache, must-revalidate"); 
header("Cache-Control: post-check=0, pre-check=0", false); 

// HTTP/1.0 
header("Pragma: no-cache"); 
//End of Clearing Cache

if($_GET["video"] == "") {
	echo "Possible file hack";
	exit;
}else
{
	$file = $_GET["video"]; // file to be send to the client
}

$speed = 128; // e.g., 8,5 kb/s download rate limit

if(file_exists($file) && is_file($file)) {
	
	//open file for reading
	$fd = fopen($file, "r");

	if($_GET["position"] == "" || $_GET["position"] == 0)
	{
		//if no position found set fileseek on 0 bytes.
		fseek($fd,0,SEEK_SET);
	}else
	{
		echo("FLV");
		echo(pack('C', 1 ));
		echo(pack('C', 1 ));
		echo(pack('N', 9 ));
		echo(pack('N', 9 ));
		fseek($fd,$_GET["position"],SEEK_SET);
	}
	
	while(!feof($fd)) 
	{
		//read the file from the current seekpoint (in bytes) with the selected speed.
		echo fread($fd, round(1024*$speed));
	}
	
	fclose ($fd);
}
?>