From 5c30eab6ad74add0b8b250792f17be42d759dcea Mon Sep 17 00:00:00 2001 From: Shish Date: Sat, 22 Sep 2012 22:58:56 +0100 Subject: [PATCH 1/4] merge Agasa's mass tagger work (replace tags mode, as opposed to the default of adding) --- ext/mass_tagger/main.php | 16 +++++++++++++--- ext/mass_tagger/theme.php | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ext/mass_tagger/main.php b/ext/mass_tagger/main.php index 7170dae8..6b7a8132 100644 --- a/ext/mass_tagger/main.php +++ b/ext/mass_tagger/main.php @@ -1,7 +1,7 @@ + * Author: Christian Walde , contributions by Shish and Agasa * License: WTFPL * Description: Tag a bunch of images at once * Documentation: @@ -38,8 +38,18 @@ class MassTagger extends Extension { $images = array_map( "Image::by_id", $ids ); - foreach($images as $image) { - $image->set_tags($tag . " " . $image->get_tag_list()); + if(isset($_POST['setadd']) && + $_POST['setadd'] == 'set') + { + foreach($images as $image) { + $image->set_tags($tag); + } + } + else + { + foreach($images as $image) { + $image->set_tags($tag . " " . $image->get_tag_list()); + } } $page->set_mode("redirect"); diff --git a/ext/mass_tagger/theme.php b/ext/mass_tagger/theme.php index 0f0b009e..5a844bac 100644 --- a/ext/mass_tagger/theme.php +++ b/ext/mass_tagger/theme.php @@ -13,6 +13,7 @@ class MassTaggerTheme extends Themelet { Click on images to mark them. Use the 'Index Options' in the Board Config to increase the amount of shown images.
+ Set instead of add? From bbe2b1dc462dd0dd7331b2426bb7b6be2c90c908 Mon Sep 17 00:00:00 2001 From: Shish Date: Sat, 22 Sep 2012 23:10:29 +0100 Subject: [PATCH 2/4] don't need to load the file into memory if we're responding with '304 not modified'... --- ext/image/main.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/image/main.php b/ext/image/main.php index f4650626..be28faed 100644 --- a/ext/image/main.php +++ b/ext/image/main.php @@ -365,8 +365,6 @@ class ImageIO extends Extension { $file = $image->get_image_filename(); } - $page->set_data(file_get_contents($file)); - if(isset($_SERVER["HTTP_IF_MODIFIED_SINCE"])) { $if_modified_since = preg_replace('/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"]); } @@ -377,9 +375,11 @@ class ImageIO extends Extension { if($if_modified_since == $gmdate_mod) { $page->add_http_header("HTTP/1.0 304 Not Modified",3); + $page->set_data(""); } else { $page->add_http_header("Last-Modified: $gmdate_mod"); + $page->set_data(file_get_contents($file)); if ( $config->get_int("image_expires") ) { $expires = date(DATE_RFC1123, time() + $config->get_int("image_expires")); From 06426bdfe6604356c08430337532082bbd540f81 Mon Sep 17 00:00:00 2001 From: Shish Date: Sat, 22 Sep 2012 23:15:25 +0100 Subject: [PATCH 3/4] when checking mime types, use the filename.ext from the DB, not the (non-existent) .ext on disk --- core/imageboard.pack.php | 2 +- core/util.inc.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php index 02f5f221..a11c1620 100644 --- a/core/imageboard.pack.php +++ b/core/imageboard.pack.php @@ -387,7 +387,7 @@ class Image { * @retval string */ public function get_mime_type() { - return getMimeType($this->get_image_filename()); + return getMimeType($this->get_image_filename(), $this->get_ext()); } /** diff --git a/core/util.inc.php b/core/util.inc.php index b1670b7e..a18b1923 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -489,7 +489,7 @@ function captcha_check() { * @param string &$file File path * @return string */ -function getMimeType($file) { +function getMimeType($file, $ext="") { $type = false; // Fileinfo documentation says fileinfo_open() will use the // MAGIC env var for the magic file @@ -527,7 +527,6 @@ function getMimeType($file) { 'avi' => 'video/x-msvideo', 'mpg' => 'video/mpeg', 'mpeg' => 'video/mpeg', 'mov' => 'video/quicktime', 'flv' => 'video/x-flv', 'php' => 'text/x-php' ); - $ext = strtolower(pathInfo($file, PATHINFO_EXTENSION)); return isset($exts[$ext]) ? $exts[$ext] : 'application/octet-stream'; } From 65ce0ff4e49106a9af5ce2d312036fbe4ceb53d0 Mon Sep 17 00:00:00 2001 From: Shish Date: Sat, 22 Sep 2012 23:24:19 +0100 Subject: [PATCH 4/4] check filename extension by lowercased version of itself --- core/util.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/core/util.inc.php b/core/util.inc.php index a18b1923..387ddee7 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -513,6 +513,7 @@ function getMimeType($file, $ext="") { if ($type !== false && strlen($type) > 0) return $type; // Otherwise do it the old fashioned way + $ext = strtolower($ext); static $exts = array( 'jpg' => 'image/jpeg', 'gif' => 'image/gif', 'png' => 'image/png', 'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'ico' => 'image/x-icon',