DAViCal
well-known.php
1 <?php
2 
3 dbg_error_log( 'well-known', 'iSchedule requested' );
4 
5 require_once('HTTPAuthSession.php');
6 $c->allow_unauthenticated = true;
7 $session = new HTTPAuthSession();
8 
9 if ( ! isset ( $request ) ) {
10  require_once('CalDAVRequest.php');
11  $request = new CalDAVRequest();
12 }
13 
14 
15 switch ( $request->path ) {
16  case '/.well-known/caldav':
17  case '/.well-known/carddav':
18  header('Location: ' . $c->protocol_server_port . ConstructURL('/',true) );
19  $request->DoResponse(301); // Moved permanently
20  // does not return.
21  case '/.well-known/timezone':
22  $parameters = '';
23  foreach( $_GET as $k => $v ) {
24  $parameters .= ($parameters == '' ? '?' : '&' );
25  $parameters .= $k.'='.rawurlencode($v);
26  }
27  header('Location: ' . $c->protocol_server_port . str_replace('/caldav.php', '', ConstructURL('/tz.php',true)).$parameters );
28  $request->DoResponse(301); // Moved permanently
29  // does not return.
30 }
31 
32 
33 
34 if ( $c->enable_scheduling != true )
35 {
36  $request->DoResponse( 404, translate('The application program does not understand that request.') );
37  // Does not return
38 }
39 dbg_error_log( 'well-known', 'method: ' . $request->method );
40 switch ( $request->method ) {
41  case 'GET':
42  ischedule_get();
43  break;
44 
45  case 'POST':
46  include('iSchedule-POST.php');
47  break;
48 
49  default:
50  dbg_error_log( 'well-known', 'Unhandled request method >>%s<<', $request->method );
51  dbg_log_array( 'well-known', '_SERVER', $_SERVER, true );
52  dbg_error_log( 'well-known', 'RAW: %s', str_replace("\n", '',str_replace("\r", '', $request->raw_post)) );
53 }
54 
55 $request->DoResponse( 500, translate('The application program does not understand that request.') );
56 
57 
58 
59 
60 
61 function ischedule_get ( )
62 {
63  global $request,$c;
64  if ( $request->path != '/.well-known/ischedule' || $_GET['query'] != 'capabilities' )
65  {
66  $request->DoResponse( 404, translate('The application program does not understand that request.' . $request->path ) );
67  return false;
68  }
69  header ( 'iSchedule-Version: 1.0' );
70  header ( 'Content-Type: application/xml; charset=utf-8' );
71  echo '<?xml version="1.0" encoding="utf-8" ?>';
72  echo <<<RESPONSE
73  <query-result xmlns="urn:ietf:params:xml:ns:ischedule">
74  <capability-set>
75  <supported-version-set>
76  <version>1.0</version>
77  </supported-version-set>
78  <supported-scheduling-message-set>
79  <comp name="VEVENT">
80  <method name="REQUEST"/>
81  <method name="ADD"/>
82  <method name="REPLY"/>
83  <method name="CANCEL"/>
84  </comp>
85  <comp name="VTODO"/>
86  <comp name="VFREEBUSY"/>
87  </supported-scheduling-message-set>
88  <supported-calendar-data-type>
89  <calendar-data-type content-type="text/calendar" version="2.0"/>
90  </supported-calendar-data-type>
91  <supported-attachment-values>
92  <inline-attachment/>
93  </supported-attachment-values>
94  <supported-recipient-uri-scheme-set>
95  <scheme>mailto</scheme>
96  </supported-recipient-uri-scheme-set>
97  <max-content-length>102400</max-content-length>
98  <min-date-time>19910101T000000Z</min-date-time>
99  <max-date-time>20381231T000000Z</max-date-time>
100  <max-instances>150</max-instances>
101  <max-recipients>250</max-recipients>
102 
103 RESPONSE;
104  // <external-attachment/> // TODO: figure out if we actually support this
105  echo ' <administrator>mailto:' . $c->admin_email . '</administrator>' . "\n";
106  echo <<<RESPONSE
107  </capability-set>
108  </query-result>
109 RESPONSE;
110 
111  @ob_flush(); exit(0);
112 }