This commit is contained in:
35
public/page/calendar/feed.php
Normal file
35
public/page/calendar/feed.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use App\App;
|
||||
use App\CalendarSync;
|
||||
|
||||
$app = App::get();
|
||||
$token = trim((string)($_GET['token'] ?? ''));
|
||||
|
||||
if ($token === '') {
|
||||
http_response_code(400);
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
echo 'Token fehlt.';
|
||||
return;
|
||||
}
|
||||
|
||||
$calendarSync = new CalendarSync($app);
|
||||
$calendarSync->ensureSchema();
|
||||
|
||||
$userId = $calendarSync->findUserIdByFeedToken($token);
|
||||
if (!$userId) {
|
||||
http_response_code(404);
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
echo 'Kalender-Feed nicht gefunden.';
|
||||
return;
|
||||
}
|
||||
|
||||
$calendarSync->touchFeedAccess($userId);
|
||||
$ics = $calendarSync->renderUserCalendarIcs($userId, 'Papa-Kind-Treff Events');
|
||||
|
||||
header('Content-Type: text/calendar; charset=utf-8');
|
||||
header('Content-Disposition: inline; filename="papa-kind-treff-events-feed.ics"');
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
|
||||
|
||||
echo $ics;
|
||||
Reference in New Issue
Block a user