From 0d81fb05388f5cb740a6530dc3224d4ed4dec4aa Mon Sep 17 00:00:00 2001 From: Shish Date: Tue, 2 Feb 2010 01:04:38 +0000 Subject: [PATCH] more warehouse_path use --- contrib/handle_flash/main.php | 3 +-- contrib/handle_ico/main.php | 5 ++--- contrib/handle_mp3/main.php | 3 +-- contrib/handle_svg/main.php | 7 +++---- ext/handle_pixel/main.php | 4 ++-- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/contrib/handle_flash/main.php b/contrib/handle_flash/main.php index 78528fce..f63f988d 100644 --- a/contrib/handle_flash/main.php +++ b/contrib/handle_flash/main.php @@ -7,9 +7,8 @@ class FlashFileHandler extends DataHandlerExtension { protected function create_thumb($hash) { - $ha = substr($hash, 0, 2); // FIXME: scale image, as not all boards use 192x192 - copy("ext/handle_flash/thumb.jpg", "thumbs/$ha/$hash"); + copy("ext/handle_flash/thumb.jpg", warehouse_path("thumbs", $hash)); } protected function supported_ext($ext) { diff --git a/contrib/handle_ico/main.php b/contrib/handle_ico/main.php index 43eb22cb..771dd506 100644 --- a/contrib/handle_ico/main.php +++ b/contrib/handle_ico/main.php @@ -91,9 +91,8 @@ class IcoFileHandler extends SimpleExtension { private function create_thumb($hash) { global $config; - $ha = substr($hash, 0, 2); - $inname = "images/$ha/$hash"; - $outname = "thumbs/$ha/$hash"; + $inname = warehouse_path("images", $hash); + $outname = warehouse_path("thumbs", $hash); $w = $config->get_int("thumb_width"); $h = $config->get_int("thumb_height"); diff --git a/contrib/handle_mp3/main.php b/contrib/handle_mp3/main.php index fb84d4d7..ba02b3c5 100644 --- a/contrib/handle_mp3/main.php +++ b/contrib/handle_mp3/main.php @@ -7,9 +7,8 @@ class MP3FileHandler extends DataHandlerExtension { protected function create_thumb($hash) { - $ha = substr($hash, 0, 2); // FIXME: scale image, as not all boards use 192x192 - copy("ext/handle_mp3/thumb.jpg", "thumbs/$ha/$hash"); + copy("ext/handle_mp3/thumb.jpg", warehouse_path("thumbs", $hash)); } protected function supported_ext($ext) { diff --git a/contrib/handle_svg/main.php b/contrib/handle_svg/main.php index fa904bc2..e9e94c25 100644 --- a/contrib/handle_svg/main.php +++ b/contrib/handle_svg/main.php @@ -16,7 +16,7 @@ class SVGFileHandler implements Extension { $ha = substr($hash, 0, 2); if(!move_upload_to_archive($event)) return; send_event(new ThumbnailGenerationEvent($event->hash, $event->type)); - $image = $this->create_image_from_data("images/$ha/$hash", $event->metadata); + $image = $this->create_image_from_data(warehouse_path("images", $hash), $event->metadata); if(is_null($image)) { throw new UploadException("SVG handler failed to create image object from data"); } @@ -41,7 +41,7 @@ class SVGFileHandler implements Extension { // } // else { // FIXME: scale image, as not all boards use 192x192 - copy("ext/handle_svg/thumb.jpg", "thumbs/$ha/$hash"); + copy("ext/handle_svg/thumb.jpg", warehouse_path("thumbs", $hash)); // } } @@ -55,11 +55,10 @@ class SVGFileHandler implements Extension { $id = int_escape($event->get_arg(0)); $image = Image::by_id($id); $hash = $image->hash; - $ha = substr($hash, 0, 2); $page->set_type("image/svg+xml"); $page->set_mode("data"); - $page->set_data(file_get_contents("images/$ha/$hash")); + $page->set_data(file_get_contents(warehouse_path("images", $hash))); } } diff --git a/ext/handle_pixel/main.php b/ext/handle_pixel/main.php index 0c0c014b..571d9c02 100644 --- a/ext/handle_pixel/main.php +++ b/ext/handle_pixel/main.php @@ -43,8 +43,8 @@ class PixelFileHandler extends DataHandlerExtension { protected function create_thumb($hash) { $ha = substr($hash, 0, 2); - $inname = "images/$ha/$hash"; - $outname = "thumbs/$ha/$hash"; + $inname = warehouse_path("images", $hash); + $outname = warehouse_path("thumbs", $hash); global $config; $ok = false;