db; $tpl =& $f->tpl; $messages =& $f->messages; $num_posts = $options['posts_per_rss']; // handle different feed formats $feed_type = isset($_REQUEST['feed']) ? $_REQUEST['feed'] : "rss2"; switch($feed_type) { // TODO: add RSS 0.91/2??? Atom1.0? case 'atom': $feed_file = 'atom.xml'; $feed_content = 'text/xml'; $feed_date = "Y-m-d\TH:i:s"; // unused break; default: // assume RSS2.0 $feed_file = "rss2.xml"; $feed_content = "text/xml"; // or 'application/rss+xml'? $feed_date = "D, d M Y H:i:s"; // RFC 2822 format Mon, 11 Jul 2005 17:04:21 break; } // Get GMT timestamp of last post modification $tstamp = $f->getLastModified(false); // ugh, send a content-type even if it should not be needed for 304s // http://support.microsoft.com/default.aspx?scid=kb;en-us;831140&Product=ISAS // we seem to be doing it right: http://www.xml.com/pub/a/2004/07/21/dive.html header("Content-type: $feed_content; charset=" . $options['charset'], true); header('X-Pingback: ' . $options['url'] . '/xmlrpc.php'); $last_modified_gmt = $f->doConditionalGet($tstamp); if ($feed_type == 'atom') { // http://feedvalidator.org/docs/error/InvalidW3CDTFDate.html $last_modified_gmt = $f->ISO8601($tstamp); // http://feedvalidator.org/docs/error/InvalidLanguage.html $tpl->setVar('option_lang', str_replace('_', '-', $f->options['lang'])); $tpl->setVar('option_copyright_notice', htmlentities($f->options['copyright_notice'])); } $posts =& $f->getPosts(null, null, 0, $num_posts, false, true); $tpl->setFile('index', $feed_file); $tpl->setVar('pub_date', $last_modified_gmt); foreach ($posts as $k => $post) { $posts[$k]['post_content'] = htmlspecialchars($post['post_content'], ENT_QUOTES, $options['charset']); if (!empty($post['post_more'])) { $posts[$k]['post_content'] .= htmlspecialchars( ' ' . $messages['post_continued'] . '', ENT_QUOTES, $options['charset']); } if ($feed_type == 'atom') $posts[$k]['post_isodate'] = $f->ISO8601((int)$post['post_tstamp_gmt']); else $posts[$k]['post_isodate'] = date($feed_date, (int)$post['post_tstamp_gmt']) . ' GMT'; } $tpl->parseBlock('ITEM', 'item', $posts, 'index'); $tpl->pparse('MAIN', 'index'); ?>