diff --git a/contrib/sitemap/main.php b/contrib/sitemap/main.php
new file mode 100644
index 00000000..bdd350ab
--- /dev/null
+++ b/contrib/sitemap/main.php
@@ -0,0 +1,54 @@
+
+ * License: GPLv2
+ * Description: Adds sitemap.xml on request.
+ * Documentation:
+ */
+
+class XMLSitemap extends SimpleExtension {
+ public function onPageRequest($event) {
+ if($event->page_matches("sitemap.xml")) {
+ $images = Image::find_images(0, 50, array());
+ $this->do_xml($images);
+ }
+ }
+
+ private function do_xml($images) {
+ global $page;
+ $page->set_mode("data");
+ $page->set_type("application/xml");
+
+ $data = "";
+ foreach($images as $image) {
+ $link = make_http(make_link("post/view/{$image->id}"));
+ $posted = date("Y-m-d", $image->posted_timestamp);
+
+ $data .= "
+
+ $link
+ $posted
+ monthly
+ 0.8
+
+ ";
+ }
+
+ $base_href = make_http(make_link("post/list"));
+
+ $xml = "<"."?xml version=\"1.0\" encoding=\"utf-8\"?".">
+
+
+ $base_href
+ 2009-01-01
+ monthly
+ 1
+
+ $data
+
+ ";
+ $page->set_data($xml);
+ }
+}
+?>