forked from extern/egroupware
* Calendar: use proxy config from setup >> configuration to download holiday calendars
This commit is contained in:
parent
659bf156f6
commit
892fc79421
@ -603,11 +603,12 @@ abstract class Framework extends Framework\Extra
|
|||||||
*
|
*
|
||||||
* @param string $username =null username for regular basic Auth
|
* @param string $username =null username for regular basic Auth
|
||||||
* @param string $password =null password --------- " ----------
|
* @param string $password =null password --------- " ----------
|
||||||
|
* @param array $opts =array() further params for http(s) context, eg. array('timeout' => 123)
|
||||||
* @return resource|null context to use with file_get_context/fopen or null if no proxy configured
|
* @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)
|
public static function proxy_context($username=null, $password=null, array $opts = array())
|
||||||
{
|
{
|
||||||
$opts = array(
|
$opts += array(
|
||||||
'method' => 'GET',
|
'method' => 'GET',
|
||||||
);
|
);
|
||||||
if (!empty($GLOBALS['egw_info']['server']['httpproxy_server']))
|
if (!empty($GLOBALS['egw_info']['server']['httpproxy_server']))
|
||||||
|
@ -153,7 +153,7 @@ class calendar_holidays
|
|||||||
error_log("No holiday iCal for '$country'!");
|
error_log("No holiday iCal for '$country'!");
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
if (!($f = fopen($url, 'r')))
|
if (!($f = fopen($url, 'r', false, Api\Framework::proxy_context())))
|
||||||
{
|
{
|
||||||
error_log("Can NOT open holiday iCal '$url' for country '$country'!");
|
error_log("Can NOT open holiday iCal '$url' for country '$country'!");
|
||||||
return array();
|
return array();
|
||||||
@ -181,12 +181,8 @@ class calendar_holidays
|
|||||||
|
|
||||||
if (!isset($urls))
|
if (!isset($urls))
|
||||||
{
|
{
|
||||||
$ctx = stream_context_create(array(
|
if (!($json = file_get_contents(self::EGW_HOLIDAY_URL.self::HOLIDAY_PATH, false,
|
||||||
'http'=> array(
|
Api\Framework::proxy_context(null, null, array('timeout' => 1)))))
|
||||||
'timeout' => 1,
|
|
||||||
)
|
|
||||||
));
|
|
||||||
if (!($json = file_get_contents(self::EGW_HOLIDAY_URL.self::HOLIDAY_PATH, false, $ctx)))
|
|
||||||
{
|
{
|
||||||
$json = file_get_contents(EGW_SERVER_ROOT.self::HOLIDAY_PATH);
|
$json = file_get_contents(EGW_SERVER_ROOT.self::HOLIDAY_PATH);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user