Page 1 of 1

fopen() behind proxy server

Posted: Tue Apr 15, 2003 8:45 am
by Nicolas777
Hi,

I have a problem with fopen() function.

I'm working on localhost and my computer is behind proxy server. I'm trying to open URL with fopen() function and the script tells me the following:

failed to create stream: Invalid argument in ...

Posted: Tue Apr 15, 2003 8:48 am
by Jim
You're trying to open a URL? Do you mean you're trying to open a file on another server?

Posted: Thu Apr 17, 2003 6:48 am
by Nicolas777
Yes. I want to open jpg file from some server.

Posted: Thu Apr 17, 2003 7:39 am
by volka
url-wrappers are enabled?

Code: Select all

<?php phpinfo(); ?>
will tell you

Code: Select all

Directive               Local Value Master Value
allow_call_time_pass_reference     Off          Off
allow_url_fopen                    On           On
...

Posted: Thu Apr 17, 2003 8:06 am
by Nicolas777

Code: Select all

Directive                     Local Value Master Value 
allow_call_time_pass_reference     On          On 
allow_url_fopen                    On          On

Posted: Thu Apr 17, 2003 8:20 am
by volka
is it a transparent proxy used for all outgoing inet-connections?
try

Code: Select all

<html><body><pre>
<?php
	// 64.246.30.37 --> php.net
	echo "gethostbyaddr('64.246.30.37') : ";
	flush();
	echo gethostbyaddr('64.246.30.37'), "\n";
	
	echo "fsockopen with ip \n";
	flush();
	$s = fsockopen('64.246.30.37', 80, $errno, $errstr, 15) or die('fsockopen failed : #'. $errno . ', '. $errstr);
	fclose($s);
	
	echo "fopen with ip \n";
	flush();
	$fp = fopen('http://64.246.30.37', 'rb') or die('fopen/http-ip failed');
	fclose($fp);
	
	echo "fopen with php.net \n";
	flush();
	$fp = fopen('http://php.net', 'rb') or die('fopen/http failed');
	
	echo "file('http://www.php.net')\n";
	flush();
	file('http://www.php.net')  or die('file/http failed');
	
	echo 'done.';
?>
</pre></body></html>

Posted: Thu Apr 17, 2003 8:29 am
by Nicolas777
I ran this script, and it gives me the following result :

Code: Select all

gethostbyaddr('64.246.30.37') : 64.246.30.37
fsockopen with ip 

Warning:  fsockopen() &#1111;function.fsockopen]: php_hostconnect: connect failed in c:\program files\apache group\apache\htdocs\test.php on line 10

Warning:  fsockopen() &#1111;function.fsockopen]: unable to connect to 64.246.30.37:80 in c:\program files\apache group\apache\htdocs\test.php on line 10

Fatal error:  Maximum execution time of 30 seconds exceeded in c:\program files\apache group\apache\htdocs\test.php on line 10