diff --git a/php/classes/ProxyUtils.php b/php/classes/ProxyUtils.php index c1b666d..0d2266e 100644 --- a/php/classes/ProxyUtils.php +++ b/php/classes/ProxyUtils.php @@ -1,37 +1,39 @@ <?php class ProxyUtils { - static function addProxyForCurl(&$ch) { - $proxy_host = PROXY_HOST; - if (!empty($proxy_host)) { - curl_setopt($ch, CURLOPT_PROXY, "http://".$proxy_host); - $proxy_userpwd = PROXY_USERPWD; - if (!empty($proxy_userpwd)) { - curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxy_userpwd); - } - } - } + static function addProxyForCurl(&$ch) { + if ( defined(PROXY_HOST) ) { + $proxy_host = PROXY_HOST; + if (!empty($proxy_host)) { + curl_setopt($ch, CURLOPT_PROXY, "http://".$proxy_host); + $proxy_userpwd = PROXY_USERPWD; + if (!empty($proxy_userpwd)) { + curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxy_userpwd); + } + } + } + } - static function getStreamContextWithProxy() { - $proxy_host = PROXY_HOST; - if (empty($proxy_host)) - return; - $options = array( - 'http' => array( - 'method' => 'GET', - 'timeout' => '5', - 'user_agent' => 'PHP libxml agent', - 'ignore_errors' => true, - ) - ); - $options['http']['proxy'] = 'tcp://'.$proxy_host; - $options['http']['request_fulluri'] = TRUE; - $proxy_userpwd = PROXY_USERPWD; - if (!empty($proxy_userpwd)) { - $options['http']['header'] = "Proxy-Authorization: Basic ".base64_encode($proxy_userpwd); - } - return stream_context_create($options); - } + static function getStreamContextWithProxy() { + $proxy_host = PROXY_HOST; + if (!defined(PROXY_HOST) || empty($proxy_host)) + return; + $options = array( + 'http' => array( + 'method' => 'GET', + 'timeout' => '5', + 'user_agent' => 'PHP libxml agent', + 'ignore_errors' => true, + ) + ); + + $options['http']['proxy'] = 'tcp://'.$proxy_host; + $options['http']['request_fulluri'] = TRUE; + $proxy_userpwd = PROXY_USERPWD; + if (!empty($proxy_userpwd)) { + $options['http']['header'] = "Proxy-Authorization: Basic ".base64_encode($proxy_userpwd); + } + return stream_context_create($options); + } } - ?> -- libgit2 0.21.2