Click to See Complete Forum and Search --> : PHP Protect?


robindean
10-29-2007, 02:08 AM
I have some code which currently operates as follows ...

header('content-type: audio/mpeg');
header('cache-control: no-store, must-revalidate');
header('expires: sun, 06 oct 1974 21:00:00 gmt');

$file_source = $_GET['source'];
$file_bandwidth = $_GET['bandwidth'];
$file_location = 'audio/'.$file_source.'_'.$file_bandwidth.'.mp3';

header('content-length: '.filesize($file_location));

$file_pointer = fopen($file_location, 'rb');

while (!feof($file_pointer)) {
echo(fread($file_pointer, 16384));
}

fclose($file_pointer);

I really, really, really want for this code to only be usable by a specific page.

The page that loads it uses it's url as a variable which is then passed into flash to be played as an mp3 file.

Is there any way that I can redirect people who try to view this script via the address bar?

Is there any way to say "If the full address of the page that is loading me externally is == something.php ... all is well" ???

In all truth, this php script url is being loaded into a flash file. Is there a prospective method there?

bokeh
10-29-2007, 07:00 AM
The best ways would be start a session and track the user around your site or just set a cookie. Other people might recommend the referer variable but that is not so reliable. Alternatively handle this with Apache.

robindean
10-30-2007, 01:40 PM
Does an embedded .swf document pose as a different user-agent than the browser that it is being viewed through?

If so, is there a way to simply verify that the script is being requested by the flash user agent?

What I'm hoping to do is say "If (user agent that is requesting this script == flash) {do something} else {do nothing}"