Page 1 of 1

Problem with file() accessing a file from a website

Posted: Mon Jul 01, 2002 3:30 pm
by mcleo
Hi all,

I've got a big problem with a simple issue as I thought. I want to
read the index.html file from a known webserver. The script looks like:

Code: Select all

$baseurl="web.utanet.at";

//following two lines are for testing purposes 
$host=gethostbyname($baseurl);
echo("host: ".$host."<br>");

//here I add the http
$url="http://".$baseurl."/grbicver/index.html";
$ret = join('',file($url));
echo($ret."<br>");
The problem is:
accessing the file without "http://"
I get the errormessage "- No such file or directory in...."

Accessing the file with "http://" forces this messages:

Warning: php_network_getaddresses: gethostbyname failed in ...
Warning: file("http://web.utanet.at/index.htm") - No error in ...
Fatal error: Maximum execution time of 30 seconds exceeded in ...

My environment is NT4.0 with apache/php accessing via a PC with jana proxy server the web.

When I access a local webserver(also installed on the proxy PC) with the script above it works.

I've no idea what causes the problem. I 've already posted this problem
in a forum dedicated to the jana server without success.

Is anyone here who can figure out what the problem is (I mean not that one between chair and monitor) and/or can help me solving the problem?



With regards

Ralph
(mcleo)

try CURL

Posted: Mon Jul 01, 2002 6:44 pm
by llimllib
A solution that will prove to be more extensible (and probably faster) in the future will be to use the CURL library. First, go into your php.ini, under "extensions" and make sure it looks like this:

Code: Select all

;Windows Extensions
;Note that MySQL and ODBC support is now built in, so no dll is needed for it.
;
;extension=php_bz2.dll
;extension=php_ctype.dll
;extension=php_cpdf.dll
extension=php_curl.dll
That is, remove the semicolon in front of php_curl. Save php.ini, and restart your Apache process. Then, from the php manual, use:

Code: Select all

<?php
$ch = curl_init();

curl_setopt ($ch, CURLOPT_URL, "http://www.example.com/");
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
	
$result = curl_exec ($ch);

curl_close ($ch);
?>
$result should now be a string containing the contents of example.com.[/url]

Re: try CURL

Posted: Tue Jul 02, 2002 1:11 pm
by mcleo
Hi llimllib,

thanks for this idea but it doesn't work either.

I -now- think the problem is that I'm using the apache server in an intranet behind a proxyserver.

So do you know, or anyone else, how, from the view of the script, the function which accesses the web could know that the proxy should be used?

I don't know where to configure this in php.ini or in httpd.conf( if this is the right one I'll promise to change to the right forum :-))


Thanks in advance,
Ralph.