diff --git a/config/example-config.php b/config/example-config.php index 460ef0c4..82e3673e 100644 --- a/config/example-config.php +++ b/config/example-config.php @@ -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 diff --git a/inc/external-fetch.php b/inc/external-fetch.php index dd5cddd9..a65e6e02 100644 --- a/inc/external-fetch.php +++ b/inc/external-fetch.php @@ -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 ); } } }