-
Notifications
You must be signed in to change notification settings - Fork 2
/
feed.php
40 lines (35 loc) · 1.27 KB
/
feed.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
use ServerStatusMonitor\Data;
require 'config.php';
require 'app/app.php';
$data = Data::get();
header("Content-type: application/atom+xml");
echo '<?xml version="1.0" encoding="UTF-8"?>'
?>
<rss version="2.0">
<channel>
<title><?= $title ?> Status</title>
<description>Service Status announcements for the <?= $title ?> services</description>
<language>en</language>
<link><?= 'https://' . $_SERVER['HTTP_HOST'] ?></link>
<lastBuildDate><?= date(DATE_RFC822) ?></lastBuildDate>
<?php foreach (array_reverse($data->entries) as $index => $entry):
$stateKey = $entry->state;
$state = $data->states->$stateKey->title;
$services = array_map(function ($serviceKey) use ($data) {
return $data->services->$serviceKey;
}, $entry->services)
?>
<item>
<title><?= $state ?></title>
<description>
State: <?= $state ?>
Affected Services: <?= implode(', ', $services) ?>
<?= $entry->message ?>
</description>
<pubDate><?= date_format(new DateTime($entry->date), DATE_RFC822) ?></pubDate>
<guid isPermaLink="false"><?= $entry->date ?></guid>
</item>
<?php endforeach; ?>
</channel>
</rss>