Set the user agent string for external calendars

This commit is contained in:
Jan Losinski 2017-04-24 21:20:34 +00:00 committed by Florian Schlichting
parent a16dfc7c41
commit b5072dd154
2 changed files with 11 additions and 2 deletions

View File

@ -211,6 +211,13 @@ $c->admin_email ='calendar-admin@example.com';
*/
// $c->external_refresh = 60;
/**
* External subscription (BIND) user agent string
* Required if your remote calendar only delivers to known user agents.
* Default: none
*/
// $c->external_ua_string = '';
/**
* If you want to force DAViCal to use HTTP Digest Authentication for CalDAV
* access. Note that this requires all user passwords to be stored in plain text

View File

@ -39,7 +39,7 @@ function create_external ( $path,$is_calendar,$is_addressbook )
}
}
function fetch_external ( $bind_id, $min_age = '1 hour' )
function fetch_external ( $bind_id, $min_age = '1 hour', $ua_string )
{
if ( ! function_exists ( "curl_init" ) ) {
dbg_error_log("external", "external resource cannot be fetched without curl, please install curl");
@ -64,6 +64,8 @@ function fetch_external ( $bind_id, $min_age = '1 hour' )
curl_setopt ( $curl, CURLOPT_NOBODY, true );
curl_setopt ( $curl, CURLOPT_TIMEVALUE, $local_ts->format("U") );
curl_setopt ( $curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE );
if ( isset( $ua_string ) )
curl_setopt($curl, CURLOPT_USERAGENT, $ua_string);
dbg_error_log("external", "checking external resource for remote changes " . $row->external_url );
$ics = curl_exec ( $curl );
$info = curl_getinfo ( $curl );
@ -115,7 +117,7 @@ function update_external ( $request )
if ( $qry->Exec('DAVResource') && $qry->rows() > 0 && $row = $qry->Fetch() ) {
if ( $row->bind_id != 0 ) {
dbg_error_log("external", "external resource needs updating, this might take a minute : %s", $row->url );
fetch_external ( $row->bind_id, $c->external_refresh . ' minutes' );
fetch_external ( $row->bind_id, $c->external_refresh . ' minutes', $c->external_ua_string );
}
}
}