tags:

views:

783

answers:

2

I have a PHP script which is running on a windows server. The script creates a soapclient object which can be given proxy_host and a proxy_port. Rather than hardcoding these values or making them a config option, I'd like the PHP script to automatically detect the local server's proxy settings so that if they change or if the script is run on a different server, it will just work. Does anybody know how to do this in PHP.

A: 

I don't believe this is currently possible, given the wide range of possible proxy configurations. Typically, components (such as payment gateways) provide configuration settings for proxy information (usually in the php.ini file) where you could set these. Otherwise, if you're running on a *Nix based environment, you could try to get the environment settings for the currently running user, using the following method:

http://us.php.net/manual/en/function.getenv.php

This way, if the servers user changes the proxy settings, your script could pick it up, and attempt to use it.

drowe
A: 

This is somewhat crazy, and you probably do not want to do this. But under win32 you could write a php addon to get the value of WinHttpGetIEProxyConfigForCurrentUser().

Alternatively with some more research you could probably find the registry values and then query them using win32std.

Jon Clegg