get_string(SetupConfig::TITLE); if (count($event->search_terms) > 0) { $search = url_escape(Tag::caret(Tag::implode($event->search_terms))); $page->add_html_header(""); } else { $page->add_html_header(""); } } public function onPageRequest(PageRequestEvent $event) { if ($event->page_matches("rss/images")) { $search_terms = $event->get_search_terms(); $page_number = $event->get_page_number(); $page_size = $event->get_page_size(); if (SPEED_HAX && $page_number > 9) { return; } $images = Image::find_images(($page_number-1)*$page_size, $page_size, $search_terms); $this->do_rss($images, $search_terms, $page_number); } } private function do_rss(array $images, array $search_terms, int $page_number) { global $page; global $config; $page->set_mode(PageMode::DATA); $page->set_type("application/rss+xml"); $data = ""; foreach ($images as $image) { $data .= $this->thumb($image); } $title = $config->get_string(SetupConfig::TITLE); $base_href = make_http(get_base_href()); $search = ""; if (count($search_terms) > 0) { $search = url_escape(Tag::implode($search_terms)) . "/"; } if ($page_number > 1) { $prev_url = make_link("rss/images/$search".($page_number-1)); $prev_link = ""; } else { $prev_link = ""; } $next_url = make_link("rss/images/$search".($page_number+1)); $next_link = ""; // no end... $version = VERSION; $xml = "<"."?xml version=\"1.0\" encoding=\"utf-8\" ?"."> $title The latest uploads to the image board $base_href Shimmie-$version (c) 2007 Shish $prev_link $next_link $data "; $page->set_data($xml); } private function thumb(Image $image): string { global $cache; $cached = $cache->get("rss-thumb:{$image->id}"); if ($cached) { return $cached; } $link = make_http(make_link("post/view/{$image->id}")); $tags = html_escape($image->get_tag_list()); $thumb_url = $image->get_thumb_link(); $image_url = $image->get_image_link(); $posted = date(DATE_RSS, strtotime($image->posted)); $content = html_escape( "
" . "

" . $this->theme->build_thumb_html($image) . "

" . "
" ); $data = " {$image->id} - $tags $link $link $posted $content "; $cache->set("rss-thumb:{$image->id}", $data, 3600); return $data; } public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { if ($event->parent=="posts") { $event->add_nav_link("posts_rss", new Link('rss/images'), "Feed"); } } }