Re: file_get_contents
| From: | Jochem Maas | Date: | Thu, 16 Nov 2006 16:10:23 +0000 |
| Subject: | Re: file_get_contents | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-244723@lists.php.net to get a copy of this message | ||
Tom Chubb wrote:
> Thanks Jochem,
> Tried that, but it's still showing php code in the text area!
> Any other ideas?
vanilla sky (go search for the tagline) ...
if I request the following I get a page with a player into:
http://www.tnhosting.co.uk/scripts/gclub/player.php
if you do the following you will get the same html source as my browser
does - if it doesn't then you are doing something wrong - quite simply
php is transparently making a http request to the webserver there is no
way the webserver will differentiate between your script and every other request
and give your the scrip the source code while everyone else is recieving
the result of running the script:
file_get_contents("http://www.tnhosting.co.uk/scripts/gclub/player.php");
below is the oneliner I used to prove this:
php -r 'echo file_get_contents("http://www.tnhosting.co.uk/scripts/gclub/player.php");'
OUTPUT: (oh look no php)
======================================
<html>
<head>
<title>Test Audio Player</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Expires" content="Mon, 26 Jul 1997 05:00:00 GMT"/>
<meta http-equiv="Pragma" content="no-cache" />
</head>
<body>
<!-- Start Player Code -->
<!-- Contact tom@tomchubb.co.uk if you have any problems -->
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"
width="400" height="15">
<param name="allowScriptAccess" value="sameDomain"/>
<param name="movie" value="http://www.tnhosting.co.uk/scripts/gclub/xspf_player_slim.swf?song_url=
http://www.tnhosting.co.uk/scripts/gclub/audio/faith.mp3&song_title=Another
Stomping Funker!&autoplay=true "/>
<param name="quality" value="high"/>
<param name="bgcolor" value="#E6E6E6"/>
<embed src="http://www.tnhosting.co.uk/scripts/gclub/xspf_player_slim.swf?song_url=
http://www.tnhosting.co.uk/scripts/gclub/audio/faith.mp3&song_title=Another
Stomping Funker!&autoplay=true "
width="400" height="15" align="center" quality="high"
bgcolor="#E6E6E6" allowscriptaccess="sameDomain"
type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">
</embed>
</object>
<!-- End Player Code -->
</body>
</html>
>
> The url is
> http://www.tnhosting.co.uk/scripts/gclub/updateplaylist.php
> and you see it on submission. Feel free to post. It's a testing
> server.
>
>
>
> On 16/11/06, Jochem Maas <jochem@iamjochem.com> wrote:
>> Tom Chubb wrote:
>> > I am trying to read the contents of a "PHP" page for an audio player
>> > and put it into a textarea to be copied and pasted into an "HTML"
>> > page.
>> > The trouble is the textarea shows unparsed PHP code and I just want the
>> > HTML.
>> > The code is:
>> >
>> > $player = file_get_contents('player.php');
>>
>> file_get_content('http://blabla.com/player.php');
>> // requires allow_url_fopen to be set to On.
>>
>> >
>> > //Strip out unnecessary HTML Code
>> > if(preg_match('/<!-- Start Player Code -->(.*)<!-- End Player Code
>> > -->/s', $player, $matches)) {
>> > $code = $matches[1];
>> > }
>> > echo "<textarea name=\"textarea\" cols=\"70\"
>> > rows=\"15\">" . $code .
>>
>> htmlentities($code)
>>
>> > "</textarea>";
>> > echo "<BR>";
>> > echo "<a href=\"player.php\">Click Here</a> to view the
>> > player \n";
>> >
>> > Looked at using eval() but found this:
>> >
>> > Kepp the following Quote in mind:
>> > If eval() is the answer, you're almost certainly asking the
>> > wrong question. -- Rasmus Lerdorf, BDFL of PHP
>>
>> indeed eval is probably not the answer.
>>
>> >
>> > (Hmmm...)
>> >
>> > Any help much appreciated.
>> >
>> > Tom
>> >
>>
>>
>
>