Secure Token Plugin with PHP

On December 17, 2011, in Javascript, Learning, PHP, Tips, Web Application, Web Security, by Sandeep Verma


Hits: 1924  

You might read our old article on how-to-prevent-downloading-and-leeching-media-files

You can review below code to secure your media files to be downloaded other then media players ;)

Creating a Secure Token SWF for JW Player

Secure Token have time limit after that token expire to get media files.

var timestamp = +new Date();

flowplayer("player", "http://www.svnlabs.com/token/player/flowplayer-3.2.7.swf", {
plugins: {
    secure: {
        url: 'player/flowplayer.securestreaming-3.2.3.swf',

        timestamp: timestamp,

        token: '69964920064c0a7626e6c97997070fcd'
    }
},

clip: {
    autoPlay: false,
    autoBuffering: true,
    duration: 30,
    urlResolvers: 'secure',
    baseUrl: 'http://www.svnlabs.com/token/'
}
});
<?php
// Get the file from the server
function get_file(){
global$streamname;
header('Content-Description: File Transfer');
header('Content-type: video/mp4');
header("Content-length: ".filesize($streamname));
header("Expires: 0");
header("Content-Transfer-Encoding: binary");
$file=fopen($streamname,'r');
echostream_get_contents($file);
fclose($file);
exit;
}
// Return secret to flowplayer for use
function get_secret(){
$token='69964920064c0a7626e6c97997070fcd';
return$token;
}
?>


  • Nick

    Uh this is Flowplayer, not JW PLAYER.. you’re completely off.

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...