RE: file_get_contents

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use curl or fopen() to make a request to that PHP page, instead of reading
in the actual contents of the file.

Example:

<?php

$url = 'http://blabla.com/player.php';

$ch=curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); 
curl_setopt($ch, CURLOPT_TIMEOUT, 120); 
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0;
Windows NT 5.0)"); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$buffer = curl_exec($ch);
curl_close($ch); 
	
echo "<TEXTAREA ...>" . $buffer . "</TEXTAREA>";

?>

> -----Original Message-----
> From: Tom Chubb [mailto:tomchubb@xxxxxxxxx]
> Sent: Thursday, November 16, 2006 10:49 AM
> To: [php] PHP General List
> Subject: Re:  file_get_contents
> 
> Thanks Jochem,
> Tried that, but it's still showing php code in the text area!
> Any other ideas?
> 
> 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@xxxxxxxxxxxxx> 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
> > >
> >
> >
> 
> 
> --
> Tom Chubb
> tomchubb@xxxxxxxxx
> 07915 053312
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux