require_once("../lib/course/Course.php"); ?>
// get current time
$now = time();
// get current announcements
$announcements = array();
$xml = new SimpleXMLElement(file_get_contents("http://cs75.net/phorum/feed.php?1,type=rss"));
foreach ($xml->channel->item as $item)
{
if ($now - 5 * 24 * 60 * 60 < strtotime($item->pubDate))
$announcements[] = $item;
}
// get recent posts (plus announcements)
$posts = new SimpleXMLElement(file_get_contents("http://cs75.net/phorum/feed.php?0,type=rss"));
// begin XHTML
$xhtml = '
';
// output current announcements
if (count($announcements) > 0)
{
// header for announcements
$xhtml .= '
Announcements';
$xhtml .= '
';
// start list
$xhtml .= '
';
// output current announcements
foreach ($announcements as $a)
{
// strip # of replies
$a->title = preg_replace("/\([^(]*\)$/", "", $a->title);
// output topic
$xhtml .= "- {$a->title}
";
}
// end list
$xhtml .= '
';
// horizontal rule
$xhtml .= '
';
}
// header for recent messages
$xhtml .= '
Recent Messages in the Forum';
$xhtml .= '
';
// start list
$xhtml .= '
';
// output <= 6 recent topics
for ($i = 0, $n = count($posts->channel->item), $max = 2; $i < $n && $max >= 0; $i++)
{
// get current item
$item = $posts->channel->item[$i];
// skip announcements
if (preg_match("/^(:?Announcements|Test)$/", $item->category)) continue;
// print topic
$xhtml .= "- {$item->title}
";
// decrement counter
$max--;
}
// end list
$xhtml .= '
';
// end XHTML
$xhtml .= '
';
// cache XHTML
course()->cache("posts", $xhtml);
// output XML
header("Content-type: text/xml");
print('');
print('');
?>