DAViCal
 All Classes Namespaces Functions Variables Pages
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_log_array( 'well-known', 'method:'. $request->method );
40 switch ( $request->method ) {
41  case 'GET': ischedule_get(); break;
42  case 'POST': include('iSchedule-POST.php'); break;
43 
44  default:
45  dbg_error_log( 'well-known', 'Unhandled request method >>%s<<', $request->method );
46  dbg_log_array( 'well-known', '_SERVER', $_SERVER, true );
47  dbg_error_log( 'well-known', 'RAW: %s', str_replace("\n", '',str_replace("\r", '', $request->raw_post)) );
48 }
49 
50 $request->DoResponse( 500, translate('The application program does not understand that request.') );
51 
52 
53 
54 
55 
56 function ischedule_get ( )
57 {
58  global $request,$c;
59  if ( $request->path != '/.well-known/ischedule' || $_GET['query'] != 'capabilities' )
60  {
61  $request->DoResponse( 404, translate('The application program does not understand that request.' . $request->path ) );
62  return false;
63  }
64  header ( 'iSchedule-Version: 1.0' );
65  header ( 'Content-Type: application/xml; charset=utf-8' );
66  echo '<?xml version="1.0" encoding="utf-8" ?>';
67  echo <<<RESPONSE
68  <query-result xmlns="urn:ietf:params:xml:ns:ischedule">
69  <capability-set>
70  <supported-version-set>
71  <version>1.0</version>
72  </supported-version-set>
73  <supported-scheduling-message-set>
74  <comp name="VEVENT">
75  <method name="REQUEST"/>
76  <method name="ADD"/>
77  <method name="REPLY"/>
78  <method name="CANCEL"/>
79  </comp>
80  <comp name="VTODO"/>
81  <comp name="VFREEBUSY"/>
82  </supported-scheduling-message-set>
83  <supported-calendar-data-type>
84  <calendar-data-type content-type="text/calendar" version="2.0"/>
85  </supported-calendar-data-type>
86  <supported-attachment-values>
87  <inline-attachment/>
88  </supported-attachment-values>
89  <supported-recipient-uri-scheme-set>
90  <scheme>mailto</scheme>
91  </supported-recipient-uri-scheme-set>
92  <max-content-length>102400</max-content-length>
93  <min-date-time>19910101T000000Z</min-date-time>
94  <max-date-time>20381231T000000Z</max-date-time>
95  <max-instances>150</max-instances>
96  <max-recipients>250</max-recipients>
97 
98 RESPONSE;
99  // <external-attachment/> // TODO: figure out if we actually support this
100  echo ' <administrator>mailto:' . $c->admin_email . '</administrator>' . "\n";
101  echo <<<RESPONSE
102  </capability-set>
103  </query-result>
104 RESPONSE;
105 
106  @ob_flush(); exit(0);
107 }