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 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
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 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
Re: [PHP] fopen and http://
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 do you have allow_url_fopen enabled? http://us4.php.net/manual/en/ref.filesystem.php#ini.allow-url-fopen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen and http://
On Fri, 8 Oct 2004, Matt M. wrote: 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 do you have allow_url_fopen enabled? http://us4.php.net/manual/en/ref.filesystem.php#ini.allow-url-fopen Yes I do, in my php.ini I have: ;; ; Fopen wrappers ; ;; ; Whether to allow the treatment of URLs (like http:// or ftp://) as files. allow_url_fopen = On -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen and http://
Adam Williams schrieb: 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 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 What say phpinfo about Registered PHP Streams ? Hendrik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen and http://
On Fri, 8 Oct 2004, Hendrik Schmieder wrote: What say phpinfo about Registered PHP Streams ? Hendrik Hi, I think I just figured out my problem...I had to use rtrim($line) because I think there was a \n or an invisible character at the end of the line that was being passed to the http:// server from looking at the server's access_log and error_log files. So now it works except on the very last line it processes, it prints does not exist, so there is still some sort of a hidden character but its not affecting fetching the URLs from the web server. so i'm still trying to figure that last line out, but everything else works. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
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: [EMAIL PROTECTED] 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
Re: [PHP] fopen and http://
On Fri, 8 Oct 2004 08:33:11 -0500 (CDT), Adam Williams [EMAIL PROTECTED] wrote: So now it works except on the very last line it processes, it prints does not exist, so there is still some sort of a hidden character but its not affecting fetching the URLs from the web server. so i'm still trying to figure that last line out, but everything else works. That new problem you're having might just be an extra newline in the file. Make sure you don't have any blank lines at the end, or check to make sure you actually have a URL to fetch before trying to grab it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php