* Admin: using proxy configuration from setup for update-check and retrieving EPL license from my.stylite.de

This commit is contained in:
Ralf Becker 2014-09-22 19:44:03 +00:00
parent 06dd8b2adb
commit 6081076741

View File

@ -938,7 +938,7 @@ abstract class egw_framework
{ {
$versions = array(); $versions = array();
$security = null; $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); list($current, $security) = explode("\n", $remote);
if (empty($security)) $security = $current; if (empty($security)) $security = $current;
@ -977,6 +977,43 @@ abstract class egw_framework
return null; 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 * Check if version is older then $days days
* *