473,385 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

fopen url wrapper

system:
php 4.4.2
windows 2003 server
apache 1.3.x

problem:
scripts don't work :-P

description:

$x='http://exmaple.com/file.txt';

Either:
$content=file_get_contents($x)

Or:
$fp=fopen($x,'r');

[ Would assume this as well:
$content=file($x); ]

When I attempt to access a script on a certain Win2K3 server that
attempts to read a remote file using the fopen url wrappers, I get some
strange results:

Opera (nothing)
MSIE (cannot be reached page [browser default thing])
Firefox (prompt to download)

I sent a head request via lynx, and this is what I get (even after
turning off windows firewall):

Looking up example.com
Making HTTP connection to example.com
Sending HTTP request.
HTTP request sent; waiting for response.
Alert!: Unexpected network read error; connection aborted.
Can't Access `http://example/test.php'
Alert!: Unable to access document.

Everything that I thought of checking in both httpd.conf and php.ini
seem to be just fine.

Does anyone have direction for troubleshooting this?
--
Justin Koivisto, ZCE - ju****@koivi.com
http://koivi.com
Feb 21 '06 #1
7 10371
Justin Koivisto wrote:
system:
php 4.4.2
windows 2003 server
apache 1.3.x

problem:
scripts don't work :-P

Right. :P
description:

$x='http://exmaple.com/file.txt';

Either:
$content=file_get_contents($x)

Or:
$fp=fopen($x,'r');

[ Would assume this as well:
$content=file($x); ]

When I attempt to access a script on a certain Win2K3 server that
attempts to read a remote file using the fopen url wrappers, I get some
strange results:

Opera (nothing)
MSIE (cannot be reached page [browser default thing])
Firefox (prompt to download)

I don't think your browser is of any concern.
Your script cannot get the remote contents. This is a PHP-issue, and not a
browser issue.

I sent a head request via lynx, and this is what I get (even after
turning off windows firewall):

Looking up example.com
Making HTTP connection to example.com
Sending HTTP request.
HTTP request sent; waiting for response.
Alert!: Unexpected network read error; connection aborted.
Can't Access `http://example/test.php'
Alert!: Unable to access document.
Good test. :-)

It shows your script hangs.

Did you check the part on fopenwrappers at php.net?
Start here:
http://nl2.php.net/manual/en/ref.fil...llow-url-fopen
[START_QUOTE]

allow_url_fopen boolean

This option enables the URL-aware fopen wrappers that enable accessing
URL object like files. Default wrappers are provided for the access of
remote files using the ftp or http protocol, some extensions like zlib may
register additional wrappers.

Note: This setting can only be set in php.ini due to security
reasons.

Note: This option was introduced immediately after the release of
version 4.0.3. For versions up to and including 4.0.3 you can only disable
this feature at compile time by using the configuration switch
--disable-url-fopen-wrapper.

[END_QUOTE]

So check your php.ini settings first.

If that doesn't help, come back here. :-)

Regards,
Erwin Moller

Everything that I thought of checking in both httpd.conf and php.ini
seem to be just fine.

Does anyone have direction for troubleshooting this?


Feb 22 '06 #2
Erwin Moller wrote:
Justin Koivisto wrote:
system:
php 4.4.2
windows 2003 server
apache 1.3.x

description:

$x='http://exmaple.com/file.txt';

Either:
$content=file_get_contents($x)

Or:
$fp=fopen($x,'r');

When I attempt to access a script on a certain Win2K3 server that
attempts to read a remote file using the fopen url wrappers, I get some
strange results:

Opera (nothing)
MSIE (cannot be reached page [browser default thing])
Firefox (prompt to download)
I don't think your browser is of any concern.
Your script cannot get the remote contents. This is a PHP-issue, and not a
browser issue.


No, the browser shouldn't matter, but I thought maybe someone else had a
similar issue but didn't relate it to the url fopen stuff. If they saw
the browser behavior, it may remind them. ;)
I sent a head request via lynx, and this is what I get (even after
turning off windows firewall):

