-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgridstatusrss.php
More file actions
46 lines (35 loc) · 1.41 KB
/
Copy pathgridstatusrss.php
File metadata and controls
46 lines (35 loc) · 1.41 KB
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
41
42
43
44
45
46
<?php
$title = "GridStatusRSS";
include_once 'include/header.php';
// Cache-Dateipfad
$feedcache_path = __DIR__.'/feed_cache.html';
$feedcache_max_age = 1800; // Cache max. 30 Minuten alt
// Prüfen, ob Cache neu geladen werden muss
if (!file_exists($feedcache_path) or filemtime($feedcache_path) < (time() - $feedcache_max_age)) {
$output = '';
foreach ($feed_urls as $feed_url) {
// Feed abrufen
$xml = @simplexml_load_string(file_get_contents($feed_url));
if (!$xml) {
$output .= "<p>Error loading feeds: <strong>" . htmlspecialchars($feed_url) . "</strong></p>";
continue;
}
$output .= '<h2>' . htmlspecialchars($xml->channel->title) . '</h2>';
$output .= '<p><a href="' . htmlspecialchars($xml->channel->link) . '">Open Feed</a></p>';
$output .= '<ul>';
$counter = 0;
foreach ($xml->channel->item as $entry) {
if (++$counter > $max_entries) break;
$date = date('d.m.Y', strtotime($entry->pubDate));
$output .= '<li><a href="'.htmlspecialchars($entry->link).'" title="'.$date.'">'.htmlspecialchars($entry->title).'</a> <small>('.$date.')</small></li>';
}
$output .= '</ul>';
}
echo $output;
//file_put_contents($feedcache_path, $output);
} else {
echo file_get_contents($feedcache_path);
}
?>
<?php include_once "include/" . FOOTER_FILE; ?>
<br><br><br><br>