Re: file_get_contents

From: Date: Fri, 17 Nov 2006 11:25:36 +0000
Subject: Re: file_get_contents
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-244799@lists.php.net to get a copy of this message
On 17/11/06, Jochem Maas <jochem@iamjochem.com> wrote:
Tom Chubb wrote: Confused! I'm now getting: file_get_contents(http://www.tnhosting.co.uk/scripts/gclub/player.php) [function.file-get-contents]: failed to open stream: Connection refused in /home/sites/tnhosting.co.uk/public_html/scripts/gclub/updateplaylist.php on line 75 How come you can access it and I can't?!? no php script can withstand me. ;-) seriously I don't know
I don't doubt it! ;-)
Permissions are 755. Obviously I was getting it when using file_get_contents('player.php') but when using the URL I get connection refused. (Don't think that it makes any difference, but allow_url_fopen is on) it makes a difference, and it sounds likes it's off - another possibility is that safe_mode is on (and that safe_mode blocks allow_url_fopen), but I don't know about that - you'll have to test it.
phpinfo() says that allow_url_fopen is on and safe mode is off
you can double check that you can reach your site from the box itself by doing a very simple 'wget' check from the commandline (assuming you have ssh access):
       wget http://www.tnhosting.co.uk/scripts/gclub/player.php
if that downloads a page then the problem is very like to be php.
Don't have shell access on my shared server
...
Did manage to get it working though using $player = file_get_contents('player.php'); //Strip out unnecessary HTML if(preg_match('/<!-- Start Player Code -->(.*)<!-- End Player Code -->/s', $player, $matches)) { $content = $matches[1]; } function phpWrapper($content) { ob_start(); $content = str_replace('<'.'?php','<'.'?',$content); eval('?'.'>'.trim($content).'<'.'?'); $content = ob_get_contents(); ob_end_clean(); return $content; } echo "<textarea name=\"textarea\" cols=\"70\" rows=\"15\">" . phpWrapper($content) . "</textarea>"; Bit messy, but it works at least. :D Thanks for your help though. T

« previous php.general (#244799) next »