开发者

Secretly adding (extra) HTTP GET Variables to a swf file through PHP

开发者 https://www.devze.com 2023-02-10 00:18 出处:网络
I\'m trying to build a workaround for embedding my (downloaded) flash videoplayer. (it\'s the JWplayer...)

I'm trying to build a workaround for embedding my (downloaded) flash videoplayer. (it's the JWplayer...)

At the moment, when somebody wants to embed the videoplayer they have to include the swf with all the added flashvars (ex: www.site.be/core/swf/player.swf?streamer=url&file=file.mp4&image=file.jpg&plugin=analytics...). That's messy, and it feels a bit risky... people who know what they are doing can also just remove the plugin and other added data, resolving in me not being able to track pageviews etc.

My workaround is like this:

$data = file_get_contents('URL');
header("content-type: application/x-shockwave-flash");
echo $data;

Turns out that, when I use file_get_contents on a regular test file, info.php, that responds through a $_GET['var'], the above stated code works, but when I use it on the flashplayer, it doesn't...

As in: the flash file does not seem to be accepting (or responding to) the added header variables...

Can somebody tell me why this is? Is this a 'flash'开发者_开发百科 related problem or a 'Php' related problem? Or are there suggestions on how to handle my "flash-embed-with-to-much-junk"-problem in a different way?

(thanks)


The flash is expecting GET parameters so you can't force them any other way.

What I would do is store the GET variables in a SESSION (called swf_vars in my example) if you want it a secret, then have the <embed> code point to a PHP script that does something like..

<?php
session_start();

// Full URL path to SWF
$url = "http://www.site.be/core/swf/player.swf?";

// These are the GET variables you want
foreach ($_SESSION['swf_vars'] as $key => $value) {
    $url .= $key . "=" . urlencode($value) . "&";
}

$url = rtrim("&", $url);

// Fetch the SWF
header("Content-Type: application/x-shockwave-flash");
echo file_get_contents($url);
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消