Looking up example.com
Making HTTP connection to example.com
Sending HTTP request.
HTTP request sent; waiting for response.
Alert!: Unexpected network read error; connection aborted.
Can't Access `http://example/test.php'
Alert!: Unable to access document.


Good test. :-)

It shows your script hangs.


I've been using lynx like this for the last year now, it sure seems to
help cut some time off guess work - especially when you are dealing with
the header() function..
Did you check the part on fopenwrappers at php.net?
Start here:
http://nl2.php.net/manual/en/ref.fil...llow-url-fopen

So check your php.ini settings first.


That was the first thing I checked to no avail. It was set correctly,
but I modified the file, resaved and restarted Apache just to be sure. I
also checked the phpinfo() output to be sure the php.ini file was where
it was expected and that the value of allow_url_fopen was set to On.

--
Justin Koivisto, ZCE - ju****@koivi.com
http://koivi.com
Feb 22 '06 #3
Justin Koivisto wrote:

<snip>
Did you check the part on fopenwrappers at php.net?
Start here:
http://nl2.php.net/manual/en/ref.fil...llow-url-fopen

So check your php.ini settings first.


That was the first thing I checked to no avail. It was set correctly,
but I modified the file, resaved and restarted Apache just to be sure. I
also checked the phpinfo() output to be sure the php.ini file was where
it was expected and that the value of allow_url_fopen was set to On.


Hi,

Ok, that is clear (and right configured) then.
Last thing I can think of:
I once had excactly the same situation, hanging fopen-wrapper.
In my case it turned out that the page I was trying to grab used some
redirection at the server that fopen-wrapper could not handle.

It boiled down to:
1) Client send request (your php/fopenwrapper)
2) Server answer with 'MOVED PERMANENTLY' or something like that.
3) fopenwrappen got completely confused.

That happened with PHP4.3 I think (not sure).

So my suggestion would be to use you lynx again to check this.
Can it handle the url you are trying to grab?

Regards,
Erwin Moller

Feb 22 '06 #4
Erwin Moller wrote:
Justin Koivisto wrote:

<snip>
Did you check the part on fopenwrappers at php.net?
Start here:
http://nl2.php.net/manual/en/ref.fil...llow-url-fopen

So check your php.ini settings first.

That was the first thing I checked to no avail. It was set correctly,
but I modified the file, resaved and restarted Apache just to be sure. I
also checked the phpinfo() output to be sure the php.ini file was where
it was expected and that the value of allow_url_fopen was set to On.


Ok, that is clear (and right configured) then.
Last thing I can think of:
I once had excactly the same situation, hanging fopen-wrapper.
In my case it turned out that the page I was trying to grab used some
redirection at the server that fopen-wrapper could not handle.

It boiled down to:
1) Client send request (your php/fopenwrapper)
2) Server answer with 'MOVED PERMANENTLY' or something like that.
3) fopenwrappen got completely confused.

That happened with PHP4.3 I think (not sure).

So my suggestion would be to use you lynx again to check this.
Can it handle the url you are trying to grab?


Yes, I've checked that before too (it's an XML file BTW):

HTTP/1.1 200 OK
Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
pre-check=0
Pragma: no-cache
Content-Type: text/xml;charset=iso-8859-1
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Server: Microsoft-IIS/6.0
Set-Cookie: PHPSESSID=a3c4ba9f6eb2dfe2d1b4d79230e4e614; path=/
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
Date: Wed, 22 Feb 2006 15:44:46 GMT
Connection: close
Fun, isn't it? :\

--
Justin Koivisto, ZCE - ju****@koivi.com
http://koivi.com
Feb 22 '06 #5
Justin Koivisto wrote:
Erwin Moller wrote:
Justin Koivisto wrote:

<snip>
Did you check the part on fopenwrappers at php.net?
Start here:
http://nl2.php.net/manual/en/ref.fil...llow-url-fopen

So check your php.ini settings first.
That was the first thing I checked to no avail. It was set correctly,
but I modified the file, resaved and restarted Apache just to be sure. I
also checked the phpinfo() output to be sure the php.ini file was where
it was expected and that the value of allow_url_fopen was set to On.


