[PHP] php fopen https error
With RHEL/CentOS 5 php I get an SSL Error RHEL/CentOS 5 php is at 5.1.6 with security fixes backported. ?php $handle = fopen(https://maps.google.com;, r); $contents = stream_get_contents($handle); fclose($handle); ? will result in something like Warning: stream_get_contents(): SSL: fatal protocol error in bla.php on line 3 Some https pages do not raise this error, e.g. https://www.redhat.com is fine What is wrong? How to debug? How to resolve? How to mitigate? Thanks -- Markus Falb -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php fopen https error
I believe this was a bug, is only a warning that may be suppressed and may have been fixed in 5.2.0. Are you aware that PHP is at 5.5.4 and that 5.1.6 is over 7 years old? -Shawn On Wed, Sep 25, 2013 at 9:09 AM, Markus Falb markus.f...@fasel.at wrote: With RHEL/CentOS 5 php I get an SSL Error RHEL/CentOS 5 php is at 5.1.6 with security fixes backported. ?php $handle = fopen(https://maps.google.com;, r); $contents = stream_get_contents($handle); fclose($handle); ? will result in something like Warning: stream_get_contents(): SSL: fatal protocol error in bla.php on line 3 Some https pages do not raise this error, e.g. https://www.redhat.com is fine What is wrong? How to debug? How to resolve? How to mitigate? Thanks -- Markus Falb -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php fopen https error
Just as I thought: 5.2.0 Fixed bug #39039 SSL: fatal protocol error when fetching HTTPS from servers running Google web server). (Ilia) On Wed, Sep 25, 2013 at 10:03 AM, Shawn McKenzie shawn.mcken...@gmail.comwrote: I believe this was a bug, is only a warning that may be suppressed and may have been fixed in 5.2.0. Are you aware that PHP is at 5.5.4 and that 5.1.6 is over 7 years old? -Shawn On Wed, Sep 25, 2013 at 9:09 AM, Markus Falb markus.f...@fasel.at wrote: With RHEL/CentOS 5 php I get an SSL Error RHEL/CentOS 5 php is at 5.1.6 with security fixes backported. ?php $handle = fopen(https://maps.google.com;, r); $contents = stream_get_contents($handle); fclose($handle); ? will result in something like Warning: stream_get_contents(): SSL: fatal protocol error in bla.php on line 3 Some https pages do not raise this error, e.g. https://www.redhat.com is fine What is wrong? How to debug? How to resolve? How to mitigate? Thanks -- Markus Falb -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php fopen https error
On 25.9.2013 17:12, Shawn McKenzie wrote: Just as I thought: 5.2.0 Fixed bug #39039 SSL: fatal protocol error when fetching HTTPS from servers running Google web server). (Ilia) Thanks, but ... I am not sure how what I am supposed to do with this information. #39039 says it is a bug and it was fixed. How do I proceed to understand this bug? Where can I find the appropiate patch? Where is this bug discussed? I am sorry if I strain it (too much?) but the link to this bug does not give a solution to the problem and it does not help to understand the problem. I understand that somewhere in cvs there is the solution, but I can not see an obvious way to get it from the information in #39039 -- Markus Falb -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php fopen https error
On 25.9.2013 17:03, Shawn McKenzie wrote: I believe this was a bug, is only a warning that may be suppressed and may have been fixed in 5.2.0. Are you aware that PHP is at 5.5.4 and that 5.1.6 is over 7 years old? Please understand that some Distributions do the only backport security stuff thing, e.g. RedHat is supporting for 10 years nowadays. I do not complain, I just try to understand the issue. Thanks -- Markus Falb -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php fopen https error
I thought I covered that. The bug was fixed 7 years ago. Upgrade PHP, I doubt there is a patch. I understand that not all coders or distributions will have the latest version of PHP, but come on, how many thousands of bugs have been fixed in 7 years? You're going to run into more. Alternatively you could try and suppress it. From the bug it sounded like it was only the warning that was the bug, so the code should work. I can't test because my PHP on CentOS is only 3 years old (5.3.3). $contents = @stream_get_contents($handle); On Wed, Sep 25, 2013 at 11:20 AM, Markus Falb markus.f...@fasel.at wrote: On 25.9.2013 17:12, Shawn McKenzie wrote: Just as I thought: 5.2.0 Fixed bug #39039 SSL: fatal protocol error when fetching HTTPS from servers running Google web server). (Ilia) Thanks, but ... I am not sure how what I am supposed to do with this information. #39039 says it is a bug and it was fixed. How do I proceed to understand this bug? Where can I find the appropiate patch? Where is this bug discussed? I am sorry if I strain it (too much?) but the link to this bug does not give a solution to the problem and it does not help to understand the problem. I understand that somewhere in cvs there is the solution, but I can not see an obvious way to get it from the information in #39039 -- Markus Falb -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen and load balancing
Adam Tong adam.to...@gmail.com hat am 11. Februar 2013 um 16:11 geschrieben: I think this is what happened. As the application was trying to open our url domain the request was sent to the load balancer, and as it does not accept internal requests, the connection was timed out. The only way we could avoid that is to not use fopen our url, is that right? You know the thing is: LoadBalancers are to balance the load from outside not the other way around. If you need to make server requests, use the internal server name. But accessing the file directly is much smarter and faster. On Mon, Feb 11, 2013 at 4:26 AM, ma...@behnke.biz ma...@behnke.biz wrote: Adam Tong adam.to...@gmail.com hat am 10. Februar 2013 um 23:41 geschrieben: Hi, We had an issue with the code of a junior php developer that used fopen to load images using the url of the companies website that is load balanced. We could not the detect the problem in dev and test because the dev and test servers are not load balanced. I know that he could load the images using just the filesystem, but I am curious to know why it failed and if the load balancer is really the source of the problem or it is a limitation on the function itself. Do you have any error messages for us? If the load balancer accessable from the internal servers? Normally it is not. Thank you -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Marco Behnke Dipl. Informatiker (FH), SAE Audio Engineer Diploma Zend Certified Engineer PHP 5.3 Tel.: 0174 / 9722336 e-Mail: ma...@behnke.biz Softwaretechnik Behnke Heinrich-Heine-Str. 7D 21218 Seevetal http://www.behnke.biz -- 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 -- Marco Behnke Dipl. Informatiker (FH), SAE Audio Engineer Diploma Zend Certified Engineer PHP 5.3 Tel.: 0174 / 9722336 e-Mail: ma...@behnke.biz Softwaretechnik Behnke Heinrich-Heine-Str. 7D 21218 Seevetal http://www.behnke.biz -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen and load balancing
Adam Tong adam.to...@gmail.com hat am 10. Februar 2013 um 23:41 geschrieben: Hi, We had an issue with the code of a junior php developer that used fopen to load images using the url of the companies website that is load balanced. We could not the detect the problem in dev and test because the dev and test servers are not load balanced. I know that he could load the images using just the filesystem, but I am curious to know why it failed and if the load balancer is really the source of the problem or it is a limitation on the function itself. Do you have any error messages for us? If the load balancer accessable from the internal servers? Normally it is not. Thank you -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Marco Behnke Dipl. Informatiker (FH), SAE Audio Engineer Diploma Zend Certified Engineer PHP 5.3 Tel.: 0174 / 9722336 e-Mail: ma...@behnke.biz Softwaretechnik Behnke Heinrich-Heine-Str. 7D 21218 Seevetal http://www.behnke.biz -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen and load balancing
I think this is what happened. As the application was trying to open our url domain the request was sent to the load balancer, and as it does not accept internal requests, the connection was timed out. The only way we could avoid that is to not use fopen our url, is that right? On Mon, Feb 11, 2013 at 4:26 AM, ma...@behnke.biz ma...@behnke.biz wrote: Adam Tong adam.to...@gmail.com hat am 10. Februar 2013 um 23:41 geschrieben: Hi, We had an issue with the code of a junior php developer that used fopen to load images using the url of the companies website that is load balanced. We could not the detect the problem in dev and test because the dev and test servers are not load balanced. I know that he could load the images using just the filesystem, but I am curious to know why it failed and if the load balancer is really the source of the problem or it is a limitation on the function itself. Do you have any error messages for us? If the load balancer accessable from the internal servers? Normally it is not. Thank you -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Marco Behnke Dipl. Informatiker (FH), SAE Audio Engineer Diploma Zend Certified Engineer PHP 5.3 Tel.: 0174 / 9722336 e-Mail: ma...@behnke.biz Softwaretechnik Behnke Heinrich-Heine-Str. 7D 21218 Seevetal http://www.behnke.biz -- 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] fopen and load balancing
On Mon, Feb 11, 2013 at 10:11 AM, Adam Tong adam.to...@gmail.com wrote: On Mon, Feb 11, 2013 at 4:26 AM, ma...@behnke.biz ma...@behnke.biz wrote: Adam Tong adam.to...@gmail.com hat am 10. Februar 2013 um 23:41 geschrieben: Hi, We had an issue with the code of a junior php developer that used fopen to load images using the url of the companies website that is load balanced. We could not the detect the problem in dev and test because the dev and test servers are not load balanced. I know that he could load the images using just the filesystem, but I am curious to know why it failed and if the load balancer is really the source of the problem or it is a limitation on the function itself. Do you have any error messages for us? If the load balancer accessable from the internal servers? Normally it is not. I think this is what happened. As the application was trying to open our url domain the request was sent to the load balancer, and as it does not accept internal requests, the connection was timed out. The only way we could avoid that is to not use fopen our url, is that right? Yeah, sure. That's as good of a guess as any of us will be able to conjure up. Since you've given us no details, no code and no error messages, we're basically relegated to blind guessing. I don't think that's what you want, so if you still have a question, I suggest you start by investigating the relevant logs. If you can't figure out the issue from there, post _relevant_ snippets to the list. Also remember that this is the PHP mailing list. (Even though we tend to masquerade as the MySQL list from time to time) If it's an issue with your very likely non-PHP load balancer, we can't really help you out. --Sean Greenslade -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fopen and load balancing
Hi, We had an issue with the code of a junior php developer that used fopen to load images using the url of the companies website that is load balanced. We could not the detect the problem in dev and test because the dev and test servers are not load balanced. I know that he could load the images using just the filesystem, but I am curious to know why it failed and if the load balancer is really the source of the problem or it is a limitation on the function itself. Thank you -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen and load balancing
On Sun, Feb 10, 2013 at 5:41 PM, Adam Tong adam.to...@gmail.com wrote: Hi, We had an issue with the code of a junior php developer that used fopen to load images using the url of the companies website that is load balanced. We could not the detect the problem in dev and test because the dev and test servers are not load balanced. I know that he could load the images using just the filesystem, but I am curious to know why it failed and if the load balancer is really the source of the problem or it is a limitation on the function itself. Thank you -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I'm not sure it sounds like an issue with the load balancer, as a load balancer shouldn't have any qualm with passing through the image data associated with an http request (which is what the fopen wrapper essentially performs behind the scenes.) It's possible that the prod servers (those making the call to fopen) aren't configured to allow the http wrapper. It could just be as simple as allow_url_fopen being set to false, in contrast to the configuration of the dev server(s). http://php.net/manual/en/function.fopen.php http://php.net/manual/en/wrappers.php http://www.php.net/manual/en/wrappers.http.php Adam -- Nephtali: A simple, flexible, fast, and security-focused PHP framework http://nephtaliproject.com
RE: [PHP] fopen() on a network share?
Hi, wht dont you try it with IP, ex: fopen('http://11.12.13.14/sharename/folder/file.xml', 'w'); Date: Mon, 15 Jun 2009 22:51:09 -0400 From: aball...@gmail.com To: nos...@mckenzies.net CC: php-general@lists.php.net Subject: Re: [PHP] fopen() on a network share? On Mon, Jun 15, 2009 at 7:24 PM, Shawn McKenzienos...@mckenzies.net wrote: Brian Dunning wrote: Extra info, in case needed: my code says fopen('\\servername\sharename\folder\file.xml', 'w'); and it returns Failed to open stream, no such file or directory. I've verified that the PHP machine does have unrestricted permissions to that share and to the directory. Thanks. On Jun 15, 2009, at 1:39 PM, Brian Dunning wrote: Running on Windows... I have a network share, \\sharename\foldername, and I want to write a file. How do I format the pathname with fopen() for this? As I remember, you either have to double slash or use the other slash. servername\\sharename\\folder\\file.xml or //servername/sharename/folder/file.xml -- Thanks! -Shawn http://www.spidean.com I think 'servername\sharename\folder\file.xml' will work if you're using single quotes around the string. The only slashes that would need escaped are the first two since the first slash in '\\' escapes the second. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ Conheça os novos produtos Windows Live! Clique aqui. http://www.windowslive.com.br
[PHP] fopen() on a network share?
Running on Windows... I have a network share, \\sharename\foldername, and I want to write a file. How do I format the pathname with fopen() for this? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen() on a network share?
Extra info, in case needed: my code says fopen('\\servername\sharename\folder\file.xml', 'w'); and it returns Failed to open stream, no such file or directory. I've verified that the PHP machine does have unrestricted permissions to that share and to the directory. Thanks. On Jun 15, 2009, at 1:39 PM, Brian Dunning wrote: Running on Windows... I have a network share, \\sharename \foldername, and I want to write a file. How do I format the pathname with fopen() for this? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen() on a network share?
Brian Dunning wrote: Extra info, in case needed: my code says fopen('\\servername\sharename\folder\file.xml', 'w'); and it returns Failed to open stream, no such file or directory. I've verified that the PHP machine does have unrestricted permissions to that share and to the directory. Thanks. On Jun 15, 2009, at 1:39 PM, Brian Dunning wrote: Running on Windows... I have a network share, \\sharename\foldername, and I want to write a file. How do I format the pathname with fopen() for this? As I remember, you either have to double slash or use the other slash. servername\\sharename\\folder\\file.xml or //servername/sharename/folder/file.xml -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen() on a network share?
On Mon, Jun 15, 2009 at 7:24 PM, Shawn McKenzienos...@mckenzies.net wrote: Brian Dunning wrote: Extra info, in case needed: my code says fopen('\\servername\sharename\folder\file.xml', 'w'); and it returns Failed to open stream, no such file or directory. I've verified that the PHP machine does have unrestricted permissions to that share and to the directory. Thanks. On Jun 15, 2009, at 1:39 PM, Brian Dunning wrote: Running on Windows... I have a network share, \\sharename\foldername, and I want to write a file. How do I format the pathname with fopen() for this? As I remember, you either have to double slash or use the other slash. servername\\sharename\\folder\\file.xml or //servername/sharename/folder/file.xml -- Thanks! -Shawn http://www.spidean.com I think 'servername\sharename\folder\file.xml' will work if you're using single quotes around the string. The only slashes that would need escaped are the first two since the first slash in '\\' escapes the second. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen not working corectly on remote IIS
On Tue, Nov 11, 2008 at 9:10 AM, Yeti [EMAIL PROTECTED] wrote: As PHP says ... there seems to be something wrong with file permissions. Make sure the IIS-user (if there is one on windows) can read intekendb.php. I don't know if you checked [1] yet. It's alot of useful info about php on IIS. Quote out of that article: The IIS user (usually IUSR_MACHINENAME) needs permission to read various files and directories, such as php.ini, docroot, and the session tmp directory. The message is pretty clear. The IIS user needs Modify permission to the file 'intekendb.txt'. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fopen not working corectly on remote IIS
Hi I have this problem for 6 months now and still no answer that solve the problem With the php I retrieve the information viewers enter in form field on a previous page after the submit. php then should take that info and proces it into a single line. After it is processed it should be written into a .txt file. I use the folowing code for the php: - - - - - - - - - 09 - ?php //retrieves all the variables. 10 - $Naam = $_POST['Naam']; 11 - $Van = $_POST['Van']; 12 - $Klas = $_POST['Klas']; 13 - $Geslag = $_POST['Geslag']; 14 - $Kommando = $_POST['Kommando']; 15 - $Kontak = $_POST['Kontak']; 16 - $Braaipakke = $_POST['Braaipakke']; 17 - $Inskrywingsfooi = $_POST['Inskrywingsfooi']; 18 - $Totaal = $_POST['Totaal']; 19 - ? - - - - - - - - - 24 - ?php//turned on to view all the errors 25 - ini_set('display_errors', 1); 26 - error_reporting(E_ALL); 27 - ? - - - - - - - - - 42 - ?php $setting = 'allow_url_fopen'; ini_set($setting, ini_get($setting) ? 0 : 1); //first makes sure that url fopen is turned on 43 - $textline = Naam en Van: $Naam $Van, Kontak Nommer: $Kontak, Groep: $Klas, Gelsag: $Geslag, Kommando: $Kommando, Aantal Kospakkies: $Braaipakke, Inskrywingsfooi: $Inskrywingsfooi, Totaal Verskuldig: $Totaal 44 - ; //processes the info into a single line (with line break at end) 45 - echo $textline; //displays the line that will be inserted into the file 46 - $file = fopen(intekendb.txt,a+); //opens the file to write the info 47 - fputs($file,$textline); //writes into the file 48 - Fclose ($file); ? //closes the file - - - - - - - - - Here are the errors this php generates: * Warning: fopen(intekendb.txt) [function.fopen]: failed to open stream: Permission denied in C:\Domains\transvaal.voortrekkers.org.za\wwwroot\kommandos\arbeidsvreugde\Bl adsye\intekendb.php on line 46 Warning: fputs(): supplied argument is not a valid stream resource in C:\Domains\transvaal.voortrekkers.org.za\wwwroot\kommandos\arbeidsvreugde\Bl adsye\intekendb.php on line 47 Warning: fclose(): supplied argument is not a valid stream resource in C:\Domains\transvaal.voortrekkers.org.za\wwwroot\kommandos\arbeidsvreugde\Bl adsye\intekendb.php on line 48 PHP Warning: fopen(intekendb.txt) [function.fopen]: failed to open stream: Permission denied in C:\Domains\transvaal.voortrekkers.org.za\wwwroot\kommandos\arbeidsvreugde\Bl adsye\intekendb.php on line 46 PHP Warning: fputs(): supplied argument is not a valid stream resource in C:\Domains\transvaal.voortrekkers.org.za\wwwroot\kommandos\arbeidsvreugde\Bl adsye\intekendb.php on line 47 PHP Warning: fclose(): supplied argument is not a valid stream resource in C:\Domains\transvaal.voortrekkers.org.za\wwwroot\kommandos\arbeidsvreugde\Bl adsye\intekendb.php on line 48 Please help me so that I can get this problem solved for once Jaco Theron
Re: [PHP] fopen not working corectly on remote IIS
As PHP says ... there seems to be something wrong with file permissions. Make sure the IIS-user (if there is one on windows) can read intekendb.php. I don't know if you checked [1] yet. It's alot of useful info about php on IIS. Quote out of that article: The IIS user (usually IUSR_MACHINENAME) needs permission to read various files and directories, such as php.ini, docroot, and the session tmp directory. Maybe [2] can help you out too. [1] http://www.php.net/manual/en/install.windows.iis.php [2] http://at.php.net/manual/en/function.fopen.php#50601 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fopen never ends?
When you run the folling script, it will never ends? I have seen this more then once, I know that there is no service running at the target host, but why is the script not printing the failed message? It's only with a few ip-number I have this problem. if ($fp = fopen('https://81.23.227.9', 'rb', false)) { echo ok; } else { echo failed; } Best Regards, Paul van Brouwershaven -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen() for http:// sometimes working, sometimes not
On Dec 27, 2007 11:31 AM, Albert Wiersch [EMAIL PROTECTED] wrote: I noticed my script at http://onlinewebcheck.com was sometimes (fairly often) failing to open some URLs that users have entered. fopen() returns false very quickly, but when tried again with the same URL, sometimes it works. What would cause this behavior? Why does fopen() occasionally fail to open valid http addresses but works at other times? Are the URLs being passed to fopen() properly escaped? Are they valid, complete with http:// placed before the domain? Try keeping a log of all URLs entered for a bit, and see which ones fail. -- Daniel P. Brown [Phone Numbers Go Here!] [They're Hidden From View!] If at first you don't succeed, stick to what you know best so that you can make enough money to pay someone else to do it for you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fopen() for http:// sometimes working, sometimes not
I noticed my script at http://onlinewebcheck.com was sometimes (fairly often) failing to open some URLs that users have entered. fopen() returns false very quickly, but when tried again with the same URL, sometimes it works. What would cause this behavior? Why does fopen() occasionally fail to open valid http addresses but works at other times? -- Albert Wiersch -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen() for http:// sometimes working, sometimes not
Daniel Brown [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Dec 27, 2007 11:31 AM, Albert Wiersch [EMAIL PROTECTED] wrote: Are the URLs being passed to fopen() properly escaped? Are they valid, complete with http:// placed before the domain? Try keeping a log of all URLs entered for a bit, and see which ones fail. It's not the URL because the same URL will not work one time but will work another time. What needs to be escaped for a URL anyway? I am just changing spaces to '%20' now. I will try upgrading to 5.2.5. I'm using 5.2.3 now. Thanks, Albert -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen() for http:// sometimes working, sometimes not
On Dec 27, 2007 12:57 PM, Albert Wiersch [EMAIL PROTECTED] wrote: What needs to be escaped for a URL anyway? I am just changing spaces to '%20' now. Arbitrary code can still be injected unless it's properly sanitized, but that's beyond the scope here. Mainly, make sure quotes (single and double) are being converted. -- Daniel P. Brown [Phone Numbers Go Here!] [They're Hidden From View!] If at first you don't succeed, stick to what you know best so that you can make enough money to pay someone else to do it for you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fopen function and charset
Hi. I want to know, what charset is applied to every file when is created with the fopen function and how can I to manage the charset when I use the fopen function? For example: If i want to create an ISO-8859-2 file, how can I to force, the fopen function to create it? Regards -- Mauricio Muriel [EMAIL PROTECTED] Cel 1: +57 300 784-0345 Cel 2: +57 311 733-0934 SIBA S.A. Calle 81 No.8-39 Ofc. 703 Bogotá, Colombia Tel: +57 (1) 211-1934 http://www.siba.com.co
RE: [PHP] fopen function and charset
[snip] I want to know, what charset is applied to every file when is created with the fopen function and how can I to manage the charset when I use the fopen function? For example: If i want to create an ISO-8859-2 file, how can I to force, the fopen function to create it? [/snip] This may start to shed some light http://us2.php.net/mbstring -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fopen and fwrite r+
I'm collecting data from a form and using it to write to a flat file like so: Quote: //this removes line breaks in an text field box and substitutes double breaks $postbody = str_replace(\r\n, br/br/,$postbody); $thepost = $postitle | $postdate | $postbody | $author \r\n; if ($posttype==add) { // the r+ flag reads and writes at the top of the file, a writes at the bottom $file = fopen(../includes/news.txt, 'r+'); fwrite ($file, $thepost\r\n); fclose($file); } else { } I can write to the bottom of the file, no problem, but if I want to put new entries at the top of the file I have problems: the previous entry is partially overwritten and mangled.. like so: (this is the top line from the text file Site Redesign | Jan 9, 07, 9:31 am | The site has a new look...etc becomes new look!...etc a 20 character post overwrites 22 a 50 character post overwrites 62 61 character post overwrites 64 260 character post overwrites 260 characters.. it seems to be random, somewhat... any ideas?
Re: [PHP] fopen and fwrite r+
# [EMAIL PROTECTED] / 2007-01-13 17:32:00 -0500: I can write to the bottom of the file, no problem, but if I want to put new entries at the top of the file I have problems: the previous entry is partially overwritten and mangled.. you cannot prepend to a file. to do that you need to create a new file, write the new data in it, and append data from the old file. class newLiner extends IteratorIterator { function current() { return $this-getInnerIterator()-current() . \n; } } $lines = array('line 1', 'line 2', 'line 3'); $data = new newLiner(new ArrayObject($lines)); $file = new SPLFileObject('file', 'r'); $temp = new SPLFileObject('temp', 'w'); $all = new AppendIterator; $all-append($data); $all-append($file); foreach ($all as $line) { $temp-fwrite($line); } $file-fflush(); $temp-fflush(); unset($file); unset($temp); -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen failed to open pipe file in Linux+Apache environment
mike xu wrote: Thanks a lot forr your reply. Here is the error msg: *Warning*: fopen(/dev/pmsg) [function.fopenhttp://localhost/Source/test/function.fopen]: failed to open stream: Permission denied in * /var/www/html/Source/test/register_user.php* on line *31 It still doesn't work even if I move pmsg to /tmp/ directory and change its own to appache... I don't really know Fedora or SELinux, but since your permissions seem ok could it be the SELinux policy for httpd causing you grief? - rjc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen failed to open pipe file in Linux+Apache environment
Hi Ryan, I just did another test, if I start the httpd by root user manually (the httpd daemon program still owns apache user by the result of `ps -aux`), the php script works fine. So, it seems the httpd start script (/etc/rc.d/init.d/httpd) did something specially which cause the permission problem... I'll continue checking it ... Thanks, Mike On 12/8/06, Ryan Creaser [EMAIL PROTECTED] wrote: mike xu wrote: Thanks a lot forr your reply. Here is the error msg: *Warning*: fopen(/dev/pmsg) [function.fopenhttp://localhost/Source/test/function.fopen]: failed to open stream: Permission denied in * /var/www/html/Source/test/register_user.php* on line *31 It still doesn't work even if I move pmsg to /tmp/ directory and change its own to appache... I don't really know Fedora or SELinux, but since your permissions seem ok could it be the SELinux policy for httpd causing you grief? - rjc
Re: [PHP] fopen failed to open pipe file in Linux+Apache environment
Its so strange, when I runing /etc/rc.d/rc3.d/S85httpd restart, the php script couldn't fopen pipe file. But if I copy /etc/rc.d/rc3.d/S85httpd to some other place (for example /root), and execute `/root/S85httpd restart`, the php script could fopen file successfully! Its so confusing ... On 12/8/06, mike xu [EMAIL PROTECTED] wrote: Hi Ryan, I just did another test, if I start the httpd by root user manually (the httpd daemon program still owns apache user by the result of `ps -aux`), the php script works fine. So, it seems the httpd start script (/etc/rc.d/init.d/httpd) did something specially which cause the permission problem... I'll continue checking it ... Thanks, Mike On 12/8/06, Ryan Creaser [EMAIL PROTECTED] wrote: mike xu wrote: Thanks a lot forr your reply. Here is the error msg: *Warning*: fopen(/dev/pmsg) [function.fopenhttp://localhost/Source/test/function.fopen ]: failed to open stream: Permission denied in * /var/www/html/Source/test/register_user.php* on line *31 It still doesn't work even if I move pmsg to /tmp/ directory and change its own to appache... I don't really know Fedora or SELinux, but since your permissions seem ok could it be the SELinux policy for httpd causing you grief? - rjc
[PHP] fopen failed to open pipe file in Linux+Apache environment
Hi, I have problem of open named pipe file in linux. Here is my sample code: $fifo_file = /dev/pmsg; @ $fp = fopen($fifo_file, 'w+b'); if(!$fp) { echo open .$fifo_file. failed; } else { $msg_cmd = ttt; fwrite($fp, $msg_cmd, strlen($msg_cmd)); fclose($fp); } There is an other program which is waiting for messages from /dev/pmsg forever. You could also test it by running `cat /dev/pmsg` in shell console. Every one have permissions of read and write for /dev/pmsg prw-rw-rw- 1 root root 0 12-08 10:13 /dev/pmsg Environment info: php-5.1.2-5, httpd-2.2.0-5.1.2, OS: Redhat FC5 Thanks in advance, Mike
Re: [PHP] fopen failed to open pipe file in Linux+Apache environment
mike xu wrote: Hi, I have problem of open named pipe file in linux. Here is my sample code: $fifo_file = /dev/pmsg; @ $fp = fopen($fifo_file, 'w+b'); It's wb+ not w+b -- 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] fopen failed to open pipe file in Linux+Apache environment
mike xu wrote: Hi, I have problem of open named pipe file in linux. Here is my sample code: $fifo_file = /dev/pmsg; @ $fp = fopen($fifo_file, 'w+b'); if(!$fp) { echo open .$fifo_file. failed; } else { $msg_cmd = ttt; fwrite($fp, $msg_cmd, strlen($msg_cmd)); fclose($fp); } There is an other program which is waiting for messages from /dev/pmsg forever. You could also test it by running `cat /dev/pmsg` in shell console. Every one have permissions of read and write for /dev/pmsg prw-rw-rw- 1 root root 0 12-08 10:13 /dev/pmsg Environment info: php-5.1.2-5, httpd-2.2.0-5.1.2, OS: Redhat FC5 Thanks in advance, Mike Are you getting any errors? What if you remove the @ from the start of line 2, any errors now? - rjc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen failed to open pipe file in Linux+Apache environment
Thanks a lot forr your reply. Here is the error msg: *Warning*: fopen(/dev/pmsg) [function.fopenhttp://localhost/Source/test/function.fopen]: failed to open stream: Permission denied in * /var/www/html/Source/test/register_user.php* on line *31 It still doesn't work even if I move pmsg to /tmp/ directory and change its own to appache... * On 12/8/06, Ryan Creaser [EMAIL PROTECTED] wrote: mike xu wrote: Hi, I have problem of open named pipe file in linux. Here is my sample code: $fifo_file = /dev/pmsg; @ $fp = fopen($fifo_file, 'w+b'); if(!$fp) { echo open .$fifo_file. failed; } else { $msg_cmd = ttt; fwrite($fp, $msg_cmd, strlen($msg_cmd)); fclose($fp); } There is an other program which is waiting for messages from /dev/pmsg forever. You could also test it by running `cat /dev/pmsg` in shell console. Every one have permissions of read and write for /dev/pmsg prw-rw-rw- 1 root root 0 12-08 10:13 /dev/pmsg Environment info: php-5.1.2-5, httpd-2.2.0-5.1.2, OS: Redhat FC5 Thanks in advance, Mike Are you getting any errors? What if you remove the @ from the start of line 2, any errors now? - rjc
[PHP] fopen: space character in filename
Hello all, this seems like an easy question, but I could sure as hell couldn't find any responces to it through initial searched. I am running php on an XP system and I need to open a file contained with a set of directories which may or may not have a space character; so for example: fopen (X:\Dont Talk\About\My Momma\please.txt, x); I tried using \ characters, no luck (even attempted to cancel out the backspace characters ala \\ and http space code %20, and still nothing.) Any ideas? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen: space character in filename
On Fri, 2006-07-28 at 16:55, Christian Calloway wrote: Hello all, this seems like an easy question, but I could sure as hell couldn't find any responces to it through initial searched. I am running php on an XP system and I need to open a file contained with a set of directories which may or may not have a space character; so for example: fopen (X:\Dont Talk\About\My Momma\please.txt, x); I tried using \ characters, no luck (even attempted to cancel out the backspace characters ala \\ and http space code %20, and still nothing.) Any ideas? RTFM -- you need to double backslash when using double quotes. Otherwise use single quotes. 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] fopen: space character in filename
On Fri, 2006-07-28 at 17:27, Robert Cummings wrote: On Fri, 2006-07-28 at 16:55, Christian Calloway wrote: Hello all, this seems like an easy question, but I could sure as hell couldn't find any responces to it through initial searched. I am running php on an XP system and I need to open a file contained with a set of directories which may or may not have a space character; so for example: fopen (X:\Dont Talk\About\My Momma\please.txt, x); I tried using \ characters, no luck (even attempted to cancel out the backspace characters ala \\ and http space code %20, and still nothing.) Any ideas? RTFM -- you need to double backslash when using double quotes. Otherwise use single quotes. And after writing that I re-read and realized you did *hah*. Make sure the file exists on the hard drive where you think it does. Also make sure you have read permissions. And hwile you're at it, make sure you have error reporting enabled so you can see any special errors that might be issued for various violations. 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] fopen: space character in filename
Christian Calloway wrote: this seems like an easy question, but I could sure as hell couldn't find any responces to it through initial searched. I am running php on an XP system and I need to open a file contained with a set of directories which may or may not have a space character; so for example: fopen (X:\Dont Talk\About\My Momma\please.txt, x); I tried using \ characters, no luck (even attempted to cancel out the backspace characters ala \\ and http space code %20, and still nothing.) Any ideas? Spaces aren't your problem here, the \'s are. You need to escape them... fopen (X:\\Dont Talk\\About\\My Momma\\please.txt, x); -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fopen failing, permission denied
I have the following code snippet: $h = fopen($path/file.txt, 'x+'); And it generates the following error: Warning: fopen(/home/./myarea/file.txt): failed to open stream: Permission denied The path is correct, but the php process doesn't seem to have file permissions in the folder. Is there some magic I can do to allow php to have file rights to the myarea folder? (This is on a purchased ISP site) Thanks DanB -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen failing, permission denied
Dan Baker wrote: I have the following code snippet: $h = fopen($path/file.txt, 'x+'); And it generates the following error: Warning: fopen(/home/./myarea/file.txt): failed to open stream: Permission denied The path is correct, but the php process doesn't seem to have file permissions in the folder. Is there some magic I can do to allow php to have file rights to the myarea folder? (This is on a purchased ISP site) Go in through ftp or ssh and fix the permissions. If you only want to read the file, then it only needs to be 644. If you need to write the file it will either need to be 646 or 664. That's your only option apart from deleting the file (through ftp) and recreating it through your php script ... or getting your host to change to the CGI version of php which is most unlikely to happen. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fopen/fwrite and owner/group settings
Hello there, I Have a problem with some file writeing. I Use fopen to create a new file, but that file gets the owner and group the same as the apache owner and group. How can i change it so that the file gets the same owner/group as the files i upload with FTP? Thx in advanced -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen/fwrite and owner/group settings
Mathijs wrote: Hello there, I Have a problem with some file writeing. I Use fopen to create a new file, but that file gets the owner and group the same as the apache owner and group. How can i change it so that the file gets the same owner/group as the files i upload with FTP? Thx in advanced You can use FTP functions to create the file (for example 'ftp_put') http://php.net/ftp HTH, cheers Silvio -- tradeOver | http://www.tradeover.net ...ready to become the King of the World? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] fopen on windows
On 11 November 2005 20:52, Jay Blanchard wrote: $theFile = fopen(docs/InstallationInstructionMaster.txt, r) || die; You need or not || here. The operator priorities are such that the above means $theFile = (fopen(docs/InstallationInstructionMaster.txt, r) || die); which assigns TRUE to $the File when the fopen() succeeds, rather than the file handle. You can't have error reporting turned up very high, or this: while(!feof($theFile)){ $theLine = fgets($theFile, 4096); echo $theLine . br\n; } would be throwing all sorts of warnings about the invalid file handle. I'm guessing that feof(TRUE) returns NULL as well as throwing the warning, so this should be an infinite loop echoing just linebreaks. Oh, wait! ;) On the other hand, the version using or works out to be: ($theFile = fopen(docs/InstallationInstructionMaster.txt, r)) or die; which assigns the result of fopen() to $theFile, and then executes die if it's false -- which is much more satisfactory. ;) Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] fopen on windows
On 11 November 2005 21:21, Nathan Tobik wrote: I've always used: fopen(C:\\dir\\dir\\file.txt); on windows, I'm not sure how PHP interprets the slashes internally though... On Windows, / in filenames is internally translated by PHP to \ -- which means you can write code that works on both Windows and *n*x using /. *Really* portable code uses the DIRECTORY_SEPARATOR constant, however. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] fopen on windows
[snip] You need or not || here. The operator priorities are such that the above means ... which assigns the result of fopen() to $theFile, and then executes die if it's false -- which is much more satisfactory. ;) [/snip] Originally I did not have any '||' or 'or' in the conditional check, with the same results. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen on windows
On Fri, November 11, 2005 2:51 pm, Jay Blanchard wrote: $theFile = fopen(docs/InstallationInstructionMaster.txt, r) || die; Don't use || when you mean 'or' :-) Nor sure it really matters here, but better to follow the crowd and use 'or' here. while(!feof($theFile)){ $theLine = fgets($theFile, 4096); 4096 is longer than any line in the file? echo $theLine . br\n; } fclose($theFile); The above code appears to work, but all that is output is lines of line breaksno data. The file is a tab delimited test file; View Source? Am I missing something other than an ice cold beer? Are you 100% certain you don't have an empty file in docs/InstallationInstructionMaster.txt sitting right next to your script, while the REAL file you want is somewhere else? Been there. Done that. Smacked the forehead. Use the full path to the file to be SURE you are reading the file you think you are reading. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] fopen on windows
On Fri, November 11, 2005 3:23 pm, Jay Blanchard wrote: // Left off the b because it ain't binary :) I think you will find this is the crucial difference if you go back to your original and take it out. Your file is text. It's not binary. On Windowz, that matters, for some odd reason. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] fopen on windows
[snip] On Fri, November 11, 2005 2:51 pm, Jay Blanchard wrote: $theFile = fopen(docs/InstallationInstructionMaster.txt, r) || die; Don't use || when you mean 'or' :-) Nor sure it really matters here, but better to follow the crowd and use 'or' here. [/snip] Okie dokie. Found there to be no change in behavior at this point. Perhaps I need to set the error checking higher, say E_ALL. [snip] while(!feof($theFile)){ $theLine = fgets($theFile, 4096); 4096 is longer than any line in the file? [/snip] Yes, it accounts for every line in the file. [snip] echo $theLine . br\n; } fclose($theFile); The above code appears to work, but all that is output is lines of line breaksno data. The file is a tab delimited test file; View Source? [/snip] Looks like; br br br br br [snip] Are you 100% certain you don't have an empty file in docs/InstallationInstructionMaster.txt sitting right next to your script, while the REAL file you want is somewhere else? Been there. Done that. Smacked the forehead. Use the full path to the file to be SURE you are reading the file you think you are reading. [/snip] Did that too. Still no joy. Several other methods have been provided and I will use one of those. However, when I get to the point that fopen would be my only choice I will likely encounter these same problems. C'est la vie! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fopen on windows
$theFile = fopen(docs/InstallationInstructionMaster.txt, r) || die; while(!feof($theFile)){ $theLine = fgets($theFile, 4096); echo $theLine . br\n; } fclose($theFile); The above code appears to work, but all that is output is lines of line breaksno data. The file is a tab delimited test file; Form Number Date / Rev Description Controlled by Engineering Controlled by RD Controlled by Marketing Located on Thermon.com Copy Located in Shipping Copy Located in Mfg Installation Instructions - Heating Cables / Industrial PN50207 0802Electric Heat Tracing Installation Procedures X X X TEP0066 0800Electric Heat Tracting Maintenance Troubleshooting Guide X X X TMP0006 0901Electrical Safety Precautions for Electric Heat Tracing 10A024 1002Instal Inst. MI Mineral Insulated Heating Cable w/ SS Tie Wire MIQFAB 0802Field Testing Procedures for MI Trace Heating Cable Am I missing something other than an ice cold beer? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen on windows
Jay Blanchard wrote: $theFile = fopen(docs/InstallationInstructionMaster.txt, r) || die; I'm not sure if it would make any difference, but I usually use or in this case rather than ||, and I know they have different operator precedence. while(!feof($theFile)){ $theLine = fgets($theFile, 4096); echo $theLine . br\n; } fclose($theFile); The above code appears to work, but all that is output is lines of line breaksno data. The file is a tab delimited test file; [snip] Am I missing something other than an ice cold beer? Well, it's a pretty model example of a line-by-line file read. I can't see anything wrong with it, so perhaps the problem lies elsewhere. There's no other files with the same name in your include_path? Maybe something to do with auto_detect_line_endings or whatever it's called, in php.ini? (I know, probably a long shot.) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] fopen on windows
[snip] Well, it's a pretty model example of a line-by-line file read. I can't see anything wrong with it, so perhaps the problem lies elsewhere. There's no other files with the same name in your include_path? Maybe something to do with auto_detect_line_endings or whatever it's called, in php.ini? (I know, probably a long shot.) [/snip] The output now looks like Array ( [0] = ) Array ( [0] = ) Array ( [0] = ) based on the following code; $theFile = fopen(docs/InstallationInstructionMaster.txt, rb) || die; while(!feof($theFile)){ $theLine = fgets($theFile); $lineArray = explode(\t, $theLine); print_r($lineArray); } fclose($theFile); It appears that something is getting read, but what? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen on windows
Jay Blanchard wrote: [snip] Well, it's a pretty model example of a line-by-line file read. I can't see anything wrong with it, so perhaps the problem lies elsewhere. There's no other files with the same name in your include_path? Maybe something to do with auto_detect_line_endings or whatever it's called, in php.ini? (I know, probably a long shot.) [/snip] The output now looks like [snip] based on the following code; $theFile = fopen(docs/InstallationInstructionMaster.txt, rb) || die; while(!feof($theFile)){ $theLine = fgets($theFile); $lineArray = explode(\t, $theLine); print_r($lineArray); } fclose($theFile); It appears that something is getting read, but what? Blank lines. Just to see if the problem is fgets(), try this: // Left off the b because it ain't binary :) $theFile = file_get_contents( docs/InstallationInstructionMaster.txt, r ) or die; $lines = explode( \n, $theFile ); foreach( $lines as $line ) { $line = explode( \t, $line ); print_r( $line ); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] fopen on windows
I've always used: fopen(C:\\dir\\dir\\file.txt); on windows, I'm not sure how PHP interprets the slashes internally though... Nate Tobik (412)661-5700 x206 VigilantMinds $theFile = fopen(docs/InstallationInstructionMaster.txt, rb) || die; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] fopen on windows
[snip] Blank lines. Just to see if the problem is fgets(), try this: // Left off the b because it ain't binary :) $theFile = file_get_contents( docs/InstallationInstructionMaster.txt, r ) or die; $lines = explode( \n, $theFile ); foreach( $lines as $line ) { $line = explode( \t, $line ); print_r( $line ); } [/snip] That works, as does the following; $lines = file('docs/InstallationInstructionMaster.txt'); foreach ($lines as $line){ echo $line . br /\n; } So, I am perplexed. fgets() seems to have a problem of some sort. Any clues? Not that what I want to do requires fgets(), just curious now as I will use one of the other two methods. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen
John Taylor-Johnston wrote: It does what I want, but I worry 4096 may not be big enough. Possible? 4096 is the number of bytes fgets() will get, but the fgets() call is inside a while loop which keeps running until the 'filepointer' (as denoted by the handle $dataFile) in question has reached the end of the given file. so if 4096 is not big enough the loop merely grabs another 4096 bytes until its grabbed it all. so actually you have a handy bit of code which will allow you to 'eat' through massive files without the requirement of being able to store the whole file in memory. Is there a way to detect the filesize and insert a value for 4096? filesize() $buffer = fgets($dataFile, $filesize); Is this what it is for? John ?php #http://ca3.php.net/fopen $filename = /var/www/html2/assets/about.htm ; $dataFile = fopen( $filename, r ) ; while (!feof($dataFile)) { $buffer = fgets($dataFile, 4096); echo $buffer; } $sql = insert into table ... $buffer; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen
if all you want to do is read the entire file try $contents = file_get_contents($filename); On Tuesday 25 October 2005 11:54 pm, John Taylor-Johnston wrote: It does what I want, but I worry 4096 may not be big enough. Possible? Is there a way to detect the filesize and insert a value for 4096? $buffer = fgets($dataFile, $filesize); Is this what it is for? John ?php #http://ca3.php.net/fopen $filename = /var/www/html2/assets/about.htm ; $dataFile = fopen( $filename, r ) ; while (!feof($dataFile)) { $buffer = fgets($dataFile, 4096); echo $buffer; } $sql = insert into table ... $buffer; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen
On Oct 26, 2005, at 12:54 AM, John Taylor-Johnston wrote: It does what I want, but I worry 4096 may not be big enough. Possible? Is there a way to detect the filesize and insert a value for 4096? $buffer = fgets($dataFile, $filesize); Is this what it is for? John ?php #http://ca3.php.net/fopen $filename = /var/www/html2/assets/about.htm ; $dataFile = fopen( $filename, r ) ; while (!feof($dataFile)) { $buffer = fgets($dataFile, 4096); echo $buffer; } $sql = insert into table ... $buffer; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php fgets (PHP 3, PHP 4, PHP 5) fgets -- Gets line from file pointer Description string fgets ( resource handle [, int length] ) Returns a string of up to length - 1 bytes read from the file pointed to by handle. Reading ends when length - 1 bytes have been read, on a newline (which is included in the return value), or on EOF (whichever comes first). If no length is specified, the length defaults to 1k, or 1024 bytes. If an error occurs, returns FALSE.
[PHP] fopen
It does what I want, but I worry 4096 may not be big enough. Possible? Is there a way to detect the filesize and insert a value for 4096? $buffer = fgets($dataFile, $filesize); Is this what it is for? John ?php #http://ca3.php.net/fopen $filename = /var/www/html2/assets/about.htm ; $dataFile = fopen( $filename, r ) ; while (!feof($dataFile)) { $buffer = fgets($dataFile, 4096); echo $buffer; } $sql = insert into table ... $buffer; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] fopen problem
Are you using the a or a+ modes on fopen, because I have a sneaky feeling the file doesn't exist. -Original Message- From: Ross [mailto:[EMAIL PROTECTED] Sent: 24 June 2005 00:33 To: php-general@lists.php.net Subject: [PHP] fopen problem * This e-mail has been received by the Revenue Internet e-mail service. * I have a bit of a problem when using fopen, fwrite and fclose locally I get the flowing warnings Warning: fopen(counterlog.txt) [function.fopen]: failed to open stream: Permission denied in c:\Inetpub\wwwroot\pillars\index.php on line 30 Warning: fwrite(): supplied argument is not a valid stream resource in c:\Inetpub\wwwroot\pillars\index.php on line 33 Warning: fclose(): supplied argument is not a valid stream resource in c:\Inetpub\wwwroot\pillars\index.php on line 36 Any ideas?? R. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php This message has been delivered to the Internet by the Revenue Internet e-mail service * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fopen problem
I have a bit of a problem when using fopen, fwrite and fclose locally I get the flowing warnings Warning: fopen(counterlog.txt) [function.fopen]: failed to open stream: Permission denied in c:\Inetpub\wwwroot\pillars\index.php on line 30 Warning: fwrite(): supplied argument is not a valid stream resource in c:\Inetpub\wwwroot\pillars\index.php on line 33 Warning: fclose(): supplied argument is not a valid stream resource in c:\Inetpub\wwwroot\pillars\index.php on line 36 Any ideas?? R. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen problem
can you show the code? did you chmod the files?
Re: [PHP] fopen problem
On Thu, June 23, 2005 4:33 pm, Ross said: Warning: fopen(counterlog.txt) [function.fopen]: failed to open stream: Permission denied in c:\Inetpub\wwwroot\pillars\index.php on line 30 The PHP user does *NOT* have permission to open the counterlog.txt file. Exactly *HOW* you change permissions changed in every Windoze version, which suck, but there it is. You should A) post *which* Windows OS you are using and B) try the Windows list and C) poke around with Windows Explorer first to see if you can't make the counterlog.txt file be owned by the User PHP is running as, which you can find out from http://php.net/phpinfo Actually, do ABC) in reverse order :-) Warning: fwrite(): supplied argument is not a valid stream resource in c:\Inetpub\wwwroot\pillars\index.php on line 33 Warning: fclose(): supplied argument is not a valid stream resource in c:\Inetpub\wwwroot\pillars\index.php on line 36 These are a direct result of the first error. Your script should NOT have even *TRIED* to run these functions, once it failed to open the file in the first place. Add a lot more error-checking to your script. Once you fix the first error, these errors will go away In Reality, they are just waiting to re-surface when something else goes wrong with your file access. So, actually, fix your script to skip these lines *FIRST* then fix the error above. Consider it part of the learning to write Good Code. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fopen for http://
Hello all- I was wondering if anyone knew of a way to call a web site using fopen. Let me tell you how things are set up and what I'm trying to do. I can call fopen to read a site and then echo it back out. That's not a problem. The problem I run into is when I try to go to a restricted area of a site. For example, in my Apache httpd.conf file I have it set up to where I have a directory that is only accessible from certain IP addresses, one of which is 127. (the localhost). The script I'm running is located on the server and the web site I'm trying to access via fopen() is on the same server. Therefore, I'm thinking that the php script should have access to read the site's restricted directory. For some reason it does not have access. I was wondering if there was a way around this or am I just doomed to never be able to access the directory via fopen(http://someurl.com/somedirectory,r;); ?? Thanks. Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen for http://
On 5/27/05, Jay Paulson [EMAIL PROTECTED] wrote: Hello all- I was wondering if anyone knew of a way to call a web site using fopen. Let me tell you how things are set up and what I'm trying to do. I can call fopen to read a site and then echo it back out. That's not a problem. The problem I run into is when I try to go to a restricted area of a site. Define restricted area. How is it restricted? Using Login Forms? Using HTTP Authentication? Using .htaccess to filter using IP Addresses? For example, in my Apache httpd.conf file I have it set up to where I have a directory that is only accessible from certain IP addresses, one of which is 127. (the localhost). The script I'm running is located on the server and the web site I'm trying to access via fopen() is on the same server. Therefore, I'm thinking that the php script should have access to read the site's restricted directory. For some reason it does not have access. What errors are you getting? Do you get the same errors, when you access the site using a Browser? Are you accessing the site via someurl.com or localhost? If you're using someurl.com, and the ip address of someurl.com is 1.2.3.4, then you'll need to add 1.2.3.4 to the list of allowed ip addresses. Your server probably doesn't recognise that 1.2.3.4 is actually the same as 127.x.x.x when deciding to allow or deny. I was wondering if there was a way around this or am I just doomed to never be able to access the directory via fopen(http://someurl.com/somedirectory,r;); ?? Thanks. Jay -- 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] fopen for http://
I was wondering if anyone knew of a way to call a web site using fopen. Let me tell you how things are set up and what I'm trying to do. I can call fopen to read a site and then echo it back out. That's not a problem. The problem I run into is when I try to go to a restricted area of a site. For example, in my Apache httpd.conf file I have it set up to where I have a directory that is only accessible from certain IP addresses, one of which is 127. (the localhost). The script I'm running is located on the server and the web site I'm trying to access via fopen() is on the same server. Therefore, I'm thinking that the php script should have access to read the site's restricted directory. For some reason it does not have access. I was wondering if there was a way around this or am I just doomed to never be able to access the directory via fopen(http://someurl.com/somedirectory,r;); ?? Why can't you just do... fopen(http://127.0.0.1/somedirectory;, r); ? Odds are when you do it the other way your IP address is *NOT* 127.0.0.1, but whatever your Internet IP address is. -philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fopen problems
Hello all, I have an install of php on a Red Hat Ent. server that is giving me fits. I have been trying to use the fopen command to retreive files from external sites and have been getting this error: Warning: fopen(http://us3.php.net/images/php.gif): failed to open stream: HTTP request failed! in /home/test/public_html/declare.php on line 2 My code is as follows: ? if($handle=fopen(http://us3.php.net/images/php.gif,r;)) { echo \n\nOPENED REMOTE FILE\n\n; while (!feof($handle)) { $buffer = fgets($handle,4096); echo $buffer; } fclose($handle); } else echo \n\nFAILED TO OPEN REMOTE FILE\n\n; ? My Fopen section of my php.ini file. ;; ; Fopen wrappers ; ;; ; Whether to allow the treatment of URLs (like http:// or ftp://) as files. allow_url_fopen = On ; Define the anonymous ftp password (your email address) ;from=[EMAIL PROTECTED] ; Define the User-Agent string ; user_agent=PHP ; Default timeout for socket based streams (seconds) default_socket_timeout = 60 ; If your scripts have to deal with files from Macintosh systems, ; or you are running on a Mac and need to deal with files from ; unix or win32 systems, setting this flag will cause PHP to ; automatically detect the EOL character in those files so that ; fgets() and file() will work regardless of the source of the file. ; auto_detect_line_endings = Off As I stated before This is on a Red Hat Ent Server that is connected to the internet behind a SonicWall (300 I believe) firewall appliance. I am able to use the fget command to retrieve files from sites that are also behind said firewall. Any help anyone could give me would be greatly appreciated. AJ Lemke -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] fopen
-Original Message- From: John Taylor-Johnston [mailto:[EMAIL PROTECTED] Sent: Saturday, March 19, 2005 7:03 AM To: php-general@lists.php.net Subject: [PHP] fopen What can I add to get more info from the die? Do I have to specify a pathname in $defaultfile? Start by _removing_ @ to get warnings? $defaultfile = ffmail.txt; #default file to write to @ $results = fopen($datafilename, a); #open file and supress errors You set $defaultfile, but tries to open $datafilename? -- Med venlig hilsen / best regards ComX Networks A/S Kim Madsen Systemudvikler/systemdeveloper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fopen
Hi, FOpen question. My script is dying. Our results file could not be opened for writing What can I add to get more info from the die? Do I «have» to specify a pathname in $defaultfile? John $defaultfile = ffmail.txt; #default file to write to @ $results = fopen($datafilename, a); #open file and supress errors #print custom error if file doesn't exist or improper permissions if (!$results) { die (Our results file could not be opened for writing.); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen and redirects
Warren Vail wrote: I am using fopen with a url to open a remote file (read only of course). The url I am providing results in a redirect and the fopen seems to be smart enough to follow the redirect to return the actual file contents. How can I get at the redirected filename? The problem is the file contains html and relative references in href's buried in the html are relative to the redirected location and not my original location, and I would like to subsequently open some of those files (like a crawler does). http://php.net/curl will give you the control to follow or not follow re-directs, as well as access to all the headers that are coming in to figure out what's going on. If it's an IIS/ASP site, count on three or four re-directs for no apparent reason, other than to waste resources and sell more hardware/software. :-p -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] fopen and http://
Just a wild guess, but try url; http://localhost/zed/htdocs/rgfindingaids/series594.html or file://zed/htdocs/rgfindingaids/series594.html to bypass your web server I am struggling with the section of the manual that deals with this as well. http://us3.php.net/manual/en/ref.stream.php hope this helps, Warren Vail -Original Message- From: Mulley, Nikhil [mailto:[EMAIL PROTECTED] Sent: Friday, October 08, 2004 6:58 AM To: Adam Williams; php-general@lists.php.net Subject: RE: [PHP] fopen and http:// May be the path is not the correct ,just check with the Web Directory you configured to be and if its htdocs then I would say that its better to remove the htdocs from the path in fopen statement. -Original Message- From: Adam Williams [mailto:[EMAIL PROTECTED] Sent: Friday, October 08, 2004 6:22 PM To: php-general@lists.php.net Subject: [PHP] fopen and http:// Hi, I'm having a problem with fopen and http files. I keep getting the error: Warning: fopen(http://zed/htdocs/rgfindingaids/series594.html ) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/awilliam/public_html/rgfaidstest.php on line 15 http://zed/htdocs/rgfindingaids/series594.html does not exist Warning: fopen(http://zed/htdocs/rgfindingaids/ser391.html ) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/awilliam/public_html/rgfaidstest.php on line 15 http://zed/htdocs/rgfindingaids/ser391.html does not exist Warning: fopen(http://zed/htdocs/rgfindingaids/ser392.html ) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/awilliam/public_html/rgfaidstest.php on line 15 http://zed/htdocs/rgfindingaids/ser392.html does not exist I have a text file /home/awilliam/public_html/rgfaids containing URLs such as: http://zed/htdocs/rgfindingaids/series594.html http://zed/htdocs/rgfindingaids/ser391.html http://zed/htdocs/rgfindingaids/ser392.html and I can bring up these URLs fine in a browser on the PC i'm running the script on. The following is my code: ? $filelist = fopen(/home/awilliam/public_html/rgfaids, r); if (!$filelist) { echo error opening rgfaids; exit; } while ( !feof($filelist)) { $line = fgets($filelist, 9); $filetotest = fopen($line, r); if (!$filetotest) { echo $line does not existbr; } elseif ($filetotest) { echo $line does exist; } } ? But I don't understand why I am getting that error about failed to open strem: HTTP request failed, when I can bring up the links fine in a browser on the server running the php script. So can anyone help me out? Thanks -- 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] fopen and http://
Warren Vail wrote: Hi, I'm having a problem with fopen and http files. I keep getting the error: Warning: fopen(http://zed/htdocs/rgfindingaids/series594.html ) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/awilliam/public_html/rgfaidstest.php on line 15 http://zed/htdocs/rgfindingaids/series594.html does not exist I have a text file /home/awilliam/public_html/rgfaids containing URLs such as: http://zed/htdocs/rgfindingaids/series594.html http://zed/htdocs/rgfindingaids/ser391.html http://zed/htdocs/rgfindingaids/ser392.html and I can bring up these URLs fine in a browser on the PC i'm running the script on. Here's the thing though: Does your SERVER know anything about 'zed'? Maybe you've configured your PC's 'hosts' file so it knows that 'zed' means 192.168.1.47 (or whatever) but did you configure your server's 'hosts' files to know that? Log in to the server with SSH and do: nslookup zed and see what you get. If the operating system has no idea where 'zed' is, then PHP sure won't be able to figure it out. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fopen and redirects
I am using fopen with a url to open a remote file (read only of course). The url I am providing results in a redirect and the fopen seems to be smart enough to follow the redirect to return the actual file contents. How can I get at the redirected filename? The problem is the file contains html and relative references in href's buried in the html are relative to the redirected location and not my original location, and I would like to subsequently open some of those files (like a crawler does). thanks in advance, Warren Vail
[PHP] FOPEN
How can I read the contents of a web page that uses basic authentication? I want to use fopen() but dont know how to do this and also send the username and password -- Diana Castillo Global Reservas, S.L. C/Granvia 22 dcdo 4-dcha 28013 Madrid-Spain Tel : 00-34-913604039 Ext 216 Fax : 00-34-915228673 email: [EMAIL PROTECTED] Web : http://www.hotelkey.com http://www.destinia.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] FOPEN
http://uk.php.net/header should help you. BTW, you should address your replies to the list and not to individual ppl. Mikey -Original Message- From: Diana Castillo [mailto:[EMAIL PROTECTED] Sent: 17 February 2005 12:36 To: [EMAIL PROTECTED] Subject: Re: [PHP] FOPEN how do I send headers with php? - Original Message - From: Mikey [EMAIL PROTECTED] To: 'Diana Castillo' [EMAIL PROTECTED] Sent: Thursday, February 17, 2005 1:32 PM Subject: RE: [PHP] FOPEN How can I read the contents of a web page that uses basic authentication? I want to use fopen() but dont know how to do this and also send the username and password I don't know exactly what they are, but it should just be a case of sending the correct HTTP headers at the start of your request http://www.w3.org/Protocols/#Specs should give you the information you need... HTH, Mikey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] FOPEN
Diana Castillo wrote: How can I read the contents of a web page that uses basic authentication? I want to use fopen() but dont know how to do this and also send the username and password You may be able to do embed the username/password in your URL: $file = fopen(http://username:[EMAIL PROTECTED]) or die(Could not open remote page); You may want to actually store the username/password in a different file, and try to make it slightly less easy to read/find that file to avoid exposing passwords, the same way you would do with MySQL username/password. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fopen problem using ftp
HI all, I have a script that uses fopen to acces for read a file using ftp: $filepointer = fopen($address,'r'); having $address string formed this way: $address = ftp:/ /.$FTPuser.:.$FTPpassword.@.$FTPserver./.$FileFolder./.$FileNa me; This script always worked for me, it has now stopped working trying it on the server of a different provider, returning an error 'failed to open stream...' I have the suspect that the funcion is failing due to the particular account name ( used also as FTP username ) this italian provider gived me when I sibscribed: It contains a @ symbol ( I.E., [EMAIL PROTECTED] ), and I believe that this confuses the parsing of the ftp://User:[EMAIL PROTECTED]/filepath string. Can you confirm this, or do you believe that the problem could be caused by other factors ( like server settings ) ? Could you suggest me e workaround? Thank you, Giulio Cantoberon Multimedia srl http://www.cantoberon.it Tel. 06 39737052
Re: [PHP] fopen problem using ftp
Giulio wrote: HI all, I have a script that uses fopen to acces for read a file using ftp: $filepointer = fopen($address,'r'); having $address string formed this way: $address = ftp:/ /.$FTPuser.:.$FTPpassword.@.$FTPserver./.$FileFolder./.$FileNa me; You really don't need all those '.' in there:P $address = ftp://$FTPuser:[EMAIL PROTECTED]/$FileFolder/$FileName; will work just fine. Not any faster or anything, just more readable. This script always worked for me, it has now stopped working trying it on the server of a different provider, returning an error 'failed to open stream...' I have the suspect that the funcion is failing due to the particular account name ( used also as FTP username ) this italian provider gived me when I sibscribed: It contains a @ symbol ( I.E., [EMAIL PROTECTED] ), and I believe that this confuses the parsing of the ftp://User:[EMAIL PROTECTED]/filepath string. Can you confirm this, or do you believe that the problem could be caused by other factors ( like server settings ) ? Could you suggest me e workaround? Try using just the 123456 of the username... Probably won't work, but worth a shot. Or do this: $FTPuserURL = urlencode($FTPuser); before you compose the $address, and use $FTPuserURL instead of $FTPuser. That will replace the @ with %40 which will almost for sure be the kosher way have @ in an FTP username in a URL. Technically, you could/should also urlencode() the password and FilePath and FileName, I think. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen problem using ftp
Why not use the built in FTP functions instead of fopen? us2.php.net/ftp Those should be able to handle any of the address problems you have, seeing as they don't use the ftp://username:[EMAIL PROTECTED] syntax, they open a connection and work with the FTP system. -- The Disguised Jedi [EMAIL PROTECTED] Now you have my $0.02. Or .01 Pounds, .014 Euros, or $0.025 CAN. I'm already internationally compatible! PHP rocks! Knowledge is Power. Power Corrupts. Go to school, become evil Disclaimer: Any disclaimer attached to this message may be ignored. However, I must say that the ENTIRE contents of this message are subject to other's criticism, corrections, and speculations. This message is Certified Virus Free -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen, fsockopen on my virtual host
Richard Lynch wrote: Al wrote: Richard Lynch wrote: Al wrote: I've got a script that fetches a stream from a file on our virtual host. Its been working fine; but, yesterday they changed something and it no longer works. Can you define no longer works a bit more clearly... Error messages? Just times out? What? $fp= fsockopen(www.oursite.org, 80, $errno, $errstr, 30); I can use any remote site and fscockopen works fine. Anyone have a suggestion as to how I deal with this problem? if ($errno){ error_log(fsockopen errored out with # $errno: $errstr); } Here is my error report: Warning: fsockopen(): unable to connect to www.restonrunners.org:80 in /www/r/reston/htdocs/phpList/PQ/PQutility.php on line 364 Operation timed out (60) fsockopen() works fine with remote URLs and even localhost; but, not with our own URL. I'd use localhost but, I need to attach some GET arguments and I can't figure out a way to do it. e.g., $str= file_get_contents(localhost?page=processqueuelogin=Pminpassword=x) Put some quotes on that, and http:// on the front, and it should work as-is. Your own domain not working is a symptom of something else though... Can you ping restonrunners.org? What happens if you try to do this in a shell: telnet restonrunners.org 80 GET / HTTP/1.0 Host: restonrunners.org Hit 'return' twice after the 'Host:' line. You should get your homepage. You may have some firewall mis-configured, or DNS issues, or /etc/hosts might be messed up or... Many things *could* be wrong to cause this, but none of them are really PHP-related. You are correct, the problem is due to the host switching to load balancing servers. Required syntax is now fsockopen(localhost.domain.com, port, time) and $string= file_get_contents(http://localhost.domain.com/path;). Thanks again -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fopen, fsockopen on my virtual host
I've got a script that fetches a stream from a file on our virtual host. Its been working fine; but, yesterday they changed something and it no longer works. $fp= fsockopen(www.oursite.org, 80, $errno, $errstr, 30); I can use any remote site and fscockopen works fine. Anyone have a suggestion as to how I deal with this problem? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen, fsockopen on my virtual host
Al wrote: I've got a script that fetches a stream from a file on our virtual host. Its been working fine; but, yesterday they changed something and it no longer works. Can you define no longer works a bit more clearly... Error messages? Just times out? What? $fp= fsockopen(www.oursite.org, 80, $errno, $errstr, 30); I can use any remote site and fscockopen works fine. Anyone have a suggestion as to how I deal with this problem? if ($errno){ error_log(fsockopen errored out with # $errno: $errstr); } -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen, fsockopen on my virtual host
Richard Lynch wrote: Al wrote: I've got a script that fetches a stream from a file on our virtual host. Its been working fine; but, yesterday they changed something and it no longer works. Can you define no longer works a bit more clearly... Error messages? Just times out? What? $fp= fsockopen(www.oursite.org, 80, $errno, $errstr, 30); I can use any remote site and fscockopen works fine. Anyone have a suggestion as to how I deal with this problem? if ($errno){ error_log(fsockopen errored out with # $errno: $errstr); } Here is my error report: Warning: fsockopen(): unable to connect to www.restonrunners.org:80 in /www/r/reston/htdocs/phpList/PQ/PQutility.php on line 364 Operation timed out (60) fsockopen() works fine with remote URLs and even localhost; but, not with our own URL. I'd use localhost but, I need to attach some GET arguments and I can't figure out a way to do it. e.g., $str= file_get_contents(localhost?page=processqueuelogin=Pminpassword=x) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen, fsockopen on my virtual host
Richard Lynch wrote: Al wrote: I've got a script that fetches a stream from a file on our virtual host. Its been working fine; but, yesterday they changed something and it no longer works. Can you define no longer works a bit more clearly... Error messages? Just times out? What? $fp= fsockopen(www.oursite.org, 80, $errno, $errstr, 30); I can use any remote site and fscockopen works fine. Anyone have a suggestion as to how I deal with this problem? if ($errno){ error_log(fsockopen errored out with # $errno: $errstr); } Same, only a minor typo correction Here is my error report: Warning: fsockopen(): unable to connect to www.restonrunners.org:80 in /www/r/restonrunners/htdocs/phpList/PQ/PQutility.php on line 364 Operation timed out (60) fsockopen() works fine with remote URLs and even localhost; but, not with our own URL. I'd use localhost but, I need to attach some GET arguments and I can't figure out a way to do it. e.g., $str= file_get_contents(localhost?page=processqueuelogin=Pminpassword=x) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen, fsockopen on my virtual host
Al wrote: Richard Lynch wrote: ... $str= file_get_contents(localhost?page=processqueuelogin=Pminpassword=x) $str = file_get_contents('http://localhost/?page=processqueuelogin=Pminpassword=x'); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen, fsockopen on my virtual host
Al wrote: Richard Lynch wrote: Al wrote: I've got a script that fetches a stream from a file on our virtual host. Its been working fine; but, yesterday they changed something and it no longer works. Can you define no longer works a bit more clearly... Error messages? Just times out? What? $fp= fsockopen(www.oursite.org, 80, $errno, $errstr, 30); I can use any remote site and fscockopen works fine. Anyone have a suggestion as to how I deal with this problem? if ($errno){ error_log(fsockopen errored out with # $errno: $errstr); } Here is my error report: Warning: fsockopen(): unable to connect to www.restonrunners.org:80 in /www/r/reston/htdocs/phpList/PQ/PQutility.php on line 364 Operation timed out (60) fsockopen() works fine with remote URLs and even localhost; but, not with our own URL. I'd use localhost but, I need to attach some GET arguments and I can't figure out a way to do it. e.g., $str= file_get_contents(localhost?page=processqueuelogin=Pminpassword=x) Put some quotes on that, and http:// on the front, and it should work as-is. Your own domain not working is a symptom of something else though... Can you ping restonrunners.org? What happens if you try to do this in a shell: telnet restonrunners.org 80 GET / HTTP/1.0 Host: restonrunners.org Hit 'return' twice after the 'Host:' line. You should get your homepage. You may have some firewall mis-configured, or DNS issues, or /etc/hosts might be messed up or... Many things *could* be wrong to cause this, but none of them are really PHP-related. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen/fpassthur
Sebastian wrote: Q I hope you have some good data validation going on too :) I am not too sure about how secure it is. basically, the files are called by an ID eg, download?type=fileid=3 so i query the db to get check if its a valid id and get the filename from the db as well. if its not found it errors out.. i was under the impression that is more secure to get files by an id from db than doing something like download?file=filename.zip i am worried about security as i am not even sure if this method would allow people to download any file from the server. maybe if you have time you can look at the script for me and find any flaws While this method may not present a clear security danger, how does the data get into the database? If I can feed a filename of anything on your system that you blindly put in the database, then I can call it with an appropriate URL. So... you can trust data coming from your database only if it was trusted/validated/sanitized going in. :) -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fopen/fpassthur
Hi all, I have created a download manger to handle files, when a user clicks a link the file is sent though fopen() and fpassthru() like this: header(Content-type: application/octet-stream); header(Content-disposition: attachment; filename= . $file['filename']); header(Content-transfer-encoding: binary); header(Content-length: . filesize($file['path'] . $file['filename'])); // get file contents $file = @fopen($file['path'] . $file['filename'], 'r'); // output fpassthru($file); exit; is this the most practical way of doing it? i don't want to display file location.. the script seems to be working okay, but i was just looking for opinions on the method. also, is it possible to insert a txt file on the fly if the file they're downloading is a ZIP file? if so, any ideas how? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen/fpassthur
Sebastian wrote: Hi all, I have created a download manger to handle files, when a user clicks a link the file is sent though fopen() and fpassthru() like this: fopen() + fpassthru() == http://php.net/readfile is this the most practical way of doing it? i don't want to display file location.. the script seems to be working okay, but i was just looking for opinions on the method. also, is it possible to insert a txt file on the fly if the file they're downloading is a ZIP file? if so, any ideas how? Probably. http://php.net/zlib should give you some ideas in that direction. It would maybe be easier to start with all unzipped files, and zip them with your text file when you send them out... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen/fpassthur
Hello Sebastian, Tuesday, December 14, 2004, 4:19:31 PM, you wrote: S header(Content-type: application/octet-stream); S header(Content-disposition: attachment; filename= . $file['filename']); S header(Content-transfer-encoding: binary); S header(Content-length: . filesize($file['path'] . $file['filename'])); I use something almost identical, except I upper-case the second words (Content-Type, Content-Disposition, etc). Not that I've found a browser in active use yet that cares less, but there we go. I'd fclose() when done, and no need to exit() - it's the last line of your script anyway. I hope you have some good data validation going on too :) S is this the most practical way of doing it? i don't want to display S file location.. the script seems to be working okay, but i was just It is the way to do it, yes. You may get some varying suggestions re: the correct headers to use though. But what you have will actually work just fine (as you've found). S also, is it possible to insert a txt file on the fly if the file S they're downloading is a ZIP file? if so, any ideas how? No, you cannot interrupt the stream. Or do anything after it for that matter - you are simulating an HTTP request for a file, that is what you're sending back. There is no way to inject something else into this single transmission. Think of another way around it. Best regards, Richard Davey -- http://www.launchcode.co.uk - PHP Development Services I am not young enough to know everything. - Oscar Wilde -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen/fpassthur
Richard Davey wrote: no need to exit() - it's the last line of your script anyway. There was a bug in PHP for a very brief period of time where scripts were not ending under some conditions after all the content was delivered. If one is running that version of PHP, exit; at the end of a script is a Good Thing. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen/fpassthur
Sebastian wrote: Q I hope you have some good data validation going on too :) I am not too sure about how secure it is. basically, the files are called by an ID eg, download?type=fileid=3 so i query the db to get check if its a valid id and get the filename from the db as well. if its not found it errors out.. i was under the impression that is more secure to get files by an id from db than doing something like download?file=filename.zip i am worried about security as i am not even sure if this method would allow people to download any file from the server. maybe if you have time you can look at the script for me and find any flaws ;) If you mean any of the potential downloads, you've got big problems. :-) What's to stop somebody from trying id=4 and id=5 and so on and getting *ALL* the files? If you mean they could download *any* file, even the ones you're not trying to let somebody download, it would be more efficient to see the script itself to point out flaws, rather than just surfing to the site and trying to break it. Though that can be instructive too, especially if you have acquired the same sort of tools your average script kiddie uses to try to break in and steal stuff. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen/fpassthur
Q I hope you have some good data validation going on too :) I am not too sure about how secure it is. basically, the files are called by an ID eg, download?type=fileid=3 so i query the db to get check if its a valid id and get the filename from the db as well. if its not found it errors out.. i was under the impression that is more secure to get files by an id from db than doing something like download?file=filename.zip i am worried about security as i am not even sure if this method would allow people to download any file from the server. maybe if you have time you can look at the script for me and find any flaws ;) thanks. - Original Message - From: Richard Davey [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, December 14, 2004 12:27 PM Subject: Re: [PHP] fopen/fpassthur Hello Sebastian, Tuesday, December 14, 2004, 4:19:31 PM, you wrote: S header(Content-type: application/octet-stream); S header(Content-disposition: attachment; filename= . $file['filename']); S header(Content-transfer-encoding: binary); S header(Content-length: . filesize($file['path'] . $file['filename'])); I use something almost identical, except I upper-case the second words (Content-Type, Content-Disposition, etc). Not that I've found a browser in active use yet that cares less, but there we go. I'd fclose() when done, and no need to exit() - it's the last line of your script anyway. I hope you have some good data validation going on too :) S is this the most practical way of doing it? i don't want to display S file location.. the script seems to be working okay, but i was just It is the way to do it, yes. You may get some varying suggestions re: the correct headers to use though. But what you have will actually work just fine (as you've found). S also, is it possible to insert a txt file on the fly if the file S they're downloading is a ZIP file? if so, any ideas how? No, you cannot interrupt the stream. Or do anything after it for that matter - you are simulating an HTTP request for a file, that is what you're sending back. There is no way to inject something else into this single transmission. Think of another way around it. Best regards, Richard Davey -- http://www.launchcode.co.uk - PHP Development Services I am not young enough to know everything. - Oscar Wilde -- 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] fopen/fpassthur
Hi all, I have created a download manger to handle files, when a user clicks a link the file is sent though fopen() and fpassthru() you could try http://us3.php.net/readfile -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fopen by URL is disabled, is there another way of reading a remote webpage?
Hi, my new server has fopen by url disabled. My ISP doesn't want to turn it on. So is there a way to do an equivilant function some other way? I need to read a remote webpage and manipulate it. Thanks, Chuck -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen by URL is disabled, is there another way of reading a remote webpage?
On Wed, 20 Oct 2004 10:46:34 -0500, Chuck Barnett [EMAIL PROTECTED] wrote: Hi, my new server has fopen by url disabled. My ISP doesn't want to turn it on. So is there a way to do an equivilant function some other way? I need to read a remote webpage and manipulate it. #!/usr/bin/php ?php `wget http://yahoo.com` ? -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen by URL is disabled, is there another way of reading a remote webpage?
-- Original message from Chuck Barnett : -- Hi, my new server has fopen by url disabled. My ISP doesn't want to turn it on. So is there a way to do an equivilant function some other way? I need to read a remote webpage and manipulate it. Thanks, Chuck You could use sockets. Here's an example from the archives http://marc.theaimsgroup.com/?l=php-generalm=105052005332001w=2 The example is sending a POST, but you can easily change it to a GET. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] fopen by URL is disabled, is there another way of readi ng a remote webpage?
CURL? http://www.php.net/manual/en/ref.curl.php Warren Vail -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 20, 2004 10:25 AM To: Chuck Barnett Cc: PHP General List Subject: Re: [PHP] fopen by URL is disabled, is there another way of reading a remote webpage? -- Original message from Chuck Barnett : -- Hi, my new server has fopen by url disabled. My ISP doesn't want to turn it on. So is there a way to do an equivilant function some other way? I need to read a remote webpage and manipulate it. Thanks, Chuck You could use sockets. Here's an example from the archives http://marc.theaimsgroup.com/?l=php-generalm=105052005332001w=2 The example is sending a POST, but you can easily change it to a GET. -- 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] fopen and http://
Hi, I'm having a problem with fopen and http files. I keep getting the error: Warning: fopen(http://zed/htdocs/rgfindingaids/series594.html ) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/awilliam/public_html/rgfaidstest.php on line 15 http://zed/htdocs/rgfindingaids/series594.html does not exist Warning: fopen(http://zed/htdocs/rgfindingaids/ser391.html ) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/awilliam/public_html/rgfaidstest.php on line 15 http://zed/htdocs/rgfindingaids/ser391.html does not exist Warning: fopen(http://zed/htdocs/rgfindingaids/ser392.html ) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/awilliam/public_html/rgfaidstest.php on line 15 http://zed/htdocs/rgfindingaids/ser392.html does not exist I have a text file /home/awilliam/public_html/rgfaids containing URLs such as: http://zed/htdocs/rgfindingaids/series594.html http://zed/htdocs/rgfindingaids/ser391.html http://zed/htdocs/rgfindingaids/ser392.html and I can bring up these URLs fine in a browser on the PC i'm running the script on. The following is my code: ? $filelist = fopen(/home/awilliam/public_html/rgfaids, r); if (!$filelist) { echo error opening rgfaids; exit; } while ( !feof($filelist)) { $line = fgets($filelist, 9); $filetotest = fopen($line, r); if (!$filetotest) { echo $line does not existbr; } elseif ($filetotest) { echo $line does exist; } } ? But I don't understand why I am getting that error about failed to open strem: HTTP request failed, when I can bring up the links fine in a browser on the server running the php script. So can anyone help me out? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php