From 608107674175360f495839d31b12edb936ce2638 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 22 Sep 2014 19:44:03 +0000 Subject: [PATCH] * Admin: using proxy configuration from setup for update-check and retrieving EPL license from my.stylite.de --- phpgwapi/inc/class.egw_framework.inc.php | 39 +++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/phpgwapi/inc/class.egw_framework.inc.php b/phpgwapi/inc/class.egw_framework.inc.php index 131c1f8b12..6ad516ef55 100644 --- a/phpgwapi/inc/class.egw_framework.inc.php +++ b/phpgwapi/inc/class.egw_framework.inc.php @@ -938,7 +938,7 @@ abstract class egw_framework { $versions = array(); $security = null; - if (($remote = file_get_contents(egw_framework::CURRENT_VERSION_URL))) + if (($remote = file_get_contents(egw_framework::CURRENT_VERSION_URL, false, self::proxy_context()))) { list($current, $security) = explode("\n", $remote); if (empty($security)) $security = $current; @@ -977,6 +977,43 @@ abstract class egw_framework return null; } + /** + * Get context to use with file_get_context or fopen to use our proxy settings from setup + * + * @param string $username =null username for regular basic auth + * @param string $password =null password --------- " ---------- + * @return resource|null context to use with file_get_context/fopen or null if no proxy configured + */ + public static function proxy_context($username=null, $password=null) + { + if (empty($GLOBALS['egw_info']['server']['httpproxy_server'])) + { + return null; + } + + $opts = array ( + 'method' => 'GET', + 'proxy' => 'tcp://'.$GLOBALS['egw_info']['server']['httpproxy_server'].':'. + ($GLOBALS['egw_info']['server']['httpproxy_port'] ? $GLOBALS['egw_info']['server']['httpproxy_port'] : 8080), + 'request_fulluri' => true, + ); + // proxy authentication + if (!empty($GLOBALS['egw_info']['server']['httpproxy_server_username'])) + { + $opts['header'][] = 'Proxy-Authorization: Basic '.base64_encode($GLOBALS['egw_info']['server']['httpproxy_server_username'].':'. + $GLOBALS['egw_info']['server']['httpproxy_server_password']); + } + // optional authentication + if (isset($username)) + { + $opts['header'][] = 'Authorization: Basic '.base64_encode($username.':'.$password); + } + return stream_context_create(array( + 'http' => $opts, + 'https' => $opts, + )); + } + /** * Check if version is older then $days days *