Page 1 of 1
PHP & Proxy
Posted: Mon Apr 11, 2005 9:29 am
by n00b Saibot
How should I configure the php.ini so that I can access outside pages via a proxy installed in the network. If now i try to access outside addresses ex.
Code: Select all
print file_get_contents('http://www.google.co.in');
it says
Warning: file_get_contents(): php_network_getaddresses: gethostbyname failed in c:\web\anurag\PHP_Utilities\SearchInfo.php on line 9
I tried to look through every setting/directive in the php.ini but I don't pass by any such configuration option
Is there any such setting

Posted: Mon Apr 11, 2005 9:44 am
by siefkencp
Have you tried using include?
Posted: Mon Apr 11, 2005 9:55 am
by n00b Saibot
siefkencp wrote:Have you tried using include?

What do you mean

Posted: Mon Apr 11, 2005 10:00 am
by Bennettman
When you include an outside page, it should get the code you usually see in the browser (i.e. the final code).
You could do the following to get the page into a variable:
Code: Select all
<?php
ob_start();
include 'http://www.google.co.in';
$content = ob_get_contents();
ob_end_clean();
?>
Posted: Mon Apr 11, 2005 11:01 am
by timvw
the problem is that php (actually, libdns or whatever your ip stack uses for hostname resolving) can't resolve the ip that belongs to the hostname.
what you could do is use an external dns server.. (add it to /etc/resolv.conf or read a windows manual

)
Posted: Tue Apr 12, 2005 2:54 am
by n00b Saibot
timvw wrote:the problem is that php (actually, libdns or whatever your ip stack uses for hostname resolving) can't resolve the ip that belongs to the hostname.
what you could do is use an external dns server.. (add it to /etc/resolv.conf or read a windows manual )
OK, Thanks for rep. but I have following:
OS: Win 98
Server: Apache 2.0
MySQL 4.sumthing
So all that libdns & /etc/resolv.conf goes tangent to my head.(not really but isn't really of that use to me

) OK, and now how will Windows Manual help in solving PHP's prob. After all I can connect to Google using IE. But the problem is that to access the net using PHP, it has to know the proxy settings. How to set it is what i am asking

Posted: Tue Apr 12, 2005 3:04 am
by timvw
it appears you can pass in a proxy variable (php5)
http://docs.php.net/en/wrappers.html
but at first sight it's not clear how to do it exactly..