mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-05-28 03:04:15 +00:00
Set the user agent string for external calendars
This commit is contained in:
parent
a16dfc7c41
commit
b5072dd154
@ -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
|
||||
|
||||
@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user