* License: GPLv2 * Description: Self explanatory */ class RSS_Comments extends SimpleExtension { public function onPostListBuilding($event) { global $config, $page; $title = $config->get_string('title'); $page->add_html_header(""); } public function onPageRequest($event) { global $config, $database, $page; if($event->page_matches("rss/comments")) { $page->set_mode("data"); $page->set_type("application/rss+xml"); $comments = $database->get_all(" SELECT users.id as user_id, users.name as user_name, comments.comment as comment, comments.id as comment_id, comments.image_id as image_id, comments.owner_ip as poster_ip, UNIX_TIMESTAMP(posted) AS posted_timestamp FROM comments LEFT JOIN users ON comments.owner_id=users.id ORDER BY comments.id DESC LIMIT 10 "); $data = ""; foreach($comments as $comment) { $image_id = $comment['image_id']; $comment_id = $comment['comment_id']; $link = make_http(make_link("post/view/$image_id")); $owner = html_escape($comment['user_name']); $posted = date(DATE_RSS, $comment['posted_timestamp']); $comment = html_escape($comment['comment']); $content = html_escape("$owner: $comment"); $data .= " $owner comments on $image_id $link $comment_id $posted $content "; } $title = $config->get_string('title'); $base_href = make_http(get_base_href()); $version = $config->get_string('version'); $xml = << $title The latest comments on the image board $base_href $version (c) 2007 Shish $data EOD; $page->set_data($xml); } } } ?>