<?php
// Will hold the RSS content
$rss = '';
// Your domain
$domain = $_SERVER['SERVER_NAME'];
// Main description (for the channel)
$domaindescr = '';
// You can put files you want ignored here
$ignore = array();
// File extension
$fileext = 'php';
// How many to show in the RSS
$limit = 10;
// By default, this is the directory wherever this file is placed (site root)
$dir = dir('.');
// This will hold valid files
$files = array();
$i = 0;
while (false !== ($file = $dir->read()) AND $i <= $limit)
{
if (is_file($file) AND !in_array($file, $ignore) AND preg_match("#(.*?)\.$fileext$#i", $file))
{
array_push($files, $file);
}
$i++;
}
$dir->close();
if (count($files))
{
foreach ($files AS $file)
{
$meta = get_meta_tags($file);
$pubdate = gmdate('D, d M Y H:i:s', filemtime($file)) . ' GMT');
$rss .= "\t\t<item>\n\t\t\t<title>$meta[title]</title>\n\t\t\t<link>http://www.$domain/$file</link>\n\t\t\t<description><![CDATA[$meta[description]]]></description>\n\t\t\t<pubDate>$pubdate</pubDate>\n\t\t</item>\n";
$rss = trim($rss);
}
}
else
{
$rss .= "\t\t<item>\n\t\t\t<title>No entries in this feed.</title>\n\t\t\t<link>http://www.$domain</link>\n\t\t\t<description><![CDATA[No entries in this feed. You can view the full site at <a href=\"http://www.$domain\">$domain</a>]]></description>\n\t\t</item>\n";
}
header('Content-Type: text/xml; charset=ISO-8859-1');
echo '<?xml version="1.0" encoding="ISO-8859-1"?>';
echo "<!DOCTYPE rss PUBLIC \"-//Netscape Communications//DTD RSS 0.91//EN\" \"http://my.netscape.com/publish/formats/rss-0.91.dtd\">\n<rss version=\"0.91\">\n<channel>\n\t<title>$domain</title>\n\t<link>http://www.$domain</link>\n\t<description><![CDATA[$domaindescr]]></description>\n$rss\n</channel>\n</rss>";
?>