Limit characters to avoid calendar spamming from FFS :). #everycommithasitshistory

This commit is contained in:
Patrick Schwarz 2024-04-22 20:49:20 +02:00
parent 35639c7dde
commit 51a4177775

View file

@ -1,8 +1,13 @@
<?php
#ini_set('display_errors', 1);
#ini_set('display_startup_errors', 1);
#error_reporting(E_ALL);
# config
$ical = 'https://cloud.MYURL/remote.php/dav/public-calendars/CALENDARID/?export';
$cachefile = 'cache/hackcal.ics';
$ical = 'https://cloud.hacknang.de/remote.php/dav/public-calendars/nZTMSHpd29ZRpAr6/?export';
$cachefile = 'cache/hacknang.ics';
$cachetime = 120; // 2 min
# requirements
@ -51,10 +56,10 @@ foreach ($events as $event) {
$result[$date][$uid]["dtstart"] = $iCal->iCalDateToDateTime($event->dtstart_array[3])->format(DateTime::ATOM);
$result[$date][$uid]["dtend"] = $iCal->iCalDateToDateTime($event->dtend_array[3])->format(DateTime::ATOM);
$result[$date][$uid]["datestr"] = (isset($event->dtstart_array[0]["VALUE"]) && $event->dtstart_array[0]["VALUE"] == 'DATE')?'Ganztägig':$start->format('H:i');
$result[$date][$uid]["summary"] = $event->summary;
$result[$date][$uid]["location"] = $event->location;
$result[$date][$uid]["description"] = $event->description;
$result[$date][$uid]["datestr"] = (isset($event->dtstart_array[0]["VALUE"]) && $event->dtstart_array[0]["VALUE"] == 'DATE')?'':$start->format('H:i');
$result[$date][$uid]["summary"] = mb_strimwidth($event->summary, 0, 255, "...");
$result[$date][$uid]["location"] = mb_strimwidth($event->location, 0, 255, "...");
$result[$date][$uid]["description"] = mb_strimwidth($event->description, 0, 255, "...");
if(isset($event->categories)) $result[$date][$uid]["categories"] = $event->categories;
}
@ -64,4 +69,4 @@ foreach ($events as $event) {
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json");
echo json_encode($result, JSON_PRETTY_PRINT);
echo json_encode($result, JSON_UNESCAPED_SLASHES);