OSDN Git Service

Cleanup. Check ASAP. Return with #plugin-name
[pukiwiki/pukiwiki.git] / plugin / rss.inc.php
1 <?php
2 /////////////////////////////////////////////////
3 // PukiWiki - Yet another WikiWikiWeb clone.
4 //
5 // $Id: rss.inc.php,v 1.7 2004/07/31 03:09:20 henoheno Exp $
6 //
7 // RecentChanges ¤Î RSS ¤ò½ÐÎÏ
8 function plugin_rss_action()
9 {
10         global $script,$rss_max,$page_title,$whatsnew;
11
12         $self = (preg_match('#^https?://#',$script) ? $script : get_script_uri());
13         if ($self === FALSE)
14         {
15                 die_message("please set '\$script' in ".INI_FILE);
16         }
17
18         $page_title_utf8 = mb_convert_encoding($page_title,'UTF-8',SOURCE_ENCODING);
19
20         $items = '';
21
22         if (!file_exists(CACHE_DIR.'recent.dat'))
23         {
24                 return '';
25         }
26         $recent = file(CACHE_DIR.'recent.dat');
27         $lines = array_splice($recent,0,$rss_max);
28         foreach ($lines as $line)
29         {
30                 list($time,$page) = explode("\t",rtrim($line));
31                 $r_page = rawurlencode($page);
32                 $title = mb_convert_encoding($page,'UTF-8',SOURCE_ENCODING);
33                 $desc = get_date('D, d M Y H:i:s T',$time);
34                 $items .= <<<EOD
35 <item>
36  <title>$title</title>
37  <link>$self?$r_page</link>
38  <description>$desc</description>
39 </item>
40
41 EOD;
42         }
43
44         header('Content-type: application/xml');
45
46         $r_whatsnew = rawurlencode($whatsnew);
47
48         print <<<EOD
49 <?xml version="1.0" encoding="UTF-8"?>
50
51 <!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN"
52             "http://my.netscape.com/publish/formats/rss-0.91.dtd">
53
54 <rss version="0.91">
55
56 <channel>
57 <title>$page_title_utf8</title>
58 <link>$self?$r_whatsnew</link>
59 <description>PukiWiki RecentChanges</description>
60 <language>ja</language>
61
62 $items
63 </channel>
64 </rss>
65 EOD;
66         exit;
67 }
68 ?>