Re: [PHP] file_get_contents() failing on CentOS.

2010-10-05 Thread Adam Richardson
On Tue, Oct 5, 2010 at 6:56 AM, Richard Quadling wrote:

> The issue _WAS_ the firewall.
>
> All sorted.
>
> Thank you.
>
>
Glad he got it working.

Adam

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com


Re: [PHP] file_get_contents() failing on CentOS.

2010-10-05 Thread Richard Quadling
The issue _WAS_ the firewall.

All sorted.

Thank you.

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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



Re: [PHP] file_get_contents() failing on CentOS.

2010-10-04 Thread Richard Quadling
On 4 October 2010 10:48, kranthi  wrote:
> http_proxy or HTTP_PROXY i m not sure
>

Thanks. Passing it on (and learning a bit).

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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



Re: [PHP] file_get_contents() failing on CentOS.

2010-10-04 Thread kranthi
and if proxxy is the issue http://proxychains.sf.net/ will help

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



Re: [PHP] file_get_contents() failing on CentOS.

2010-10-04 Thread Richard Quadling
On 4 October 2010 11:24, Richard Quadling  wrote:
> On 4 October 2010 10:48, kranthi  wrote:
>> http_proxy or HTTP_PROXY i m not sure
>>
>
> Thanks. Passing it on (and learning a bit).

http://docs.php.net/manual/en/function.stream-context-get-default.php#72086

Could help to some degree. Not sure if SOAPClient will go through the
context, though there is a 'stream_context' parameter that can be set
...

All passed on.
-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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



Re: [PHP] file_get_contents() failing on CentOS.

2010-10-04 Thread kranthi
http_proxy or HTTP_PROXY i m not sure

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



Re: [PHP] file_get_contents() failing on CentOS.

2010-10-04 Thread Richard Quadling
On 1 October 2010 16:19, kranthi  wrote:
> probably not the issue, but is the php engine behind a proxy server ?
> wget uses the environment variable, but PHP does not
>
> Kranthi.
> http://goo.gl/e6t3
>

Hopefully getting a reply today on this.

What env_var is used by wget?

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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



Re: [PHP] file_get_contents() failing on CentOS.

2010-10-01 Thread kranthi
probably not the issue, but is the php engine behind a proxy server ?
wget uses the environment variable, but PHP does not

Kranthi.
http://goo.gl/e6t3

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



Re: [PHP] file_get_contents() failing on CentOS.

