add index.php

This commit is contained in:
Christopher 2019-03-12 20:38:58 +01:00
parent c3fc2561e2
commit a3f46f2822

49
index.php Normal file
View file

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