]> git.defcon.no Git - plsgen/blob - rss.php
Three new features, three bugfixes. Version 0.4 code.
[plsgen] / rss.php
1 <?php
2
3 $site_url = "http://site.example.com";
4 $stream_title = "example.com photogallerystream";
5 $stream_description = "The latest entries in a photo";
6 $contact_address = "someone@example.com";
7
8 $maxcount = 50;
9
10 $ctimes = array();
11 $album = array();
12 $title = array();
13 $idximage = array();
14
15 //define the path as relative
16 $basepath = "./";
17
18 //using the opendir function
19 $dir_handle = @opendir($basepath) or die("Unable to open $basepath");
20
21 //running the while loop
22 while ($dir = readdir($dir_handle)) {
23 $target = $basepath . $dir;
24
25
26 if ((!is_file($target)) &&
27 (file_exists($target)) &&
28 ($dir != "images") &&
29 ($dir != ".") &&
30 ($dir != ".."))
31 {
32 if (is_file($target . "/.title"))
33 {
34 $ctime = filectime($target . "/.title");
35 $key = date("Y-m-d-His", $ctime);
36 $album[$key] = $dir;
37 $ctimes[$key] = $ctime;
38
39 $fd = fopen($target . "/.title", "r");
40 $buf = chop(fgets($fd, 4096));
41 fclose($fd);
42 $title[$key] = $buf;
43
44 if (is_file($target . "/.indeximage")) {
45 $fd = fopen($target . "/.indeximage", "r");
46 $buf = "thumb/";
47 $buf .= chop(fgets($fd, 4096));
48 chop ($buf);
49 fclose($fd);
50 $idximage[$key] = $buf;
51 }
52
53 }
54 }
55 }
56 //closing the directory
57 closedir($dir_handle);
58
59 krsort($album);
60 header("Content-type: application/xml;\n\n");
61 print ("<rss version='2.0' xmlns:dc='http://purl.org/dc/elements/1.1/'
62 xmlns:content='http://purl.org/rss/1.0/modules/content/'>\n");
63 print ("<!-- rss version='2.0' xmlns:dc='http://purl.org/dc/elements/1.1/' -->\n");
64 print (" <channel>\n");
65 print (" <title>" . $stream_title . "</title>\n");
66 print (" <link>" . $site_url . "</link>\n");
67 print (" <description>" . $stream_description . "</description>\n");
68 print (" <docs>http://blogs.law.harvard.edu/tech/rss</docs>\n");
69 print (" <managingEditor>" . $contact_address . "</managingEditor>\n");
70 print (" <webMaster>" . $contact_address . "</webMaster>\n");
71
72 /* // disse må fixxes
73 <pubDate> <pubDate>
74 </lastBuildDate> </lastBuildDate> */
75
76 foreach ( $album as $key => $value ) {
77 print ("<item>\n");
78 print ("<title>");
79 $i_title = html_entity_decode($title[$key]);
80 $url = $site_url . "/" . $value;
81 print ($i_title);
82 print ("</title>\n");
83 print (" <pubDate>" . date("D, j M Y H:i:s +0100", $ctimes[$key]) . "</pubDate>\n");
84 print (" <link>" . $url . "</link>\n");
85 print (" <guid>$key$value</guid>\n");
86 print (" <description>\n");
87 printf ("The photo gallery '%s' at <a href='%s'>%s</a> was updated/published at %s", $i_title,$url,$url,date("D, j M Y H:i:s +0100", $ctimes[$key]));
88 print (" </description>\n");
89 print ("<content:encoded><![CDATA[ ");
90 printf("<center><img src='%s/%s' /></center>", $url, $idximage[$key]);
91 printf ("The photo gallery '%s' at <a href='%s'>%s</a> was updated/published at %s", $i_title,$url,$url,date("D, j M Y H:i:s +0100", $ctimes[$key]));
92 print (" ]]></content:encoded>");
93 print ("</item>\n");
94
95 $maxcount--;
96 if ($maxcount < 1) break;
97 }
98 print (" </channel>\n");
99 print ("</rss>");
100 ?>
101
102