Rev 448 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
438 | tom | 1 | <?php |
2 | |||
3 | require '../_taios.php'; |
||
4 | |||
5 | header("Content-type: application/rss+xml"); |
||
6 | |||
7 | $page = new Taios_Page('Photos RSS Feed', '../'); |
||
8 | |||
9 | $dirName = $_GET['dir']; |
||
10 | if (empty($dirName)) |
||
11 | { |
||
12 | $dirName = "Lassitor"; |
||
13 | } |
||
14 | |||
522 | muzer | 15 | while (strpos($dirName, '../') !== false) { |
16 | $dirName = str_replace("../", "/", $dirName); |
||
17 | } |
||
18 | |||
438 | tom | 19 | write('<?xml version="1.0" encoding="UTF-8" ?>'); |
20 | write('<rss version="2.0">'); |
||
21 | write('<channel>'); |
||
444 | tom | 22 | write('<title>Tim32 Photo RSS - ' . $dirName . '</title>'); |
438 | tom | 23 | write('<description>This is the RSS feed for the Tim32 Photos.</description>'); |
24 | write('<link>http://tim32.org/photos/album.php?dir=' . $dirName . '</link>'); |
||
25 | |||
26 | $directory = "albums/" . $dirName . "/"; |
||
27 | $sortOrder = "newestFirst"; |
||
28 | |||
29 | $results = array(); |
||
30 | $handler = opendir($directory); |
||
31 | |||
32 | while ($file = readdir($handler)) |
||
33 | { |
||
34 | if ($file != '.' && $file != '..' && $file != "robots.txt" && $file != ".htaccess" && getimagesize($directory . $file)) |
||
35 | { |
||
36 | $currentModified = filectime($directory . $file); |
||
37 | $file_names[] = $file; |
||
38 | $file_dates[] = $currentModified; |
||
39 | } |
||
40 | } |
||
41 | |||
42 | closedir($handler); |
||
43 | |||
44 | if ($sortOrder == "newestFirst") |
||
45 | { |
||
46 | arsort($file_dates); |
||
47 | } |
||
48 | else |
||
49 | { |
||
50 | asort($file_dates); |
||
51 | } |
||
52 | |||
53 | $file_names_Array = array_keys($file_dates); |
||
54 | foreach ($file_names_Array as $idx => $name) $name=$file_names[$name]; |
||
55 | $file_dates = array_merge($file_dates); |
||
56 | |||
57 | $indexInArray = 0; |
||
58 | |||
59 | foreach ($file_dates as $date) |
||
60 | { |
||
61 | $j = $file_names_Array[$indexInArray]; |
||
62 | $file = $file_names[$j]; |
||
63 | |||
64 | $filename = $directory . $file; |
||
65 | |||
66 | write('<item>'); |
||
67 | write('<title>' . $file . '</title>'); |
||
441 | tom | 68 | write('<link>http://tim32.org/photos/' . str_replace(" ", "%20", $filename) . '</link>'); |
448 | tom | 69 | write('<guid>id_' . $file . '</guid>'); |
438 | tom | 70 | write('<pubDate>' . date('D, d M Y H:i:s O', $date). '</pubDate>'); |
443 | tom | 71 | write('<description><![CDATA[<img src="http://tim32.org/photos/' . str_replace(" ", "%20", $filename) . '" />]]></description>'); |
438 | tom | 72 | write('</item>'); |
73 | |||
74 | $indexInArray++; |
||
75 | } |
||
76 | |||
77 | write('</channel>'); |
||
78 | write('</rss>'); |
||
79 | |||
80 | ?> |