1 | <?php
|
---|
2 | $file_root = ".";
|
---|
3 |
|
---|
4 | // load libraries
|
---|
5 | require($file_root."/include/"."incl.php");
|
---|
6 |
|
---|
7 |
|
---|
8 | // get list of news items
|
---|
9 | $news = get_files($file_root."/news","xml");
|
---|
10 | $news = array_reverse ($news);
|
---|
11 |
|
---|
12 |
|
---|
13 | // loop and gather news
|
---|
14 | $newslist = "";
|
---|
15 | $c = 0;
|
---|
16 | while (list($key,$item) = each($news)) {
|
---|
17 | $c++;
|
---|
18 |
|
---|
19 | // Load news item (it's in a pseudo XML format).
|
---|
20 | $file = $file_root."/news/".$item;
|
---|
21 | if (file_exists($file)) {
|
---|
22 | $fp = @fopen($file, "r");
|
---|
23 | $data = fread($fp, filesize($file));
|
---|
24 | @fclose($fp);
|
---|
25 |
|
---|
26 | $news_date = "";
|
---|
27 | if (eregi("<DATE>(.*)</DATE>", $data, $out)) {
|
---|
28 | $news_date = strtotime($out[1]);
|
---|
29 | }
|
---|
30 |
|
---|
31 | $news_author = "";
|
---|
32 | if (eregi("<AUTHOR>(.*)</AUTHOR>", $data, $out)) {
|
---|
33 | $news_author = "Posted by ".$out[1];
|
---|
34 | }
|
---|
35 |
|
---|
36 | $news_title = "";
|
---|
37 | if (eregi("<NAME>(.*)</NAME>", $data, $out)) {
|
---|
38 | $news_title = $out[1];
|
---|
39 | }
|
---|
40 |
|
---|
41 | $news_img = "";
|
---|
42 | if (eregi("<IMG>(.*)</IMG>", $data, $out)) {
|
---|
43 | $news_img = $out[1];
|
---|
44 | }
|
---|
45 |
|
---|
46 | $news_body = "";
|
---|
47 | if (eregi("<BODY>(.*)</BODY>", $data, $out)) {
|
---|
48 | $news_body = $out[1];
|
---|
49 | }
|
---|
50 | }
|
---|
51 |
|
---|
52 | // Display news item
|
---|
53 |
|
---|
54 | $newslist .=
|
---|
55 | '<entry>'.
|
---|
56 | '<title type="html">'.htmlentities($news_title).'</title>'.
|
---|
57 | '<id>tag:scummvm.org,2006:news/atom/'.$news_date.'</id>'.
|
---|
58 | '<link rel="alternate">http://scummvm.org/?shownews=archive#'.date("Y-m-d", $news_date).'</link>'.
|
---|
59 | '<content type="html">'.htmlentities($news_body).'</content>'.
|
---|
60 | '<published>'.date("Y-m-d\Th:i:s\Z", $news_date - date("Z", $news_date)).'</published>'.
|
---|
61 | '<author><name>'.$news_author.'</name></author>'.
|
---|
62 | '</entry>';
|
---|
63 |
|
---|
64 | // Get date of latest (first) item
|
---|
65 | if ($c == 1) {
|
---|
66 | $published = date("Y-m-d\Th:i:s\Z", $news_date - date("Z", $news_date));
|
---|
67 | }
|
---|
68 | // Only show first five records
|
---|
69 | if ($c == 4) {
|
---|
70 | break;
|
---|
71 | }
|
---|
72 | } // end of news loop
|
---|
73 |
|
---|
74 |
|
---|
75 |
|
---|
76 | // Display output
|
---|
77 | header("Content-type: application/atom+xml");
|
---|
78 | ?>
|
---|
79 | <feed xml:lang="en" xml:base="http://<?php echo $_SERVER['SERVER_NAME'];?>/" xmlns="http://www.w3.org/2005/Atom">
|
---|
80 | <id>tag:scummvm.org,2006:news/atom</id>
|
---|
81 | <title>ScummVM news</title>
|
---|
82 | <link rel="self" href="http://<?php echo $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];?>"/>
|
---|
83 | <author>
|
---|
84 | <name>ScummVM team</name>
|
---|
85 | <uri>http://scummvm.org/</uri>
|
---|
86 | </author>
|
---|
87 | <updated><?php echo $published;?></updated>
|
---|
88 | <? echo $newslist;?>
|
---|
89 | </feed>
|
---|