public function display_page(Page $page) { global $config; $tl_enabled = $config->get_string("transload_engine", "none") != "none"; $upload_list = ""; for ($i = 0; $i < $config->get_int('upload_count'); $i++) { $n = $i + 1; $width = $tl_enabled ? "35%" : "80%"; $upload_list .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<td width='50'>File {$n}</td>\n\t\t\t\t\t<td width='250'><input accept='image/jpeg,image/png,image/gif' id='data{$i}' name='data{$i}' type='file'></td>\n\t\t\t"; if ($tl_enabled) { $upload_list .= "\n\t\t\t\t\t<td width='50'>URL {$n}</td>\n\t\t\t\t\t<td width='250'><input id='url{$i}' name='url{$i}' type='text'></td>\n\t\t\t\t"; } $upload_list .= "\n\t\t\t\t</tr>\n\t\t\t"; } $max_size = $config->get_int('upload_size'); $max_kb = to_shorthand_int($max_size); $html = "\n\t\t\t<script>\n\t\t\t\$(document).ready(function() {\n\t\t\t\t\$('#tag_box').DefaultValue('tagme');\n\t\t\t\t\$('#tag_box').autocomplete('" . make_link("api/internal/tag_list/complete") . "', {\n\t\t\t\t\twidth: 320,\n\t\t\t\t\tmax: 15,\n\t\t\t\t\thighlight: false,\n\t\t\t\t\tmultiple: true,\n\t\t\t\t\tmultipleSeparator: ' ',\n\t\t\t\t\tscroll: true,\n\t\t\t\t\tscrollHeight: 300,\n\t\t\t\t\tselectFirst: false\n\t\t\t\t});\n\t\t\t});\n\t\t\t</script>\n\t\t\t<form enctype='multipart/form-data' action='" . make_link("upload") . "' method='POST'>\n\t\t\t\t<table id='large_upload_form'>\n\t\t\t\t\t{$upload_list}\n\t\t\t\t\t<tr><td>Tags</td><td colspan='3'><input id='tag_box' name='tags' type='text'></td></tr>\n\t\t\t\t\t<tr><td>Source</td><td colspan='3'><input name='source' type='text'></td></tr>\n\t\t\t\t\t<tr><td colspan='4'><input id='uploadbutton' type='submit' value='Post'></td></tr>\n\t\t\t\t</table>\n\t\t\t</form>\n\t\t\t<small>(Max file size is {$max_kb})</small>\n\t\t"; if ($tl_enabled) { $link = make_http(make_link("upload")); $title = "Upload to " . $config->get_string('title'); $html .= '<p><a href="javascript:location.href="' . $link . '?url="+location.href+"&tags="+prompt("enter tags")">' . $title . '</a> (Drag & drop onto your bookmarks toolbar, then click when looking at an image)'; } $page->set_title("Upload"); $page->set_heading("Upload"); $page->add_block(new NavBlock()); $page->add_block(new Block("Upload", $html, "main", 20)); }
public function onInitExt(InitExtEvent $event) { global $config; $config->set_default_string("mail_sub", $config->get_string("site_title") . " - "); $config->set_default_string("mail_img", make_http("ext/mail/banner.png")); $config->set_default_string("mail_style", make_http("ext/mail/mail.css")); $config->set_default_string("mail_fot", "<a href='" . make_http(make_link()) . "'>" . $config->get_string("site_title") . "</a>"); }
private function data(Image $image) { global $config; $text_link = $image->parse_link_template($config->get_string("ext_link-img_text-link_format")); $text_link = trim($text_link) == "" ? null : $text_link; // null blank setting so the url gets filled in on the text links. return array('thumb_src' => make_http($image->get_thumb_link()), 'image_src' => make_http($image->get_image_link()), 'post_link' => make_http($_SERVER["REQUEST_URI"]), 'text_link' => $text_link); }
function __construct($main) { $matches = array(); $lines = file($main); $number_of_lines = count($lines); preg_match("#ext/(.*)/main.php#", $main, $matches); $this->ext_name = $matches[1]; $this->name = $this->ext_name; $this->enabled = $this->is_enabled($this->ext_name); for ($i = 0; $i < $number_of_lines; $i++) { $line = $lines[$i]; if (preg_match("/Name: (.*)/", $line, $matches)) { $this->name = $matches[1]; } if (preg_match("/Visibility: (.*)/", $line, $matches)) { $this->visibility = $matches[1]; } if (preg_match("/Link: (.*)/", $line, $matches)) { $this->link = $matches[1]; if ($this->link[0] == "/") { $this->link = make_link(substr($this->link, 1)); } } if (preg_match("/Version: (.*)/", $line, $matches)) { $this->version = $matches[1]; } if (preg_match("/Author: (.*) [<\\(](.*@.*)[>\\)]/", $line, $matches)) { $this->author = $matches[1]; $this->email = $matches[2]; } else { if (preg_match("/Author: (.*)/", $line, $matches)) { $this->author = $matches[1]; } } if (preg_match("/(.*)Description: ?(.*)/", $line, $matches)) { $this->description = $matches[2]; $start = $matches[1] . " "; $start_len = strlen($start); while (substr($lines[$i + 1], 0, $start_len) == $start) { $this->description .= " " . substr($lines[$i + 1], $start_len); $i++; } } if (preg_match("/(.*)Documentation: ?(.*)/", $line, $matches)) { $this->documentation = $matches[2]; $start = $matches[1] . " "; $start_len = strlen($start); while (substr($lines[$i + 1], 0, $start_len) == $start) { $this->documentation .= " " . substr($lines[$i + 1], $start_len); $i++; } $this->documentation = str_replace('$site', make_http(get_base_href()), $this->documentation); } if (preg_match("/\\*\\//", $line, $matches)) { break; } } }
/** * Adds functionality for post/list. * * @param PageRequestEvent $event */ public function onPageRequest(PageRequestEvent $event) { if ($event->page_matches("post/list")) { $pageinfo = $this->get_list_pageinfo($event); $prev_url = make_http(make_link("post/list/" . $pageinfo["prev"])); $next_url = make_http(make_link("post/list/" . $pageinfo["next"])); $this->add_arrowkeys_code($prev_url, $next_url); } }
private function curl_purge($path) { $url = make_http(make_link($path)); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PURGE"); $result = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); return $result; }
public function onPageRequest(PageRequestEvent $event) { global $page, $user; // Adds header to enable chatbox $root = get_base_href(); $yPath = make_http($root . "/ext/chatbox/"); $page->add_html_header("\n\t\t\t\t<script src=\"http://code.jquery.com/jquery-migrate-1.2.1.js\" type=\"text/javascript\"></script>\n\t\t\t\t<script src=\"{$root}/ext/chatbox/js/yshout.js\" type=\"text/javascript\"></script>\n\n\t\t\t\t<link rel=\"stylesheet\" href=\"{$root}/ext/chatbox/css/dark.yshout.css\" />\n\n\t\t\t\t<script type=\"text/javascript\">\n\t\t\t\t\tnickname = '{$user->name}';\n\t\t\t\t\tnew YShout({ yPath: '{$yPath}' });\n\t\t\t\t</script>\n\t\t", 500); // loads the chatbox at the set location $html = "<div id=\"yshout\"></div>"; $chatblock = new Block("Chatbox", $html, "main", 97); $page->add_block($chatblock); }
public function display_page(Image $image, $editor_parts) { global $page; $h_metatags = str_replace(" ", ", ", html_escape($image->get_tag_list())); $page->set_title("Image {$image->id}: " . html_escape($image->get_tag_list())); $page->add_html_header("<meta name=\"keywords\" content=\"{$h_metatags}\">"); $page->add_html_header("<meta property=\"og:title\" content=\"{$h_metatags}\">"); $page->add_html_header("<meta property=\"og:type\" content=\"article\">"); $page->add_html_header("<meta property=\"og:image\" content=\"" . make_http($image->get_thumb_link()) . "\">"); $page->add_html_header("<meta property=\"og:url\" content=\"" . make_http(make_link("post/view/{$image->id}")) . "\">"); $page->set_heading(html_escape($image->get_tag_list())); $page->add_block(new Block(null, $this->build_pin($image), "subtoolbar", 0)); $page->add_block(new Block(null, $this->build_info($image, $editor_parts), "left", 20)); }
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 .= "\n\t\t\t<url>\n\t\t\t<loc>{$link}</loc>\n\t\t\t<lastmod>{$posted}</lastmod>\n\t\t\t<changefreq>monthly</changefreq>\n\t\t\t<priority>0.8</priority>\n\t\t\t</url>\n\t\t\t"; } $base_href = make_http(make_link("post/list")); $xml = "<" . "?xml version=\"1.0\" encoding=\"utf-8\"?" . ">\n\t\t\t\t<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n\t\t\t\t<url>\n\t\t\t\t<loc>{$base_href}</loc>\n\t\t\t\t<lastmod>2009-01-01</lastmod>\n\t\t\t\t<changefreq>monthly</changefreq>\n\t\t\t\t<priority>1</priority>\n\t\t\t\t</url>\n\t\t\t\t{$data}\n\t\t\t\t</urlset>\n\t\t\t\t"; $page->set_data($xml); }
private function curl_purge($path) { // waiting for curl timeout adds ~5 minutes to unit tests if (defined("UNITTEST")) { return; } $url = make_http(make_link($path)); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PURGE"); curl_setopt($ch, CURLOPT_TIMEOUT, 5); $result = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); //return $result; }
public function display_page($image, $editor_parts) { global $page; $metatags = str_replace(" ", ", ", html_escape($image->get_tag_list())); $page->set_title("Image {$image->id}: " . html_escape($image->get_tag_list())); $page->set_heading(html_escape($image->get_tag_list())); $page->add_html_header("<meta name=\"keywords\" content=\"{$metatags}\">"); $page->add_html_header("<meta property=\"og:title\" content=\"{$metatags}\">"); $page->add_html_header("<meta property=\"og:type\" content=\"article\">"); $page->add_html_header("<meta property=\"og:image\" content=\"" . make_http($image->get_thumb_link()) . "\">"); $page->add_html_header("<meta property=\"og:url\" content=\"" . make_http(make_link("post/view/{$image->id}")) . "\">"); $page->add_block(new Block("Navigation", $this->build_navigation($image), "left", 0)); $page->add_block(new Block("Statistics", $this->build_stats($image), "left", 15)); $page->add_block(new Block(null, $this->build_image_editor($image, $editor_parts), "main", 10)); $page->add_block(new Block(null, $this->build_pin($image), "main", 11)); }
/** * @param Image $image * @return string */ private function thumb(Image $image) { global $database; $cached = $database->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()); $owner = $image->get_owner(); $thumb_url = $image->get_thumb_link(); $image_url = $image->get_image_link(); $posted = date(DATE_RSS, $image->posted_timestamp); $content = html_escape("<p>" . $this->theme->build_thumb_html($image) . "</p>" . "<p>Uploaded by " . html_escape($owner->name) . "</p>"); $data = "\n\t\t<item>\n\t\t\t<title>{$image->id} - {$tags}</title>\n\t\t\t<link>{$link}</link>\n\t\t\t<guid isPermaLink=\"true\">{$link}</guid>\n\t\t\t<pubDate>{$posted}</pubDate>\n\t\t\t<description>{$content}</description>\n\t\t\t<media:thumbnail url=\"{$thumb_url}\"/>\n\t\t\t<media:content url=\"{$image_url}\"/>\n\t\t</item>\n\t\t"; $database->cache->set("rss-thumb:{$image->id}", $data, 3600); return $data; }
public function display_page() { global $config, $page; $base_href = get_base_href(); $oekW = $config->get_int("oekaki_width", 400); $oekH = $config->get_int("oekaki_height", 400); if (isset($_POST['oekW']) && isset($_POST['oekH'])) { $oekW = int_escape($_POST['oekW']); $oekH = int_escape($_POST['oekH']); } $html = "\n <applet archive='{$base_href}/ext/oekaki/chibipaint.jar' code='chibipaint.ChibiPaint.class' width='800' height='600'>\n <param name='canvasWidth' value='" . $oekW . "' />\n <param name='canvasHeight' value='" . $oekH . "' />\n <param name='postUrl' value='" . make_http(make_link("oekaki/upload")) . "' />\n <param name='exitUrl' value='" . make_http(make_link("oekaki/claim")) . "' />\n <param name='exitUrlTarget' value='_self' />\n JAVA NOT INSTALLED :(<!-- alternative content for users who don't have Java installed -->\n </applet>\n\t\t"; # <param name='loadImage' value='http://yourserver/oekaki/pictures/168.png' /> # <param name='loadChibiFile' value='http://yourserver/oekaki/pictures/168.chi' /> // FIXME: prevent oekaki block from collapsing on click in cerctain themes. This causes canvas reset $page->set_title("Oekaki"); $page->set_heading("Oekaki"); $page->add_block(new NavBlock()); $page->add_block(new Block("Oekaki", $html, "main", 20)); }
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("\n\t\t\t\t\tSELECT\n\t\t\t\t\tusers.id as user_id, users.name as user_name,\n\t\t\t\t\tcomments.comment as comment, comments.id as comment_id,\n\t\t\t\t\tcomments.image_id as image_id, comments.owner_ip as poster_ip,\n\t\t\t\t\tUNIX_TIMESTAMP(posted) AS posted_timestamp\n\t\t\t\t\tFROM comments\n\t\t\t\t\tLEFT JOIN users ON comments.owner_id=users.id\n\t\t\t\t\tORDER BY comments.id DESC\n\t\t\t\t\tLIMIT 10\n\t\t\t\t\t"); $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 .= "\n\t\t\t\t\t<item>\n\t\t\t\t\t\t<title>{$owner} comments on {$image_id}</title>\n\t\t\t\t\t\t<link>{$link}</link>\n\t\t\t\t\t\t<guid isPermaLink=\"false\">{$comment_id}</guid>\n\t\t\t\t\t\t<pubDate>{$posted}</pubDate>\n\t\t\t\t\t\t<description>{$content}</description>\n\t\t\t\t\t</item>\n\t\t\t\t"; } $title = $config->get_string('title'); $base_href = make_http($config->get_string('base_href')); $version = $config->get_string('version'); $xml = <<<EOD <?xml version="1.0" encoding="utf-8" ?> <rss version="2.0"> \t<channel> \t\t<title>{$title}</title> \t\t<description>The latest comments on the image board</description> \t\t<link>{$base_href}</link> \t\t<generator>{$version}</generator> \t\t<copyright>(c) 2007 Shish</copyright> \t\t{$data} \t</channel> </rss> EOD; $page->set_data($xml); } }
private function do_rss($images, $search_terms, $page_number) { global $page; global $config; $page->set_mode("data"); $page->set_type("application/rss+xml"); $data = ""; foreach ($images as $image) { $link = make_http(make_link("post/view/{$image->id}")); $tags = $image->get_tag_list(); $owner = $image->get_owner(); $thumb_url = $image->get_thumb_link(); $image_url = $image->get_image_link(); $posted = date(DATE_RSS, $image->posted_timestamp); $content = html_escape("<p>" . Themelet::build_thumb_html($image) . "</p>" . "<p>Uploaded by " . $owner->name . "</p>"); $data .= "\n\t\t<item>\n\t\t\t<title>{$image->id} - {$tags}</title>\n\t\t\t<link>{$link}</link>\n\t\t\t<guid isPermaLink=\"true\">{$link}</guid>\n\t\t\t<pubDate>{$posted}</pubDate>\n\t\t\t<description>{$content}</description>\n\t\t\t<media:thumbnail url=\"{$thumb_url}\"/>\n\t\t\t<media:content url=\"{$image_url}\"/>\n\t\t</item>\n\t\t\t"; } $title = $config->get_string('title'); $base_href = make_http($config->get_string('base_href')); $search = ""; if (count($search_terms) > 0) { $search = html_escape(implode(" ", $search_terms)) . "/"; } if ($page_number > 1) { $prev_url = make_link("rss/images/{$search}" . ($page_number - 1)); $prev_link = "<atom:link rel=\"previous\" href=\"{$prev_url}\" />"; } else { $prev_link = ""; } $next_url = make_link("rss/images/{$search}" . ($page_number + 1)); $next_link = "<atom:link rel=\"next\" href=\"{$next_url}\" />"; // no end... $version = VERSION; $xml = "<" . "?xml version=\"1.0\" encoding=\"utf-8\" ?" . ">\n<rss version=\"2.0\" xmlns:media=\"http://search.yahoo.com/mrss\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n <channel>\n <title>{$title}</title>\n <description>The latest uploads to the image board</description>\n\t\t<link>{$base_href}</link>\n\t\t<generator>Shimmie-{$version}</generator>\n\t\t<copyright>(c) 2007 Shish</copyright>\n\t\t{$prev_link}\n\t\t{$next_link}\n\t\t{$data}\n\t</channel>\n</rss>"; $page->set_data($xml); }
public function send() { $headers = "From: " . $this->sitename . " <" . $this->siteemail . ">\r\n"; $headers .= "Reply-To: " . $this->siteemail . "\r\n"; $headers .= "X-Mailer: PHP/" . phpversion() . "\r\n"; $headers .= "errors-to: " . $this->siteemail . "\r\n"; $headers .= "Date: " . date(DATE_RFC2822); $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $message = ' <html> <head> <link rel="stylesheet" href="' . $this->style . '" type="text/css"> </head> <body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0" bgcolor="#EEEEEE" > <table width="100%" cellpadding="10" cellspacing="0" class="backgroundTable" bgcolor="#EEEEEE" > <tr> <td valign="top" align="center"> <table width="550" cellpadding="0" cellspacing="0"> <tr> <td style="background-color:#FFFFFF;border-top:0px solid #333333;border-bottom:10px solid #FFFFFF;"><center><a href="' . $this->sitedomain . '"><IMG SRC="' . $this->header_img . '" alt="' . $this->sitename . '" name="Header" BORDER="0" align="center" title="' . $this->sitename . '"></a> </center></td> </tr> </table> <table width="550" cellpadding="20" cellspacing="0" bgcolor="#FFFFFF"> <tr> <td bgcolor="#FFFFFF" valign="top" style="font-size:12px;color:#000000;line-height:150%;font-family:trebuchet ms;"> <p> <span style="font-size:20px; font-weight:bold; color:#3399FF; font-family:arial; line-height:110%;">' . $this->header . '</span><br> <span style="font-size:11px;font-weight:normal;color:#666666;font-style:italic;font-family:arial;">' . $this->date . '</span><br> </p> <p>' . $this->body . '</p> <p>' . $this->footer . '</p> </td> </tr> <tr> <td style="background-color:#FFFFCC;border-top:10px solid #FFFFFF;" valign="top"> <span style="font-size:10px;color:#996600;line-height:100%;font-family:verdana;"> This email was sent to you since you are a member of <a href="' . $this->sitedomain . '">' . $this->sitename . '</a>. To change your email preferences, visit your <a href="' . make_http(make_link("preferences")) . '">Account preferences</a>.<br /> <br /> Contact us:<br /> <a href="' . $this->siteemail . '">' . $this->siteemail . '</a><br /><br /> Copyright (C) <a href="' . $this->sitedomain . '">' . $this->sitename . '</a><br /> </span></td> </tr> </table> </td> </tr> </table> </body> </html> '; $sent = mail($this->to, $this->subject, $message, $headers); if ($sent) { log_info("mail", "Sent message '{$this->subject}' to '{$this->to}'"); } else { log_info("mail", "Error sending message '{$this->subject}' to '{$this->to}'"); } return $sent; }
public function display_page(Page $page) { global $config; $tl_enabled = $config->get_string("transload_engine", "none") != "none"; // Uploader 2.0! $upload_list = ""; for ($i = 0; $i < $config->get_int('upload_count'); $i++) { $a = $i + 1; $s = $i - 1; if (!$i == 0) { $upload_list .= "<tr id='row{$i}' style='display:none'>"; } else { $upload_list .= "<tr id='row{$i}'>"; } $upload_list .= "<td width='15'>"; if ($i == 0) { $upload_list .= "<div id='hide{$i}'><img id='wrapper' src='ext/upload/minus.png' />" . "<a href='#' onclick='javascript:document.getElementById("row{$a}").style.display = "";document.getElementById("hide{$i}").style.display = "none";document.getElementById("hide{$a}").style.display = "";'>" . "<img src='ext/upload/plus.png'></a></div></td>"; } else { $upload_list .= "<div id='hide{$i}'>\n\t\t\t\t\t\t<a href='#' onclick='javascript:document.getElementById("row{$i}").style.display = "none";" . "document.getElementById("hide{$i}").style.display = "none";" . "document.getElementById("hide{$s}").style.display = "";" . "document.getElementById("data{$i}").value = "";" . "document.getElementById("url{$i}").value = "";'>" . "<img src='ext/upload/minus.png' /></a>"; if ($a == $config->get_int('upload_count')) { $upload_list .= "<img id='wrapper' src='ext/upload/plus.png' />"; } else { $upload_list .= "<a href='#' onclick='javascript:document.getElementById("row{$a}").style.display = "";" . "document.getElementById("hide{$i}").style.display = "none";" . "document.getElementById("hide{$a}").style.display = "";'>" . "<img src='ext/upload/plus.png' /></a>"; } $upload_list .= "</div></td>"; } $upload_list .= "<td width='60'><form><input id='radio_buttona' type='radio' name='method' value='file' checked='checked' onclick='javascript:document.getElementById("url{$i}").style.display = "none";document.getElementById("url{$i}").value = "";document.getElementById("data{$i}").style.display = ""' /> File<br>"; if ($tl_enabled) { $upload_list .= "<input id='radio_buttonb' type='radio' name='method' value='url' onclick='javascript:document.getElementById("data{$i}").style.display = "none";document.getElementById("data{$i}").value = "";document.getElementById("url{$i}").style.display = ""' /> URL</ br></td></form>\n\t\t\t\t\t\n\t\t\t\t\t<td><input id='data{$i}' name='data{$i}' class='wid' type='file'><input id='url{$i}' name='url{$i}' class='wid' type='text' style='display:none'></td>\n\t\t\t\t\t"; } else { $upload_list .= "</form></td>\n\t\t\t\t\t<td width='250'><input id='data{$i}' name='data{$i}' class='wid' type='file'></td>\n\t\t\t\t\t"; } $upload_list .= "\n\t\t\t\t</tr>\n\t\t\t"; } $max_size = $config->get_int('upload_size'); $max_kb = to_shorthand_int($max_size); $html = "\n\t\t\t<script type='text/javascript'>\n\t\t\t\$(document).ready(function() {\n\t\t\t\t\$('#tag_box').DefaultValue('tagme');\n\t\t\t\t\$('#tag_box').autocomplete('" . make_link("api/internal/tag_list/complete") . "', {\n\t\t\t\t\twidth: 320,\n\t\t\t\t\tmax: 15,\n\t\t\t\t\thighlight: false,\n\t\t\t\t\tmultiple: true,\n\t\t\t\t\tmultipleSeparator: ' ',\n\t\t\t\t\tscroll: true,\n\t\t\t\t\tscrollHeight: 300,\n\t\t\t\t\tselectFirst: false\n\t\t\t\t});\n\t\t\t});\n\t\t\t</script>\n\t\t\t" . make_form(make_link("upload"), "POST", $multipart = True) . "\n\t\t\t\t<table id='large_upload_form' class='vert'>\n\t\t\t\t\t{$upload_list}\n\t\t\t\t\t<tr><td></td><td>Tags<td colspan='3'><input id='tag_box' name='tags' type='text'></td></tr>\n\t\t\t\t\t<tr><td></td><td>Source</td><td colspan='3'><input name='source' type='text'></td></tr>\n\t\t\t\t\t<tr><td colspan='4'><input id='uploadbutton' type='submit' value='Post'></td></tr>\n\t\t\t\t</table>\n\t\t\t</form>\n\t\t\t<small>(Max file size is {$max_kb})</small>\n\t\t"; if ($tl_enabled) { $link = make_http(make_link("upload")); if ($config->get_bool('nice_urls')) { $delimiter = '?'; } else { $delimiter = '&'; } $title = "Upload to " . $config->get_string('title'); $html .= '<p><a href="javascript:location.href="' . $link . $delimiter . 'url="+location.href+"&tags="+prompt("enter tags")">' . $title . '</a> (Drag & drop onto your bookmarks toolbar, then click when looking at an image)'; /* Danbooru > Shimmie Bookmarklet. This "should" work on any site running danbooru, unless for some odd reason they switched around the id's or aren't using post/list. Most likely this will stop working when Danbooru updates to v2, all depends if they switch the ids or not >_>. Clicking the link on a danbooru image page should give you something along the lines of: 'http://www.website.com/shimmie/upload?url="http://sonohara.donmai.us/data/crazylongurl.jpg&tags="too many tags"&rating="s"&source="http://danbooru.donmai.us/post/show/012345/"' TODO: Possibly make the entire/most of the script into a .js file, and just make the bookmarklet load it on click (Something like that?) */ $title = "Danbooru to " . $config->get_string('title'); $html .= '<p><a href="javascript:' . 'var ste="' . $link . $delimiter . 'url=";var tag=document.getElementById("post_tags").value;var rtg=document.documentElement.innerHTML.match("<li>Rating: (.*)<\\/li>");var srx="http://" + document.location.hostname+document.location.href.match("\\/post\\/show\\/.*\\/");' . 'if (confirm("OK = Use Current tags.\\nCancel = Use new tags.")==true){' . 'if(tag.search(/\\bflash\\b/)==-1){' . 'location.href=ste+document.getElementById("highres").href+"&tags="+tag+"&rating="+rtg[1]+"&source="+srx;}' . 'else{' . 'location.href=ste+document.getElementsByName("movie")[0].value+"&tags="+tag+"&rating="+rtg[1]+"&source="+srx;}' . '}else{' . 'var p=prompt("Enter Tags","");' . 'if(tag.search(/\\bflash\\b/)==-1){' . 'location.href=ste+document.getElementById("highres").href+"&tags="+p+"&rating="+rtg[1]+"&source="+srx;}' . 'else{' . 'location.href=ste+document.getElementsByName("movie")[0].value+"&tags="+p+"&rating="+rtg[1]+"&source="+srx;}' . '}">' . $title . '</a> (As above, Click on a Danbooru-run image page. (This also grabs the tags/rating/source!))'; } $page->set_title("Upload"); $page->set_heading("Upload"); $page->add_block(new NavBlock()); $page->add_block(new Block("Upload", $html, "main", 20)); }
/** * @return string */ protected function h_bookmarklets() { global $config; $link = make_http(make_link("upload")); $main_page = make_http(make_link()); $title = $config->get_string('title'); $max_size = $config->get_int('upload_size'); $max_kb = to_shorthand_int($max_size); $delimiter = $config->get_bool('nice_urls') ? '?' : '&'; $html = ''; $js = 'javascript:( function() { if(typeof window=="undefined" || !window.location || window.location.href=="about:blank") { window.location = "' . $main_page . '"; } else if(typeof document=="undefined" || !document.body) { window.location = "' . $main_page . '?url="+encodeURIComponent(window.location.href); } else if(window.location.href.match("\\/\\/' . $_SERVER["HTTP_HOST"] . '.*")) { alert("You are already at ' . $title . '!"); } else { var tags = prompt("Please enter tags", "tagme"); if(tags != "" && tags != null) { var link = "' . $link . $delimiter . 'url="+location.href+"&tags="+tags; var w = window.open(link, "_blank"); } } } )();'; $html .= '<a href=\'' . $js . '\'>Upload to ' . $title . '</a>'; $html .= ' (Drag & drop onto your bookmarks toolbar, then click when looking at an image)'; // Bookmarklet checks if shimmie supports ext. If not, won't upload to site/shows alert saying not supported. $supported_ext = "jpg jpeg gif png"; if (class_exists("FlashFileHandler")) { $supported_ext .= " swf"; } if (class_exists("ICOFileHandler")) { $supported_ext .= " ico ani cur"; } if (class_exists("MP3FileHandler")) { $supported_ext .= " mp3"; } if (class_exists("SVGFileHandler")) { $supported_ext .= " svg"; } if (class_exists("VideoFileHandler")) { $supported_ext .= " flv mp4 ogv webm m4v"; } $title = "Booru to " . $config->get_string('title'); // CA=0: Ask to use current or new tags | CA=1: Always use current tags | CA=2: Always use new tags $html .= '<p><a href="javascript: var ste="' . $link . $delimiter . 'url="; var supext="' . $supported_ext . '"; var maxsize="' . $max_kb . '"; var CA=0; void(document.body.appendChild(document.createElement("script")).src="' . make_http(get_base_href()) . "/ext/upload/bookmarklet.js" . '") ">' . $title . '</a> (Click when looking at an image page. Works on sites running Shimmie / Danbooru / Gelbooru. (This also grabs the tags / rating / source!))'; return $html; }
public function onCommentPosting($event) { global $user; $this->msg(make_http(make_link("post/view/" . $event->image_id)) . " - " . $user->name . ": " . str_replace("\n", " ", $event->comment)); }
/** * Adds an array of urls to the sitemap with the given information. * * @param array $urls * @param string $changefreq * @param string $priority * @param string $date */ private function add_sitemap_queue($urls, $changefreq = "monthly", $priority = "0.5", $date = "2013-02-01") { foreach ($urls as $url) { $link = make_http(make_link("{$url}")); $this->sitemap_queue .= "\n <url>\n <loc>{$link}</loc>\n <lastmod>{$date}</lastmod>\n <changefreq>{$changefreq}</changefreq>\n <priority>{$priority}</priority>\n </url>"; } }
/** * Get a page based on the SCore URL, eg get_page("post/list") will do * the right thing; no need for http:// or any such */ protected function get_page($page) { // Check if we are running on the command line if (php_sapi_name() == 'cli' || $_SERVER['HTTP_HOST'] == "<cli command>") { $host = constant("_TRAVIS_WEBHOST"); $this->assertFalse(empty($host)); // Make sure that we know the host address. $raw = $this->get($host . "/index.php?q=" . str_replace("?", "&", $page)); } else { $raw = $this->get(make_http(make_link($page))); } $this->assertNoText("Internal Error"); $this->assertNoText("Exception:"); $this->assertNoText("Error:"); $this->assertNoText("Warning:"); $this->assertNoText("Notice:"); return $raw; }
public function onSetupBuilding(SetupBuildingEvent $event) { $this->set_dir(); $cron_url = make_http(make_link("/cron_upload/" . $this->upload_key)); $cron_cmd = "curl --silent {$cron_url}"; $documentation_link = make_http(make_link("cron_upload")); $sb = new SetupBlock("Cron Uploader"); $sb->add_label("<b>Settings</b><br>"); $sb->add_int_option("cron_uploader_count", "How many to upload each time"); $sb->add_text_option("cron_uploader_dir", "<br>Set Cron Uploader root directory<br>"); $sb->add_label("<br>Cron Command: <input type='text' size='60' value='{$cron_cmd}'><br>\n\t\tCreate a cron job with the command above.<br/>\n\t\t<a href='{$documentation_link}'>Read the documentation</a> if you're not sure what to do."); $event->panel->add_block($sb); }
public function onDisplayingImage(DisplayingImageEvent $event) { $this->theme->links_block(make_http(make_link('image/' . $event->image->id . '.jpg'))); }
/** * Get a page based on the SCore URL, eg get_page("post/list") will do * the right thing; no need for http:// or any such */ protected function get_page($page) { $raw = $this->get(make_http(make_link($page))); $this->assertNoText("Exception:"); $this->assertNoText("Error:"); $this->assertNoText("Warning:"); $this->assertNoText("Notice:"); return $raw; }
/** * Constructor * @param Image $img */ function __construct(Image $img) { global $config; // author $author = $img->get_owner(); $this->author = $author->name; $this->creator_id = intval($author->id); // file $this->height = intval($img->height); $this->width = intval($img->width); $this->file_ext = $img->ext; $this->file_size = intval($img->filesize); $this->file_url = make_http($img->get_image_link()); $this->md5 = $img->hash; // meta $this->change = intval($img->id); //DaFug is this even supposed to do? ChangeID? // Should be JSON specific, just strip this when converting to XML $this->created_at = array('n' => 123456789, 's' => strtotime($img->posted), 'json_class' => 'Time'); $this->id = intval($img->id); $this->parent_id = null; if (defined('ENABLED_EXTS')) { if (strstr(ENABLED_EXTS, 'rating') !== false) { // 'u' is not a "valid" rating if ($img->rating == 's' || $img->rating == 'q' || $img->rating == 'e') { $this->rating = $img->rating; } } if (strstr(ENABLED_EXTS, 'numeric_score') !== false) { $this->score = $img->numeric_score; } } $this->source = $img->source; $this->status = 'active'; //not supported in Shimmie... yet $this->tags = $img->get_tag_list(); $this->has_children = false; $this->has_comments = false; $this->has_notes = false; // thumb $this->preview_height = $config->get_int('thumb_height'); $this->preview_width = $config->get_int('thumb_width'); $this->preview_url = make_http($img->get_thumb_link()); // sample (use the full image here) $this->sample_height = intval($img->height); $this->sample_width = intval($img->width); $this->sample_url = make_http($img->get_image_link()); }
/** * add_post() * Adds a post to the database. * * Parameters: * - login: login * - password: password * - file: file as a multipart form * - source: source url * - title: title **IGNORED** * - tags: list of tags as a string, delimited by whitespace * - md5: MD5 hash of upload in hexadecimal format * - rating: rating of the post. can be explicit, questionable, or safe. **IGNORED** * * Notes: * - The only necessary parameter is tags and either file or source. * - If you want to sign your post, you need a way to authenticate your account, either by supplying login and password, or by supplying a cookie. * - If an account is not supplied or if it doesnt authenticate, he post will be added anonymously. * - If the md5 parameter is supplied and does not match the hash of whats on the server, the post is rejected. * * Response * The response depends on the method used: * Post: * - X-Danbooru-Location set to the URL for newly uploaded post. * Get: * - Redirected to the newly uploaded post. */ private function api_add_post() { global $user, $config, $page; $danboorup_kludge = 1; // danboorup for firefox makes broken links out of location: /path // Check first if a login was supplied, if it wasn't check if the user is logged in via cookie // If all that fails, it's an anonymous upload $this->authenticate_user(); // Now we check if a file was uploaded or a url was provided to transload // Much of this code is borrowed from /ext/upload if (!$user->can("create_image")) { $page->set_code(409); $page->add_http_header("X-Danbooru-Errors: authentication error"); return; } if (isset($_FILES['file'])) { // A file was POST'd in $file = $_FILES['file']['tmp_name']; $filename = $_FILES['file']['name']; // If both a file is posted and a source provided, I'm assuming source is the source of the file if (isset($_REQUEST['source']) && !empty($_REQUEST['source'])) { $source = $_REQUEST['source']; } else { $source = null; } } elseif (isset($_FILES['post'])) { $file = $_FILES['post']['tmp_name']['file']; $filename = $_FILES['post']['name']['file']; if (isset($_REQUEST['post']['source']) && !empty($_REQUEST['post']['source'])) { $source = $_REQUEST['post']['source']; } else { $source = null; } } elseif (isset($_REQUEST['source']) || isset($_REQUEST['post']['source'])) { // A url was provided $source = isset($_REQUEST['source']) ? $_REQUEST['source'] : $_REQUEST['post']['source']; $file = tempnam("/tmp", "shimmie_transload"); $ok = transload($source, $file); if (!$ok) { $page->set_code(409); $page->add_http_header("X-Danbooru-Errors: fopen read error"); return; } $filename = basename($source); } else { // Nothing was specified at all $page->set_code(409); $page->add_http_header("X-Danbooru-Errors: no input files"); return; } // Get tags out of url $posttags = Tag::explode(isset($_REQUEST['tags']) ? $_REQUEST['tags'] : $_REQUEST['post']['tags']); // Was an md5 supplied? Does it match the file hash? $hash = md5_file($file); if (isset($_REQUEST['md5']) && strtolower($_REQUEST['md5']) != $hash) { $page->set_code(409); $page->add_http_header("X-Danbooru-Errors: md5 mismatch"); return; } // Upload size checking is now performed in the upload extension // It is also currently broken due to some confusion over file variable ($tmp_filename?) // Does it exist already? $existing = Image::by_hash($hash); if (!is_null($existing)) { $page->set_code(409); $page->add_http_header("X-Danbooru-Errors: duplicate"); $existinglink = make_link("post/view/" . $existing->id); if ($danboorup_kludge) { $existinglink = make_http($existinglink); } $page->add_http_header("X-Danbooru-Location: {$existinglink}"); return; } // Fire off an event which should process the new file and add it to the db $fileinfo = pathinfo($filename); $metadata = array(); $metadata['filename'] = $fileinfo['basename']; $metadata['extension'] = $fileinfo['extension']; $metadata['tags'] = $posttags; $metadata['source'] = $source; //log_debug("danbooru_api","========== NEW($filename) ========="); //log_debug("danbooru_api", "upload($filename): fileinfo(".var_export($fileinfo,TRUE)."), metadata(".var_export($metadata,TRUE).")..."); try { $nevent = new DataUploadEvent($file, $metadata); //log_debug("danbooru_api", "send_event(".var_export($nevent,TRUE).")"); send_event($nevent); // If it went ok, grab the id for the newly uploaded image and pass it in the header $newimg = Image::by_hash($hash); // FIXME: Unsupported file doesn't throw an error? $newid = make_link("post/view/" . $newimg->id); if ($danboorup_kludge) { $newid = make_http($newid); } // Did we POST or GET this call? if ($_SERVER['REQUEST_METHOD'] == 'POST') { $page->add_http_header("X-Danbooru-Location: {$newid}"); } else { $page->add_http_header("Location: {$newid}"); } } catch (UploadException $ex) { // Did something screw up? $page->set_code(409); $page->add_http_header("X-Danbooru-Errors: exception - " . $ex->getMessage()); } }
private function api_danbooru(PageRequestEvent $event) { global $page; global $config; global $database; global $user; $page->set_mode("data"); $page->set_type("application/xml"); //debug //$page->set_type("text/plain"); $results = array(); $danboorup_kludge = 1; // danboorup for firefox makes broken links out of location: /path /* add_post() Adds a post to the database. Parameters * login: login * password: password * file: file as a multipart form * source: source url * title: title **IGNORED** * tags: list of tags as a string, delimited by whitespace * md5: MD5 hash of upload in hexadecimal format * rating: rating of the post. can be explicit, questionable, or safe. **IGNORED** Notes * The only necessary parameter is tags and either file or source. * If you want to sign your post, you need a way to authenticate your account, either by supplying login and password, or by supplying a cookie. * If an account is not supplied or if it doesnt authenticate, he post will be added anonymously. * If the md5 parameter is supplied and does not match the hash of whats on the server, the post is rejected. Response The response depends on the method used: Post * X-Danbooru-Location set to the URL for newly uploaded post. Get * Redirected to the newly uploaded post. */ if ($event->get_arg(1) == 'add_post' || $event->get_arg(1) == 'post' && $event->get_arg(2) == 'create.xml') { // No XML data is returned from this function $page->set_type("text/plain"); // Check first if a login was supplied, if it wasn't check if the user is logged in via cookie // If all that fails, it's an anonymous upload $this->authenticate_user(); // Now we check if a file was uploaded or a url was provided to transload // Much of this code is borrowed from /ext/upload if ($user->can("create_image")) { if (isset($_FILES['file'])) { // A file was POST'd in $file = $_FILES['file']['tmp_name']; $filename = $_FILES['file']['name']; // If both a file is posted and a source provided, I'm assuming source is the source of the file if (isset($_REQUEST['source']) && !empty($_REQUEST['source'])) { $source = $_REQUEST['source']; } else { $source = null; } } elseif (isset($_FILES['post'])) { $file = $_FILES['post']['tmp_name']['file']; $filename = $_FILES['post']['name']['file']; if (isset($_REQUEST['post']['source']) && !empty($_REQUEST['post']['source'])) { $source = $_REQUEST['post']['source']; } else { $source = null; } } elseif (isset($_REQUEST['source']) || isset($_REQUEST['post']['source'])) { // A url was provided $url = isset($_REQUEST['source']) ? $_REQUEST['source'] : $_REQUEST['post']['source']; $source = $url; $tmp_filename = tempnam("/tmp", "shimmie_transload"); // Are we using fopen wrappers or curl? if ($config->get_string("transload_engine") == "fopen") { $fp = fopen($url, "r"); if (!$fp) { $page->add_http_header("HTTP/1.0 409 Conflict"); $page->add_http_header("X-Danbooru-Errors: fopen read error"); } $data = ""; $length = 0; while (!feof($fp) && $length <= $config->get_int('upload_size')) { $data .= fread($fp, 8192); $length = strlen($data); } fclose($fp); $fp = fopen($tmp_filename, "w"); fwrite($fp, $data); fclose($fp); } if ($config->get_string("transload_engine") == "curl") { $ch = curl_init($url); $fp = fopen($tmp_filename, "w"); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); fclose($fp); } $file = $tmp_filename; $filename = basename($url); } else { // Nothing was specified at all $page->add_http_header("HTTP/1.0 409 Conflict"); $page->add_http_header("X-Danbooru-Errors: no input files"); return; } // Get tags out of url $posttags = Tag::explode(isset($_REQUEST['tags']) ? $_REQUEST['tags'] : $_REQUEST['post']['tags']); $hash = md5_file($file); // Was an md5 supplied? Does it match the file hash? if (isset($_REQUEST['md5'])) { if (strtolower($_REQUEST['md5']) != $hash) { $page->add_http_header("HTTP/1.0 409 Conflict"); $page->add_http_header("X-Danbooru-Errors: md5 mismatch"); return; } } // Upload size checking is now performed in the upload extension // It is also currently broken due to some confusion over file variable ($tmp_filename?) // Does it exist already? $existing = Image::by_hash($hash); if (!is_null($existing)) { $page->add_http_header("HTTP/1.0 409 Conflict"); $page->add_http_header("X-Danbooru-Errors: duplicate"); $existinglink = make_link("post/view/" . $existing->id); if ($danboorup_kludge) { $existinglink = make_http($existinglink); } $page->add_http_header("X-Danbooru-Location: {$existinglink}"); return; // wut! } // Fire off an event which should process the new file and add it to the db $fileinfo = pathinfo($filename); $metadata = array(); $metadata['filename'] = $fileinfo['basename']; $metadata['extension'] = $fileinfo['extension']; $metadata['tags'] = $posttags; $metadata['source'] = $source; //log_debug("danbooru_api","========== NEW($filename) ========="); //log_debug("danbooru_api", "upload($filename): fileinfo(".var_export($fileinfo,TRUE)."), metadata(".var_export($metadata,TRUE).")..."); try { $nevent = new DataUploadEvent($file, $metadata); //log_debug("danbooru_api", "send_event(".var_export($nevent,TRUE).")"); send_event($nevent); // If it went ok, grab the id for the newly uploaded image and pass it in the header $newimg = Image::by_hash($hash); // FIXME: Unsupported file doesn't throw an error? $newid = make_link("post/view/" . $newimg->id); if ($danboorup_kludge) { $newid = make_http($newid); } // Did we POST or GET this call? if ($_SERVER['REQUEST_METHOD'] == 'POST') { $page->add_http_header("X-Danbooru-Location: {$newid}"); } else { $page->add_http_header("Location: {$newid}"); } } catch (UploadException $ex) { // Did something screw up? $page->add_http_header("HTTP/1.0 409 Conflict"); $page->add_http_header("X-Danbooru-Errors: exception - " . $ex->getMessage()); return; } } else { $page->add_http_header("HTTP/1.0 409 Conflict"); $page->add_http_header("X-Danbooru-Errors: authentication error"); return; } } /* find_posts() Find all posts that match the search criteria. Posts will be ordered by id descending. Parameters * md5: md5 hash to search for (comma delimited) * id: id to search for (comma delimited) * tags: what tags to search for * limit: limit * page: page number * after_id: limit results to posts added after this id */ if ($event->get_arg(1) == 'find_posts' || $event->get_arg(1) == 'post' && $event->get_arg(2) == 'index.xml') { $this->authenticate_user(); $start = 0; if (isset($_GET['md5'])) { $md5list = explode(",", $_GET['md5']); foreach ($md5list as $md5) { $results[] = Image::by_hash($md5); } $count = count($results); } elseif (isset($_GET['id'])) { $idlist = explode(",", $_GET['id']); foreach ($idlist as $id) { $results[] = Image::by_id($id); } $count = count($results); } else { $limit = isset($_GET['limit']) ? int_escape($_GET['limit']) : 100; // Calculate start offset. if (isset($_GET['page'])) { // Danbooru API uses 'page' >= 1 $start = (int_escape($_GET['page']) - 1) * $limit; } else { if (isset($_GET['pid'])) { // Gelbooru API uses 'pid' >= 0 $start = int_escape($_GET['pid']) * $limit; } else { $start = 0; } } $tags = isset($_GET['tags']) ? Tag::explode($_GET['tags']) : array(); $count = Image::count_images($tags); $results = Image::find_images(max($start, 0), min($limit, 100), $tags); } // Now we have the array $results filled with Image objects // Let's display them $xml = "<posts count=\"{$count}\" offset=\"{$start}\">\n"; foreach ($results as $img) { // Sanity check to see if $img is really an image object // If it isn't (e.g. someone requested an invalid md5 or id), break out of the this if (!is_object($img)) { continue; } $taglist = $img->get_tag_list(); $owner = $img->get_owner(); $previewsize = get_thumbnail_size($img->width, $img->height); $xml .= xml_tag("post", array("id" => $img->id, "md5" => $img->hash, "file_name" => $img->filename, "file_url" => $img->get_image_link(), "height" => $img->height, "width" => $img->width, "preview_url" => $img->get_thumb_link(), "preview_height" => $previewsize[1], "preview_width" => $previewsize[0], "rating" => "u", "date" => $img->posted, "is_warehoused" => false, "tags" => $taglist, "source" => $img->source, "score" => 0, "author" => $owner->name)); } $xml .= "</posts>"; $page->set_data($xml); } /* find_tags() Find all tags that match the search criteria. Parameters * id: A comma delimited list of tag id numbers. * name: A comma delimited list of tag names. * tags: any typical tag query. See Tag#parse_query for details. * after_id: limit results to tags with an id number after after_id. Useful if you only want to refresh */ if ($event->get_arg(1) == 'find_tags') { if (isset($_GET['id'])) { $idlist = explode(",", $_GET['id']); foreach ($idlist as $id) { $sqlresult = $database->execute("SELECT id,tag,count FROM tags WHERE id = ?", array($id)); if (!$sqlresult->EOF) { $results[] = array($sqlresult->fields['count'], $sqlresult->fields['tag'], $sqlresult->fields['id']); } } } elseif (isset($_GET['name'])) { $namelist = explode(",", $_GET['name']); foreach ($namelist as $name) { $sqlresult = $database->execute("SELECT id,tag,count FROM tags WHERE tag = ?", array($name)); if (!$sqlresult->EOF) { $results[] = array($sqlresult->fields['count'], $sqlresult->fields['tag'], $sqlresult->fields['id']); } } } else { $start = isset($_GET['after_id']) ? int_escape($_GET['offset']) : 0; $sqlresult = $database->execute("SELECT id,tag,count FROM tags WHERE count > 0 AND id >= ? ORDER BY id DESC", array($start)); while (!$sqlresult->EOF) { $results[] = array($sqlresult->fields['count'], $sqlresult->fields['tag'], $sqlresult->fields['id']); $sqlresult->MoveNext(); } } // Tag results collected, build XML output $xml = "<tags>\n"; foreach ($results as $tag) { $xml .= "<tag type=\"0\" count=\"{$tag['0']}\" name=\"" . $this->xmlspecialchars($tag[1]) . "\" id=\"{$tag['2']}\"/>\n"; } $xml .= "</tags>"; $page->set_data($xml); } // Hackery for danbooruup 0.3.2 providing the wrong view url. This simply redirects to the proper // Shimmie view page // Example: danbooruup says the url is http://shimmie/api/danbooru/post/show/123 // This redirects that to http://shimmie/post/view/123 if ($event->get_arg(1) == 'post' && $event->get_arg(2) == 'show') { $fixedlocation = make_link("post/view/" . $event->get_arg(3)); $page->set_mode("redirect"); $page->set_redirect($fixedlocation); } }