3 * CalDAV Server - main program
7 * @author Andrew McMillan <andrew@catalyst.net.nz>
8 * @copyright Catalyst .Net Ltd
9 * @license http://gnu.org/copyleft/gpl.html GNU GPL v2
11 require("./always.php");
12 dbg_error_log( "caldav", " User agent: %s", ((isset($_SERVER['HTTP_USER_AGENT']) ?
$_SERVER['HTTP_USER_AGENT'] : "Unfortunately Mulberry does not send a 'User-agent' header with its requests :-(")) );
13 dbg_log_array( "headers", '_SERVER', $_SERVER, true );
14 require("PublicSession.php");
15 $session = new PublicSession();
17 /** A simplified DAV header in this case */
18 $dav = "1, 2, calendar-access";
20 require_once("CalDAVRequest.php");
21 $request = new CalDAVRequest();
22 if ( ! $request->IsPublic() &&
23 (! isset($request->ticket
)
24 ||
$request->ticket
->expired
25 ||
! $request->ticket
->MatchesPath($request->path
) ) ) {
26 dbg_error_log( "caldav", 'Public: %d, Ticket: %d, Expired: %d, Matches(%s): %d',
28 isset($request->ticket
),
29 (isset($request->ticket
)?
$request->ticket
->expired
:'--'),
31 (isset($request->ticket
)?
$request->ticket
->MatchesPath($request->path
):'--')
33 $request->DoResponse( 403, translate('Anonymous users may only access public calendars') );
37 switch ( $request->method
) {
38 case 'OPTIONS': include_once("caldav-OPTIONS.php"); break;
39 case 'REPORT': include_once("caldav-REPORT.php"); break;
40 case 'PROPFIND': include_once("caldav-PROPFIND.php"); break;
41 case 'GET': include_once("caldav-GET.php"); break;
42 case 'HEAD': include_once("caldav-GET.php"); break;
51 $request->DoResponse( 403, translate('Anonymous users are not allowed to modify calendars') );
54 case 'TESTRRULE': include_once("test-RRULE.php"); break;
57 dbg_error_log( "caldav", "Unhandled request method >>%s<<", $request->method
);
58 dbg_log_array( "caldav", '_SERVER', $_SERVER, true );
59 dbg_error_log( "caldav", "RAW: %s", str_replace("\n", "",str_replace("\r", "", $request->raw_post
)) );
62 $request->DoResponse( 500, translate("The application program does not understand that request.") );