2010-09-30 Thread Richard Quadling
On 30 September 2010 20:27, Adam Richardson  wrote:
> On Thu, Sep 30, 2010 at 5:02 AM, Richard Quadling 
> wrote:
>>
>> Hi.
>>
>> I'm trying to help a friend with a CentOS setup.
>>
>> He's installed PHP and SOAP using yum install php-soap and he is
>> having problems.
>>
>> I assisted in the developed the php script he is using and it is
>> working fine on Windows.
>>
>> In testing, we can do ...
>>
>> # wget http://www.php.net
>>
>> but not ...
>>
>> # php -r "echo file_get_contents('http://www.php.net');"
>> PHP Warning:  file_get_contents(http://www.php.net): failed to open
>> stream: HTTP request failed!  in Command line code on line 1
>>
>>
>> I've checked allow_url_fopen and that is set to 1
>>
>> As a test ...
>>
>> # php -d allow_url_fopen=1 -r "echo
>> file_get_contents('http://www.php.net');"
>> PHP Warning:  file_get_contents(http://www.php.net): failed to open
>> stream: HTTP request failed!  in Command line code on line 1
>> (This works fine on windows system)
>>
>> # php -d allow_url_fopen=0 -r "echo
>> file_get_contents('http://www.php.net');"
>> PHP Warning:  file_get_contents(): URL file-access is disabled in the
>> server configuration in Command line code on line 1
>> PHP Warning:  file_get_contents(http://www.php.net): failed to open
>> stream: no suitable wrapper could be found in Command line code on
>> line 1
>>
>> Neither will actually return the contents.
>>
>> Considering wget works and PHP doesn't _AND_ that this is linux, I'm lost.
>>
>> Wireshark shoes no communication at all when PHP is used to try and
>> get to www.php.net, but it does show everything accurately when using
>> wget.
>>
>> I've got the output of php -i and of the debug data from wget.
>>
>> So. Any pointers, suggestions, things to read/try/etc.
>>
>> Regards,
>>
>> Richard.
>>
>> --
>> Richard Quadling
>> Twitter : EE : Zend
>> @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
> Some firewalls used to take exception to file_get_contents() requests whilst
> still allowing some http requests, and if I recall correctly, CentOS uses a
> pretty old version of PHP, so perhaps it's worth checking out:
> bugs[dot]php[dot]net/bug[dot]php?id=40197
> A shot in the dark.
> Adam
> P.S. - The link kept getting my reply marked as spam.  That pesky little
> php.net ;)
>
> --
> Nephtali:  PHP web framework that functions beautifully
> http://nephtaliproject.com
>

Thanks for that. I've passed the details on.

OOI, wget uses HTTP/1.1 ...

---request begin---
GET / HTTP/1.0
User-Agent: Wget/1.11.4 Red Hat modified
Accept: */*
Host: www.php.net
Connection: Keep-Alive


The bug report certainly matches the behaviour.

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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



RE: [PHP] file_get_contents limit

2010-06-29 Thread Daevid Vincent
> -Original Message-
> From: Andrew Ballard [mailto:aball...@gmail.com] 
> Sent: Tuesday, June 29, 2010 1:56 PM
> To: a...@ashleysheridan.co.uk
> Cc: Jo?o C?ndido de Souza Neto; php-general@lists.php.net
> Subject: Re: [PHP] file_get_contents limit
> 
> On Tue, Jun 29, 2010 at 4:39 PM, Ashley Sheridan
>  wrote:
> >
> > On Tue, 2010-06-29 at 16:37 -0400, Andrew Ballard wrote:
> >
> > > On Tue, Jun 29, 2010 at 4:21 PM, Ashley Sheridan
> > >  wrote:
> > > >
> > > > Have you looked at the memory settings in php.ini?
> > > >
> > >
> > > I doubt that is the cause, at least not by itself. 21504 
> characters is
> > > only 21K of data (could be more if the characters are multi-byte
> > > encoded, but still less than 100K) , and the default 
> memory limit in
> > > PHP is 128M. I'm not sure what else it could be, though, 
> as I don't
> > > see any limitations on file_get_contents() discussed in 
> the manual.
> >
> > Default memory limit is still 32MB on every default install 
> I've seen.
> >
> 
> The manual currently shows 128M, and that's what I've seen for some
> time now. Even so, a function returning less than 100K shouldn't
> exhaust 32M of memory either, unless something else is at play. If
> there is a memory limit being reached, PHP should log either an error
> or warning (I can't remember which).

Maybe try to specify the number of $maxlen bytes to read?

http://us4.php.net/file_get_contents

string file_get_contents  (  string $filename  [,  bool $use_include_path =
false  [,  resource $context  [,  int $offset = -1  [,  int $maxlen = -1
 )

You could also do it the faster and "old fashioned" way:

$fh = fopen('/tmp/test.zip', 'r');
$data = fread($fh, filesize('/tmp/test.zip'));
fclose($fh); 

Or if it's multibyte maybe try this:

function file_get_contents_utf8($fn) {
 $content = file_get_contents($fn);
  return mb_convert_encoding($content, 'UTF-8',
  mb_detect_encoding($content, 'UTF-8, ISO-8859-1', true));
} 



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



Re: [PHP] file_get_contents limit

2010-06-29 Thread Andrew Ballard
On Tue, Jun 29, 2010 at 4:39 PM, Ashley Sheridan
 wrote:
>
> On Tue, 2010-06-29 at 16:37 -0400, Andrew Ballard wrote:
>
> > On Tue, Jun 29, 2010 at 4:21 PM, Ashley Sheridan
> >  wrote:
> > >
> > > Have you looked at the memory settings in php.ini?
> > >
> >
> > I doubt that is the cause, at least not by itself. 21504 characters is
> > only 21K of data (could be more if the characters are multi-byte
> > encoded, but still less than 100K) , and the default memory limit in
> > PHP is 128M. I'm not sure what else it could be, though, as I don't
> > see any limitations on file_get_contents() discussed in the manual.
>
> Default memory limit is still 32MB on every default install I've seen.
>

The manual currently shows 128M, and that's what I've seen for some
time now. Even so, a function returning less than 100K shouldn't
exhaust 32M of memory either, unless something else is at play. If
there is a memory limit being reached, PHP should log either an error
or warning (I can't remember which).

Andrew

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



Re: [PHP] file_get_contents limit

2010-06-29 Thread Ashley Sheridan
On Tue, 2010-06-29 at 16:37 -0400, Andrew Ballard wrote:

> On Tue, Jun 29, 2010 at 4:21 PM, Ashley Sheridan
>  wrote:
> > On Tue, 2010-06-29 at 17:02 -0300, Jo?o C?ndido de Souza Neto wrote:
> >
> >> The characters are stripped off of the end of the file after that point.
> >>
> >> --
> >> Joo Cndido de Souza Neto
> >>
> >> "Ashley Sheridan"  escreveu na mensagem
> >> news:1277841481.2253.39.ca...@localhost...
> >> > On Tue, 2010-06-29 at 16:53 -0300, Jo?o C?ndido de Souza Neto wrote:
> >> >
> >> >> Ive got a file with only one line 21917 characters long but when I read
> >> >> this file using $varData = file_get_contents("file.txt") it gets only
> >> >> 21504
> >> >> characters.
> >> >>
> >> >> Anyone would know why does it happen?
> >> >>
> >> >> Thanks in advance.
> >> >>
> >> >> --
> >> >> Joo Cndido de Souza Neto
> >> >>
> >> >>
> >> >>
> >> >
> >> >
> >> > Are the characters stripped off of the end of the file after that point,
> >> > or is the encoding not correctly determined and some characters are
> >> > converted the wrong ones?
> >> >
> >> > Thanks,
> >> > Ash
> >> > http://www.ashleysheridan.co.uk
> >> >
> >> >
> >> >
> >>
> >>
> >>
> >
> > Have you looked at the memory settings in php.ini?
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> >
> 
> I doubt that is the cause, at least not by itself. 21504 characters is
> only 21K of data (could be more if the characters are multi-byte
> encoded, but still less than 100K) , and the default memory limit in
> PHP is 128M. I'm not sure what else it could be, though, as I don't
> see any limitations on file_get_contents() discussed in the manual.
> 
> Andrew


Default memory limit is still 32MB on every default install I've seen.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] file_get_contents limit

2010-06-29 Thread Andrew Ballard
On Tue, Jun 29, 2010 at 4:21 PM, Ashley Sheridan
 wrote:
> On Tue, 2010-06-29 at 17:02 -0300, Jo?o C?ndido de Souza Neto wrote:
>
>> The characters are stripped off of the end of the file after that point.
>>
>> --
>> Joo Cndido de Souza Neto
>>
>> "Ashley Sheridan"  escreveu na mensagem
>> news:1277841481.2253.39.ca...@localhost...
>> > On Tue, 2010-06-29 at 16:53 -0300, Jo?o C?ndido de Souza Neto wrote:
>> >
>> >> Ive got a file with only one line 21917 characters long but when I read
>> >> this file using $varData = file_get_contents("file.txt") it gets only
>> >> 21504
>> >> characters.
>> >>
>> >> Anyone would know why does it happen?
>> >>
>> >> Thanks in advance.
>> >>
>> >> --
>> >> Joo Cndido de Souza Neto
>> >>
>> >>
>> >>
>> >
>> >
>> > Are the characters stripped off of the end of the file after that point,
>> > or is the encoding not correctly determined and some characters are
>> > converted the wrong ones?
>> >
>> > Thanks,
>> > Ash
>> > http://www.ashleysheridan.co.uk
>> >
>> >
>> >
>>
>>
>>
>
> Have you looked at the memory settings in php.ini?
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>

I doubt that is the cause, at least not by itself. 21504 characters is
only 21K of data (could be more if the characters are multi-byte
encoded, but still less than 100K) , and the default memory limit in
PHP is 128M. I'm not sure what else it could be, though, as I don't
see any limitations on file_get_contents() discussed in the manual.

Andrew

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



Re: [PHP] file_get_contents limit

2010-06-29 Thread Ashley Sheridan
On Tue, 2010-06-29 at 17:02 -0300, Jo?o C?ndido de Souza Neto wrote:

> The characters are stripped off of the end of the file after that point.
> 
> -- 
> Joo Cndido de Souza Neto
> 
> "Ashley Sheridan"  escreveu na mensagem 
> news:1277841481.2253.39.ca...@localhost...
> > On Tue, 2010-06-29 at 16:53 -0300, Jo?o C?ndido de Souza Neto wrote:
> >
> >> Ive got a file with only one line 21917 characters long but when I read
> >> this file using $varData = file_get_contents("file.txt") it gets only 
> >> 21504
> >> characters.
> >>
> >> Anyone would know why does it happen?
> >>
> >> Thanks in advance.
> >>
> >> -- 
> >> Joo Cndido de Souza Neto
> >>
> >>
> >>
> >
> >
> > Are the characters stripped off of the end of the file after that point,
> > or is the encoding not correctly determined and some characters are
> > converted the wrong ones?
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> > 
> 
> 
> 

Have you looked at the memory settings in php.ini?

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] file_get_contents limit

2010-06-29 Thread Jo�o C�ndido de Souza Neto
The characters are stripped off of the end of the file after that point.

-- 
João Cândido de Souza Neto

"Ashley Sheridan"  escreveu na mensagem 
news:1277841481.2253.39.ca...@localhost...
> On Tue, 2010-06-29 at 16:53 -0300, Jo?o C?ndido de Souza Neto wrote:
>
>> Ive got a file with only one line 21917 characters long but when I read
>> this file using $varData = file_get_contents("file.txt") it gets only 
>> 21504
>> characters.
>>
>> Anyone would know why does it happen?
>>
>> Thanks in advance.
>>
>> -- 
>> Joo Cndido de Souza Neto
>>
>>
>>
>
>
> Are the characters stripped off of the end of the file after that point,
> or is the encoding not correctly determined and some characters are
> converted the wrong ones?
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
> 



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



Re: [PHP] file_get_contents limit

2010-06-29 Thread Ashley Sheridan
On Tue, 2010-06-29 at 16:53 -0300, Jo?o C?ndido de Souza Neto wrote:

> Ive got a file with only one line 21917 characters long but when I read 
> this file using $varData = file_get_contents("file.txt") it gets only 21504 
> characters.
> 
> Anyone would know why does it happen?
> 
> Thanks in advance.
> 
> -- 
> Joo Cndido de Souza Neto
> 
> 
> 


Are the characters stripped off of the end of the file after that point,
or is the encoding not correctly determined and some characters are
converted the wrong ones?

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-16 Thread Richard Quadling
2009/12/16 René Fournier :
> On 2009-12-15, at 11:55 PM, Richard Quadling wrote:
>
> Do you have a default stream context defined for the http stream?
>
> Nope.
>
> A _LONG_ time ago, when I was using a firewall with NTLM
> authentication (which PHP doesn't deal with), I had to route all my
> calls through a local proxy.
>
> This was the code I had ...
>
>  // Define the default, system-wide context.
> $r_default_context = stream_context_get_default(
> array(
> 'http' => array( // All HTTP requests are passed through the local
> NTLM proxy server on port 8080.
> 'proxy' => 'tcp://127.0.0.1:8080',
> 'request_fulluri' => True,
> ),
> )
> );
>
> // Though we said system wide, some extensions need a little coaxing.
> libxml_set_streams_context($r_default_context);
>
>
> Now, you may not see this in your code, but may be in a script which
> is loaded via auto_prepend_file.
>
> Wish it were, but my test code is bare bones.
>
> I would also suggest running something like WireShark at the same time
> as your script. See if there is ANY traffic over the wire.
>
> Do the cURL and file_get_contents() code generate identical requests?
>
> cURL -- both PHP and command-line -- fetches files and URLs (remote and
> local) w/o issues. file_get_contents() fetches files, but fails on all URLs
> (remote and local). This is why I believe the problem lies with the
> machine's configuration and not the Firewall.
> It's pretty confounding, isn't it? I'm not sure what to do at this point.
> ...Rene
>
>

But by using something like WireShark you can see exactly what
requests ARE being made. You may be getting a redirect reply which is
failing or something daft. Anything really.



-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-15 Thread René Fournier
On 2009-12-15, at 11:55 PM, Richard Quadling wrote:

> Do you have a default stream context defined for the http stream?

Nope.

> 
> A _LONG_ time ago, when I was using a firewall with NTLM
> authentication (which PHP doesn't deal with), I had to route all my
> calls through a local proxy.
> 
> This was the code I had ...
> 
>  // Define the default, system-wide context.
> $r_default_context = stream_context_get_default(
>   array(
>   'http' => array( // All HTTP requests are passed through the 
> local
> NTLM proxy server on port 8080.
>   'proxy' => 'tcp://127.0.0.1:8080',
>   'request_fulluri' => True,
>   ),
>   )
> );
> 
> // Though we said system wide, some extensions need a little coaxing.
> libxml_set_streams_context($r_default_context);
> 
> 
> Now, you may not see this in your code, but may be in a script which
> is loaded via auto_prepend_file.

Wish it were, but my test code is bare bones.

> 
> I would also suggest running something like WireShark at the same time
> as your script. See if there is ANY traffic over the wire.
> 
> Do the cURL and file_get_contents() code generate identical requests?

cURL -- both PHP and command-line -- fetches files and URLs (remote and local) 
w/o issues. file_get_contents() fetches files, but fails on all URLs (remote 
and local). This is why I believe the problem lies with the machine's 
configuration and not the Firewall.

It's pretty confounding, isn't it? I'm not sure what to do at this point.

...Rene




Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-15 Thread René Fournier
On 2009-12-15, at 11:55 PM, Richard Quadling wrote:

> Do you have a default stream context defined for the http stream?

Nope.

> 
> A _LONG_ time ago, when I was using a firewall with NTLM
> authentication (which PHP doesn't deal with), I had to route all my
> calls through a local proxy.
> 
> This was the code I had ...
> 
>  // Define the default, system-wide context.
> $r_default_context = stream_context_get_default(
>   array(
>   'http' => array( // All HTTP requests are passed through the 
> local
> NTLM proxy server on port 8080.
>   'proxy' => 'tcp://127.0.0.1:8080',
>   'request_fulluri' => True,
>   ),
>   )
> );
> 
> // Though we said system wide, some extensions need a little coaxing.
> libxml_set_streams_context($r_default_context);
> 
> 
> Now, you may not see this in your code, but may be in a script which
> is loaded via auto_prepend_file.

Wish it were, but my test code is bare bones.

> 
> I would also suggest running something like WireShark at the same time
> as your script. See if there is ANY traffic over the wire.
> 
> Do the cURL and file_get_contents() code generate identical requests?

cURL -- both PHP and command-line -- fetches files and URLs (remote and local) 
w/o issues. file_get_contents() fetches files, but fails on all URLs (remote 
and local). This is why I believe the problem lies with the machine's 
configuration and not the Firewall.

It's pretty confounding, isn't it? I'm not sure what to do at this point.

...Rene




Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-15 Thread Richard Quadling
2009/12/14 Ashley Sheridan 
>
> On Mon, 2009-12-14 at 17:03 +0200, Cafer Şimşek wrote:
>
> René Fournier  writes:
>
> > On 2009-12-14, at 10:44 PM, Cafer Şimşek wrote:
> >
> >> René Fournier  writes:
> >>
> >>> 4.as per php.ini, allow_url_fopen On
> >>
> >> Look at from phpinfo() the settings is already "On".
> >
> > Yes, I know.
> >
> > Which is why it's odd that the function fails on URLs.
>
> try to get url content from any browser or (if you use Linux / Unix)
> curl.
>
> --
> Cafer Şimşek
> DEV Staff Leader
> http://pazar.com/
>
>
> He already said Curl works, and changing the browser won't affect what PHP is 
> doing.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>

Do you have a default stream context defined for the http stream?

A _LONG_ time ago, when I was using a firewall with NTLM
authentication (which PHP doesn't deal with), I had to route all my
calls through a local proxy.

This was the code I had ...

 array( // All HTTP requests are passed through the 
local
NTLM proxy server on port 8080.
'proxy' => 'tcp://127.0.0.1:8080',
'request_fulluri' => True,
),
)
);

// Though we said system wide, some extensions need a little coaxing.
libxml_set_streams_context($r_default_context);


Now, you may not see this in your code, but may be in a script which
is loaded via auto_prepend_file.

I would also suggest running something like WireShark at the same time
as your script. See if there is ANY traffic over the wire.

Do the cURL and file_get_contents() code generate identical requests?


--
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-14 Thread Ashley Sheridan
On Mon, 2009-12-14 at 17:03 +0200, Cafer Şimşek wrote:

> René Fournier  writes:
> 
> > On 2009-12-14, at 10:44 PM, Cafer Şimşek wrote:
> >
> >> René Fournier  writes:
> >> 
> >>> 4.as per php.ini, allow_url_fopen On
> >> 
> >> Look at from phpinfo() the settings is already "On".
> >
> > Yes, I know.
> >
> > Which is why it's odd that the function fails on URLs.
> 
> try to get url content from any browser or (if you use Linux / Unix)
> curl.
> 
> -- 
> Cafer Şimşek
> DEV Staff Leader
> http://pazar.com/
> 


He already said Curl works, and changing the browser won't affect what
PHP is doing.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-14 Thread Cafer Şimşek
René Fournier  writes:

> On 2009-12-14, at 10:44 PM, Cafer Şimşek wrote:
>
>> René Fournier  writes:
>> 
>>> 4.  as per php.ini, allow_url_fopen On
>> 
>> Look at from phpinfo() the settings is already "On".
>
> Yes, I know.
>
> Which is why it's odd that the function fails on URLs.

try to get url content from any browser or (if you use Linux / Unix)
curl.

-- 
Cafer Şimşek
DEV Staff Leader
http://pazar.com/

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



Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-14 Thread René Fournier

On 2009-12-14, at 10:44 PM, Cafer Şimşek wrote:

> René Fournier  writes:
> 
>> 4.   as per php.ini, allow_url_fopen On
> 
> Look at from phpinfo() the settings is already "On".

Yes, I know.

Which is why it's odd that the function fails on URLs.


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



Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-14 Thread Cafer Şimşek
René Fournier  writes:

> 4.as per php.ini, allow_url_fopen On

Look at from phpinfo() the settings is already "On".

Best Regards.

-- 
Cafer Şimşek
DEV Staff Leader
http://pazar.com/

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



Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-14 Thread René Fournier
Well thanks for trying. For anyone reading this, who wants to be a hero and 
solve the impossible:

1.  file_get_contents ($url) doesn't work -- (on remote URLs or local URLs)
2.  file_get_contents ($file) works.
3.  CURL works (on remote and local URLs).
4.  as per php.ini, allow_url_fopen On

Xserve
- OS X Server 10.6.2
- PHP 5.3 (default)


So... it's as if PHP is not respecting the allow_url_fopen direction in 
php.ini. If that directive were set to Off, everything would make sense (files 
load, urls don't (local or remote)).

Anyone have anything to add? Anyone, anyone?

Bueller?


On 2009-12-14, at 10:05 PM, Gaurav Kumar wrote:

> Sorry buddy, I cant think of anything else which is going on wrong.
> 
> 
> 2009/12/14 René Fournier 
> 
> PHP Version   5.3.0
> 
> Directive Local Value Master Value
> allow_call_time_pass_referenceOff Off
> allow_url_fopen   On
> 
> 
> On 2009-12-14, at 12:26 AM, Gaurav Kumar wrote:
> 
>> What is the value for "allow_url_fopen" in your php.ini? It should be 1.
>> 
>> 
>> 
>> 
>> 
>> 2009/12/13 René Fournier 
>> CURL works (remote and local)
>> file_get_contents() doesn't work (remote or local).
>> 
>> 
>> 
>> On 2009-12-13, at 4:39 PM, Gaurav Kumar wrote:
>> 
>>> Ok Agreed. 
>>> 
>>> Lets do one last chance to ensure that your system is allowing external 
>>> connections or connection to other systems in the network-
>>> 
>>> Use Curl to get in the file contents. Check your PHP that Curl is enabled. 
>>> Through phpinfo();
>>> 
>>> If the script output the google page then this means that there is nothing 
>>> that is stopping you form getting in the content externally.
>>> 
>>> >> // $str =  file_get_contents ('http://www.google.com');
>>> // echo $str;
>>> 
>>> 
>>> // create a new cURL resource
>>> $ch = curl_init();
>>> 
>>> // set URL and other appropriate options
>>> curl_setopt($ch, CURLOPT_URL, "http://www.google.co.in";); 
>>> //http://www.google.com
>>> curl_setopt($ch, CURLOPT_HEADER, 0);
>>> 
>>> // grab URL and pass it to the browser
>>> curl_exec($ch);
>>> 
>>> // close cURL resource, and free up system resources
>>> curl_close($ch);
>>> 
>>> ?>
>>> 
>>> Thanks,
>>> 
>>> Gaurav Kumar
>>> 
>>> 
>>> 
>>> 2009/12/13 René Fournier 
>>> The thing is, the file_get_contents() fails the same way on local URLs -- 
>>> that is, web sites hosted on the same machine. Or even using the machine's 
>>> own IP address.
>>> 
>>> On 2009-12-13, at 4:00 AM, Gaurav Kumar wrote:
>>> 
 Hi Rene,
 
 The only thing which is a hurdle is that your system/computer is not 
 allowing external connections. There seems to be nothing else wrong.
 
 I strongly suggest check your system firewall, any central server settings 
 through which your system gets internet access, any antivirus s/w 
 installed etc.. this can be the only reason. Something is stopping you to 
 access external connection.
 
 Let me know when your problem is fixed.
 Also I tried the below code and it works fine-
 
 >>> $str =  file_get_contents ('http://www.google.com');
 echo $str;
 ?>
 
 Thanks,
 
 Gaurav Kumar
 
 
 
 2009/12/11 René Fournier 
 Hi Gaurav,
 
 On 2009-12-11, at 2:55 PM, Gaurav Kumar wrote:
 
> A very typical problem. Good you sent the error message.
> 
> This problem can be caused due to one of the following-
> 
> 1. I have faced similar problem due to local firewall settings.
 
 Don't think this is it, since (1) the firewall settings haven't changed, 
 and (2) other machines on the same network can execute this same code and 
 function (but they aren't running OS X Server 10.6.
 
> 2. Try some other domain; i.e. other than google com. Try some of the 
> local area website with a particular page like 
> www.somedomain.com/somefile.html
 
 I've tried many different external and local web sites, and they all fail.
 
> 3. Some times the remote host does not allow you to connect to get the 
> file contents.
 
 (Also not the cause -- as explained above.)
 
 
> 4. # 3 can be either way round from both the ends a) you host server does 
> not allow external connections b) Remote host does not allow anonymous 
> connection.
 
 Thanks for the options. I don't think they apply in this case. If you have 
 any other suggestions on what to do, I would welcome them.
 
 
 
> Gaurav Kumar
> blog.oswebstudio.com
> 
> 
> 
> On Thu, Dec 10, 2009 at 9:01 PM, René Fournier  
> wrote:
> I thought error_reporting would display them, but I guess php.ini had 
> them suppressed. Anyway, with:
> 
>  
> error_reporting(-1);
> ini_set('display_errors', 1);
> set_time_limit(0);
> var_dump (file_get_contents ('http://www.google.com'));
> 
> ?>
> 
> I get:
> 
> Wa

Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-14 Thread Gaurav Kumar
Sorry buddy, I cant think of anything else which is going on wrong.


2009/12/14 René Fournier 

>
> PHP Version 5.3.0
>
> Directive Local Value Master Value
> allow_call_time_pass_reference Off Off
> allow_url_fopen On
>
>
> On 2009-12-14, at 12:26 AM, Gaurav Kumar wrote:
>
> What is the value for 
> "allow_url_fopen"
> in your php.ini? It should be 1.
>
>
>
>
>
> 2009/12/13 René Fournier 
>
>> CURL works (remote and local)
>> file_get_contents() doesn't work (remote or local).
>>
>>
>>
>> On 2009-12-13, at 4:39 PM, Gaurav Kumar wrote:
>>
>> Ok Agreed.
>>
>> Lets do one last chance to ensure that your system is allowing external
>> connections or connection to other systems in the network-
>>
>> Use Curl to get in the file contents. Check your PHP that Curl is enabled.
>> Through phpinfo();
>>
>> If the script output the google page then this means that there is nothing
>> that is stopping you form getting in the content externally.
>>
>> > // $str =  file_get_contents ('http://www.google.com');
>> // echo $str;
>>
>>
>> // create a new cURL resource
>> $ch = curl_init();
>>
>> // set URL and other appropriate options
>> curl_setopt($ch, CURLOPT_URL, "http://www.google.co.in";); //
>> http://www.google.com
>> curl_setopt($ch, CURLOPT_HEADER, 0);
>>
>> // grab URL and pass it to the browser
>> curl_exec($ch);
>>
>> // close cURL resource, and free up system resources
>> curl_close($ch);
>>
>> ?>
>>
>> Thanks,
>>
>> Gaurav Kumar
>>
>>
>>
>> 2009/12/13 René Fournier 
>>
>>> The thing is, the file_get_contents() fails the same way on local URLs --
>>> that is, web sites hosted on the same machine. Or even using the machine's
>>> own IP address.
>>>
>>> On 2009-12-13, at 4:00 AM, Gaurav Kumar wrote:
>>>
>>> Hi Rene,
>>>
>>> The only thing which is a hurdle is that your system/computer is not
>>> allowing external connections. There seems to be nothing else wrong.
>>>
>>> I strongly suggest check your system firewall, any central server
>>> settings through which your system gets internet access, any antivirus s/w
>>> installed etc.. this can be the only reason. Something is stopping you to
>>> access external connection.
>>>
>>> Let me know when your problem is fixed.
>>> Also I tried the below code and it works fine-
>>>
>>> >> $str =  file_get_contents ('http://www.google.com');
>>> echo $str;
>>> ?>
>>>
>>> Thanks,
>>>
>>> Gaurav Kumar
>>>
>>>
>>>
>>> 2009/12/11 René Fournier 
>>>
 Hi Gaurav,

 On 2009-12-11, at 2:55 PM, Gaurav Kumar wrote:

 A very typical problem. Good you sent the error message.

 This problem can be caused due to one of the following-

 1. I have faced similar problem due to local firewall settings.


 Don't think this is it, since (1) the firewall settings haven't changed,
 and (2) other machines on the same network can execute this same code and
 function (but they aren't running OS X Server 10.6.

 2. Try some other domain; i.e. other than google com. Try some of the
 local area website with a particular page like
 www.somedomain.com/somefile.html


 I've tried many different external and local web sites, and they all
 fail.

 3. Some times the remote host does not allow you to connect to get the
 file contents.


 (Also not the cause -- as explained above.)


 4. # 3 can be either way round from both the ends a) you host server
 does not allow external connections b) Remote host does not allow anonymous
 connection.


 Thanks for the options. I don't think they apply in this case. If you
 have any other suggestions on what to do, I would welcome them.



 Gaurav Kumar
 blog.oswebstudio.com



 On Thu, Dec 10, 2009 at 9:01 PM, René Fournier 
 wrote:

> I thought error_reporting would display them, but I guess php.ini had
> them suppressed. Anyway, with:
>
> 
> error_reporting(-1);
> ini_set('display_errors', 1);
> set_time_limit(0);
> var_dump (file_get_contents ('http://www.google.com'));
>
> ?>
>
> I get:
>
> Warning: file_get_contents(http://www.google.com): failed to open
> stream: Operation now in progress in //.php on line 7 bool(false)
>
> Does that help with the diagnosis?
>
>
> On 2009-12-10, at 12:28 AM, Richard Quadling wrote:
>
> > 2009/12/9 René Fournier :
> >> It is, and I use curl elsewhere in the same script to fetch remote
> content.
> >> This exact same function works fine on my MacBook Pro (10.6 client,
> PHP 5.3), and *was* previously working fine under Server 10.4.11 and PHP
> 5.3,
> >>
> >> On 2009-12-09, at 11:10 PM, laruence wrote:
> >>
> >>> try
> >>> wget http://www.google.com in your command line to see whether the
> network is reacha

Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-13 Thread René Fournier

PHP Version 5.3.0

Directive   Local Value Master Value
allow_call_time_pass_reference  Off Off
allow_url_fopen On


On 2009-12-14, at 12:26 AM, Gaurav Kumar wrote:

> What is the value for "allow_url_fopen" in your php.ini? It should be 1.
> 
> 
> 
> 
> 
> 2009/12/13 René Fournier 
> CURL works (remote and local)
> file_get_contents() doesn't work (remote or local).
> 
> 
> 
> On 2009-12-13, at 4:39 PM, Gaurav Kumar wrote:
> 
>> Ok Agreed. 
>> 
>> Lets do one last chance to ensure that your system is allowing external 
>> connections or connection to other systems in the network-
>> 
>> Use Curl to get in the file contents. Check your PHP that Curl is enabled. 
>> Through phpinfo();
>> 
>> If the script output the google page then this means that there is nothing 
>> that is stopping you form getting in the content externally.
>> 
>> > // $str =  file_get_contents ('http://www.google.com');
>> // echo $str;
>> 
>> 
>> // create a new cURL resource
>> $ch = curl_init();
>> 
>> // set URL and other appropriate options
>> curl_setopt($ch, CURLOPT_URL, "http://www.google.co.in";); 
>> //http://www.google.com
>> curl_setopt($ch, CURLOPT_HEADER, 0);
>> 
>> // grab URL and pass it to the browser
>> curl_exec($ch);
>> 
>> // close cURL resource, and free up system resources
>> curl_close($ch);
>> 
>> ?>
>> 
>> Thanks,
>> 
>> Gaurav Kumar
>> 
>> 
>> 
>> 2009/12/13 René Fournier 
>> The thing is, the file_get_contents() fails the same way on local URLs -- 
>> that is, web sites hosted on the same machine. Or even using the machine's 
>> own IP address.
>> 
>> On 2009-12-13, at 4:00 AM, Gaurav Kumar wrote:
>> 
>>> Hi Rene,
>>> 
>>> The only thing which is a hurdle is that your system/computer is not 
>>> allowing external connections. There seems to be nothing else wrong.
>>> 
>>> I strongly suggest check your system firewall, any central server settings 
>>> through which your system gets internet access, any antivirus s/w installed 
>>> etc.. this can be the only reason. Something is stopping you to access 
>>> external connection.
>>> 
>>> Let me know when your problem is fixed.
>>> Also I tried the below code and it works fine-
>>> 
>>> >> $str =  file_get_contents ('http://www.google.com');
>>> echo $str;
>>> ?>
>>> 
>>> Thanks,
>>> 
>>> Gaurav Kumar
>>> 
>>> 
>>> 
>>> 2009/12/11 René Fournier 
>>> Hi Gaurav,
>>> 
>>> On 2009-12-11, at 2:55 PM, Gaurav Kumar wrote:
>>> 
 A very typical problem. Good you sent the error message.
 
 This problem can be caused due to one of the following-
 
 1. I have faced similar problem due to local firewall settings.
>>> 
>>> Don't think this is it, since (1) the firewall settings haven't changed, 
>>> and (2) other machines on the same network can execute this same code and 
>>> function (but they aren't running OS X Server 10.6.
>>> 
 2. Try some other domain; i.e. other than google com. Try some of the 
 local area website with a particular page like 
 www.somedomain.com/somefile.html
>>> 
>>> I've tried many different external and local web sites, and they all fail.
>>> 
 3. Some times the remote host does not allow you to connect to get the 
 file contents.
>>> 
>>> (Also not the cause -- as explained above.)
>>> 
>>> 
 4. # 3 can be either way round from both the ends a) you host server does 
 not allow external connections b) Remote host does not allow anonymous 
 connection.
>>> 
>>> Thanks for the options. I don't think they apply in this case. If you have 
>>> any other suggestions on what to do, I would welcome them.
>>> 
>>> 
>>> 
 Gaurav Kumar
 blog.oswebstudio.com
 
 
 
 On Thu, Dec 10, 2009 at 9:01 PM, René Fournier  
 wrote:
 I thought error_reporting would display them, but I guess php.ini had them 
 suppressed. Anyway, with:
 
 >>> 
 error_reporting(-1);
 ini_set('display_errors', 1);
 set_time_limit(0);
 var_dump (file_get_contents ('http://www.google.com'));
 
 ?>
 
 I get:
 
 Warning: file_get_contents(http://www.google.com): failed to open stream: 
 Operation now in progress in //.php on line 7 bool(false)
 
 Does that help with the diagnosis?
 
 
 On 2009-12-10, at 12:28 AM, Richard Quadling wrote:
 
 > 2009/12/9 René Fournier :
 >> It is, and I use curl elsewhere in the same script to fetch remote 
 >> content.
 >> This exact same function works fine on my MacBook Pro (10.6 client, PHP 
 >> 5.3), and *was* previously working fine under Server 10.4.11 and PHP 
 >> 5.3,
 >>
 >> On 2009-12-09, at 11:10 PM, laruence wrote:
 >>
 >>> try
 >>> wget http://www.google.com in your command line to see whether the 
 >>> network is reachable
 >>>
 >>> LinuxManMikeC wrote:
 
  On Wed, Dec 9, 2009 at 8:02 AM, LinuxManMikeC 
   wrote:
 
 > On Wed, Dec 9, 2009 at 6:45 AM, René

Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-13 Thread Gaurav Kumar
What is the value for
"allow_url_fopen"
in your php.ini? It should be 1.





2009/12/13 René Fournier 

> CURL works (remote and local)
> file_get_contents() doesn't work (remote or local).
>
>
>
> On 2009-12-13, at 4:39 PM, Gaurav Kumar wrote:
>
> Ok Agreed.
>
> Lets do one last chance to ensure that your system is allowing external
> connections or connection to other systems in the network-
>
> Use Curl to get in the file contents. Check your PHP that Curl is enabled.
> Through phpinfo();
>
> If the script output the google page then this means that there is nothing
> that is stopping you form getting in the content externally.
>
>  // $str =  file_get_contents ('http://www.google.com');
> // echo $str;
>
>
> // create a new cURL resource
> $ch = curl_init();
>
> // set URL and other appropriate options
> curl_setopt($ch, CURLOPT_URL, "http://www.google.co.in";); //
> http://www.google.com
> curl_setopt($ch, CURLOPT_HEADER, 0);
>
> // grab URL and pass it to the browser
> curl_exec($ch);
>
> // close cURL resource, and free up system resources
> curl_close($ch);
>
> ?>
>
> Thanks,
>
> Gaurav Kumar
>
>
>
> 2009/12/13 René Fournier 
>
>> The thing is, the file_get_contents() fails the same way on local URLs --
>> that is, web sites hosted on the same machine. Or even using the machine's
>> own IP address.
>>
>> On 2009-12-13, at 4:00 AM, Gaurav Kumar wrote:
>>
>> Hi Rene,
>>
>> The only thing which is a hurdle is that your system/computer is not
>> allowing external connections. There seems to be nothing else wrong.
>>
>> I strongly suggest check your system firewall, any central server settings
>> through which your system gets internet access, any antivirus s/w installed
>> etc.. this can be the only reason. Something is stopping you to access
>> external connection.
>>
>> Let me know when your problem is fixed.
>> Also I tried the below code and it works fine-
>>
>> > $str =  file_get_contents ('http://www.google.com');
>> echo $str;
>> ?>
>>
>> Thanks,
>>
>> Gaurav Kumar
>>
>>
>>
>> 2009/12/11 René Fournier 
>>
>>> Hi Gaurav,
>>>
>>> On 2009-12-11, at 2:55 PM, Gaurav Kumar wrote:
>>>
>>> A very typical problem. Good you sent the error message.
>>>
>>> This problem can be caused due to one of the following-
>>>
>>> 1. I have faced similar problem due to local firewall settings.
>>>
>>>
>>> Don't think this is it, since (1) the firewall settings haven't changed,
>>> and (2) other machines on the same network can execute this same code and
>>> function (but they aren't running OS X Server 10.6.
>>>
>>> 2. Try some other domain; i.e. other than google com. Try some of the
>>> local area website with a particular page like
>>> www.somedomain.com/somefile.html
>>>
>>>
>>> I've tried many different external and local web sites, and they all
>>> fail.
>>>
>>> 3. Some times the remote host does not allow you to connect to get the
>>> file contents.
>>>
>>>
>>> (Also not the cause -- as explained above.)
>>>
>>>
>>> 4. # 3 can be either way round from both the ends a) you host server does
>>> not allow external connections b) Remote host does not allow anonymous
>>> connection.
>>>
>>>
>>> Thanks for the options. I don't think they apply in this case. If you
>>> have any other suggestions on what to do, I would welcome them.
>>>
>>>
>>>
>>> Gaurav Kumar
>>> blog.oswebstudio.com
>>>
>>>
>>>
>>> On Thu, Dec 10, 2009 at 9:01 PM, René Fournier wrote:
>>>
 I thought error_reporting would display them, but I guess php.ini had
 them suppressed. Anyway, with:

 >>>
 error_reporting(-1);
 ini_set('display_errors', 1);
 set_time_limit(0);
 var_dump (file_get_contents ('http://www.google.com'));

 ?>

 I get:

 Warning: file_get_contents(http://www.google.com): failed to open
 stream: Operation now in progress in //.php on line 7 bool(false)

 Does that help with the diagnosis?


 On 2009-12-10, at 12:28 AM, Richard Quadling wrote:

 > 2009/12/9 René Fournier :
 >> It is, and I use curl elsewhere in the same script to fetch remote
 content.
 >> This exact same function works fine on my MacBook Pro (10.6 client,
 PHP 5.3), and *was* previously working fine under Server 10.4.11 and PHP
 5.3,
 >>
 >> On 2009-12-09, at 11:10 PM, laruence wrote:
 >>
 >>> try
 >>> wget http://www.google.com in your command line to see whether the
 network is reachable
 >>>
 >>> LinuxManMikeC wrote:
 
  On Wed, Dec 9, 2009 at 8:02 AM, LinuxManMikeC <
 linuxmanmi...@gmail.com> wrote:
 
 > On Wed, Dec 9, 2009 at 6:45 AM, René Fournier <
 m...@renefournier.com> wrote:
 >
 >> Strange problem I'm having on Mac OS X Server 10.6 running PHP
 5.3. Any call of file_get_contents() on a local file works fine -- the file
 is read and returned. But any cal

Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-13 Thread René Fournier
CURL works (remote and local)
file_get_contents() doesn't work (remote or local).



On 2009-12-13, at 4:39 PM, Gaurav Kumar wrote:

> Ok Agreed. 
> 
> Lets do one last chance to ensure that your system is allowing external 
> connections or connection to other systems in the network-
> 
> Use Curl to get in the file contents. Check your PHP that Curl is enabled. 
> Through phpinfo();
> 
> If the script output the google page then this means that there is nothing 
> that is stopping you form getting in the content externally.
> 
>  // $str =  file_get_contents ('http://www.google.com');
> // echo $str;
> 
> 
> // create a new cURL resource
> $ch = curl_init();
> 
> // set URL and other appropriate options
> curl_setopt($ch, CURLOPT_URL, "http://www.google.co.in";); 
> //http://www.google.com
> curl_setopt($ch, CURLOPT_HEADER, 0);
> 
> // grab URL and pass it to the browser
> curl_exec($ch);
> 
> // close cURL resource, and free up system resources
> curl_close($ch);
> 
> ?>
> 
> Thanks,
> 
> Gaurav Kumar
> 
> 
> 
> 2009/12/13 René Fournier 
> The thing is, the file_get_contents() fails the same way on local URLs -- 
> that is, web sites hosted on the same machine. Or even using the machine's 
> own IP address.
> 
> On 2009-12-13, at 4:00 AM, Gaurav Kumar wrote:
> 
>> Hi Rene,
>> 
>> The only thing which is a hurdle is that your system/computer is not 
>> allowing external connections. There seems to be nothing else wrong.
>> 
>> I strongly suggest check your system firewall, any central server settings 
>> through which your system gets internet access, any antivirus s/w installed 
>> etc.. this can be the only reason. Something is stopping you to access 
>> external connection.
>> 
>> Let me know when your problem is fixed.
>> Also I tried the below code and it works fine-
>> 
>> > $str =  file_get_contents ('http://www.google.com');
>> echo $str;
>> ?>
>> 
>> Thanks,
>> 
>> Gaurav Kumar
>> 
>> 
>> 
>> 2009/12/11 René Fournier 
>> Hi Gaurav,
>> 
>> On 2009-12-11, at 2:55 PM, Gaurav Kumar wrote:
>> 
>>> A very typical problem. Good you sent the error message.
>>> 
>>> This problem can be caused due to one of the following-
>>> 
>>> 1. I have faced similar problem due to local firewall settings.
>> 
>> Don't think this is it, since (1) the firewall settings haven't changed, and 
>> (2) other machines on the same network can execute this same code and 
>> function (but they aren't running OS X Server 10.6.
>> 
>>> 2. Try some other domain; i.e. other than google com. Try some of the local 
>>> area website with a particular page like www.somedomain.com/somefile.html
>> 
>> I've tried many different external and local web sites, and they all fail.
>> 
>>> 3. Some times the remote host does not allow you to connect to get the file 
>>> contents.
>> 
>> (Also not the cause -- as explained above.)
>> 
>> 
>>> 4. # 3 can be either way round from both the ends a) you host server does 
>>> not allow external connections b) Remote host does not allow anonymous 
>>> connection.
>> 
>> Thanks for the options. I don't think they apply in this case. If you have 
>> any other suggestions on what to do, I would welcome them.
>> 
>> 
>> 
>>> Gaurav Kumar
>>> blog.oswebstudio.com
>>> 
>>> 
>>> 
>>> On Thu, Dec 10, 2009 at 9:01 PM, René Fournier  
>>> wrote:
>>> I thought error_reporting would display them, but I guess php.ini had them 
>>> suppressed. Anyway, with:
>>> 
>>> >> 
>>> error_reporting(-1);
>>> ini_set('display_errors', 1);
>>> set_time_limit(0);
>>> var_dump (file_get_contents ('http://www.google.com'));
>>> 
>>> ?>
>>> 
>>> I get:
>>> 
>>> Warning: file_get_contents(http://www.google.com): failed to open stream: 
>>> Operation now in progress in //.php on line 7 bool(false)
>>> 
>>> Does that help with the diagnosis?
>>> 
>>> 
>>> On 2009-12-10, at 12:28 AM, Richard Quadling wrote:
>>> 
>>> > 2009/12/9 René Fournier :
>>> >> It is, and I use curl elsewhere in the same script to fetch remote 
>>> >> content.
>>> >> This exact same function works fine on my MacBook Pro (10.6 client, PHP 
>>> >> 5.3), and *was* previously working fine under Server 10.4.11 and PHP 5.3,
>>> >>
>>> >> On 2009-12-09, at 11:10 PM, laruence wrote:
>>> >>
>>> >>> try
>>> >>> wget http://www.google.com in your command line to see whether the 
>>> >>> network is reachable
>>> >>>
>>> >>> LinuxManMikeC wrote:
>>> 
>>>  On Wed, Dec 9, 2009 at 8:02 AM, LinuxManMikeC 
>>>   wrote:
>>> 
>>> > On Wed, Dec 9, 2009 at 6:45 AM, René Fournier  
>>> > wrote:
>>> >
>>> >> Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. 
>>> >> Any call of file_get_contents() on a local file works fine -- the 
>>> >> file is read and returned. But any call of file_get_contents on a 
>>> >> url -- any url, local or remote -- always returns false.
>>> >>
>>> >> var_dump (file_get_contents ('http://www.google.com/'));
>>> >>
>>> >> bool(false)
>>> >>
>>> >> I'v

Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-13 Thread Gaurav Kumar
Ok Agreed.

Lets do one last chance to ensure that your system is allowing external
connections or connection to other systems in the network-

Use Curl to get in the file contents. Check your PHP that Curl is enabled.
Through phpinfo();

If the script output the google page then this means that there is nothing
that is stopping you form getting in the content externally.

http://www.google.com');
// echo $str;


// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://www.google.co.in";); //
http://www.google.com
curl_setopt($ch, CURLOPT_HEADER, 0);

// grab URL and pass it to the browser
curl_exec($ch);

// close cURL resource, and free up system resources
curl_close($ch);

?>

Thanks,

Gaurav Kumar



2009/12/13 René Fournier 

> The thing is, the file_get_contents() fails the same way on local URLs --
> that is, web sites hosted on the same machine. Or even using the machine's
> own IP address.
>
> On 2009-12-13, at 4:00 AM, Gaurav Kumar wrote:
>
> Hi Rene,
>
> The only thing which is a hurdle is that your system/computer is not
> allowing external connections. There seems to be nothing else wrong.
>
> I strongly suggest check your system firewall, any central server settings
> through which your system gets internet access, any antivirus s/w installed
> etc.. this can be the only reason. Something is stopping you to access
> external connection.
>
> Let me know when your problem is fixed.
> Also I tried the below code and it works fine-
>
>  $str =  file_get_contents ('http://www.google.com');
> echo $str;
> ?>
>
> Thanks,
>
> Gaurav Kumar
>
>
>
> 2009/12/11 René Fournier 
>
>> Hi Gaurav,
>>
>> On 2009-12-11, at 2:55 PM, Gaurav Kumar wrote:
>>
>> A very typical problem. Good you sent the error message.
>>
>> This problem can be caused due to one of the following-
>>
>> 1. I have faced similar problem due to local firewall settings.
>>
>>
>> Don't think this is it, since (1) the firewall settings haven't changed,
>> and (2) other machines on the same network can execute this same code and
>> function (but they aren't running OS X Server 10.6.
>>
>> 2. Try some other domain; i.e. other than google com. Try some of the
>> local area website with a particular page like
>> www.somedomain.com/somefile.html
>>
>>
>> I've tried many different external and local web sites, and they all fail.
>>
>> 3. Some times the remote host does not allow you to connect to get the
>> file contents.
>>
>>
>> (Also not the cause -- as explained above.)
>>
>>
>> 4. # 3 can be either way round from both the ends a) you host server does
>> not allow external connections b) Remote host does not allow anonymous
>> connection.
>>
>>
>> Thanks for the options. I don't think they apply in this case. If you have
>> any other suggestions on what to do, I would welcome them.
>>
>>
>>
>> Gaurav Kumar
>> blog.oswebstudio.com
>>
>>
>>
>> On Thu, Dec 10, 2009 at 9:01 PM, René Fournier wrote:
>>
>>> I thought error_reporting would display them, but I guess php.ini had
>>> them suppressed. Anyway, with:
>>>
>>> >>
>>> error_reporting(-1);
>>> ini_set('display_errors', 1);
>>> set_time_limit(0);
>>> var_dump (file_get_contents ('http://www.google.com'));
>>>
>>> ?>
>>>
>>> I get:
>>>
>>> Warning: file_get_contents(http://www.google.com): failed to open
>>> stream: Operation now in progress in //.php on line 7 bool(false)
>>>
>>> Does that help with the diagnosis?
>>>
>>>
>>> On 2009-12-10, at 12:28 AM, Richard Quadling wrote:
>>>
>>> > 2009/12/9 René Fournier :
>>> >> It is, and I use curl elsewhere in the same script to fetch remote
>>> content.
>>> >> This exact same function works fine on my MacBook Pro (10.6 client,
>>> PHP 5.3), and *was* previously working fine under Server 10.4.11 and PHP
>>> 5.3,
>>> >>
>>> >> On 2009-12-09, at 11:10 PM, laruence wrote:
>>> >>
>>> >>> try
>>> >>> wget http://www.google.com in your command line to see whether the
>>> network is reachable
>>> >>>
>>> >>> LinuxManMikeC wrote:
>>> 
>>>  On Wed, Dec 9, 2009 at 8:02 AM, LinuxManMikeC <
>>> linuxmanmi...@gmail.com> wrote:
>>> 
>>> > On Wed, Dec 9, 2009 at 6:45 AM, René Fournier 
>>> wrote:
>>> >
>>> >> Strange problem I'm having on Mac OS X Server 10.6 running PHP
>>> 5.3. Any call of file_get_contents() on a local file works fine -- the file
>>> is read and returned. But any call of file_get_contents on a url -- any url,
>>> local or remote -- always returns false.
>>> >>
>>> >> var_dump (file_get_contents 
>>> >> ('http://www.google.com/')
>>> );
>>> >>
>>> >> bool(false)
>>> >>
>>> >> I've checked php.ini, and the obvious seems okay:
>>> >>
>>> >>allow_url_fopen => On => On
>>> >>
>>> >> Any ideas?
>>> >>
>>> >> ...Rene
>>> >>
>>> >
>>> http://us2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen
>>> >
>>> >
>>> 
>>> 

Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-12 Thread René Fournier
The thing is, the file_get_contents() fails the same way on local URLs -- that 
is, web sites hosted on the same machine. Or even using the machine's own IP 
address.

On 2009-12-13, at 4:00 AM, Gaurav Kumar wrote:

> Hi Rene,
> 
> The only thing which is a hurdle is that your system/computer is not allowing 
> external connections. There seems to be nothing else wrong.
> 
> I strongly suggest check your system firewall, any central server settings 
> through which your system gets internet access, any antivirus s/w installed 
> etc.. this can be the only reason. Something is stopping you to access 
> external connection.
> 
> Let me know when your problem is fixed.
> Also I tried the below code and it works fine-
> 
>  $str =  file_get_contents ('http://www.google.com');
> echo $str;
> ?>
> 
> Thanks,
> 
> Gaurav Kumar
> 
> 
> 
> 2009/12/11 René Fournier 
> Hi Gaurav,
> 
> On 2009-12-11, at 2:55 PM, Gaurav Kumar wrote:
> 
>> A very typical problem. Good you sent the error message.
>> 
>> This problem can be caused due to one of the following-
>> 
>> 1. I have faced similar problem due to local firewall settings.
> 
> Don't think this is it, since (1) the firewall settings haven't changed, and 
> (2) other machines on the same network can execute this same code and 
> function (but they aren't running OS X Server 10.6.
> 
>> 2. Try some other domain; i.e. other than google com. Try some of the local 
>> area website with a particular page like www.somedomain.com/somefile.html
> 
> I've tried many different external and local web sites, and they all fail.
> 
>> 3. Some times the remote host does not allow you to connect to get the file 
>> contents.
> 
> (Also not the cause -- as explained above.)
> 
> 
>> 4. # 3 can be either way round from both the ends a) you host server does 
>> not allow external connections b) Remote host does not allow anonymous 
>> connection.
> 
> Thanks for the options. I don't think they apply in this case. If you have 
> any other suggestions on what to do, I would welcome them.
> 
> 
> 
>> Gaurav Kumar
>> blog.oswebstudio.com
>> 
>> 
>> 
>> On Thu, Dec 10, 2009 at 9:01 PM, René Fournier  wrote:
>> I thought error_reporting would display them, but I guess php.ini had them 
>> suppressed. Anyway, with:
>> 
>> > 
>> error_reporting(-1);
>> ini_set('display_errors', 1);
>> set_time_limit(0);
>> var_dump (file_get_contents ('http://www.google.com'));
>> 
>> ?>
>> 
>> I get:
>> 
>> Warning: file_get_contents(http://www.google.com): failed to open stream: 
>> Operation now in progress in //.php on line 7 bool(false)
>> 
>> Does that help with the diagnosis?
>> 
>> 
>> On 2009-12-10, at 12:28 AM, Richard Quadling wrote:
>> 
>> > 2009/12/9 René Fournier :
>> >> It is, and I use curl elsewhere in the same script to fetch remote 
>> >> content.
>> >> This exact same function works fine on my MacBook Pro (10.6 client, PHP 
>> >> 5.3), and *was* previously working fine under Server 10.4.11 and PHP 5.3,
>> >>
>> >> On 2009-12-09, at 11:10 PM, laruence wrote:
>> >>
>> >>> try
>> >>> wget http://www.google.com in your command line to see whether the 
>> >>> network is reachable
>> >>>
>> >>> LinuxManMikeC wrote:
>> 
>>  On Wed, Dec 9, 2009 at 8:02 AM, LinuxManMikeC  
>>  wrote:
>> 
>> > On Wed, Dec 9, 2009 at 6:45 AM, René Fournier  
>> > wrote:
>> >
>> >> Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. 
>> >> Any call of file_get_contents() on a local file works fine -- the 
>> >> file is read and returned. But any call of file_get_contents on a url 
>> >> -- any url, local or remote -- always returns false.
>> >>
>> >> var_dump (file_get_contents ('http://www.google.com/'));
>> >>
>> >> bool(false)
>> >>
>> >> I've checked php.ini, and the obvious seems okay:
>> >>
>> >>allow_url_fopen => On => On
>> >>
>> >> Any ideas?
>> >>
>> >> ...Rene
>> >>
>> > http://us2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen
>> >
>> >
>> 
>>  "I've checked php.ini"
>>  Right, must remember not to reply to stuff till I'm awake. :-D
>> 
>>  --
>>  PHP General Mailing List (http://www.php.net/)
>>  To unsubscribe, visit: http://www.php.net/unsub.php
>> 
>> 
>> >>>
>> >>> --
>> >>> <2866791487_dbbbdddf9e.jpg>惠 新宸 xinchen.hui | 商务搜索部 | 
>> >>> (+8610)82602112-7974 | <2866349865_203e53a6c6.jpg>:laruence
>> >>
>> >>
>> >
>> > Do you have ANY errors/warning/notices?
>> >
>> >
>> >
>> > --
>> > -
>> > Richard Quadling
>> > "Standing on the shoulders of some very clever giants!"
>> > EE : http://www.experts-exchange.com/M_248814.html
>> > Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
>> > ZOPA : http://uk.zopa.com/member/RQuadling
>> 
>> 
> 
> 



Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-12 Thread Gaurav Kumar
Hi Rene,

The only thing which is a hurdle is that your system/computer is not
allowing external connections. There seems to be nothing else wrong.

I strongly suggest check your system firewall, any central server settings
through which your system gets internet access, any antivirus s/w installed
etc.. this can be the only reason. Something is stopping you to access
external connection.

Let me know when your problem is fixed.
Also I tried the below code and it works fine-

http://www.google.com');
echo $str;
?>

Thanks,

Gaurav Kumar



2009/12/11 René Fournier 

> Hi Gaurav,
>
> On 2009-12-11, at 2:55 PM, Gaurav Kumar wrote:
>
> A very typical problem. Good you sent the error message.
>
> This problem can be caused due to one of the following-
>
> 1. I have faced similar problem due to local firewall settings.
>
>
> Don't think this is it, since (1) the firewall settings haven't changed,
> and (2) other machines on the same network can execute this same code and
> function (but they aren't running OS X Server 10.6.
>
> 2. Try some other domain; i.e. other than google com. Try some of the local
> area website with a particular page like www.somedomain.com/somefile.html
>
>
> I've tried many different external and local web sites, and they all fail.
>
> 3. Some times the remote host does not allow you to connect to get the file
> contents.
>
>
> (Also not the cause -- as explained above.)
>
>
> 4. # 3 can be either way round from both the ends a) you host server does
> not allow external connections b) Remote host does not allow anonymous
> connection.
>
>
> Thanks for the options. I don't think they apply in this case. If you have
> any other suggestions on what to do, I would welcome them.
>
>
>
> Gaurav Kumar
> blog.oswebstudio.com
>
>
>
> On Thu, Dec 10, 2009 at 9:01 PM, René Fournier wrote:
>
>> I thought error_reporting would display them, but I guess php.ini had them
>> suppressed. Anyway, with:
>>
>> >
>> error_reporting(-1);
>> ini_set('display_errors', 1);
>> set_time_limit(0);
>> var_dump (file_get_contents ('http://www.google.com'));
>>
>> ?>
>>
>> I get:
>>
>> Warning: file_get_contents(http://www.google.com): failed to open stream:
>> Operation now in progress in //.php on line 7 bool(false)
>>
>> Does that help with the diagnosis?
>>
>>
>> On 2009-12-10, at 12:28 AM, Richard Quadling wrote:
>>
>> > 2009/12/9 René Fournier :
>> >> It is, and I use curl elsewhere in the same script to fetch remote
>> content.
>> >> This exact same function works fine on my MacBook Pro (10.6 client, PHP
>> 5.3), and *was* previously working fine under Server 10.4.11 and PHP 5.3,
>> >>
>> >> On 2009-12-09, at 11:10 PM, laruence wrote:
>> >>
>> >>> try
>> >>> wget http://www.google.com in your command line to see whether the
>> network is reachable
>> >>>
>> >>> LinuxManMikeC wrote:
>> 
>>  On Wed, Dec 9, 2009 at 8:02 AM, LinuxManMikeC <
>> linuxmanmi...@gmail.com> wrote:
>> 
>> > On Wed, Dec 9, 2009 at 6:45 AM, René Fournier 
>> wrote:
>> >
>> >> Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3.
>> Any call of file_get_contents() on a local file works fine -- the file is
>> read and returned. But any call of file_get_contents on a url -- any url,
>> local or remote -- always returns false.
>> >>
>> >> var_dump (file_get_contents 
>> >> ('http://www.google.com/')
>> );
>> >>
>> >> bool(false)
>> >>
>> >> I've checked php.ini, and the obvious seems okay:
>> >>
>> >>allow_url_fopen => On => On
>> >>
>> >> Any ideas?
>> >>
>> >> ...Rene
>> >>
>> >
>> http://us2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen
>> >
>> >
>> 
>>  "I've checked php.ini"
>>  Right, must remember not to reply to stuff till I'm awake. :-D
>> 
>>  --
>>  PHP General Mailing List (http://www.php.net/)
>>  To unsubscribe, visit: http://www.php.net/unsub.php
>> 
>> 
>> >>>
>> >>> --
>> >>> <2866791487_dbbbdddf9e.jpg>惠 新宸 xinchen.hui | 商务搜索部 |
>> (+8610)82602112-7974 | <2866349865_203e53a6c6.jpg>:laruence
>> >>
>> >>
>> >
>> > Do you have ANY errors/warning/notices?
>> >
>> >
>> >
>> > --
>> > -
>> > Richard Quadling
>> > "Standing on the shoulders of some very clever giants!"
>> > EE : http://www.experts-exchange.com/M_248814.html
>> > Zend Certified Engineer :
>> http://zend.com/zce.php?c=ZEND002498&r=213474731
>> > ZOPA : http://uk.zopa.com/member/RQuadling
>>
>>
>
>


Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-11 Thread René Fournier
Hi Gaurav,

On 2009-12-11, at 2:55 PM, Gaurav Kumar wrote:

> A very typical problem. Good you sent the error message.
> 
> This problem can be caused due to one of the following-
> 
> 1. I have faced similar problem due to local firewall settings.

Don't think this is it, since (1) the firewall settings haven't changed, and 
(2) other machines on the same network can execute this same code and function 
(but they aren't running OS X Server 10.6.

> 2. Try some other domain; i.e. other than google com. Try some of the local 
> area website with a particular page like www.somedomain.com/somefile.html

I've tried many different external and local web sites, and they all fail.

> 3. Some times the remote host does not allow you to connect to get the file 
> contents.

(Also not the cause -- as explained above.)

> 4. # 3 can be either way round from both the ends a) you host server does not 
> allow external connections b) Remote host does not allow anonymous connection.

Thanks for the options. I don't think they apply in this case. If you have any 
other suggestions on what to do, I would welcome them.



> Gaurav Kumar
> blog.oswebstudio.com
> 
> 
> 
> On Thu, Dec 10, 2009 at 9:01 PM, René Fournier  wrote:
> I thought error_reporting would display them, but I guess php.ini had them 
> suppressed. Anyway, with:
> 
>  
> error_reporting(-1);
> ini_set('display_errors', 1);
> set_time_limit(0);
> var_dump (file_get_contents ('http://www.google.com'));
> 
> ?>
> 
> I get:
> 
> Warning: file_get_contents(http://www.google.com): failed to open stream: 
> Operation now in progress in //.php on line 7 bool(false)
> 
> Does that help with the diagnosis?
> 
> 
> On 2009-12-10, at 12:28 AM, Richard Quadling wrote:
> 
> > 2009/12/9 René Fournier :
> >> It is, and I use curl elsewhere in the same script to fetch remote content.
> >> This exact same function works fine on my MacBook Pro (10.6 client, PHP 
> >> 5.3), and *was* previously working fine under Server 10.4.11 and PHP 5.3,
> >>
> >> On 2009-12-09, at 11:10 PM, laruence wrote:
> >>
> >>> try
> >>> wget http://www.google.com in your command line to see whether the 
> >>> network is reachable
> >>>
> >>> LinuxManMikeC wrote:
> 
>  On Wed, Dec 9, 2009 at 8:02 AM, LinuxManMikeC  
>  wrote:
> 
> > On Wed, Dec 9, 2009 at 6:45 AM, René Fournier  
> > wrote:
> >
> >> Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. 
> >> Any call of file_get_contents() on a local file works fine -- the file 
> >> is read and returned. But any call of file_get_contents on a url -- 
> >> any url, local or remote -- always returns false.
> >>
> >> var_dump (file_get_contents ('http://www.google.com/'));
> >>
> >> bool(false)
> >>
> >> I've checked php.ini, and the obvious seems okay:
> >>
> >>allow_url_fopen => On => On
> >>
> >> Any ideas?
> >>
> >> ...Rene
> >>
> > http://us2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen
> >
> >
> 
>  "I've checked php.ini"
>  Right, must remember not to reply to stuff till I'm awake. :-D
> 
>  --
>  PHP General Mailing List (http://www.php.net/)
>  To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> >>>
> >>> --
> >>> <2866791487_dbbbdddf9e.jpg>惠 新宸 xinchen.hui | 商务搜索部 | 
> >>> (+8610)82602112-7974 | <2866349865_203e53a6c6.jpg>:laruence
> >>
> >>
> >
> > Do you have ANY errors/warning/notices?
> >
> >
> >
> > --
> > -
> > Richard Quadling
> > "Standing on the shoulders of some very clever giants!"
> > EE : http://www.experts-exchange.com/M_248814.html
> > Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
> > ZOPA : http://uk.zopa.com/member/RQuadling
> 
> 



Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-10 Thread Gaurav Kumar
A very typical problem. Good you sent the error message.

This problem can be caused due to one of the following-

1. I have faced similar problem due to local firewall settings.
2. Try some other domain; i.e. other than google com. Try some of the local
area website with a particular page like www.somedomain.com/somefile.html
3. Some times the remote host does not allow you to connect to get the file
contents.
4. # 3 can be either way round from both the ends a) you host server does
not allow external connections b) Remote host does not allow anonymous
connection.

Hope this helps..

Gaurav Kumar
blog.oswebstudio.com



On Thu, Dec 10, 2009 at 9:01 PM, René Fournier  wrote:

> I thought error_reporting would display them, but I guess php.ini had them
> suppressed. Anyway, with:
>
> 
> error_reporting(-1);
> ini_set('display_errors', 1);
> set_time_limit(0);
> var_dump (file_get_contents ('http://www.google.com'));
>
> ?>
>
> I get:
>
> Warning: file_get_contents(http://www.google.com): failed to open stream:
> Operation now in progress in //.php on line 7 bool(false)
>
> Does that help with the diagnosis?
>
>
> On 2009-12-10, at 12:28 AM, Richard Quadling wrote:
>
> > 2009/12/9 René Fournier :
> >> It is, and I use curl elsewhere in the same script to fetch remote
> content.
> >> This exact same function works fine on my MacBook Pro (10.6 client, PHP
> 5.3), and *was* previously working fine under Server 10.4.11 and PHP 5.3,
> >>
> >> On 2009-12-09, at 11:10 PM, laruence wrote:
> >>
> >>> try
> >>> wget http://www.google.com in your command line to see whether the
> network is reachable
> >>>
> >>> LinuxManMikeC wrote:
> 
>  On Wed, Dec 9, 2009 at 8:02 AM, LinuxManMikeC <
> linuxmanmi...@gmail.com> wrote:
> 
> > On Wed, Dec 9, 2009 at 6:45 AM, René Fournier 
> wrote:
> >
> >> Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3.
> Any call of file_get_contents() on a local file works fine -- the file is
> read and returned. But any call of file_get_contents on a url -- any url,
> local or remote -- always returns false.
> >>
> >> var_dump (file_get_contents 
> >> ('http://www.google.com/')
> );
> >>
> >> bool(false)
> >>
> >> I've checked php.ini, and the obvious seems okay:
> >>
> >>allow_url_fopen => On => On
> >>
> >> Any ideas?
> >>
> >> ...Rene
> >>
> >
> http://us2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen
> >
> >
> 
>  "I've checked php.ini"
>  Right, must remember not to reply to stuff till I'm awake. :-D
> 
>  --
>  PHP General Mailing List (http://www.php.net/)
>  To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> >>>
> >>> --
> >>> <2866791487_dbbbdddf9e.jpg>惠 新宸 xinchen.hui | 商务搜索部 |
> (+8610)82602112-7974 | <2866349865_203e53a6c6.jpg>:laruence
> >>
> >>
> >
> > Do you have ANY errors/warning/notices?
> >
> >
> >
> > --
> > -
> > Richard Quadling
> > "Standing on the shoulders of some very clever giants!"
> > EE : http://www.experts-exchange.com/M_248814.html
> > Zend Certified Engineer :
> http://zend.com/zce.php?c=ZEND002498&r=213474731
> > ZOPA : http://uk.zopa.com/member/RQuadling
>
>


Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-10 Thread René Fournier
I thought error_reporting would display them, but I guess php.ini had them 
suppressed. Anyway, with:

http://www.google.com'));

?>

I get:

Warning: file_get_contents(http://www.google.com): failed to open stream: 
Operation now in progress in //.php on line 7 bool(false)

Does that help with the diagnosis?


On 2009-12-10, at 12:28 AM, Richard Quadling wrote:

> 2009/12/9 René Fournier :
>> It is, and I use curl elsewhere in the same script to fetch remote content.
>> This exact same function works fine on my MacBook Pro (10.6 client, PHP 
>> 5.3), and *was* previously working fine under Server 10.4.11 and PHP 5.3,
>> 
>> On 2009-12-09, at 11:10 PM, laruence wrote:
>> 
>>> try
>>> wget http://www.google.com in your command line to see whether the network 
>>> is reachable
>>> 
>>> LinuxManMikeC wrote:
 
 On Wed, Dec 9, 2009 at 8:02 AM, LinuxManMikeC  
 wrote:
 
> On Wed, Dec 9, 2009 at 6:45 AM, René Fournier  
> wrote:
> 
>> Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. Any 
>> call of file_get_contents() on a local file works fine -- the file is 
>> read and returned. But any call of file_get_contents on a url -- any 
>> url, local or remote -- always returns false.
>> 
>> var_dump (file_get_contents ('http://www.google.com/'));
>> 
>> bool(false)
>> 
>> I've checked php.ini, and the obvious seems okay:
>> 
>>allow_url_fopen => On => On
>> 
>> Any ideas?
>> 
>> ...Rene
>> 
> http://us2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen
> 
> 
 
 "I've checked php.ini"
 Right, must remember not to reply to stuff till I'm awake. :-D
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
>>> 
>>> --
>>> <2866791487_dbbbdddf9e.jpg>惠 新宸 xinchen.hui | 商务搜索部 | (+8610)82602112-7974 
>>> | <2866349865_203e53a6c6.jpg>:laruence
>> 
>> 
> 
> Do you have ANY errors/warning/notices?
> 
> 
> 
> -- 
> -
> Richard Quadling
> "Standing on the shoulders of some very clever giants!"
> EE : http://www.experts-exchange.com/M_248814.html
> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
> ZOPA : http://uk.zopa.com/member/RQuadling



Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-09 Thread Richard Quadling
2009/12/9 René Fournier :
> It is, and I use curl elsewhere in the same script to fetch remote content.
> This exact same function works fine on my MacBook Pro (10.6 client, PHP 5.3), 
> and *was* previously working fine under Server 10.4.11 and PHP 5.3,
>
> On 2009-12-09, at 11:10 PM, laruence wrote:
>
>> try
>> wget http://www.google.com in your command line to see whether the network 
>> is reachable
>>
>> LinuxManMikeC wrote:
>>>
>>> On Wed, Dec 9, 2009 at 8:02 AM, LinuxManMikeC  
>>> wrote:
>>>
 On Wed, Dec 9, 2009 at 6:45 AM, René Fournier  
 wrote:

> Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. Any 
> call of file_get_contents() on a local file works fine -- the file is 
> read and returned. But any call of file_get_contents on a url -- any url, 
> local or remote -- always returns false.
>
> var_dump (file_get_contents ('http://www.google.com/'));
>
> bool(false)
>
> I've checked php.ini, and the obvious seems okay:
>
>        allow_url_fopen => On => On
>
> Any ideas?
>
> ...Rene
>
 http://us2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen


>>>
>>> "I've checked php.ini"
>>> Right, must remember not to reply to stuff till I'm awake. :-D
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>> --
>> <2866791487_dbbbdddf9e.jpg>惠 新宸 xinchen.hui | 商务搜索部 | (+8610)82602112-7974 | 
>> <2866349865_203e53a6c6.jpg>:laruence
>
>

Do you have ANY errors/warning/notices?



-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-09 Thread René Fournier
It is, and I use curl elsewhere in the same script to fetch remote content.
This exact same function works fine on my MacBook Pro (10.6 client, PHP 5.3), 
and *was* previously working fine under Server 10.4.11 and PHP 5.3,

On 2009-12-09, at 11:10 PM, laruence wrote:

> try 
> wget http://www.google.com in your command line to see whether the network is 
> reachable
> 
> LinuxManMikeC wrote:
>> 
>> On Wed, Dec 9, 2009 at 8:02 AM, LinuxManMikeC  
>> wrote:
>>   
>>> On Wed, Dec 9, 2009 at 6:45 AM, René Fournier  wrote:
>>> 
 Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. Any 
 call of file_get_contents() on a local file works fine -- the file is read 
 and returned. But any call of file_get_contents on a url -- any url, local 
 or remote -- always returns false.
 
 var_dump (file_get_contents ('http://www.google.com/'));
 
 bool(false)
 
 I've checked php.ini, and the obvious seems okay:
 
allow_url_fopen => On => On
 
 Any ideas?
 
 ...Rene
   
>>> http://us2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen
>>> 
>>> 
>> 
>> "I've checked php.ini"
>> Right, must remember not to reply to stuff till I'm awake. :-D
>> 
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 
>>   
> 
> -- 
> <2866791487_dbbbdddf9e.jpg>惠 新宸 xinchen.hui | 商务搜索部 | (+8610)82602112-7974 | 
> <2866349865_203e53a6c6.jpg>:laruence



Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-09 Thread René Fournier
No.
And it doesn't matter if the url is local (localhost, host.domain.com) or 
remote.

On 2009-12-09, at 10:30 PM, kranthi wrote:

> may be unrelated to your problem... but are you behind a proxy?



Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-09 Thread LinuxManMikeC
On Wed, Dec 9, 2009 at 8:02 AM, LinuxManMikeC  wrote:
> On Wed, Dec 9, 2009 at 6:45 AM, René Fournier  wrote:
>> Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. Any call 
>> of file_get_contents() on a local file works fine -- the file is read and 
>> returned. But any call of file_get_contents on a url -- any url, local or 
>> remote -- always returns false.
>>
>> var_dump (file_get_contents ('http://www.google.com/'));
>>
>> bool(false)
>>
>> I've checked php.ini, and the obvious seems okay:
>>
>>        allow_url_fopen => On => On
>>
>> Any ideas?
>>
>> ...Rene
>
> http://us2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen
>

"I've checked php.ini"
Right, must remember not to reply to stuff till I'm awake. :-D

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



Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-09 Thread LinuxManMikeC
On Wed, Dec 9, 2009 at 6:45 AM, René Fournier  wrote:
> Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. Any call 
> of file_get_contents() on a local file works fine -- the file is read and 
> returned. But any call of file_get_contents on a url -- any url, local or 
> remote -- always returns false.
>
> var_dump (file_get_contents ('http://www.google.com/'));
>
> bool(false)
>
> I've checked php.ini, and the obvious seems okay:
>
>        allow_url_fopen => On => On
>
> Any ideas?
>
> ...Rene

http://us2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen

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



Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-09 Thread kranthi
may be unrelated to your problem... but are you behind a proxy?

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



Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false

2009-12-09 Thread Richard Quadling
2009/12/9 René Fournier :
> Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. Any call 
> of file_get_contents() on a local file works fine -- the file is read and 
> returned. But any call of file_get_contents on a url -- any url, local or 
> remote -- always returns false.
>
> var_dump (file_get_contents ('http://www.google.com/'));
>
> bool(false)
>
> I've checked php.ini, and the obvious seems okay:
>
>        allow_url_fopen => On => On
>
> Any ideas?
>
> ...Rene

If you enable all errors, anything extra? ...

http://www.google.com'));





-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] file_get_contents works in base script but not in an included script

2009-05-18 Thread Paul M Foster
On Mon, May 18, 2009 at 03:54:31PM -0600, LinuxManMikeC wrote:

> In PHP4, I am using file_get_contents('file.sql',true) to bring in SQL
> queries from files who's directory is on the include path.  It works
> fine in the main php scripts (ones accessible through URLs), but when
> done in a php script that is included by one of the main scripts I
> just get false instead of a string.  The files exist, the include path
> is correctly set at all times (I've checked), and the exact same code
> works when placed directly in the main php script.  I've been tearing
> through documentation for hours.  Is there some quirk, or setting I'm
> missing?  Below is an example of what I'm doing.
> 
> main.php
>set_include_path(get_include_path . ':/absolute/path/to/sql');
> 
>   include('inc.php');
>   $SQL1 = file_get_contents('query.sql',true);
>   //$SQL1 == contents of query.sql
> ?>
> 
> includes/inc.php
>$SQL2 = file_get_contents('query.sql',true);
>   //$SQL2 == false
>   //My path is still intact here
> ?>

Ten to one, this is a pathing problem in the inc.php script. Make a copy
of the query.sql file and put it in the includes directory. Test. Make a
copy and put it in the document root. Test. At some point it will work,
and you'll know where inc.php expects to find it. Then you can work out
why it expects that. Then you'll grasp the "quirk".

Paul

-- 
Paul M. Foster

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



Re: [PHP] file_get_contents for URLs?

2009-04-07 Thread Richard Heyes
> Hey all,

Hello.

> I'm doing some maintenance work on an existing system and there is a piece
> of code that uses file_get_contents() to read data from a URL, which is fine
> in theory I suppose.
>
> But the problem is sometimes the server where that URL lives is not
> available, and the system hangs indefinitely.
>
> Shouldn't this be done with curl, and if so can it be done so that the call
> will time out and return control back when the server is not available?

Looking at the docs alone, it looks like you can pass a stream as the
third argument to file_get_contents(). So create a stream, set the
timeout on that (using stream_context_create() &
stream_context_set_option() ), and then pass it to
file_get_contents().

-- 
Richard Heyes

HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari:
http://www.rgraph.net (Updated March 28th)

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



Re: [PHP] file_get_contents for URLs?

2009-04-07 Thread Jan G.B.
Well, you might want to do it with curl, you might want to write your
own socketscript, or your just check the return variable of
file_get_contents() - it'll be false on failure and it won't try to
get an invalid URL forever. Guess the error is somewhere else, when
your script continues indefinitely.
I'm using theis function in that way with a daily cronjob, and the
remote server isn't so stable... trust me. ;)

But setting the timeout can be done in php.ini or like suggested on
the php.net manual:
http://www.php.net/manual/en/function.file-get-contents.php#82527

byebye


2009/4/7 Skip Evans :
> Hey all,
>
> I'm doing some maintenance work on an existing system and there is a piece
> of code that uses file_get_contents() to read data from a URL, which is fine
> in theory I suppose.
>
> But the problem is sometimes the server where that URL lives is not
> available, and the system hangs indefinitely.
>
> Shouldn't this be done with curl, and if so can it be done so that the call
> will time out and return control back when the server is not available?
>
> Any other recommendations?
>
> I just came across this code and it's one of the client's biggest
> complaints.
>
> --
> 
> Skip Evans
> Big Sky Penguin, LLC
> 503 S Baldwin St, #1
> Madison WI 53703
> 608.250.2720
> http://bigskypenguin.com
> 
> Those of you who believe in
> telekinesis, raise my hand.
>  -- Kurt Vonnegut
>
> --
> 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



Re: [PHP] file_get_contents urlencode spaces: yeah right?

2008-11-10 Thread Chris

Jim Lucas wrote:

Dee Ayy wrote:

PHP Version 5.1.6
$contents = file_get_contents("http://user:[EMAIL 
PROTECTED]/some/path/htmlfile.html");   
//WORKS
$contents = file_get_contents("http://user:[EMAIL PROTECTED]/some/path/htmlfile
with spaces.html");//FAILS(1)
$contents = file_get_contents("http://user:[EMAIL 
PROTECTED]/some/path/nonhtmlfile.ext"); 
//WORKS
$contents = file_get_contents("http://user:[EMAIL 
PROTECTED]/some/path/nonhtmlfile
with spaces.ext"); //FAILS(2)
$contents = file_get_contents(urlencode("http://user:[EMAIL 
PROTECTED]/some/path/eitherfile
with spaces.ext"));//FAILS BUT I DON'T REALLY CARE
$contents = file_get_contents(urlencode("http://user:[EMAIL 
PROTECTED]/some/path/eitherfilenospaces.ext"));   //FAILS
BUT I DON'T REALLY CARE
$contents = file_get_contents("http://user:[EMAIL 
PROTECTED]/some/path/".urlencode("eitherfile
with spaces.ext"));//FAILS WTF(1)
$contents = file_get_contents("http://user:[EMAIL 
PROTECTED]/some/path/eitherfile+with+spaces.ext");  //FAILS
WTF(2)


Warning:
file_get_contents(http://[EMAIL PROTECTED]/some/path/eitherfile+with+spaces.ext)
[function.file-get-contents]:
failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in
/the/script/index.php on line (the file_get_contents
line)

Yes, the files are there.

file_get_contents docs:
Note: If you're opening a URI with special characters, such as spaces,
you need to encode the URI with urlencode().

WTF?!?!
How do I get FAILS(1) and FAILS(2) to work, in light of FAILS WTF(1)
and FAILS WTF(2)?



Try replacing the '+' signs with %20.  Worked for me.


Or use http://www.php.net/rawurlencode

--
Postgresql & php tutorials
http://www.designmagick.com/


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



Re: [PHP] file_get_contents urlencode spaces: yeah right?

2008-11-10 Thread Maciek Sokolewicz

Dee Ayy wrote:

On Mon, Nov 10, 2008 at 5:26 PM, Dee Ayy <[EMAIL PROTECTED]> wrote:

My bad.

I urlencoded the %20 LOL

%20 works.



And just in time to go home.
Thanks.


if you use rawurlencode() instead of urlencode() this won't be a 
problem; since that does change spaces to %20 instead of +.


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



Re: [PHP] file_get_contents urlencode spaces: yeah right?

2008-11-10 Thread Dee Ayy
On Mon, Nov 10, 2008 at 5:26 PM, Dee Ayy <[EMAIL PROTECTED]> wrote:
> My bad.
>
> I urlencoded the %20 LOL
>
> %20 works.
>

And just in time to go home.
Thanks.

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



Re: [PHP] file_get_contents urlencode spaces: yeah right?

2008-11-10 Thread Dee Ayy
My bad.

I urlencoded the %20 LOL

%20 works.

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



Re: [PHP] file_get_contents urlencode spaces: yeah right?

2008-11-10 Thread Dee Ayy
> Have you tried to output the result of urlencode and paste the whole
> thing in a browser to make sure that it works?

The FF 3.0.3 browser likes
http://user:[EMAIL PROTECTED]/some/path/eitherfile with spaces.ext
and
http://user:[EMAIL PROTECTED]/some/path/eitherfile%20with%20spaces.ext
but NOT
http://user:[EMAIL PROTECTED]/some/path/eitherfile+with+spaces.ext
like Jim Lucas said.

Any thoughts on agent or server settings?

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



Re: [PHP] file_get_contents urlencode spaces: yeah right?

2008-11-10 Thread Jim Lucas
Dee Ayy wrote:
> PHP Version 5.1.6
> $contents = file_get_contents("http://user:[EMAIL 
> PROTECTED]/some/path/htmlfile.html"); 
>   //WORKS
> $contents = file_get_contents("http://user:[EMAIL 
> PROTECTED]/some/path/htmlfile
> with spaces.html");   //FAILS(1)
> $contents = file_get_contents("http://user:[EMAIL 
> PROTECTED]/some/path/nonhtmlfile.ext");   
>   //WORKS
> $contents = file_get_contents("http://user:[EMAIL 
> PROTECTED]/some/path/nonhtmlfile
> with spaces.ext");//FAILS(2)
> $contents = file_get_contents(urlencode("http://user:[EMAIL 
> PROTECTED]/some/path/eitherfile
> with spaces.ext"));   //FAILS BUT I DON'T REALLY CARE
> $contents = file_get_contents(urlencode("http://user:[EMAIL 
> PROTECTED]/some/path/eitherfilenospaces.ext"));   //FAILS
> BUT I DON'T REALLY CARE
> $contents = file_get_contents("http://user:[EMAIL 
> PROTECTED]/some/path/".urlencode("eitherfile
> with spaces.ext"));   //FAILS WTF(1)
> $contents = file_get_contents("http://user:[EMAIL 
> PROTECTED]/some/path/eitherfile+with+spaces.ext");  //FAILS
> WTF(2)
> 
> 
> Warning:
> file_get_contents(http://[EMAIL 
> PROTECTED]/some/path/eitherfile+with+spaces.ext)
> [function.file-get-contents]:
> failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in
> /the/script/index.php on line (the file_get_contents
> line)
> 
> Yes, the files are there.
> 
> file_get_contents docs:
> Note: If you're opening a URI with special characters, such as spaces,
> you need to encode the URI with urlencode().
> 
> WTF?!?!
> How do I get FAILS(1) and FAILS(2) to work, in light of FAILS WTF(1)
> and FAILS WTF(2)?
> 

Try replacing the '+' signs with %20.  Worked for me.

I had the same results as you on my server.  The only fix I found was to 
replace the + with %20.

Maybe the user agent & server are doing something special that 
file_get_contents() & server are not doing.

-- 
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare


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



Re: [PHP] file_get_contents urlencode spaces: yeah right?

2008-11-10 Thread Micah Gersten
Dee Ayy wrote:
> PHP Version 5.1.6
> $contents = file_get_contents("http://user:[EMAIL 
> PROTECTED]/some/path/htmlfile.html"); 
>   //WORKS
> $contents = file_get_contents("http://user:[EMAIL 
> PROTECTED]/some/path/htmlfile
> with spaces.html");   //FAILS(1)
> $contents = file_get_contents("http://user:[EMAIL 
> PROTECTED]/some/path/nonhtmlfile.ext");   
>   //WORKS
> $contents = file_get_contents("http://user:[EMAIL 
> PROTECTED]/some/path/nonhtmlfile
> with spaces.ext");//FAILS(2)
> $contents = file_get_contents(urlencode("http://user:[EMAIL 
> PROTECTED]/some/path/eitherfile
> with spaces.ext"));   //FAILS BUT I DON'T REALLY CARE
> $contents = file_get_contents(urlencode("http://user:[EMAIL 
> PROTECTED]/some/path/eitherfilenospaces.ext"));   //FAILS
> BUT I DON'T REALLY CARE
> $contents = file_get_contents("http://user:[EMAIL 
> PROTECTED]/some/path/".urlencode("eitherfile
> with spaces.ext"));   //FAILS WTF(1)
> $contents = file_get_contents("http://user:[EMAIL 
> PROTECTED]/some/path/eitherfile+with+spaces.ext");  //FAILS
> WTF(2)
>
> 
> Warning:
> file_get_contents(http://[EMAIL 
> PROTECTED]/some/path/eitherfile+with+spaces.ext)
> [function.file-get-contents]:
> failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in
> /the/script/index.php on line (the file_get_contents
> line)
>
> Yes, the files are there.
>
> file_get_contents docs:
> Note: If you're opening a URI with special characters, such as spaces,
> you need to encode the URI with urlencode().
>
> WTF?!?!
> How do I get FAILS(1) and FAILS(2) to work, in light of FAILS WTF(1)
> and FAILS WTF(2)?
>
>   

Have you tried to output the result of urlencode and paste the whole
thing in a browser to make sure that it works?

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



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



Re: [PHP] file_get_contents crash, if file is bigger than memory_limit

2007-06-24 Thread Jochem Maas
ecc wrote:
> I really dont know, if this is the right board for this... but i think, i
> have to write it down.

if your looking to post a feature request then there is no list for that
- the bug database would be the place to do it ... but please don't bother the
devs with your feature request - it won't happen for reasons that are public 
record.

> 
> Please throw an error, if file_get_contents cant read a file because
> memory_limit overflow!

go read the archives of [EMAIL PROTECTED] for numerous reasons why that
it not going to happen.

> 
> I´ve programmed a tool parsing checksums from large files. Because i have to
> manage header-offsets, i have to read the files using file_get_contents.

given that your own comment in the example below states "while loop reading
the data! (This works!)" I can't see why you *have* to use file_get_contents()

have you tried filesize() and chcked the result is less than memory_limit?

> (This should be the fastest way for this task says the manual... right!)
> 
> The problem is, that if the memory_limit in the php.ini is set to 64MB, and
> the file read in by file_get_contents is bigger than 64MB, file_get_contents
> crashes without an EXCETPION. This crash cant be catched!

why do you think it should throw an exception? it won't, especially not a
particular class of exception that you made up o the spot.

php errors and exceptions are 2 different things, before going any
further you should read up on both so that you understand the difference.

> 
> I want handle this this way:
> 
> try{
> $data = file_get_contents($file);
> }
> catch (MemoryLimitReachedException $e){
> // try the same using a while loop reading the data! (This works!)
> }
> 
> Hope, there is a solution for this.
> 
> Thank you.
> Andreas
> http://www.php-gtk.eu/apps/emucontrolcenter
> 

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



Re: [PHP] file_get_contents

2007-06-08 Thread Richard Lynch


On Thu, June 7, 2007 3:09 pm, Chris Boget wrote:
>>> What's going on?
>> That's the strangest absolute path I've ever seen... it seems to
>> have
>> some kind of non-absolute prefix.
>> This has been a troll >:)
>
> Pardon?  I'm not sure what you mean?

I think it was a Windows-bashing joke...

But maybe using Linux style pathnames would work...

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] file_get_contents

2007-06-08 Thread Richard Lynch
On Thu, June 7, 2007 2:39 pm, Chris Boget wrote:
> Does file_get_contents() not work with absolute paths?

Works for me.

In fact, I try to always use absolute paths so that I don't end up
affecting the totally wrong file.

> I'm able to
> successfully write data to a file that I create dynamically but when I
> go
> back to actually read the contents of the file, nothing seems to work.
>  Not
> file_get_contents(), not file(), not fread() and not fgets();
>
> $mydata = 'joebobbriggs';
> $filename = 'c:\\temp\\my_file_name.txt';
> $resource = fopen( $filename, 'w+' );
> fwrite( $resource, $mydata );
> fclose( $resource );

Perhaps a clearstatcache() here is needed???

I wouldn't expect it to be, but maybe...

> echo 'File data: ' . file_get_contents( $filename );
>
> Nothing gets displayed but I see that the file was created and that it
> has
> the data I defined.

Can you run it in a second script and get the file contents, without
opening and writing the file first?

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] file_get_contents

2007-06-07 Thread Robert Cummings
On Thu, 2007-06-07 at 16:09 -0400, Chris Boget wrote:
> >> What's going on?
> > That's the strangest absolute path I've ever seen... it seems to have
> > some kind of non-absolute prefix.
> > This has been a troll >:)
> 
> Pardon?  I'm not sure what you mean?

Just jabbing at windows :)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] file_get_contents

2007-06-07 Thread Chris Boget

What's going on?

That's the strangest absolute path I've ever seen... it seems to have
some kind of non-absolute prefix.
This has been a troll >:)


Pardon?  I'm not sure what you mean?

thnx,
Chris

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



Re: [PHP] file_get_contents

2007-06-07 Thread Robert Cummings
On Thu, 2007-06-07 at 15:39 -0400, Chris Boget wrote:
> Does file_get_contents() not work with absolute paths?  I'm able to 
> successfully write data to a file that I create dynamically but when I go 
> back to actually read the contents of the file, nothing seems to work.  Not 
> file_get_contents(), not file(), not fread() and not fgets();
> 
> $mydata = 'joebobbriggs';
> $filename = 'c:\\temp\\my_file_name.txt';
> $resource = fopen( $filename, 'w+' );
> fwrite( $resource, $mydata );
> fclose( $resource );
> 
> echo 'File data: ' . file_get_contents( $filename );
> 
> Nothing gets displayed but I see that the file was created and that it has 
> the data I defined.
> 
> What's going on?

That's the strangest absolute path I've ever seen... it seems to have
some kind of non-absolute prefix.

This has been a troll >:)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] file_get_contents and https

2007-05-31 Thread Bob Hanson

Problem solved. Thank you all very much for such quick responses.

The solution was to get ssleay32.dll from the PHP 5 ZIP distribution and 
put in my PHP directory.


For the record:

With Windows and PHP 5 all that is needed to use the https protocol in 
file_get_contents is to make sure that both


libeay32.dll
ssleay32.dll

are on the Windows path, which in my case includes the path to my PHP 
directory, so I just put them there.


Excellent! Many thanks.

Bob Hanson

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



Re: [PHP] file_get_contents and https

2007-05-31 Thread David Giragosian

On 5/31/07, Stut <[EMAIL PROTECTED]> wrote:


Bob Hanson wrote:
> Thanks, Jay.
>
> I tried it first with a simple "http://"; call, and that worked fine. So
> unless "https:..." requires something additional in the way of
> arguments, that doesn't seem to be the issue.
>
> I'm hoping someone who has done this remembers what special installation
> issues there might be. When I look on the web I see lots of discussion,
> but it's pretty hard to figure out how much of it is currently
> applicable and how much of it is ancient history.

Was PHP built with openssl enabled? If not, that's ya problem.



phpinfo() is your friend.

-Stut


> Jay Blanchard wrote:
>
>> [snip]
>> I am new to PHP; using Apache 2.2 and PHP 5/Windows. I'd like to do
>> this:
>>
>> $x = file_get_contents("https://user:[EMAIL PROTECTED]")
>>
>> I get:
>>
>> Warning: file_get_contents(https://...) [function.file-get-contents]:
>> failed to open stream: Invalid argument in ... on line...
>> [/snip]
>>
>> The warning that you get is "Invalid argument..." Have you read
>> http://us2.php.net/file_get_contents to make sure that you are
including
>> all needed arguments?
>>
>>
> The URL for file_get_contents doesn't give many clues to its use with
> https.



David


Re: [PHP] file_get_contents and https

2007-05-31 Thread Stut

Bob Hanson wrote:

Thanks, Jay.

I tried it first with a simple "http://"; call, and that worked fine. So 
unless "https:..." requires something additional in the way of 
arguments, that doesn't seem to be the issue.


I'm hoping someone who has done this remembers what special installation 
issues there might be. When I look on the web I see lots of discussion, 
but it's pretty hard to figure out how much of it is currently 
applicable and how much of it is ancient history.


Was PHP built with openssl enabled? If not, that's ya problem.

-Stut


Jay Blanchard wrote:


[snip]
I am new to PHP; using Apache 2.2 and PHP 5/Windows. I'd like to do
this:

$x = file_get_contents("https://user:[EMAIL PROTECTED]")

I get:

Warning: file_get_contents(https://...) [function.file-get-contents]: 
failed to open stream: Invalid argument in ... on line...

[/snip]

The warning that you get is "Invalid argument..." Have you read
http://us2.php.net/file_get_contents to make sure that you are including
all needed arguments?
 

The URL for file_get_contents doesn't give many clues to its use with 
https.





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



Re: [PHP] file_get_contents and https

2007-05-31 Thread Bob Hanson

Thanks, Jay.

I tried it first with a simple "http://"; call, and that worked fine. So 
unless "https:..." requires something additional in the way of 
arguments, that doesn't seem to be the issue.


I'm hoping someone who has done this remembers what special installation 
issues there might be. When I look on the web I see lots of discussion, 
but it's pretty hard to figure out how much of it is currently 
applicable and how much of it is ancient history.


Bob


Jay Blanchard wrote:


[snip]
I am new to PHP; using Apache 2.2 and PHP 5/Windows. I'd like to do
this:

$x = file_get_contents("https://user:[EMAIL PROTECTED]")

I get:

Warning: file_get_contents(https://...) [function.file-get-contents]: 
failed to open stream: Invalid argument in ... on line...

[/snip]

The warning that you get is "Invalid argument..." Have you read
http://us2.php.net/file_get_contents to make sure that you are including
all needed arguments?
 

The URL for file_get_contents doesn't give many clues to its use with 
https.



--
Robert M. Hanson
Professor of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr


If nature does not answer first what we want,
it is better to take what answer we get. 


-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900

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



RE: [PHP] file_get_contents and https

2007-05-31 Thread Jay Blanchard
[snip]
I am new to PHP; using Apache 2.2 and PHP 5/Windows. I'd like to do
this:

$x = file_get_contents("https://user:[EMAIL PROTECTED]")

I get:

Warning: file_get_contents(https://...) [function.file-get-contents]: 
failed to open stream: Invalid argument in ... on line...
[/snip]

The warning that you get is "Invalid argument..." Have you read
http://us2.php.net/file_get_contents to make sure that you are including
all needed arguments?

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



Re: [PHP] file_get_contents

2007-02-06 Thread scotdiddle

Steven,

I asked this same question a week or so on the ZEND PHP Fourm

See the answer to my post for an elegant solution:

http://www.zend.com/forums/index.php?t=msg&th=2977&start=0&S=fe14095d33458d18b9bc49ea04a9a13b

Scot L. Diddle, Richmond VA





Quoting Steven Macintyre <[EMAIL PROTECTED]>:


Hiya,

I need to be able to read a file into a string - I have used the above
command and it works ... now ... I need to read a file into a string - that
requires a username and password to access the authentication is normal HTTP
basic realm

Any ideas?



Kind Regards


Steven Macintyre

--

www.friends4friends.co.za

--
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



Re: [PHP] file_get_contents gets 404 error

2007-01-12 Thread Németh Zoltán
2007. 01. 11, csütörtök keltezéssel 22.11-kor Frank Arensmeier ezt írta:
> In the manual it says:
> 
> "You can use a URL as a filename with this function if the fopen  
> wrappers have been enabled...".
> 
> First of all, I would check your php.ini file. If everything is ok  
> (fopen wrappers are on), maybe you could post some code. The last  
> option would be to use an other way round by using e.g. curl or  
> anything else. If anybody else is able to open the URL you provided,  
> it must be either you code or your server / PHP config that is  
> messing things up.
> 
> //frank

Yes, fopen wrappers were on.
However, together with our system administrator we could solve the
problem.
The problem itself was with apache configuration. As I was running
file_get_contents on the server that contains the site I wanted to get,
apache translated the request to 127.0.0.1 which resulted in 404 since
there is no webpage for 127.0.0.1.
The sysadmin made some changes in apache config and after that it is
working fine.

Thanks
Zoltán Németh

> 11 jan 2007 kl. 17.01 skrev Németh Zoltán:
> 
> > 2007. 01. 11, csütörtök keltezéssel 16.55-kor Jochem Maas ezt írta:
> >> Németh Zoltán wrote:
> >>> Hi all,
> >>>
> >>> I have some php websites, for example http://www.alterationx.hu/
> >>>
> >>> Now I'm trying to get the site with file_get_contents, and I'm  
> >>> getting
> >>> this error:
> >>>
> >>> Warning: file_get_contents(http://www.alterationx.hu/): failed to  
> >>> open
> >>> stream: HTTP request failed! HTTP/1.1 404 Not Found
> >>
> >> try this?:
> >>
> >> file_get_contents("http://www.alterationx.hu/index.php";);
> >>
> >> (it works for me. that said it works for me without the  
> >> 'index.php' at the end also.)
> >
> > I tried this also, and get the same error still...
> >
> >>
> >> also check you logs on the site in question to figure out what  
> >> exactly is going
> >> on (i.e. what is being requested, if anything).
> >
> > Yes, I'll contact our system administrator to check the apache logs
> >
> > Thanks
> > Zoltán Németh
> >
> >>
> >>>
> >>> can anyone tell me why?
> >>>
> >>> The site otherwise is working, and also getting other sites (not  
> >>> php) on
> >>> the same server with file_get_contents is working.
> >>>
> >>> Thanks in advance
> >>> Zoltán Németh
> >>>
> >>
> >
> > -- 
> > 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



Re: [PHP] file_get_contents gets 404 error

2007-01-11 Thread Frank Arensmeier

In the manual it says:

"You can use a URL as a filename with this function if the fopen  
wrappers have been enabled...".


First of all, I would check your php.ini file. If everything is ok  
(fopen wrappers are on), maybe you could post some code. The last  
option would be to use an other way round by using e.g. curl or  
anything else. If anybody else is able to open the URL you provided,  
it must be either you code or your server / PHP config that is  
messing things up.


//frank
11 jan 2007 kl. 17.01 skrev Németh Zoltán:


2007. 01. 11, csütörtök keltezéssel 16.55-kor Jochem Maas ezt írta:

Németh Zoltán wrote:

Hi all,

I have some php websites, for example http://www.alterationx.hu/

Now I'm trying to get the site with file_get_contents, and I'm  
getting

this error:

Warning: file_get_contents(http://www.alterationx.hu/): failed to  
open

stream: HTTP request failed! HTTP/1.1 404 Not Found


try this?:

file_get_contents("http://www.alterationx.hu/index.php";);

(it works for me. that said it works for me without the  
'index.php' at the end also.)


I tried this also, and get the same error still...



also check you logs on the site in question to figure out what  
exactly is going

on (i.e. what is being requested, if anything).


Yes, I'll contact our system administrator to check the apache logs

Thanks
Zoltán Németh





can anyone tell me why?

The site otherwise is working, and also getting other sites (not  
php) on

the same server with file_get_contents is working.

Thanks in advance
Zoltán Németh





--
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



Re: [PHP] file_get_contents gets 404 error

2007-01-11 Thread Németh Zoltán
2007. 01. 11, csütörtök keltezéssel 16.55-kor Jochem Maas ezt írta:
> Németh Zoltán wrote:
> > Hi all,
> > 
> > I have some php websites, for example http://www.alterationx.hu/
> > 
> > Now I'm trying to get the site with file_get_contents, and I'm getting
> > this error:
> > 
> > Warning: file_get_contents(http://www.alterationx.hu/): failed to open
> > stream: HTTP request failed! HTTP/1.1 404 Not Found
> 
> try this?:
> 
> file_get_contents("http://www.alterationx.hu/index.php";);
> 
> (it works for me. that said it works for me without the 'index.php' at the 
> end also.)

I tried this also, and get the same error still...

> 
> also check you logs on the site in question to figure out what exactly is 
> going
> on (i.e. what is being requested, if anything).

Yes, I'll contact our system administrator to check the apache logs

Thanks
Zoltán Németh

> 
> > 
> > can anyone tell me why?
> > 
> > The site otherwise is working, and also getting other sites (not php) on
> > the same server with file_get_contents is working.
> > 
> > Thanks in advance
> > Zoltán Németh
> > 
> 

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



Re: [PHP] file_get_contents gets 404 error

2007-01-11 Thread Jochem Maas
Németh Zoltán wrote:
> Hi all,
> 
> I have some php websites, for example http://www.alterationx.hu/
> 
> Now I'm trying to get the site with file_get_contents, and I'm getting
> this error:
> 
> Warning: file_get_contents(http://www.alterationx.hu/): failed to open
> stream: HTTP request failed! HTTP/1.1 404 Not Found

try this?:

file_get_contents("http://www.alterationx.hu/index.php";);

(it works for me. that said it works for me without the 'index.php' at the end 
also.)

also check you logs on the site in question to figure out what exactly is going
on (i.e. what is being requested, if anything).

> 
> can anyone tell me why?
> 
> The site otherwise is working, and also getting other sites (not php) on
> the same server with file_get_contents is working.
> 
> Thanks in advance
> Zoltán Németh
> 

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



Re: [PHP] file_get_contents

2006-11-17 Thread Jochem Maas
Stut wrote:
> Tom Chubb wrote:
>> The host support team told me that:
>> Our servers do not allows a HTTP connection onto itself. This is a
>> security precaution to stop recursive code. 

morons

';
teachTheIdiotSysAdmin();
}

?>

>> You can try to reference
>> the code by path rather than HTTP
>> ...which works fine!
> 
> Won't something like this work...
> 
> ob_start();
> // If needed you can set up vars used by player.php here
> include('player.php');
> $code = ob_get_contents();
> ob_end_clean();
> 
> That will capture any output from player.php and stuff it into $code.
> Much nicer than anything else suggested so far.

yes indeed - actually this is the best solution - no eval, no extra
request. good catch Stut

> 
> -Stut
> 

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



Re: [PHP] file_get_contents

2006-11-17 Thread Stut

Tom Chubb wrote:

The host support team told me that:
Our servers do not allows a HTTP connection onto itself. This is a
security precaution to stop recursive code. You can try to reference
the code by path rather than HTTP
...which works fine!


Won't something like this work...

ob_start();
// If needed you can set up vars used by player.php here
include('player.php');
$code = ob_get_contents();
ob_end_clean();

That will capture any output from player.php and stuff it into $code. 
Much nicer than anything else suggested so far.


-Stut

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



Re: [PHP] file_get_contents

2006-11-17 Thread Tom Chubb

The host support team told me that:
Our servers do not allows a HTTP connection onto itself. This is a
security precaution to stop recursive code. You can try to reference
the code by path rather than HTTP
...which works fine!



On 17/11/06, Tom Chubb <[EMAIL PROTECTED]> wrote:

Very interesting!
I have a reseller account and on another site, the DNS entries were
messed up by the host. Could be a similar problem.
Thanks

On 17/11/06, Stut <[EMAIL PROTECTED]> 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?!?
> > Permissions are 755.
> > Obviously I was getting it when using file_get_contents('player.php')
> > but when using the URL I get connection refused.
>
> The domain www.tnhosting.co.uk is probably not resolving to the right IP
> when used from that box. Can't think of any other reason that would work
> remotely but not locally.
>
> -Stut
>




--
Tom Chubb
[EMAIL PROTECTED]
07915 053312

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



Re: [PHP] file_get_contents

2006-11-17 Thread Tom Chubb

Very interesting!
I have a reseller account and on another site, the DNS entries were
messed up by the host. Could be a similar problem.
Thanks

On 17/11/06, Stut <[EMAIL PROTECTED]> 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?!?
> Permissions are 755.
> Obviously I was getting it when using file_get_contents('player.php')
> but when using the URL I get connection refused.

The domain www.tnhosting.co.uk is probably not resolving to the right IP
when used from that box. Can't think of any other reason that would work
remotely but not locally.

-Stut



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



Re: [PHP] file_get_contents

2006-11-17 Thread Tom Chubb

On 17/11/06, Jochem Maas <[EMAIL PROTECTED]> 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('/(.*)/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 "" .
phpWrapper($content) . "";


Bit messy, but it works at least. :D
Thanks for your help though.

T

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



Re: [PHP] file_get_contents

2006-11-17 Thread Stut

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?!?
Permissions are 755.
Obviously I was getting it when using file_get_contents('player.php')
but when using the URL I get connection refused.


The domain www.tnhosting.co.uk is probably not resolving to the right IP 
when used from that box. Can't think of any other reason that would work 
remotely but not locally.


-Stut

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



Re: [PHP] file_get_contents

2006-11-17 Thread Jochem Maas
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

> 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.

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.

> 


...

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



Re: [PHP] file_get_contents

2006-11-16 Thread Tom Chubb

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?!?
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)

BTW, Brad, I was stripping the HTML tags around the object ok, but I'm
echoing variables in player.php.
$song_url & $song_title, are read from a seperate file after upload
and that is what's being updated by this script, but the textarea was
showing the php code.

Thanks for your patience, guys.

T



On 16/11/06, Jochem Maas <[EMAIL PROTECTED]> wrote:

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)
==


Test Audio Player








http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"; 
width="400" height="15">
 
 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 "/>
 
 
 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";> 






>
> 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 <[EMAIL PROTECTED]> 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('/(.*)/s', $player, $matches)) {
>> > $code = $matches[1];
>> > }
>> > echo "" . $code .
>>
>> htmlentities($code)
>>
>> > "";
>> > echo "";
>> > echo "Click Here 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
>> >
>>
>>
>
>




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



RE: [PHP] file_get_contents

2006-11-16 Thread Brad Fuller

Yes, I realize that now ;)

I didn't read it thoroughly enough before I posted :P

I think what Tom is referring to as "PHP code" is just the extra HTML tags
around the object tag that he is trying to strip out.

Tom -

Try this:

http://www.tnhosting.co.uk/scripts/gclub/player.php";);

$nstart = strpos($code, '');
$nstop  = strpos($code, '');

echo "" . substr($code, $nstart, $nstop-$nstart) . "";

?>

> -Original Message-
> From: Jochem Maas [mailto:[EMAIL PROTECTED]
> Sent: Thursday, November 16, 2006 11:12 AM
> To: Brad Fuller
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] file_get_contents
> 
> Brad Fuller wrote:
> > Use curl or fopen() to make a request to that PHP page, instead of
> reading
> > in the actual contents of the file.
> 
> heh Brad  wtf do you think thw following line does??:
> 
> $html =
> file_get_contents("http://www.tnhosting.co.uk/scripts/gclub/player.php";);
> 
> >
> > Example:
> >
> >  >
> > $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 "" . $buffer . "";
> >
> > ?>
> >
> >> -Original Message-
> >> From: Tom Chubb [mailto:[EMAIL PROTECTED]
> >> Sent: Thursday, November 16, 2006 10:49 AM
> >> To: [php] PHP General List
> >> Subject: Re: [PHP] 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 <[EMAIL PROTECTED]> 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('/(.*)/s', $player, $matches)) {
> >>>> $code = $matches[1];
> >>>> }
> >>>> echo "" . $code .
> >>> htmlentities($code)
> >>>
> >>>> "";
> >>>> echo "";
> >>>> echo "Click Here 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
> >> [EMAIL PROTECTED]
> >> 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



Re: [PHP] file_get_contents

2006-11-16 Thread Jochem Maas
Brad Fuller wrote:
> Use curl or fopen() to make a request to that PHP page, instead of reading
> in the actual contents of the file.

heh Brad  wtf do you think thw following line does??:

$html = 
file_get_contents("http://www.tnhosting.co.uk/scripts/gclub/player.php";);

> 
> Example:
> 
>  
> $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 "" . $buffer . "";
> 
> ?>
> 
>> -Original Message-
>> From: Tom Chubb [mailto:[EMAIL PROTECTED]
>> Sent: Thursday, November 16, 2006 10:49 AM
>> To: [php] PHP General List
>> Subject: Re: [PHP] 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 <[EMAIL PROTECTED]> 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('/(.*)/s', $player, $matches)) {
>>>> $code = $matches[1];
>>>> }
>>>> echo "" . $code .
>>> htmlentities($code)
>>>
>>>> "";
>>>> echo "";
>>>> echo "Click Here 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
>> [EMAIL PROTECTED]
>> 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



Re: [PHP] file_get_contents

2006-11-16 Thread Jochem Maas
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)
==


Test Audio Player








http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0";
 width="400" height="15">
  
  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 "/>
  
  
  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";> 






> 
> 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 <[EMAIL PROTECTED]> 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('/(.*)/s', $player, $matches)) {
>> > $code = $matches[1];
>> > }
>> > echo "" . $code .
>>
>> htmlentities($code)
>>
>> > "";
>> > echo "";
>> > echo "Click Here 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
>> >
>>
>>
> 
> 

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



RE: [PHP] file_get_contents

2006-11-16 Thread Brad Fuller

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

Example:

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 "" . $buffer . "";

?>

> -Original Message-
> From: Tom Chubb [mailto:[EMAIL PROTECTED]
> Sent: Thursday, November 16, 2006 10:49 AM
> To: [php] PHP General List
> Subject: Re: [PHP] 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 <[EMAIL PROTECTED]> 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('/(.*)/s', $player, $matches)) {
> > > $code = $matches[1];
> > > }
> > > echo "" . $code .
> >
> > htmlentities($code)
> >
> > > "";
> > > echo "";
> > > echo "Click Here 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
> [EMAIL PROTECTED]
> 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



Re: [PHP] file_get_contents

2006-11-16 Thread Tom Chubb

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 <[EMAIL PROTECTED]> 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('/(.*)/s', $player, $matches)) {
> $code = $matches[1];
> }
> echo "" . $code .

htmlentities($code)

> "";
> echo "";
> echo "Click Here 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
[EMAIL PROTECTED]
07915 053312

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



Re: [PHP] file_get_contents

2006-11-16 Thread Jochem Maas
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('/(.*)/s', $player, $matches)) {
> $code = $matches[1];
> }
> echo "" . $code .

htmlentities($code)

> "";
> echo "";
> echo "Click Here 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
> 

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



RE: [PHP] file_get_contents / url wrappers

2006-03-27 Thread Shaunak Kashyap
It is possible that the site is rejecting the script since it is not a
browser. You can fake a browser by using the User-Agent header.

I am also going to take the liberty to suggest an alternate means to the
same end. If you are on a *nix system you can run the wget command to
connect to the site and retrieve the data. With the right options to
wget the user agent can be faked and the output be sent to stdout. Then
using output buffering you can capture the output to a string.

Shaunak Kashyap
 
Senior Web Developer
WPT Enterprises, Inc.
5700 Wilshire Blvd., Suite 350
Los Angeles, CA 90036
 
Direct: 323.330.9870
Main: 323.330.9900
 
www.worldpokertour.com
 
Confidentiality Notice:  This e-mail transmission (and/or the
attachments accompanying) it may contain confidential information
belonging to the sender which is protected.  The information is intended
only for the use of the intended recipient.  If you are not the intended
recipient, you are hereby notified that any disclosure, copying,
distribution or taking of any action in reliance on the contents of this
information is prohibited. If you have received this transmission in
error, please notify the sender by reply e-mail and destroy all copies
of this transmission.


> -Original Message-
> From: Mike Dunlop [mailto:[EMAIL PROTECTED]
> Sent: Monday, March 27, 2006 2:15 PM
> To: php-general@lists.php.net
> Subject: [PHP] file_get_contents / url wrappers
> 
> Hi gang,
> 
> If i am trying to read the contents of url into a string and I am
> getting 403 errors yet the page will load perfectly through a normal
> browser, do u think the site is looking at the http request headers
> and determining it's not a browser and thus blocking access? If
> something like that was happening, does anyone know what headers i
> should put into a request to simulate a browser?
> 
> error msg :: <...> failed to open stream: HTTP request failed! HTTP/
> 1.1 403 Forbidden in <...>
> 
> Any info is much appreciated.
> 
> Thanks - MD
> 
> ...
> Mike Dunlop
> Director of Technology Development
> [ e ] [EMAIL PROTECTED]
> [ p ] 323.644.7808
> 

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



Re: [PHP] File_get_contents()

2005-04-07 Thread Josip Dzolonga
Jeff McKeon wrote:
Does anyone know if it's possible to have file_get_contents() accept a
file handle?
 

Why would you need that ?
--
Josip Dzolonga
http://josip.dotgeek.org
jdzolonga[at]gmail.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] File_get_contents()

2005-04-07 Thread Jeff McKeon
Because I was unclear on how file_get_contents() worked... :o)

The php manual is a little vague on the topic.

Best Reguards,

Jeff McKeon
IT Manager
Telaurus Communications LLC
[EMAIL PROTECTED]
+1 (973) 889-8990 

> -Original Message-
> From: Josip Dzolonga [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, April 07, 2005 8:11 AM
> To: Jeff McKeon
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] File_get_contents()
> 
> 
> Jeff McKeon wrote:
> 
> >Does anyone know if it's possible to have 
> file_get_contents() accept a 
> >file handle?
> >  
> >
> Why would you need that ?
> 
> -- 
> Josip Dzolonga
> http://josip.dotgeek.org
> 
> jdzolonga[at]gmail.com
> 
> 

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



RE: [PHP] File_get_contents()

2005-04-07 Thread Jeff McKeon
Thanks!!!

> -Original Message-
> From: Franklin van de Meent [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, April 07, 2005 7:34 AM
> To: php-general@lists.php.net
> Subject: Re: [PHP] File_get_contents()
> 
> 
> If you have set allow_url_fopen to On in your php.ini, 
> file_get_contents('php://stdin'); should work
> 
> 
> On Apr 7, 2005 2:21 PM, Jeff McKeon <[EMAIL PROTECTED]> wrote:
> > 
> > Sorry,
> > 
> > What I'm actually doing is this.
> > 
> > $handle=fopen("php//stdin/","r");
> > file_get_contents($handle);
> > 
> > I should have put that in the original post, my bad.
> > 
> > Now that I look at it, does anyone think this would work...
> > 
> > file_get_contents("php//stdin/");
> > 
> > --
> > 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
> 
> 

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



Re: [PHP] File_get_contents()

2005-04-07 Thread Franklin van de Meent
If you have set allow_url_fopen to On in your php.ini,
file_get_contents('php://stdin'); should work


On Apr 7, 2005 2:21 PM, Jeff McKeon <[EMAIL PROTECTED]> wrote:
> 
> Sorry,
> 
> What I'm actually doing is this.
> 
> $handle=fopen("php//stdin/","r");
> file_get_contents($handle);
> 
> I should have put that in the original post, my bad.
> 
> Now that I look at it, does anyone think this would work...
> 
> file_get_contents("php//stdin/");
> 
> --
> 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



Re: [PHP] File_get_contents()

2005-04-07 Thread Jason Wong
On Thursday 07 April 2005 20:21, Jeff McKeon wrote:

> Now that I look at it, does anyone think this would work...
>
> file_get_contents("php//stdin/");

That should be:

  'php://stdin'

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

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



RE: [PHP] File_get_contents()

2005-04-07 Thread Jeff McKeon
> 
> > -Original Message-
> > From: Jeff McKeon [mailto:[EMAIL PROTECTED]
> > Sent: 7 April 2005 1:03 pm
> > To: php-general@lists.php.net
> > Subject: [PHP] File_get_contents()
> >
> >
> > Does anyone know if it's possible to have 
> file_get_contents() accept a 
> > file handle?
> >
> > $handle=fopen("/tmp/file","r");
> > file_get_contents($handle);
> >
> > This doesn't seem to work for me, it generates an error about first 
> > parameter needing to be a string.
> >
> > I've tried:
> >
> > file_get_contents('{$handle}');
> >
> > But that doesn't work either...
> >
> > Thanks,
> >
> > jeff
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> 

> -Original Message-
> From: George Pitcher [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, April 07, 2005 7:17 AM
> To: Jeff McKeon
> Subject: RE: [PHP] File_get_contents()
> 
> 
> Jeff,
> 
> Do you need to give it a handle? You can just point 
> 'file_get_contents' to the file, unopened.
> 
> eg: file_get_contents("/tmp/file");
> 
> 'file_get_contents' can only read the contents so there's no 
> requirement to set a 'read' option.
> 
> George
> 

Sorry,

What I'm actually doing is this.

$handle=fopen("php//stdin/","r");
file_get_contents($handle);

I should have put that in the original post, my bad.

Now that I look at it, does anyone think this would work...

file_get_contents("php//stdin/"); 

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



Re: [PHP] file_get_contents ( string filename [, int use_include_path])

2002-08-14 Thread Bas Jobsen

> string filename
The name of the file. b.e test.html or $_SERVER['DOCUMENT_ROOT'].'test.html'
> int use_include_path
Optional 1 true or 0 (or nothing) false the file above is in my default 
include path.
Manual: you can use the optional second parameter and set it to "1", if you 
want to search for the file in the include_path, too. 

The default include path is defined in your php.ini:
Specifies a list of directories where the require(), include() and 
fopen_with_path() functions look for files. 

So call it like:
$string_with_file_contents=('file_with_the_wanted_content.ext');
 

Op donderdag 15 augustus 2002 00:06, schreef [EMAIL PROTECTED]:
> Can someone explain me more abou the usage of this code:
>
> file_get_contents ( string filename [, int use_include_path])
>
> I just got it from the annual, and I still don't get what they mean by
>
> string filename
>
> and
>
> int use_include_path
>
> Thanks,
>
> This has to do with the other question I posted earlier, yes
>
> - Vic
>
>
>
> __
> Post your ad for free now! http://personals.yahoo.ca

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