Jump to content

Plz help me: How do i use php script in a html page.


dinold02

Recommended Posts

Hi, I am new to php scripting.

 

I just learned about this "Generating One-Time URLs with PHP"

Please visit this link for more info http://www.onlamp.com/pub/a/php/2002...time_URLs.html

 

My question is that How Could I use this code that generates this special link to the file and use it into object player.

 

I think this may be confusing to many.

 

This is the code to embedded a MS Media Player.

 

Quote:

<embed id="wmplayer" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" src="PUT THE VIDEO LINK HERE" width="419" height="350" type="application/x-mplayer2" volume="0" showtracker="0" showpositioncontrols="0" showgotobar="0" showdisplay="0" showaudiocontrols="1" showcontrols="1" sendplaystatechangeevents="-1" sendmousemoveevents="0" sendmouseclickevents="0" sendkeyboardevents="0" senderrorevents="-1" sendwarningevents="-1" sendopenstatechangeevents="-1" enabletracker="-1" enablefullscreencontrols="1" enablepositioncontrols="-1" enablecontextmenu="0" enabled="-1" displaysize="4" displaymode="0" allowchangedisplaysize="-1" allowscan="-1" autosize="-1" autostart="1" allowfullscreen="true" bgcolor="#000000"><noembed></noembed>

And This PHP code generates Url that can be accessed one single time.

 

Quote:

<?

/*

* generate_url.php

*

* Script for generating URLs that can be accessed one single time.

*

*/

 

/* Generate a unique token: */

$token = md5(uniqid(rand(),1));

 

/* This file is used for storing tokens. One token per line. */

$file = "/tmp/urls.txt";

if( !($fd = fopen($file,"a")) )

die("Could not open $file!");

 

if( !(flock($fd,LOCK_EX)) )

die("Could not aquire exclusive lock on $file!");

 

if( !(fwrite($fd,$token."\n")) )

die("Could not write to $file!");

 

if( !(flock($fd,LOCK_UN)) )

die("Could not release lock on $file!");

 

if( !(fclose($fd)) )

die("Could not close file pointer for $file!");

 

/* Parse out the current working directory for this script. */

$cwd = substr($_SERVER['PHP_SELF'],0,strrpos($_SERVER['PHP_SELF'],"/"));

 

/* Report the one-time URL to the user: */

print "Use this URL to download the secret file:<br><br>\n";

print "<a href='http://".$_SERVER['HTTP_HOST'].

"$cwd/get_file.php?q=$token'>\n";

print "http://".$_SERVER['HTTP_HOST']."/get_file.php?q=$token</a>\n";

 

?>

What I am trying to do is that I want to use this code with the embedded Media Player. On the embedded media player where it asked for the source "src="PUT THE VIDEO LINK HERE" I want to use the "http://".$_SERVER['HTTP_HOST']."/get_file.php?q=$token" link that is being generated by the script to it.

 

So This will make it hard for people to leech my video. But how do i use both scripts together and make this happen.

 

So basically I want the embedded media player source to read this link "http://".$_SERVER['HTTP_HOST']."/get_file.php?q=$token" to play. How do i make it work out.

 

So on the media player it should open the generated link and play.

Link to comment
Share on other sites

  • 2 weeks later...

In order to parse PHP in an html file, you have to add a line inside the .htaccess file giving a directive to parse php inside .html files otherwise it will be ignored and output as plain text.

 

.htaccess

AddType application/x-httpd-php .html

 

I saw that same article and thought it would be a nice function to have, but could not get it to work for nothing. I gave up on it.

 

But as for how to use php inside .html file, the answer is above.

 

nate

Link to comment
Share on other sites

In order to parse PHP in an html file, you have to add a line inside the .htaccess file giving a directive to parse php inside .html files otherwise it will be ignored and output as plain text.

 

.htaccess

AddType application/x-httpd-php .html

 

I saw that same article and thought it would be a nice function to have, but could not get it to work for nothing. I gave up on it.

 

But as for how to use php inside .html file, the answer is above.

 

nate

 

Oh? I thought you cant use PHP in an HTML file but you can use HTML in a PHP file?

Link to comment
Share on other sites

Yes, you can use php in any kind of file if you give a directive to the server telling it to parse the file for PHP.

 

You could even create your own file type and have it parsed as php. It is just a matter of telling the server what type of files to parse for php. On my server, I created a new file type with a .j3a extension. I was able to parse PHP inside it by adding this line to my .htaccess file.

 

You can look at your webhosts faq to see what they require.

 

AddType x-mapp-php5 .j3a

 

Nate

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.