<? /* Photosoc RSS news script. June 06. */ ?>
<?
/* Output header: */
header("Content-type: text/xml");
/* Connect to db & stuff. */
include "../config.inc.php";
/* Grab all news. */
$news = $db->execute("SELECT * FROM cms_stories WHERE showOnPage=1 ORDER BY sid DESC LIMIT 10");
/* RSS requires 'lastBuildDate' info. */
$lastpub = $db->execute("SELECT time FROM cms_stories ORDER BY time DESC LIMIT 1");
$lastpub = $lastpub->fields["time"]; // overwrite
$lastpub = gmdate("r", $lastpub); // ovewrite again.
?>
<? echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; ?>
<? echo "<?xml-stylesheet title=\"XSL_formatting\" type=\"text/xsl\" href=\"rss.xsl\"?>\n"; ?>
<rss version="2.0">
    <channel>
        <title>UoB Photographic Society News</title>
        <link>http://www.ubuphotosoc.co.uk/</link>
        <language>en-gb</language>
        <lastBuildDate><? echo $lastpub; ?></lastBuildDate>
        <ttl>43200</ttl>
        <description>All the latest news from the University of Bristol Photographic Society.</description>
        <docs>http://blogs.law.harvard.edu/tech/rss</docs>
        
<? /* output entries as RSS items. */
while (!$news->EOF)
{
    /* fetch text: */
    $newstext = strip_tags(stripslashes($news->fields["hometext"]));
    /* format date: */
    $newDate = gmdate("r", $news->fields["time"]);
    /* chop up desc: */
    $firstbreak = strpos($newstext, "\n");
    $desc = substr($newstext, 0, $firstbreak - 2);
    echo "\t<item>\n";
    echo "\t\t<title>".stripslashes(strip_tags(htmlspecialchars($news->fields["title"])))."</title>\n";
    echo "\t\t<link>http://www.ubuphotosoc.co.uk/articles.php?type=news&amp;id=".$news->fields["sid"]."</link>\n";
    echo "\t\t<description><![CDATA[<p>".$desc." ...</p>]]></description>\n";
    echo "\t\t<pubDate>".$newDate."</pubDate>\n";
    echo "\t\t<guid isPermaLink=\"true\">http://www.ubuphotosoc.co.uk/articles.php?type=news&amp;id=".$news->fields["sid"]."</guid>\n";
    echo "\t</item>\n\n";
    $news->MoveNext();
}
?>
    
    </channel>
</rss>