EventDisplay/index.php

57 lines
1.2 KiB
PHP
Raw Permalink Normal View History

2019-03-12 20:38:58 +01:00
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="refresh" content="5; URL=index.php?time=<?php echo time() ?>">
<title>Events</title>
</head>
<body>
<?php
$ical = file_get_contents("https://www.un-hack-bar.de/events.ics");
$icalLines = explode("\n", $ical);
$events = array();
$eventData = array();
foreach ($icalLines as $line)
{
$data = explode(":", trim($line), 2);
if($data[0] == "SUMMARY")
$eventData['SUMMARY'] = str_replace("[UNHB] ", "", $data[1]);
if($data[0] == "DTSTAMP")
2019-03-12 20:53:13 +01:00
$eventData['DTSTAMP'] = strtotime(substr($data[1], 0, 8));
2019-03-12 20:38:58 +01:00
if($data[0] == "END" and $data[1] == "VEVENT")
{
2019-03-12 20:53:13 +01:00
if($eventData['DTSTAMP'] > time())
{
array_unshift($events, $eventData);
if(count($events) == 4)
break;
}
2019-03-12 20:38:58 +01:00
$eventData = array();
2019-03-12 20:53:13 +01:00
2019-03-12 20:38:58 +01:00
}
}
foreach ($events as $thisEvent)
{
2019-03-12 20:53:13 +01:00
echo "<h1>".date('d M Y', $thisEvent['DTSTAMP'])." (".$thisEvent['DTSTAMP']." - ".time().") => ".$thisEvent['SUMMARY']."</h1>";
2019-03-12 20:38:58 +01:00
}
?>
</body>
</html>