summaryrefslogtreecommitdiffstats
path: root/rss.php
blob: f2baab88e42597334909bc824a13bb1c4fe09b1e (plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php

// (c) 2014 Timothy Pearson
// All Rights Reserved

function processDir($dirname, $phpfile) {
	if ($handle = opendir("./" . $dirname . "/")) {
	
		$filenames = array();
		while ($file = readdir($handle)) {
			$filenames[] = $file;
		}
		rsort($filenames);
		
		foreach($filenames as $file) {
			// sort($handle, SORT_NUMERIC);
			if (($file != ".") && ($file != "..") && ($file{0} != '.')) {
				echo "    <item>\n";
				$datestring = $file;
				$datestring = str_replace(".", "-", $datestring);
				$datetime = strtotime($datestring);
				$datestring = date(DATE_RSS, $datetime);
				echo "        <pubDate>$datestring</pubDate>\n";
				
				$data = file_get_contents($dirname . "/$file"); //read the file
				$convert = explode("\n", $data); //create array separate by new line
				for ($i=0;$i<count($convert);$i++) {
					$title = "        <title>";
					if ($i != 0) {
						$linestring = strip_tags($convert[$i]);
						$linestring = str_replace("<", "&lt;", $linestring);
						$linestring = str_replace(">", "&gt;", $linestring);
						echo $linestring. "<br>\n"; //write value by index
					}
					else {
						$title = $title . strip_tags($convert[$i]) . "</title>\n";
						echo $title;
						echo "        <description><![CDATA[\n";
					}
// 					if ($i == $newscollapsedlines) {
// 						echo '<div id="hiddennews-' . $file . '" style="display: none">';
// 					}
				}
				echo "        ]]></description>\n";
// 				if (count($convert) > $newscollapsedlines) {
					echo "        <link>http://www.trinitydesktop.org/newsentry.php?entry=" . $file . "</link>\n";
					echo "        <guid isPermaLink=\"true\">http://www.trinitydesktop.org/newsentry.php?entry=" . $file . "</guid>\n";
// 				}
				echo "    </item>\n";
			}
		}

		closedir($handle);
	}
}

header('Content-type: application/rss+xml');

/*echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";*/
echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n";
echo "<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n";
echo "  <channel>\n";
echo "    <atom:link href=\"http://www.trinitydesktop.org/rss.php\" rel=\"self\" type=\"application/rss+xml\" />\n";
echo "    <title>Trinity Desktop Environment News</title>\n";
echo "    <link>http://www.trinitydesktop.org/</link>\n";
echo "    <description>News of the Trinity Desktop Environment, a full-featured professional desktop for Linux.</description>\n";
echo "    <language>en</language>\n";

processDir('news', 'newsentry.php');
processDir('rssentries', 'rssentry.php');

echo "  </channel>\n";
echo "</rss>\n";

?>