썸네일과 htmlpurifier 필터링에 대한 hook 코드 추가
This commit is contained in:
@ -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 = "";
|
||||
|
||||
@ -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; $i<count($_POST['chk_bo_table']); $i++)
|
||||
{
|
||||
@ -52,6 +54,8 @@ while ($row = sql_fetch_array($result))
|
||||
$result2 = sql_query($sql2);
|
||||
while ($row2 = sql_fetch_array($result2))
|
||||
{
|
||||
$save[$cnt]['wr_contents'][] = $row2['wr_content'];
|
||||
|
||||
$nick = cut_str($member['mb_nick'], $config['cf_cut_name']);
|
||||
if (!$row2['wr_is_comment'] && $config['cf_use_copy_log']) {
|
||||
if(strstr($row2['wr_option'], 'html')) {
|
||||
@ -210,16 +214,20 @@ if ($sw == 'move')
|
||||
{
|
||||
if( isset($save[$i]['bf_file']) && $save[$i]['bf_file'] ){
|
||||
for ($k=0; $k<count($save[$i]['bf_file']); $k++) {
|
||||
$del_file = $save[$i]['bf_file'][$k];
|
||||
$del_file = run_replace('delete_file_path', clean_relative_paths($save[$i]['bf_file'][$k]), $save[$i]);
|
||||
|
||||
if ( is_file($del_file) && file_exists($del_file) ){
|
||||
@unlink($del_file);
|
||||
}
|
||||
|
||||
|
||||
// 썸네일 파일 삭제, 먼지손 님 코드 제안
|
||||
delete_board_thumbnail($bo_table, basename($save[$i]['bf_file'][$k]));
|
||||
}
|
||||
}
|
||||
|
||||
for ($k=0; $k<count($save[$i]['wr_contents']); $k++){
|
||||
delete_editor_thumbnail($save[$i]['wr_contents'][$k]);
|
||||
}
|
||||
|
||||
sql_query(" delete from $write_table where wr_parent = '{$save[$i]['wr_id']}' ");
|
||||
sql_query(" delete from {$g5['board_new_table']} where bo_table = '$bo_table' and wr_id = '{$save[$i]['wr_id']}' ");
|
||||
|
||||
@ -611,7 +611,7 @@ function html_purifier($html)
|
||||
//유튜브, 비메오 전체화면 가능하게 하기
|
||||
$config->set('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문의 첨부파일 썸네일 삭제
|
||||
|
||||
@ -110,6 +110,8 @@ function get_view_thumbnail($contents, $thumb_width=0)
|
||||
for($i=0; $i<count($matches[1]); $i++) {
|
||||
|
||||
$img = $matches[1][$i];
|
||||
$img_tag = isset($matches[0][$i]) ? $matches[0][$i] : '';
|
||||
|
||||
preg_match("/src=[\'\"]?([^>\'\"]+[^>\'\"]+)/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 = '<a href="'.G5_BBS_URL.'/view_image.php?fn='.urlencode($imgurl).'" target="_blank" class="view_image">'.$thumb_tag.'</a>';
|
||||
@ -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];
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user