From fc4b095fa1a85f19cc7f13ad8b1263fdd4635f86 Mon Sep 17 00:00:00 2001 From: thisgun Date: Tue, 11 Aug 2020 17:59:14 +0900 Subject: [PATCH] =?UTF-8?q?=EC=8D=B8=EB=84=A4=EC=9D=BC=EA=B3=BC=20htmlpuri?= =?UTF-8?q?fier=20=ED=95=84=ED=84=B0=EB=A7=81=EC=97=90=20=EB=8C=80?= =?UTF-8?q?=ED=95=9C=20hook=20=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adm/board_form.php | 2 ++ bbs/move_update.php | 12 ++++++++++-- lib/common.lib.php | 6 +++++- lib/thumbnail.lib.php | 37 ++++++++++++++++++++++++++++++------- 4 files changed, 47 insertions(+), 10 deletions(-) diff --git a/adm/board_form.php b/adm/board_form.php index 58b9538c3..0fd63b0f3 100644 --- a/adm/board_form.php +++ b/adm/board_form.php @@ -84,6 +84,8 @@ if (!isset($board['bo_select_editor'])) { sql_query(" ALTER TABLE `{$g5['board_table']}` ADD `bo_select_editor` VARCHAR(50) NOT NULL DEFAULT '' AFTER `bo_use_dhtml_editor` "); } +run_event('adm_board_form_before', $board, $w); + $required = ""; $readonly = ""; $sound_only = ""; diff --git a/bbs/move_update.php b/bbs/move_update.php index 044586264..0b5f85508 100644 --- a/bbs/move_update.php +++ b/bbs/move_update.php @@ -27,6 +27,8 @@ $sql = " select distinct wr_num from $write_table where wr_id in ({$wr_id_list}) $result = sql_query($sql); while ($row = sql_fetch_array($result)) { + $save[$cnt]['wr_contents'] = array(); + $wr_num = $row['wr_num']; for ($i=0; $iset('Filter.Custom', array(new HTMLPurifier_Filter_Iframevideo())); $purifier = new HTMLPurifier($config); - return $purifier->purify($html); + return run_replace('html_purifier_result', $purifier->purify($html), $purifier, $html); } @@ -2318,6 +2318,8 @@ function delete_editor_thumbnail($contents) { if(!$contents) return; + + run_event('delete_editor_thumbnail_before', $contents); // $contents 중 img 태그 추출 $matchs = get_editor_image($contents); @@ -2338,6 +2340,8 @@ function delete_editor_thumbnail($contents) unlink($filename); } } + + run_event('delete_editor_thumbnail_after', $contents, $matchs); } // 1:1문의 첨부파일 썸네일 삭제 diff --git a/lib/thumbnail.lib.php b/lib/thumbnail.lib.php index 47e296801..d534edef1 100644 --- a/lib/thumbnail.lib.php +++ b/lib/thumbnail.lib.php @@ -110,6 +110,8 @@ function get_view_thumbnail($contents, $thumb_width=0) for($i=0; $i\'\"]+[^>\'\"]+)/i", $img, $m); $src = $m[1]; preg_match("/style=[\"\']?([^\"\'>]+)/i", $img, $m); @@ -161,16 +163,22 @@ function get_view_thumbnail($contents, $thumb_width=0) } } - // 원본 width가 thumb_width보다 작다면 - if($size[0] <= $thumb_width) - continue; - // Animated GIF 체크 $is_animated = false; if($size[2] == 1) { $is_animated = is_animated_gif($srcfile); + + if($replace_content = run_replace('thumbnail_is_animated_gif_content', '', $contents, $srcfile, $is_animated, $img_tag, $data_path, $size)){ + + $contents = $replace_content; + continue; + } } + // 원본 width가 thumb_width보다 작다면 + if($size[0] <= $thumb_width) + continue; + // 썸네일 높이 $thumb_height = round(($thumb_width * $size[1]) / $size[0]); $filename = basename($srcfile); @@ -192,7 +200,6 @@ function get_view_thumbnail($contents, $thumb_width=0) } // $img_tag에 editor 경로가 있으면 원본보기 링크 추가 - $img_tag = $matches[0][$i]; if(strpos($img_tag, G5_DATA_DIR.'/'.G5_EDITOR_DIR) && preg_match("/\.({$config['cf_image_extension']})$/i", $filename)) { $imgurl = str_replace(G5_URL, "", $src); $thumb_tag = ''.$thumb_tag.''; @@ -687,8 +694,19 @@ and the roundoff errors in the Gaussian blur process, are welcome. } function is_animated_gif($filename) { - if(!($fh = @fopen($filename, 'rb'))) + + static $cache = array(); + $key = md5($filename); + + if( isset($cache[$key]) ){ + return $cache[$key]; + } + + if(!($fh = @fopen($filename, 'rb'))){ + $cache[$key] = false; return false; + } + $count = 0; // 출처 : http://www.php.net/manual/en/function.imagecreatefromgif.php#104473 // an animated gif contains multiple "frames", with each frame having a @@ -705,6 +723,11 @@ function is_animated_gif($filename) { } fclose($fh); - return $count > 1; + + $cache[$key] = ($count > 1) ? true : false; + + run_event('is_animated_gif_after', $filename, $cache[$key]); + + return $cache[$key]; } ?> \ No newline at end of file