-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathrss.php
42 lines (34 loc) · 1.91 KB
/
rss.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
41
42
<?php
include('config.php');
header("Content-Type: application/xml; charset=utf-8");
echo "<?xml version='1.0' encoding='utf-8'?>" . PHP_EOL;
echo "<rss version='2.0'>" . PHP_EOL;
echo "<channel>" . PHP_EOL;
echo "<title>" . $title . "</title>" . PHP_EOL;
echo "<image><url>" . $base_url . DIRECTORY_SEPARATOR . "favicon.png</url><title>$title</title><link>$base_url</link></image>" . PHP_EOL;
echo "<link>$base_url</link>" . PHP_EOL;
echo "<description>" . $title . " " . $subtitle . "</description>" . PHP_EOL;
$date = date("Y-m-d", strtotime("-" . $rss_feed_limit . " day"));
$dir = new RecursiveDirectoryIterator($base_photo_dir);
$iterator = new RecursiveIteratorIterator($dir);
$rss_items = array();
foreach ($iterator as $file) {
if (!$file->isDir() && !str_contains($file->getPathname(), ".tims") && file_exists($tims_dir . basename($file->getPathname()))) {
$exif = @exif_read_data($file, 0, true);
$datestamp = htmlentities(date('Y-m-d', strtotime($exif['EXIF']['DateTimeOriginal']))) ?? NULL;
if ($datestamp > $date) {
array_push($rss_items, $file);
}
}
}
foreach ($rss_items as $item) {
$album = str_replace($base_photo_dir, "", dirname($item->getPathname()));
echo "<item>" . PHP_EOL;
echo "<title>" . htmlspecialchars(pathinfo(basename($item->getPathname()), PATHINFO_FILENAME), ENT_QUOTES) . "</title>" . PHP_EOL;
echo "<link>" . htmlspecialchars("$base_url/index.php?file=" . bin2hex($item->getPathname()) . "&album=" . ltrim($album, "/"), ENT_QUOTES) . "</link>" . PHP_EOL;
echo "<description>" . htmlspecialchars("<img src='" . $base_url . DIRECTORY_SEPARATOR . $tims_dir . basename($item->getPathname()) . "' width=128 />", ENT_QUOTES) . "</description>" . PHP_EOL;
echo "<pubDate>" . htmlspecialchars(date("Y-m-d H:i:s", $item->getMTime()), ENT_QUOTES) . "</pubDate>" . PHP_EOL;
echo "</item>" . PHP_EOL;
}
echo "</channel>" . PHP_EOL;
echo "</rss>";