You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
2.5 KiB
75 lines
2.5 KiB
<?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>https://www.trinitydesktop.org/newsentry.php?entry=" . $file . "</link>\n";
|
|
echo " <guid isPermaLink=\"true\">https://www.trinitydesktop.org/newsentry.php?entry=" . $file . "</guid>\n";
|
|
// }
|
|
echo " </item>\n";
|
|
}
|
|
}
|
|
|
|
closedir($handle);
|
|
}
|
|
}
|
|
|
|
header('Content-type: application/rss+xml; charset=utf-8');
|
|
|
|
echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
|
|
echo "<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n";
|
|
echo " <channel>\n";
|
|
echo " <atom:link href=\"https://www.trinitydesktop.org/rss.php\" rel=\"self\" type=\"application/rss+xml\" />\n";
|
|
echo " <title>Trinity Desktop Environment News</title>\n";
|
|
echo " <link>https://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";
|
|
|
|
?>
|