diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2015-10-05 13:46:54 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2015-10-05 13:46:54 -0500 |
commit | 5ed01bd42b0aaf222f3b04b611e31b3d0974b6a4 (patch) | |
tree | e2adf4f018d79bce5853d42cdbda6c05c25955fa /rss.php | |
download | website-core-5ed01bd42b0aaf222f3b04b611e31b3d0974b6a4.tar.gz website-core-5ed01bd42b0aaf222f3b04b611e31b3d0974b6a4.zip |
Initial import of static files
Diffstat (limited to 'rss.php')
-rwxr-xr-x | rss.php | 77 |
1 files changed, 77 insertions, 0 deletions
@@ -0,0 +1,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("<", "<", $linestring); + $linestring = str_replace(">", ">", $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"; + +?> + + |