neue ordnerstruktur, php-code hinzugefügt
die ordner public und src hinzugefügt, zapcallib.php für iCalendar files hinzugefügt, getContent.php und getEvent.php hinzugefügt
This commit is contained in:
parent
592aba679e
commit
2048026c27
19 changed files with 3281 additions and 1 deletions
102
src/getContent.php
Normal file
102
src/getContent.php
Normal file
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
/**
|
||||
* User: vincent
|
||||
* Date: 14/12/2016
|
||||
* Time: 2:55 PM
|
||||
*/
|
||||
/* include_once("config.php"); */
|
||||
|
||||
$status = getStatus();
|
||||
|
||||
function getContent() {
|
||||
$pagename = filter_input(INPUT_GET, 'title', FILTER_SANITIZE_URL);
|
||||
$page = $root_url . '/content/' . $pagename . '.txt';
|
||||
$file = fopen($page, 'rb');
|
||||
if($file) {
|
||||
echo stream_get_contents($file);
|
||||
fclose($file);
|
||||
} else {
|
||||
echo "Page not found";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[][]
|
||||
*/
|
||||
function apiRequest()
|
||||
{
|
||||
$ch = curl_init('https://status.kraut.space/api');
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return json_decode($result, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
function getStatus(): bool
|
||||
{
|
||||
try { return apiRequest()['state']['open']; }
|
||||
catch (Error $e) { return false; }
|
||||
}
|
||||
|
||||
function getKrautButtonColor($status) {
|
||||
if ($status) {
|
||||
echo "<img src='./img/icons/users.svg' id='krauticon'>";
|
||||
} else {
|
||||
echo "<img src='./img/icons/user-times.svg' id='krauticon'>";
|
||||
}
|
||||
}
|
||||
|
||||
function getKrautStatus($status) {
|
||||
if ($status) {
|
||||
echo "Raum ist offen";
|
||||
} else {
|
||||
echo "Raum ist geschlossen";
|
||||
}
|
||||
}
|
||||
|
||||
function getKrautSidebar($status)
|
||||
{
|
||||
if ($status) {
|
||||
echo <<<END
|
||||
<div class="sidebar-heading">
|
||||
<div class="icondiv"><img src="./img/icons/users.svg" class="icon" alt="Person"></div>
|
||||
<h4>Raum ist geöffnet</h4>
|
||||
<p>Schaut einfach vorbei</p>
|
||||
</div>
|
||||
END;
|
||||
|
||||
} else {
|
||||
echo <<<END
|
||||
<div class="sidebar-heading">
|
||||
<div class="icondiv"><img src="./img/icons/user-times.svg" class="icon" alt="niemand"></div>
|
||||
<h4>Niemand ist im Raum</h4>
|
||||
<p>Keine Hackerseele anwesend</p>
|
||||
</div>
|
||||
END;
|
||||
}
|
||||
}
|
||||
|
||||
function getKrautButton(bool $status)
|
||||
{
|
||||
if ($status) {
|
||||
echo <<<END
|
||||
<div id="roombutton" class="krautopen">
|
||||
<img src="./img/icons/users.svg" id="roomicon" alt="Person">
|
||||
<p>Raum ist geöffnet</p>
|
||||
</div>
|
||||
END;
|
||||
|
||||
} else {
|
||||
echo <<<END
|
||||
<div id="roombutton" class="krautclose">
|
||||
<img src="./img/icons/user-times.svg" id="roomicon" alt="niemand">
|
||||
<p>Raum ist geschlossen</p>
|
||||
</div>
|
||||
END;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue