minimalist-dong/minclude/rss-export.inc

61 lines
1.7 KiB
PHP

<?php
function rssexport() {
global $articledir, $config, $switchchar;
print"<?"; ?>xml version="1.0"?>
<rss version="0.92">
<channel>
<?php
echo"
<title>$config[SITETITLE]</title>
<link>$config[URL]</link>
<description>$config[DESCRIPTION]</description>
<language>$config[LANGUAGE]</language>
<webmaster>$config[EMAIL]</webmaster>
";
$articlelist=get_articlelist(0, $config[RDFARTICLELIMIT]);
// Avoid overflows if we don't have a lot of articles
if (sizeof($articlelist) < $config[RDFARTICLELIMIT]) {
$config[RDFARTICLELIMIT] = sizeof($articlelist);
}
// Main content loop starts here
for ($index=0;$index < $config[RDFARTICLELIMIT];$index++) {
$bodytext="";
$workfile="$articledir/$articlelist[$index]";
$articlefile=fopen ($workfile, "r");
$headline = chop(fgets($articlefile, 300));
// Throw away the first blank line ...
$toss = chop(fgets($articlefile, 300));
while (!feof ($articlefile)) {
$oneline = chop(fgets($articlefile, 300));
$oneline = preg_replace("|##(.*)#(.*)##|U", "\\1", $oneline);
if (preg_match("|^%%|", $oneline)) {
$oneline = preg_replace("|%%(.*)%%|U", "&lt;image: \\1&gt;", $oneline);
}
if (!$oneline) { // Only export the first paragraph
break;
}
$oneline = $oneline." ";
$bodytext = $bodytext.$oneline;
$bodytext = strip_tags("$bodytext");
$link=$config[URL].$switchchar."showentry=".$articlelist[$index];
}
print "\t<item>\n";
print "\t\t<title>$headline</title>\n";
print "\t\t<description>$bodytext</description>\n";
print "\t\t<link><![CDATA[$link]]></link>\n";
print "\t</item>\n\n";
fclose ($articlefile);
} // Main content loop ends
print "</channel>\n</rss>";
}
?>