/    Sign up×
Community /Pin to ProfileBookmark

I have some code which currently operates as follows …

[CODE]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);[/CODE]

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?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@bokehOct 29.2007 — 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.
Copy linkTweet thisAlerts:
@robindeanauthorOct 30.2007 — 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}"
×

Success!

Help @robindean spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...