[PHP] Re: file_get_contents doesn't work on one particular server

2009-04-29 Thread Shawn McKenzie
Shawn McKenzie wrote:
> Brian Dunning wrote:
>> Howdy all - We have a production server that runs our script fine. We're
>> setting up a test server, and this particular script returns a length of
>> zero:
>>
>> $ctx = stream_context_create(array('http' => array('timeout' => 1200)));
>> // 20 minutes per file
>> $contents = file_get_contents($full_url, 0, $ctx);
>>
>> You can paste the $full_url into a browser and it works fine (it's
>> always a PDF document). It works fine with the same variables on the
>> production server. Is there some configuration option that we've missed
>> that's preventing it from working? Note that this is all https, and I
>> did notice this difference in the phpinfo() but don't know if it's
>> relevant:
>>
>> Production server: PHP 5.2.6
>> Registered PHP streams: php, file, data, http, ftp, compress.zlib,
>> compress.bzip2, https, ftps, zip
>>
>> Test server: PHP 5.2.9-2
>> Registered PHP streams: php, file, data, http, ftp, compress.zlib
>>
>>
> 
> Most likely allow_url_fopen = Off in the test server php.ini.  If you
> had error reporting on it would tell you.
> 

Sorry, didn't pay attention to the registered streams :-(

You need to install a PHP package with ssl or compile it with
--with-openssl.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



[PHP] Re: file_get_contents doesn't work on one particular server

2009-04-29 Thread Shawn McKenzie
Brian Dunning wrote:
> Howdy all - We have a production server that runs our script fine. We're
> setting up a test server, and this particular script returns a length of
> zero:
> 
> $ctx = stream_context_create(array('http' => array('timeout' => 1200)));
> // 20 minutes per file
> $contents = file_get_contents($full_url, 0, $ctx);
> 
> You can paste the $full_url into a browser and it works fine (it's
> always a PDF document). It works fine with the same variables on the
> production server. Is there some configuration option that we've missed
> that's preventing it from working? Note that this is all https, and I
> did notice this difference in the phpinfo() but don't know if it's
> relevant:
> 
> Production server: PHP 5.2.6
> Registered PHP streams: php, file, data, http, ftp, compress.zlib,
> compress.bzip2, https, ftps, zip
> 
> Test server: PHP 5.2.9-2
> Registered PHP streams: php, file, data, http, ftp, compress.zlib
> 
> 

Most likely allow_url_fopen = Off in the test server php.ini.  If you
had error reporting on it would tell you.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



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

2007-06-24 Thread Jochem Maas
it's difficult to read.
why?
don't top post.

oh and please post to the list.

[EMAIL PROTECTED] wrote:
> 1. I dont know, if this is an feature request

well you're the only one who might.

> 
>>> 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()
> 
> Hm, strange answer, i think. Do you ever have used the file functions of php. 
> Why the developers of php say, that file_get_contents is the way to read 
> files? Maybe because its faster then a while contruct.

was it ever said that it's the only way?

> Or am i wrong?
> 
>>> have you tried filesize() and chcked the result is less than memory_limit?
> Thats an good answer, but i think, the can also be done by php internally + 
> throwing an exception :-)

ah so you were there when php core developers decided that BC would be 
completely broken and
all core errors would be throw as exceptions? me, I must have missed that.
php exceptions are generally a user level construct - the php core generates 
error not exceptions
(with the exception of a few OO based php extensions [php intended])

you might consider that you probably need to work with a tool for a little 
longer than
5 minutes before being in a position to determine whether a change to the tool 
is possible or
desirable. php is used by 100,000's of people changing the language is not 
something
you do 'just like that'

> Maybe i have to read the [EMAIL PROTECTED] strange, this is like the 
> hitchhiker. Read the hidden manual! 
> Never head before of this internals 
> if you are a php core developer.  i´m not, 

I'm not a core developer either, but that doesn't stop me following development 
issues
and discussions on their mailing list.

> i´m a stupid little programmer!

you said it not me, guv.

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

> Never head of Pseudocode, examples?? Dont know, how to name this Exception... 
> if you have an better name... "WhateverException"
> 
> Ok, das musste raus... ist nicht so gemeint :-) 

I'm dutch, I don't speak german - I can guess at the meaning of the above but 
for the sake of
everyone else stick to english, the language used on this list, please.

> 
> Gruß,
> Andreas
> 
> 
> 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] Re: file_get_contents

2007-02-06 Thread Richard Lynch
On Tue, February 6, 2007 7:53 am, Colin Guthrie wrote:
> Steven Macintyre wrote:
>> 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?
>
> $var =
> file_get_contents('http://username:[EMAIL 
> PROTECTED]/path/to/secret/file.txt');
>
> This is standard web syntax - e.g. it will work in a web browser,
> wget,
> curl, etc.

Actually, IE is dropping (has dropped?) support for the
username:password part because their users are too dumb to chop out
their password before posting their URL or something...

I found this in some KB article somewhere, I think...

They didn't actually express it as user stupidity, mind you. :-)

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving 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



[PHP] Re: file_get_contents

2007-02-06 Thread Colin Guthrie
Steven Macintyre wrote:
> 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?

$var =
file_get_contents('http://username:[EMAIL PROTECTED]/path/to/secret/file.txt');

This is standard web syntax - e.g. it will work in a web browser, wget,
curl, etc.

Col.

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



[PHP] Re: File_get_contents()

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

file_get_contents() does the file handle operations internally, so it
only expects the name of the file.  If you want to use file handles
yourself, then you should just fopen(), fread(), and fclose().

--
Teach a man to fish...

NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins


signature.asc
Description: OpenPGP digital signature


[PHP] Re: file_get_contents source??

2002-04-19 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Giovanni Lenzi) wrote:

> file_get_contents function is supposed to return the contents of a file in a
> binary safe manner. I tried it on two different servers which has different
> versions of APACHE+PHP but it still not works.
> The server give me this response:
> 
> Fatal error: Call to undefined function: file_get_contents() in
> /usr/home/s/a/sauzer/public_html/sfidario/readstreams/1.0/warsupcoming.php
> on line 17

>From : "file_get_contents (PHP 4 CVS 
only)".  That's why it's not in your version.  Reading further, it says 
"Identical to readfile(), except that file_get_contents() returns the file 
in a string."  So if don't need to do additional manipulation of the 
contents, there is one viable alternative.  The user annotations suggest 
two additional alternatives.

-- 
CC

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