From 064b24ffc135eb976638659ff5a36c542e534749 Mon Sep 17 00:00:00 2001 From: Shish Date: Fri, 14 Jun 2019 13:47:50 +0100 Subject: [PATCH] formatting pass --- core/exceptions.php | 2 +- core/extension.php | 6 +- core/imageboard/misc.php | 72 ++++++++++-------- ext/bulk_actions/main.php | 38 +++++----- ext/bulk_actions/theme.php | 66 ++++++++-------- ext/cron_uploader/main.php | 32 ++++---- ext/handle_flash/main.php | 2 +- ext/handle_pixel/main.php | 23 ++++-- ext/handle_svg/main.php | 4 +- ext/image/main.php | 18 ++--- ext/rating/main.php | 13 ++-- ext/rating/theme.php | 3 +- ext/regen_thumb/main.php | 54 +++++++------- ext/regen_thumb/theme.php | 7 +- ext/rotate/main.php | 14 ++-- ext/transcode/main.php | 149 ++++++++++++++++++------------------- ext/transcode/theme.php | 7 +- ext/upload/main.php | 10 ++- 18 files changed, 265 insertions(+), 255 deletions(-) diff --git a/core/exceptions.php b/core/exceptions.php index bf923d96..736b029e 100644 --- a/core/exceptions.php +++ b/core/exceptions.php @@ -53,4 +53,4 @@ class ImageResizeException extends SCoreException { $this->error = $error; } -} \ No newline at end of file +} diff --git a/core/extension.php b/core/extension.php index 7274f868..b7472583 100644 --- a/core/extension.php +++ b/core/extension.php @@ -221,17 +221,17 @@ abstract class DataHandlerExtension extends Extension { $result = false; if ($this->supported_ext($event->type)) { - if($event->force) { + if ($event->force) { $result = $this->create_thumb($event->hash); } else { $outname = warehouse_path("thumbs", $event->hash); - if(file_exists($outname)) { + if (file_exists($outname)) { return; } $result = $this->create_thumb($event->hash); } } - if($result) { + if ($result) { $event->generated = true; } } diff --git a/core/imageboard/misc.php b/core/imageboard/misc.php index eb3c4146..dbdf25f5 100644 --- a/core/imageboard/misc.php +++ b/core/imageboard/misc.php @@ -66,15 +66,15 @@ function add_image(string $tmpname, string $filename, string $tags): void } -function get_extension_from_mime(String $file_path): ?String +function get_extension_from_mime(String $file_path): ?String { global $config; $mime = mime_content_type($file_path); - if(!empty($mime)) { + if (!empty($mime)) { $ext = get_extension($mime); - if(!empty($ext)) { + if (!empty($ext)) { return $ext; - } + } throw new UploadException("Could not determine extension for mimetype ".$mime); } throw new UploadException("Could not determine file mime type: ".$file_path); @@ -168,7 +168,7 @@ function get_thumbnail_max_size_scaled(): array return [$max_width, $max_height]; } -function create_thumbnail_convert($hash): bool +function create_thumbnail_convert($hash): bool { global $config; @@ -178,8 +178,7 @@ function create_thumbnail_convert($hash): bool $q = $config->get_int("thumb_quality"); $convert = $config->get_string("thumb_convert_path"); - if($convert==null||$convert=="") - { + if ($convert==null||$convert=="") { return false; } @@ -202,7 +201,7 @@ function create_thumbnail_convert($hash): bool } $bg = "black"; - if($type=="webp") { + if ($type=="webp") { $bg = "none"; } $format = '"%s" -flatten -strip -thumbnail %ux%u%s -quality %u -background %s "%s[0]" %s:"%s"'; @@ -225,7 +224,7 @@ function create_thumbnail_ffmpeg($hash): bool global $config; $ffmpeg = $config->get_string("thumb_ffmpeg_path"); - if($ffmpeg==null||$ffmpeg=="") { + if ($ffmpeg==null||$ffmpeg=="") { return false; } @@ -237,12 +236,12 @@ function create_thumbnail_ffmpeg($hash): bool $codec = "mjpeg"; $quality = $config->get_int("thumb_quality"); - if($config->get_string("thumb_type")=="webp") { + if ($config->get_string("thumb_type")=="webp") { $codec = "libwebp"; } else { - // mjpeg quality ranges from 2-31, with 2 being the best quality. + // mjpeg quality ranges from 2-31, with 2 being the best quality. $quality = floor(31 - (31 * ($quality/100))); - if($quality<2) { + if ($quality<2) { $quality = 2; } } @@ -321,13 +320,19 @@ function calc_memory_use(array $info): int return (int)$memory_use; } -function image_resize_gd(String $image_filename, array $info, int $new_width, int $new_height, - string $output_filename=null, string $output_type=null, int $output_quality = 80) -{ +function image_resize_gd( + String $image_filename, + array $info, + int $new_width, + int $new_height, + string $output_filename=null, + string $output_type=null, + int $output_quality = 80 +) { $width = $info[0]; $height = $info[1]; - if($output_type==null) { + if ($output_type==null) { /* If not specified, output to the same format as the original image */ switch ($info[2]) { case IMAGETYPE_GIF: $output_type = "gif"; break; @@ -337,7 +342,7 @@ function image_resize_gd(String $image_filename, array $info, int $new_width, in case IMAGETYPE_BMP: $output_type = "bmp"; break; default: throw new ImageResizeException("Failed to save the new image - Unsupported image type."); } - } + } $memory_use = calc_memory_use($info); $memory_limit = get_memory_limit(); @@ -348,15 +353,15 @@ function image_resize_gd(String $image_filename, array $info, int $new_width, in $image = imagecreatefromstring(file_get_contents($image_filename)); $image_resized = imagecreatetruecolor($new_width, $new_height); try { - if($image===false) { + if ($image===false) { throw new ImageResizeException("Could not load image: ".$image_filename); } - if($image_resized===false) { + if ($image_resized===false) { throw new ImageResizeException("Could not create output image with dimensions $new_width c $new_height "); } // Handle transparent images - switch($info[2]) { + switch ($info[2]) { case IMAGETYPE_GIF: $transparency = imagecolortransparent($image); $palletsize = imagecolorstotal($image); @@ -368,12 +373,12 @@ function image_resize_gd(String $image_filename, array $info, int $new_width, in // Allocate the same color in the new image resource $transparency = imagecolorallocate($image_resized, $transparent_color['red'], $transparent_color['green'], $transparent_color['blue']); - if($transparency===false) { + if ($transparency===false) { throw new ImageResizeException("Unable to allocate transparent color"); } // Completely fill the background of the new image with allocated color. - if(imagefill($image_resized, 0, 0, $transparency)===false) { + if (imagefill($image_resized, 0, 0, $transparency)===false) { throw new ImageResizeException("Unable to fill new image with transparent color"); } @@ -386,24 +391,24 @@ function image_resize_gd(String $image_filename, array $info, int $new_width, in // // More info here: http://stackoverflow.com/questions/279236/how-do-i-resize-pngs-with-transparency-in-php // - if(imagealphablending($image_resized, false)===false) { + if (imagealphablending($image_resized, false)===false) { throw new ImageResizeException("Unable to disable image alpha blending"); } - if(imagesavealpha($image_resized, true)===false) { + if (imagesavealpha($image_resized, true)===false) { throw new ImageResizeException("Unable to enable image save alpha"); } $transparent_color = imagecolorallocatealpha($image_resized, 255, 255, 255, 127); - if($transparent_color===false) { + if ($transparent_color===false) { throw new ImageResizeException("Unable to allocate transparent color"); } - if(imagefilledrectangle($image_resized, 0, 0, $new_width, $new_height, $transparent_color)===false) { + if (imagefilledrectangle($image_resized, 0, 0, $new_width, $new_height, $transparent_color)===false) { throw new ImageResizeException("Unable to fill new image with transparent color"); } break; } // Actually resize the image. - if(imagecopyresampled( + if (imagecopyresampled( $image_resized, $image, 0, @@ -415,11 +420,11 @@ function image_resize_gd(String $image_filename, array $info, int $new_width, in $width, $height )===false) { - throw new ImageResizeException("Unable to copy resized image data to new image"); - } + throw new ImageResizeException("Unable to copy resized image data to new image"); + } $result = false; - switch($output_type) { + switch ($output_type) { case "bmp": $result = imagebmp($image_resized, $output_filename, true); break; @@ -439,7 +444,7 @@ function image_resize_gd(String $image_filename, array $info, int $new_width, in default: throw new ImageResizeException("Failed to save the new image - Unsupported image type: $output_type"); } - if($result==false) { + if ($result==false) { throw new ImageResizeException("Failed to save the new image, function returned false when saving type: $output_type"); } } finally { @@ -448,7 +453,8 @@ function image_resize_gd(String $image_filename, array $info, int $new_width, in } } -function is_animated_gif(String $image_filename) { +function is_animated_gif(String $image_filename) +{ $isanigif = 0; if (($fh = @fopen($image_filename, 'rb'))) { //check if gif is animated (via http://www.php.net/manual/en/function.imagecreatefromgif.php#104473) @@ -458,4 +464,4 @@ function is_animated_gif(String $image_filename) { } } return ($isanigif == 0); -} \ No newline at end of file +} diff --git a/ext/bulk_actions/main.php b/ext/bulk_actions/main.php index 291dd513..2c93de4e 100644 --- a/ext/bulk_actions/main.php +++ b/ext/bulk_actions/main.php @@ -12,22 +12,23 @@ class BulkActionBlockBuildingEvent extends Event { /** @var array */ - public $actions = array(); + public $actions = []; public function add_action(String $action, string $button_text, String $confirmation_message = "", String $block = "", int $position = 40) { - if ($block == null) + if ($block == null) { $block = ""; + } array_push( $this->actions, - array( + [ "block" => $block, "confirmation_message" => $confirmation_message, "action" => $action, "button_text" => $button_text, "position" => $position - ) + ] ); } } @@ -41,7 +42,7 @@ class BulkActionEvent extends Event /** @var PageRequestEvent */ public $page_request; - function __construct(String $action, PageRequestEvent $pageRequestEvent, array $items) + public function __construct(String $action, PageRequestEvent $pageRequestEvent, array $items) { $this->action = $action; $this->page_request = $pageRequestEvent; @@ -59,10 +60,11 @@ class BulkActions extends Extension $babbe = new BulkActionBlockBuildingEvent(); send_event($babbe); - if (sizeof($babbe->actions) == 0) - return; + if (sizeof($babbe->actions) == 0) { + return; + } - usort($babbe->actions, array($this, "sort_blocks")); + usort($babbe->actions, [$this, "sort_blocks"]); $this->theme->display_selector($page, $babbe->actions, Tag::implode($event->search_terms)); } @@ -73,15 +75,15 @@ class BulkActions extends Extension global $user; if ($user->can("delete_image")) { - $event->add_action("bulk_delete","Delete", "Delete selected images?", "", 10); + $event->add_action("bulk_delete", "Delete", "Delete selected images?", "", 10); } if ($user->can("bulk_edit_image_tag")) { - $event->add_action("bulk_tag","Tag", "", $this->theme->render_tag_input(), 10); + $event->add_action("bulk_tag", "Tag", "", $this->theme->render_tag_input(), 10); } if ($user->can("bulk_edit_image_source")) { - $event->add_action("bulk_source","Set Source", "", $this->theme->render_source_input(), 10); + $event->add_action("bulk_source", "Set Source", "", $this->theme->render_source_input(), 10); } } @@ -144,7 +146,7 @@ class BulkActions extends Extension } } } - } else if (isset($_POST['bulk_query']) && $_POST['bulk_query'] != "") { + } elseif (isset($_POST['bulk_query']) && $_POST['bulk_query'] != "") { $query = $_POST['bulk_query']; if ($query != null && $query != "") { $n = 0; @@ -178,8 +180,8 @@ class BulkActions extends Extension } private function sort_blocks($a, $b) - { - return $a["position"] - $b["position"]; + { + return $a["position"] - $b["position"]; } private function delete_items(array $items): int @@ -188,7 +190,7 @@ class BulkActions extends Extension foreach ($items as $id) { try { $image = Image::by_id($id); - if($image==null) { + if ($image==null) { continue; } @@ -219,7 +221,7 @@ class BulkActions extends Extension if ($replace) { foreach ($items as $id) { $image = Image::by_id($id); - if($image==null) { + if ($image==null) { continue; } @@ -229,7 +231,7 @@ class BulkActions extends Extension } else { foreach ($items as $id) { $image = Image::by_id($id); - if($image==null) { + if ($image==null) { continue; } @@ -254,7 +256,7 @@ class BulkActions extends Extension foreach ($items as $id) { try { $image = Image::by_id($id); - if($image==null) { + if ($image==null) { continue; } diff --git a/ext/bulk_actions/theme.php b/ext/bulk_actions/theme.php index b0c06856..538c74df 100644 --- a/ext/bulk_actions/theme.php +++ b/ext/bulk_actions/theme.php @@ -2,13 +2,11 @@ class BulkActionsTheme extends Themelet { + public function display_selector(Page $page, $actions, $query) + { + global $user; - - public function display_selector(Page $page, $actions, $query) - { - global $user; - - $body = " + $body = " "; - } + if ($hasQuery) { + $body .= ""; + } - foreach ($actions as $action) { - $body .= "
" . make_form(make_link("bulk_action"), "POST", False, "", "return validate_selections(this,'" . html_escape($action["confirmation_message"]) . "');") . - "" . - "" . - "" . - $action["block"] . - "" . - "
"; - } + foreach ($actions as $action) { + $body .= "
" . make_form(make_link("bulk_action"), "POST", false, "", "return validate_selections(this,'" . html_escape($action["confirmation_message"]) . "');") . + "" . + "" . + "" . + $action["block"] . + "" . + "
"; + } - if (!$hasQuery) { - $body .= ""; - } - $block = new Block("Bulk Actions", $body, "left", 30); - $page->add_block($block); - } + if (!$hasQuery) { + $body .= ""; + } + $block = new Block("Bulk Actions", $body, "left", 30); + $page->add_block($block); + } - public function render_tag_input() - { - return "" . - ""; - } + public function render_tag_input() + { + return "" . + ""; + } - public function render_source_input() - { - return ""; - } + public function render_source_input() + { + return ""; + } } diff --git a/ext/cron_uploader/main.php b/ext/cron_uploader/main.php index 05eb0162..f4bd3c51 100644 --- a/ext/cron_uploader/main.php +++ b/ext/cron_uploader/main.php @@ -282,7 +282,7 @@ class CronUploader extends Extension $result = $this->add_image($img[0], $img[1], $img[2]); $database->commit(); $this->move_uploaded($img[0], $img[1], $output_subdir, false); - if($result==null) { + if ($result==null) { $merged++; } else { $added++; @@ -290,7 +290,7 @@ class CronUploader extends Extension } catch (Exception $e) { $failed++; $this->move_uploaded($img[0], $img[1], $output_subdir, true); - $msgNumber = $this->add_upload_info("(".gettype($e).") ".$e->getMessage()); + $msgNumber = $this->add_upload_info("(".gettype($e).") ".$e->getMessage()); $msgNumber = $this->add_upload_info($e->getTraceAsString()); if (strpos($e->getMessage(), 'SQLSTATE') !== false) { // Postgres invalidates the transaction if there is an SQL error, @@ -299,7 +299,8 @@ class CronUploader extends Extension } try { $database->rollback(); - } catch (Exception $e) {} + } catch (Exception $e) { + } } } @@ -325,17 +326,16 @@ class CronUploader extends Extension $relativeDir = dirname(substr($path, strlen($this->root_dir) + 7)); - // Determine which dir to move to - if ($corrupt) { - // Move to corrupt dir - $newDir .= "/failed_to_upload/".$output_subdir.$relativeDir; - $info = "ERROR: Image was not uploaded."; - } - else { - $newDir .= "/uploaded/".$output_subdir.$relativeDir; - $info = "Image successfully uploaded. "; - } - $newDir = str_replace ( "//", "/", $newDir."/" ); + // Determine which dir to move to + if ($corrupt) { + // Move to corrupt dir + $newDir .= "/failed_to_upload/".$output_subdir.$relativeDir; + $info = "ERROR: Image was not uploaded."; + } else { + $newDir .= "/uploaded/".$output_subdir.$relativeDir; + $info = "Image successfully uploaded. "; + } + $newDir = str_replace("//", "/", $newDir."/"); if (!is_dir($newDir)) { mkdir($newDir, 0775, true); @@ -360,7 +360,7 @@ class CronUploader extends Extension if (array_key_exists('extension', $pathinfo)) { $metadata ['extension'] = $pathinfo ['extension']; } - $metadata ['tags'] = Tag::explode($tags); + $metadata ['tags'] = Tag::explode($tags); $metadata ['source'] = null; $event = new DataUploadEvent($tmpname, $metadata); send_event($event); @@ -369,7 +369,7 @@ class CronUploader extends Extension $infomsg = ""; // Will contain info message if ($event->image_id == -1) { throw new Exception("File type not recognised. Filename: {$filename}"); - } else if ($event->image_id == null) { + } elseif ($event->image_id == null) { $infomsg = "Image merged. Filename: {$filename}"; } else { $infomsg = "Image uploaded. ID: {$event->image_id} - Filename: {$filename}"; diff --git a/ext/handle_flash/main.php b/ext/handle_flash/main.php index cec86d13..8da00583 100644 --- a/ext/handle_flash/main.php +++ b/ext/handle_flash/main.php @@ -12,7 +12,7 @@ class FlashFileHandler extends DataHandlerExtension { global $config; - if(!create_thumbnail_ffmpeg($hash)) { + if (!create_thumbnail_ffmpeg($hash)) { copy("ext/handle_flash/thumb.jpg", warehouse_path("thumbs", $hash)); } return true; diff --git a/ext/handle_pixel/main.php b/ext/handle_pixel/main.php index 04b26448..e10d8f75 100644 --- a/ext/handle_pixel/main.php +++ b/ext/handle_pixel/main.php @@ -97,19 +97,26 @@ class PixelFileHandler extends DataHandlerExtension try { $info = getimagesize($inname); $tsize = get_thumbnail_size_scaled($info[0], $info[1]); - $image = image_resize_gd($inname, $info, $tsize[0], $tsize[1], - $outname, $config->get_string('thumb_type'),$config->get_int('thumb_quality')); - } catch(InsufficientMemoryException $e) { - $tsize = get_thumbnail_max_size_scaled(); - $thumb = imagecreatetruecolor($tsize[0], min($tsize[1], 64)); + $image = image_resize_gd( + $inname, + $info, + $tsize[0], + $tsize[1], + $outname, + $config->get_string('thumb_type'), + $config->get_int('thumb_quality') + ); + } catch (InsufficientMemoryException $e) { + $tsize = get_thumbnail_max_size_scaled(); + $thumb = imagecreatetruecolor($tsize[0], min($tsize[1], 64)); $white = imagecolorallocate($thumb, 255, 255, 255); $black = imagecolorallocate($thumb, 0, 0, 0); imagefill($thumb, 0, 0, $white); - log_warning("handle_pixel","Insufficient memory while creating thumbnail: ".$e->getMessage()); + log_warning("handle_pixel", "Insufficient memory while creating thumbnail: ".$e->getMessage()); imagestring($thumb, 5, 10, 24, "Image Too Large :(", $black); return true; - } catch(Exception $e) { - log_error("handle_pixel","Error while creating thumbnail: ".$e->getMessage()); + } catch (Exception $e) { + log_error("handle_pixel", "Error while creating thumbnail: ".$e->getMessage()); return false; } diff --git a/ext/handle_svg/main.php b/ext/handle_svg/main.php index 97127816..5676d24f 100644 --- a/ext/handle_svg/main.php +++ b/ext/handle_svg/main.php @@ -3,7 +3,7 @@ * Name: Handle SVG * Author: Shish * Link: http://code.shishnet.org/shimmie2/ - * Description: Handle static SVG files. + * Description: Handle static SVG files. */ use enshrined\svgSanitize\Sanitizer; @@ -34,7 +34,7 @@ class SVGFileHandler extends DataHandlerExtension protected function create_thumb(string $hash): bool { - if(!create_thumbnail_convert($hash)) { + if (!create_thumbnail_convert($hash)) { copy("ext/handle_svg/thumb.jpg", warehouse_path("thumbs", $hash)); } return true; diff --git a/ext/image/main.php b/ext/image/main.php index 362cb944..b2fe5722 100644 --- a/ext/image/main.php +++ b/ext/image/main.php @@ -253,12 +253,12 @@ class ImageIO extends Extension if (!is_null($image)) { $page->set_mode("data"); if ($type == "thumb") { - $ext = $config->get_string("thumb_type"); - if (array_key_exists($ext, MIME_TYPE_MAP)) { - $page->set_type(MIME_TYPE_MAP[$ext]); - } else { - $page->set_type("image/jpeg"); - } + $ext = $config->get_string("thumb_type"); + if (array_key_exists($ext, MIME_TYPE_MAP)) { + $page->set_type(MIME_TYPE_MAP[$ext]); + } else { + $page->set_type("image/jpeg"); + } $file = $image->get_thumb_filename(); } else { @@ -278,9 +278,9 @@ class ImageIO extends Extension $page->set_data(""); } else { $page->add_http_header("Last-Modified: $gmdate_mod"); - if ($type != "thumb") { - $page->add_http_header("Content-Disposition: inline; filename=".$image->get_nice_image_name()); - } + if ($type != "thumb") { + $page->add_http_header("Content-Disposition: inline; filename=".$image->get_nice_image_name()); + } $page->set_data(file_get_contents($file)); if ($config->get_int("image_expires")) { diff --git a/ext/rating/main.php b/ext/rating/main.php index 948e4b1a..18b40823 100644 --- a/ext/rating/main.php +++ b/ext/rating/main.php @@ -170,16 +170,15 @@ class Ratings extends Extension global $user; if ($user->is_admin()) { - $event->add_action("bulk_rate","Set Rating","",$this->theme->get_selection_rater_html("bulk_rating")); + $event->add_action("bulk_rate", "Set Rating", "", $this->theme->get_selection_rater_html("bulk_rating")); } - } public function onBulkAction(BulkActionEvent $event) { global $user; - switch($event->action) { + switch ($event->action) { case "bulk_rate": if (!isset($_POST['bulk_rating'])) { return; @@ -189,12 +188,12 @@ class Ratings extends Extension $total = 0; foreach ($event->items as $id) { $image = Image::by_id($id); - if($image==null) { + if ($image==null) { continue; } send_event(new RatingSetEvent($image, $rating)); - $total++; + $total++; } flash_message("Rating set for $total items"); } @@ -331,7 +330,7 @@ class Ratings extends Extension if ($config->get_int("ext_ratings2_version") < 3) { $database->Execute("UPDATE images SET rating = 'u' WHERE rating is null"); - switch($database->get_driver_name()) { + switch ($database->get_driver_name()) { case "mysql": $database->Execute("ALTER TABLE images CHANGE rating rating CHAR(1) NOT NULL DEFAULT 'u'"); break; @@ -340,7 +339,7 @@ class Ratings extends Extension $database->Execute("ALTER TABLE images ALTER COLUMN rating SET NOT NULL"); break; } - $config->set_int("ext_ratings2_version", 3); + $config->set_int("ext_ratings2_version", 3); } } diff --git a/ext/rating/theme.php b/ext/rating/theme.php index 67f85831..d414e3f6 100644 --- a/ext/rating/theme.php +++ b/ext/rating/theme.php @@ -46,7 +46,8 @@ class RatingsTheme extends Themelet $page->add_block(new Block("List Controls", $html, "left")); } - public function get_selection_rater_html(String $id = "select_rating") { + public function get_selection_rater_html(String $id = "select_rating") + { return "Only missing thumbs"; } @@ -49,7 +50,7 @@ class RegenThumbTheme extends Themelet $types = []; $results = $database->get_all("SELECT ext, count(*) count FROM images group by ext"); foreach ($results as $result) { - array_push($types,""); + array_push($types, ""); } $html = " @@ -67,7 +68,7 @@ class RegenThumbTheme extends Themelet

-

".make_form(make_link("admin/delete_thumbs"),"POST",False, "","return confirm('Are you sure you want to delete all thumbnails?')")." +

".make_form(make_link("admin/delete_thumbs"), "POST", false, "", "return confirm('Are you sure you want to delete all thumbnails?')")."
"; - foreach($options as $display=>$value) { + foreach ($options as $display=>$value) { $html .= ""; } return $html.""; - } public function display_transcode_error(Page $page, string $title, string $message) @@ -37,5 +37,4 @@ class TranscodeImageTheme extends Themelet $page->add_block(new NavBlock()); $page->add_block(new Block($title, $message)); } - } diff --git a/ext/upload/main.php b/ext/upload/main.php index acb853de..f42f1360 100644 --- a/ext/upload/main.php +++ b/ext/upload/main.php @@ -46,10 +46,10 @@ class DataUploadEvent extends Event $this->set_tmpname($tmpname); - if($config->get_bool("upload_use_mime")) { + if ($config->get_bool("upload_use_mime")) { $this->set_type(get_extension_from_mime($tmpname)); } else { - if(array_key_exists('extension',$metadata)&&!empty($metadata['extension'])) { + if (array_key_exists('extension', $metadata)&&!empty($metadata['extension'])) { $this->type = strtolower($metadata['extension']); } else { throw new UploadException("Could not determine extension for file ".$metadata["filename"]); @@ -57,12 +57,14 @@ class DataUploadEvent extends Event } } - public function set_type(String $type) { + public function set_type(String $type) + { $this->type = strtolower($type); $this->metadata["extension"] = $this->type; } - public function set_tmpname(String $tmpname) { + public function set_tmpname(String $tmpname) + { $this->tmpname = $tmpname; $this->metadata['hash'] = md5_file($tmpname); $this->metadata['size'] = filesize($tmpname);