56 lines
1.2 KiB
PHP
56 lines
1.2 KiB
PHP
<!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")
|
|
$eventData['DTSTAMP'] = strtotime(substr($data[1], 0, 8));
|
|
|
|
if($data[0] == "END" and $data[1] == "VEVENT")
|
|
{
|
|
if($eventData['DTSTAMP'] > time())
|
|
{
|
|
array_unshift($events, $eventData);
|
|
|
|
if(count($events) == 4)
|
|
break;
|
|
}
|
|
|
|
$eventData = array();
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
foreach ($events as $thisEvent)
|
|
{
|
|
echo "<h1>".date('d M Y', $thisEvent['DTSTAMP'])." (".$thisEvent['DTSTAMP']." - ".time().") => ".$thisEvent['SUMMARY']."</h1>";
|
|
}
|
|
|
|
?>
|
|
</body>
|
|
</html>
|
|
|
|
|