[PHP] file_get_contents() failing on CentOS.
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
Re: [PHP] Which PHP 5.3 documentation generators have you found?
On 29 September 2010 20:07, Adam Richardson wrote: > On Wed, Sep 29, 2010 at 2:54 PM, a...@ashleysheridan.co.uk < > a...@ashleysheridan.co.uk> wrote: > >> Does phpDocumenter not do the trick? I must admit, I've not tried anything >> specific to 5.3 (i can imagine the namespace thing would be a major part if >> the documentation) but its served me well with other php5 code. >> >> >> > In the past I've been really pleased using phpDocumentor, however I'm afraid > the namespaces in 5.3 cause it to choke :( > > Adam > > -- > Nephtali: PHP web framework that functions beautifully > http://nephtaliproject.com > Gently side-stepping the namespace issue, I've used phpDocumentor with the ExtJS extension to make really nice documentation (http://zymengine.com/dev/news/30-phpdoc-extjs-converter-template). There are a few issues (http://code.google.com/p/zym/issues/list). I've resolved some and supplied patches. -- 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
[PHP] version_compare
I found this code... if (version_compare(PHP_VERSION, '5.2.0', '>=')) { $text=filter_var($text, FILTER_SANITIZE_URL); } ...to be questionable. Under what conditions would version_compare() return true, yet the filter_var() be undefined? Because that's what is happening. Thank you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Database Administration
Thanks for the replies, they have been most enlightening. :)
Re: [PHP] version_compare
On Thu, Sep 30, 2010 at 9:43 PM, Brian Smither wrote: > > I found this code... > if (version_compare(PHP_VERSION, '5.2.0', '>=')) { It means condition (PHP_VERSION >= 5.2.0) > $text=filter_var($text, FILTER_SANITIZE_URL); > } > > ...to be questionable. > > Under what conditions would version_compare() return true, yet the > filter_var() be undefined? Because that's what is happening. > > Thank you. > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Shiplu Mokadd.im My talks, http://talk.cmyweb.net Follow me, http://twitter.com/shiplu SUST Programmers, http://groups.google.com/group/p2psust Innovation distinguishes bet ... ... (ask Steve Jobs the rest) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] version_compare
On Thu, Sep 30, 2010 at 09:43:22AM -0600, Brian Smither wrote: > > I found this code... > if (version_compare(PHP_VERSION, '5.2.0', '>=')) { > $text=filter_var($text, FILTER_SANITIZE_URL); > } > > ...to be questionable. > > Under what conditions would version_compare() return true, yet the > filter_var() be undefined? Because that's what is happening. If your PHP was compiled without support for the filter functions? I assume when you say that filter_var() is "undefined" you mean that the software returns a message that the function itself cannot be found? Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] version_compare
Brian Smither wrote: > I found this code... > if (version_compare(PHP_VERSION, '5.2.0', '>=')) { > $text=filter_var($text, FILTER_SANITIZE_URL); > } > > ...to be questionable. > > Under what conditions would version_compare() return true, yet the > filter_var() be undefined? Because that's what is happening. > > Thank you. > > > > Personally, I would change that to be if ( function_exists('filter_var') ) { $text = filter_var($text, FILTER_SANITIZE_URL); } Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] version_compare
>Personally, I would change that to be >if ( function_exists('filter_var') ) { So would I: *But it's not my code. *I wish to learn and understand the cause of the problem - not walk around it. >It means condition (PHP_VERSION >= 5.2.0) I understand that. There was a second, more relevant, part to my question. I have found the version of PHP used as reported in the HTTP header responses. filter_var() is undefined in PHP/5.2.4_p20070914-pl2-gentoo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Which PHP 5.3 documentation generators have you found?
On Wed, 29 Sep 2010, Adam Richardson wrote: > Hi all, > > Anybody know of a documentation generator which plays nicely with PHP > 5.3? I've always been a fan of phpDocumentor. -- Erik Arneson GPG Key ID : 1024D/62DA1D25 BitCoin : 1LqvuGUqJ4ZUSoE7YE9ngETjwp4yZ2uSdP Office : +1.541.291.9776Skype : callto://pymander http://www.leisurenouveau.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] version_compare
Brian Smither wrote: >> Personally, I would change that to be >> if ( function_exists('filter_var') ) { > > So would I: > *But it's not my code. > *I wish to learn and understand the cause of the problem - not walk around it. > >> It means condition (PHP_VERSION >= 5.2.0) > > I understand that. There was a second, more relevant, part to my question. > > I have found the version of PHP used as reported in the HTTP header responses. > > filter_var() is undefined in PHP/5.2.4_p20070914-pl2-gentoo > As Paul pointed out, maybe your version of PHP was built without the filter_var function compiled in. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Which PHP 5.3 documentation generators have you found?
On Thu, Sep 30, 2010 at 2:30 PM, Erik L. Arneson wrote: > On Wed, 29 Sep 2010, Adam Richardson wrote: > > Hi all, > > > > Anybody know of a documentation generator which plays nicely with PHP > > 5.3? > > I've always been a fan of phpDocumentor. > > I agree, it's worked very well in the past. However, it looks like it's been a while since a new release: http://www.phpdoc.org/news.php?id=57 My code makes extensive use of namespaces and other new features found within PHP 5.3, and these don't appear to be supported within phpDocumentor. Any other options? Adam -- Nephtali: PHP web framework that functions beautifully http://nephtaliproject.com
[PHP] filter_var (was: Re: [PHP] version_compare)
>As Paul pointed out, maybe your version of PHP was built without the >filter_var function compiled in. This is what I have learned about PHP with filter_var() as an illustrative point: Many people who provide elaborations on PHP make too many assumptions or are blatently and woefully incomplete. Statements such as "PHP 5.2.0 or higher is required for this to work" is misleading. The PHP online manual pages for respective functions make no distinction that any particular function or capability is an optional include for a build - considered an "extension" as opposed to, what?, "native code"? I have also learned that when coding my own scripts, I must not only read the manual page for that function, but also any metadata for it and its group, such as the Introduction page, Installing/Configuring, etc. And where, when I finally find it, if I can reason out that I should be looking for it, it may say "The filter extension is enabled by default as of PHP 5.2.0", that I need to be reasonably cautious because some idiot may build PHP 5.2.0+ without this extension. Are the array_*() functions also an optional extension? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Which PHP 5.3 documentation generators have you found?
While we don't use any 5.3 specific features such as namespaces yet, we set up our continuous integration system to use Doxygen. It runs significantly faster than phpDocumentor, though we put zero effort into tuning either system.
Re: [PHP] file_get_contents() failing on CentOS.
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] PHP Email Question
On Wed, Sep 29, 2010 at 1:37 PM, Joe Jackson wrote: > Hi > > I am trying the following snippet as Bostjan suggested, and an email is > getting sent when I submit the form however in the body of the email I am > getting none of the form data in the body of the email. All I am getting is > the letter 'z' ? Also in the from field of the email this is showing as my > email address and not the email address of the user who has sent the form > > Any ideas on where I am going wrong with this snippet? Any advice would be > much appreciated > > $msgContent = "Name: ". $values['name'] ."\n"; > $msgContent .= "Address: ". $values['address'] ."\n"; > $msgContent .= "Telephone: ". $values['telephone'] ."\n"; > $msgContent .= "Email Address: ". $values['emailaddress'] ."\n"; > $msgContent .= "Message: ". $values['message'] ."\n"; > > function ProcessForm($values) > { > mail('myemail:domain.com', 'Website Enquiry', $msgContent, "From: > \"{$values['name']}\" <{$values['emailaddress']}>"); > > // Replace with actual page or redirect :P > echo "Thank you!Thank > you!"; Not sure if it it is a typo above, are you actually passing $msgContent in the function above? If it is a global variable, you would need to add a 'global' declaration: function ProcessForm($values) { global $msgContent; mail('myemail:domain.com', 'Website Enquiry', $msgContent, "From: \"{$values['name']}\" <{$values['emailaddress']}>\r\n"); . . . } Also try adding CRLF sequence at the end of the header line as shown above. Ravi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Which PHP 5.3 documentation generators have you found?
On Fri, Oct 1, 2010 at 6:44 AM, David Harkness wrote: > While we don't use any 5.3 specific features such as namespaces yet, we set > up our continuous integration system to use Doxygen. It runs significantly > faster than phpDocumentor, though we put zero effort into tuning either > system. > I started patching Doxygen a while ago but got sort of side tracked. Out of PHPDocumentor and Doxygen, Doxygen seemed to be the closest as it had namespace support already for other languages. only the tokens needed changing. It uses Flex /Bison as the lexer and scanner so it's pretty flexible. YMMV. I have a bunch of FaiF code to release but i won't do so until i have adequate documentation so I'll get around to adding support one of these days. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php