document closed Debian bug
[davical.git] / htdocs / public.php
blobcc12f8ee797bad1b3b7cacd180fec82f173b7279
1 <?php
2 /**
3 * CalDAV Server - main program
5 * @package davical
6 * @subpackage caldav
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";
19 header( "DAV: $dav");
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',
27 $request->IsPublic(),
28 isset($request->ticket),
29 (isset($request->ticket)?$request->ticket->expired:'--'),
30 $request->path,
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;
44 case 'PROPPATCH':
45 case 'MKCALENDAR':
46 case 'MKCOL':
47 case 'PUT':
48 case 'DELETE':
49 case 'LOCK':
50 case 'UNLOCK':
51 $request->DoResponse( 403, translate('Anonymous users are not allowed to modify calendars') );
52 break;
54 case 'TESTRRULE': include_once("test-RRULE.php"); break;
56 default:
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.") );