Ok, that is clear (and right configured) then.
Last thing I can think of:
I once had excactly the same situation, hanging fopen-wrapper.
In my case it turned out that the page I was trying to grab used some
redirection at the server that fopen-wrapper could not handle.

It boiled down to:
1) Client send request (your php/fopenwrapper)
2) Server answer with 'MOVED PERMANENTLY' or something like that.
3) fopenwrappen got completely confused.

That happened with PHP4.3 I think (not sure).

So my suggestion would be to use you lynx again to check this.
Can it handle the url you are trying to grab?


Yes, I've checked that before too (it's an XML file BTW):

HTTP/1.1 200 OK
Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
pre-check=0
Pragma: no-cache
Content-Type: text/xml;charset=iso-8859-1
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Server: Microsoft-IIS/6.0
Set-Cookie: PHPSESSID=a3c4ba9f6eb2dfe2d1b4d79230e4e614; path=/
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
Date: Wed, 22 Feb 2006 15:44:46 GMT
Connection: close
Fun, isn't it? :\


Darn. :-/
Sorry mate, I am out of options.

If you find the problem, please repost it here.
Good luck.

Regards,
Erwin Moller
Feb 22 '06 #6
Erwin Moller wrote:

Darn. :-/
Sorry mate, I am out of options.

If you find the problem, please repost it here.
Good luck.


I've contacted the ISP requesting remote access to a fresh os install of
the server so I can go through and do the installs myself so I exactly
how the system is set up. ;) We'll see what happens with that as my
client is the only one that is using the server at this time.

--
Justin Koivisto, ZCE - ju****@koivi.com
http://koivi.com
Feb 22 '06 #7
Justin Koivisto wrote:
Erwin Moller wrote:
Darn. :-/
Sorry mate, I am out of options.

If you find the problem, please repost it here.
Good luck.


I've contacted the ISP requesting remote access to a fresh os install of
the server so I can go through and do the installs myself so I exactly
how the system is set up. ;) We'll see what happens with that as my
client is the only one that is using the server at this time.


heh - that was the way to go... I have not idea why it wasn't working,
but it must have been something that they had done during their install
at some point.

--
Justin Koivisto, ZCE - ju****@koivi.com
http://koivi.com
Feb 23 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Oliver Spiesshofer | last post by:
Hi, I have a script that calls an fopen() on an external URL. I can run the script from the server as an url fine. When however the script should be run from crontab, it does not work. I get ...
1
by: Xerxes | last post by:
Hi, I want to open a file for debugging purposes and want to know how I can access it (write to it) from across multiple php files. I want to be able to write debugging information from within...
5
by: Shaoyong Wang | last post by:
Dear All, I want to write a simple PHP code to verify whether a given list of URLs is broken or not. The URLs given have various formats, for example, http://www.afro.com/history/history.html...
3
by: James | last post by:
Hi guys, I have been building a search engine here - not because I have plans of dethrowning Google but as a simple app upon which to develop a function set that I can use for other things. ...
5
by: meenasamy | last post by:
Hi all i have used a script that i downloaded and uses the fopen($url,'r'); function to access a url to retrieve data and i get this error Fatal error: fopen(): Unable to find the wrapper...
9
by: Julien Biezemans | last post by:
Hi! Here is the problem: I'd like to restrict local filesystem stream operations to one directory just like a root jail. fopen('/file.bin') would actually open /some/path/file.bin. One goal...
25
by: subramanian100in | last post by:
Consider the following program: #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv) { if (argc != 2) { printf("Usage: <program-name<text-file>\n");
0
by: Julien Biezemans | last post by:
Hi everyone, I've written a file:// scheme stream wrapper that acts like chroot() (but is more flexible, does not require root privileges and works on any platform). Everything works just fine...
0
by: Peter Frost | last post by:
We're running PHP4.3 on a Solaris 9 box. PHP was compiled with the following option: '--with-openssl=/usr/local/ssl' phpinfo() suggests that openssl is enabled. However, when we try to use...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.