hook 추가 및 여러 코드 수정

This commit is contained in:
thisgun
2019-08-09 09:24:08 +09:00
parent 35ca744794
commit a0b9cd39cb
24 changed files with 142 additions and 51 deletions
+9
View File
@@ -160,6 +160,8 @@ if ($copy_case == 'schema_data_both') {
}
}
$d->close();
run_event('admin_board_copy_file', $bo_table, $target_table);
// 글복사
$sql = " insert into {$g5['write_prefix']}$target_table select * from {$g5['write_prefix']}$bo_table ";
@@ -181,6 +183,9 @@ if ($copy_case == 'schema_data_both') {
if (count($file_copy)) {
for ($i=0; $i<count($file_copy); $i++) {
$file_copy[$i] = run_replace('admin_copy_update_file', $file_copy[$i], $file_copy[$i]['bf_file'], $bo_table, $target_table);
$sql = " insert into {$g5['board_file_table']}
set bo_table = '$target_table',
wr_id = '{$file_copy[$i]['wr_id']}',
@@ -189,11 +194,15 @@ if (count($file_copy)) {
bf_file = '{$file_copy[$i]['bf_file']}',
bf_download = '{$file_copy[$i]['bf_download']}',
bf_content = '".addslashes($file_copy[$i]['bf_content'])."',
bf_fileurl = '".addslashes($file_copy[$i]['bf_fileurl'])."',
bf_thumburl = '".addslashes($file_copy[$i]['bf_thumburl'])."',
bf_storage = '".addslashes($file_copy[$i]['bf_storage'])."',
bf_filesize = '{$file_copy[$i]['bf_filesize']}',
bf_width = '{$file_copy[$i]['bf_width']}',
bf_height = '{$file_copy[$i]['bf_height']}',
bf_type = '{$file_copy[$i]['bf_type']}',
bf_datetime = '{$file_copy[$i]['bf_datetime']}' ";
sql_query($sql, false);
}
}
+6
View File
@@ -10,6 +10,10 @@ if (!count($_POST['chk'])) {
check_admin_token();
$act_button = isset($_POST['act_button']) ? strip_tags($_POST['act_button']) : '';
$chk = (isset($_POST['chk']) && is_array($_POST['chk'])) ? $_POST['chk'] : array();
$board_table = (isset($_POST['board_table']) && is_array($_POST['board_table'])) ? $_POST['board_table'] : array();
if ($_POST['act_button'] == "선택수정") {
auth_check($auth[$sub_menu], 'w');
@@ -74,5 +78,7 @@ if ($_POST['act_button'] == "선택수정") {
}
run_event('admin_board_list_update', $act_button, $chk, $board_table, $qstr);
goto_url('./board_list.php?'.$qstr);
?>
+14
View File
@@ -147,6 +147,20 @@ if(!isset($member['mb_memo_cnt'])) {
$is_check = true;
}
// 파일테이블에 추가 칼럼
$sql = " SHOW COLUMNS FROM `{$g5['board_file_table']}` LIKE 'bf_fileurl' ";
$row = sql_fetch($sql);
if( !$row ) {
sql_query(" ALTER TABLE `{$g5['board_file_table']}`
ADD COLUMN `bf_fileurl` VARCHAR(255) NOT NULL DEFAULT '' AFTER `bf_content`,
ADD COLUMN `bf_thumburl` VARCHAR(255) NOT NULL DEFAULT '' AFTER `bf_fileurl`,
ADD COLUMN `bf_storage` VARCHAR(50) NOT NULL DEFAULT '' AFTER `bf_thumburl`", true);
$is_check = true;
}
$is_check = run_replace('admin_dbupgrade', $is_check);
$db_upgrade_msg = $is_check ? 'DB 업그레이드가 완료되었습니다.' : '더 이상 업그레이드 할 내용이 없습니다.<br>현재 DB 업그레이드가 완료된 상태입니다.';
+5 -1
View File
@@ -80,7 +80,11 @@ while ($row = sql_fetch_array($result))
$sql2 = " select * from {$g5['board_file_table']} where bo_table = '$bo_table' and wr_id = '{$row['wr_id']}' ";
$result2 = sql_query($sql2);
while ($row2 = sql_fetch_array($result2)) {
@unlink(G5_DATA_PATH.'/file/'.$bo_table.'/'.str_replace('../', '', $row2['bf_file']));
$delete_file = run_replace('delete_file_path', G5_DATA_PATH.'/file/'.$bo_table.'/'.str_replace('../', '', $row2['bf_file']), $row2);
if( file_exists($delete_file) ){
@unlink($delete_file);
}
// 썸네일삭제
if(preg_match("/\.({$config['cf_image_extension']})$/i", $row2['bf_file'])) {
delete_board_thumbnail($bo_table, $row2['bf_file']);
+4 -1
View File
@@ -98,7 +98,10 @@ for ($i=$chk_count-1; $i>=0; $i--)
$result2 = sql_query($sql2);
while ($row2 = sql_fetch_array($result2)) {
// 파일삭제
@unlink(G5_DATA_PATH.'/file/'.$bo_table.'/'.str_replace('../', '',$row2['bf_file']));
$delete_file = run_replace('delete_file_path', G5_DATA_PATH.'/file/'.$bo_table.'/'.str_replace('../', '',$row2['bf_file']), $row2);
if( file_exists($delete_file) ){
@unlink($delete_file);
}
// 썸네일삭제
if(preg_match("/\.({$config['cf_image_extension']})$/i", $row2['bf_file'])) {
+7 -2
View File
@@ -17,7 +17,7 @@ if (!get_session('ss_view_'.$bo_table.'_'.$wr_id))
if($board['bo_download_point'] < 0 && $is_guest)
alert('다운로드 권한이 없습니다.\\n회원이시라면 로그인 후 이용해 보십시오.', G5_BBS_URL.'/login.php?wr_id='.$wr_id.'&amp;'.$qstr.'&amp;url='.urlencode(get_pretty_url($bo_table, $wr_id)));
$sql = " select bf_source, bf_file from {$g5['board_file_table']} where bo_table = '$bo_table' and wr_id = '$wr_id' and bf_no = '$no' ";
$sql = " select * from {$g5['board_file_table']} where bo_table = '$bo_table' and wr_id = '$wr_id' and bf_no = '$no' ";
$file = sql_fetch($sql);
if (!$file['bf_file'])
alert_close('파일 정보가 존재하지 않습니다.');
@@ -47,8 +47,11 @@ if ($member['mb_level'] < $board['bo_download_level']) {
$filepath = G5_DATA_PATH.'/file/'.$bo_table.'/'.$file['bf_file'];
$filepath = addslashes($filepath);
if (!is_file($filepath) || !file_exists($filepath))
$file_exist_check = (!is_file($filepath) || !file_exists($filepath)) ? false : true;
if ( false === run_replace('download_file_exist_check', $file_exist_check, $file) ){
alert('파일이 존재하지 않습니다.');
}
// 사용자 코드 실행
@include_once($board_skin_path.'/download.skin.php');
@@ -101,6 +104,8 @@ $original = urlencode($file['bf_source']);
@include_once($board_skin_path.'/download.tail.skin.php');
run_event('download_file_header', $file, $file_exist_check);
if(preg_match("/msie/i", $_SERVER['HTTP_USER_AGENT']) && preg_match("/5\.5/", $_SERVER['HTTP_USER_AGENT'])) {
header("content-type: doesn/matter");
header("content-length: ".filesize("$filepath"));
+15 -3
View File
@@ -126,8 +126,13 @@ while ($row = sql_fetch_array($result))
// 원본파일을 복사하고 퍼미션을 변경
// 제이프로님 코드제안 적용
$copy_file_name = ($bo_table !== $move_bo_table) ? $row3['bf_file'] : $row2['wr_id'].'_copy_'.$insert_id.'_'.$row3['bf_file'];
@copy($src_dir.'/'.$row3['bf_file'], $dst_dir.'/'.$copy_file_name);
@chmod($dst_dir.'/'.$copy_file_name, G5_FILE_PERMISSION);
$is_exist_file = is_file($src_dir.'/'.$row3['bf_file']) && file_exists($src_dir.'/'.$row3['bf_file']);
if( $is_exist_file ){
@copy($src_dir.'/'.$row3['bf_file'], $dst_dir.'/'.$copy_file_name);
@chmod($dst_dir.'/'.$row3['bf_file'], G5_FILE_PERMISSION);
}
$row3 = run_replace('bbs_move_update_file', $row3, $copy_file_name, $bo_table, $move_bo_table, $insert_id);
}
$sql = " insert into {$g5['board_file_table']}
@@ -138,6 +143,9 @@ while ($row = sql_fetch_array($result))
bf_file = '$copy_file_name',
bf_download = '{$row3['bf_download']}',
bf_content = '".addslashes($row3['bf_content'])."',
bf_fileurl = '".addslashes($row3['bf_fileurl'])."',
bf_thumburl = '".addslashes($row3['bf_thumburl'])."',
bf_storage = '".addslashes($row3['bf_storage'])."',
bf_filesize = '{$row3['bf_filesize']}',
bf_width = '{$row3['bf_width']}',
bf_height = '{$row3['bf_height']}',
@@ -200,7 +208,11 @@ if ($sw == 'move')
{
if( isset($save[$i]['bf_file']) && $save[$i]['bf_file'] ){
for ($k=0; $k<count($save[$i]['bf_file']); $k++) {
@unlink($save[$i]['bf_file'][$k]);
$del_file = $save[$i]['bf_file'][$k];
if ( is_file($del_file) && file_exists($del_file) ){
@unlink($del_file);
}
// 썸네일 파일 삭제, 먼지손 님 코드 제안
delete_board_thumbnail($bo_table, basename($save[$i]['bf_file'][$k]));
+22 -4
View File
@@ -466,13 +466,20 @@ for ($i=0; $i<count($_FILES['bf_file']['name']); $i++) {
$upload[$i]['image'][0] = '';
$upload[$i]['image'][1] = '';
$upload[$i]['image'][2] = '';
$upload[$i]['fileurl'] = '';
$upload[$i]['thumburl'] = '';
$upload[$i]['storage'] = '';
// 삭제에 체크가 되어있다면 파일을 삭제합니다.
if (isset($_POST['bf_file_del'][$i]) && $_POST['bf_file_del'][$i]) {
$upload[$i]['del_check'] = true;
$row = sql_fetch(" select bf_file from {$g5['board_file_table']} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' and bf_no = '{$i}' ");
@unlink(G5_DATA_PATH.'/file/'.$bo_table.'/'.$row['bf_file']);
$row = sql_fetch(" select * from {$g5['board_file_table']} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' and bf_no = '{$i}' ");
$delete_file = run_replace('delete_file_path', G5_DATA_PATH.'/file/'.$bo_table.'/'.str_replace('../', '', $row['bf_file']), $row);
if( file_exists($delete_file) ){
@unlink($delete_file);
}
// 썸네일삭제
if(preg_match("/\.({$config['cf_image_extension']})$/i", $row['bf_file'])) {
delete_board_thumbnail($bo_table, $row['bf_file']);
@@ -524,8 +531,12 @@ for ($i=0; $i<count($_FILES['bf_file']['name']); $i++) {
// 4.00.11 - 글답변에서 파일 업로드시 원글의 파일이 삭제되는 오류를 수정
if ($w == 'u') {
// 존재하는 파일이 있다면 삭제합니다.
$row = sql_fetch(" select bf_file from {$g5['board_file_table']} where bo_table = '$bo_table' and wr_id = '$wr_id' and bf_no = '$i' ");
@unlink(G5_DATA_PATH.'/file/'.$bo_table.'/'.$row['bf_file']);
$row = sql_fetch(" select * from {$g5['board_file_table']} where bo_table = '$bo_table' and wr_id = '$wr_id' and bf_no = '$i' ");
$delete_file = run_replace('delete_file_path', G5_DATA_PATH.'/file/'.$bo_table.'/'.str_replace('../', '', $row['bf_file']), $row);
if( file_exists($delete_file) ){
@unlink(G5_DATA_PATH.'/file/'.$bo_table.'/'.$row['bf_file']);
}
// 이미지파일이면 썸네일삭제
if(preg_match("/\.({$config['cf_image_extension']})$/i", $row['bf_file'])) {
delete_board_thumbnail($bo_table, $row['bf_file']);
@@ -554,6 +565,7 @@ for ($i=0; $i<count($_FILES['bf_file']['name']); $i++) {
chmod($dest_file, G5_FILE_PERMISSION);
$dest_file = run_replace('write_update_upload_file', $dest_file, $board, $wr_id, $w);
$upload[$i] = run_replace('write_update_upload_array', $upload[$i], $dest_file, $board, $wr_id, $w);
}
}
@@ -575,6 +587,9 @@ for ($i=0; $i<count($upload); $i++)
set bf_source = '{$upload[$i]['source']}',
bf_file = '{$upload[$i]['file']}',
bf_content = '{$bf_content[$i]}',
bf_fileurl = '{$upload[$i]['fileurl']}',
bf_thumburl = '{$upload[$i]['thumburl']}',
bf_storage = '{$upload[$i]['storage']}',
bf_filesize = '{$upload[$i]['filesize']}',
bf_width = '{$upload[$i]['image']['0']}',
bf_height = '{$upload[$i]['image']['1']}',
@@ -604,6 +619,9 @@ for ($i=0; $i<count($upload); $i++)
bf_source = '{$upload[$i]['source']}',
bf_file = '{$upload[$i]['file']}',
bf_content = '{$bf_content[$i]}',
bf_fileurl = '{$upload[$i]['fileurl']}',
bf_thumburl = '{$upload[$i]['thumburl']}',
bf_storage = '{$upload[$i]['storage']}',
bf_download = 0,
bf_filesize = '{$upload[$i]['filesize']}',
bf_width = '{$upload[$i]['image']['0']}',
+3
View File
@@ -133,6 +133,9 @@ CREATE TABLE IF NOT EXISTS `g5_board_file` (
`bf_file` varchar(255) NOT NULL default '',
`bf_download` int(11) NOT NULL,
`bf_content` text NOT NULL,
`bf_fileurl` VARCHAR(255) NOT NULL DEFAULT '',
`bf_thumburl` VARCHAR(255) NOT NULL DEFAULT '',
`bf_storage` VARCHAR(50) NOT NULL DEFAULT '',
`bf_filesize` int(11) NOT NULL default '0',
`bf_width` int(11) NOT NULL default '0',
`bf_height` smallint(6) NOT NULL default '0',
+3
View File
@@ -310,6 +310,9 @@ function get_file($bo_table, $wr_id)
$file[$no]['image_width'] = $row['bf_width'] ? $row['bf_width'] : 640;
$file[$no]['image_height'] = $row['bf_height'] ? $row['bf_height'] : 480;
$file[$no]['image_type'] = $row['bf_type'];
$file[$no]['bf_fileurl'] = $row['bf_fileurl'];
$file[$no]['bf_thumburl'] = $row['bf_thumburl'];
$file[$no]['bf_storage'] = $row['bf_storage'];
$file['count']++;
}
+21 -1
View File
@@ -7,7 +7,7 @@ if (!defined('_GNUBOARD_')) exit;
function get_list_thumbnail($bo_table, $wr_id, $thumb_width, $thumb_height, $is_create=false, $is_crop=false, $crop_mode='center', $is_sharpen=false, $um_value='80/0.5/3')
{
global $g5, $config;
$filename = $alt = "";
$filename = $alt = $data_path = '';
$edt = false;
$row = get_thumbnail_find_cache($bo_table, $wr_id, 'file');
@@ -45,6 +45,8 @@ function get_list_thumbnail($bo_table, $wr_id, $thumb_width, $thumb_height, $is_
break;
}
$filename = run_replace('get_editor_filename', $filename, $p);
} //end for
} //end if
}
@@ -52,6 +54,10 @@ function get_list_thumbnail($bo_table, $wr_id, $thumb_width, $thumb_height, $is_
if(!$filename)
return false;
if( $thumbnail_info = run_replace('get_list_thumbnail_info', array(), array('bo_table'=>$bo_table, 'wr_id'=>$wr_id, 'data_path'=>$data_path, 'edt'=>$edt, 'filename'=>$filename, 'filepath'=>$filepath, 'thumb_width'=>$thumb_width, 'thumb_height'=>$thumb_height, 'is_create'=>$is_create, 'is_crop'=>$is_crop, 'crop_mode'=>$crop_mode, 'is_sharpen'=>$is_sharpen, 'um_value'=>$um_value)) ){
return $thumbnail_info;
}
$tname = thumbnail($filename, $filepath, $filepath, $thumb_width, $thumb_height, $is_create, $is_crop, $crop_mode, $is_sharpen, $um_value);
if($tname) {
@@ -73,6 +79,20 @@ function get_list_thumbnail($bo_table, $wr_id, $thumb_width, $thumb_height, $is_
return $thumb;
}
// 게시글보기 파일 썸네일 리턴
function get_file_thumbnail($file){
if( ! is_array($file) ) return '';
if( $contents = run_replace('get_file_thumbnail_tags', '', $file) ){
return $contents;
} else if ($file['view']) {
return get_view_thumbnail($file['view']);
}
return $file['view'];
}
// 게시글보기 썸네일 생성
function get_view_thumbnail($contents, $thumb_width=0)
{
+1 -4
View File
@@ -84,10 +84,7 @@ jQuery(function($){
echo "<div id=\"bo_v_img\">\n";
for ($i=0; $i<=count($view['file']); $i++) {
if ($view['file'][$i]['view']) {
//echo $view['file'][$i]['view'];
echo get_view_thumbnail($view['file'][$i]['view']);
}
echo get_file_thumbnail($view['file'][$i]);
}
echo "</div>\n";
}
+1 -4
View File
@@ -86,10 +86,7 @@ jQuery(function($){
echo "<div id=\"bo_v_img\">\n";
for ($i=0; $i<=count($view['file']); $i++) {
if ($view['file'][$i]['view']) {
//echo $view['file'][$i]['view'];
echo get_view_thumbnail($view['file'][$i]['view']);
}
echo get_file_thumbnail($view['file'][$i]);
}
echo "</div>\n";
}
@@ -34,6 +34,10 @@ if( $file_arr[1] !== che_get_file_passname() ){
$filepath = SAVE_DIR . '/' . $filesrc;
$r = false;
if( function_exists('run_event') ){
run_event('delete_editor_file', $filepath, $r);
}
if (file_exists($filepath)) {
$r = unlink($filepath);
if ($r) {
@@ -117,9 +117,14 @@ try {
} catch (Exception $e) {
}
$rdata = sprintf('{"fileUrl": "%s/%s", "filePath": "%s", "fileName": "%s", "fileSize": "%d" }',
SAVE_URL,
$filename,
$file_url = SAVE_URL.'/'.$filename;
if( function_exists('run_replace') ){
$file_url = run_replace('get_editor_upload_url', $file_url, $savefile, array());
}
$rdata = sprintf('{"fileUrl": "%s", "filePath": "%s", "fileName": "%s", "fileSize": "%d" }',
$file_url,
$savefile,
$filename,
$filesize );
@@ -1176,6 +1176,10 @@ class UploadHandler
$image_width_height = $this->get_image_size($file_path);
$file->width = $image_width_height[0];
$file->height = $image_width_height[1];
if( function_exists('run_replace') ){
$file->url = run_replace('get_editor_upload_url', $file->url, $file_path, $file);
}
} else { //로빈아빠님이 알려주심, 이미지 업로드 체크
unlink($file_path);
$file->error = $this->get_error_message('accept_file_types');
@@ -1441,6 +1445,11 @@ class UploadHandler
if( substr($file_name, 0 , 32) != $this->get_file_passname() ) continue; //session_id() 와 비교하여 틀리면 지우지 않음
$file_path = $this->get_upload_path($file_name);
$success = is_file($file_path) && $file_name[0] !== '.' && unlink($file_path);
if( function_exists('run_event') ){
run_event('delete_editor_file', $file_path, $success);
}
if ($success) {
foreach($this->options['image_versions'] as $version => $options) {
if (!empty($version)) {
+1 -4
View File
@@ -94,10 +94,7 @@ add_stylesheet('<link rel="stylesheet" href="'.$board_skin_url.'/style.css">', 0
echo "<div id=\"bo_v_img\">\n";
for ($i=0; $i<=count($view['file']); $i++) {
if ($view['file'][$i]['view']) {
//echo $view['file'][$i]['view'];
echo get_view_thumbnail($view['file'][$i]['view']);
}
echo get_file_thumbnail($view['file'][$i]);
}
echo "</div>\n";
+1 -4
View File
@@ -94,10 +94,7 @@ add_stylesheet('<link rel="stylesheet" href="'.$board_skin_url.'/style.css">', 0
echo "<div id=\"bo_v_img\">\n";
for ($i=0; $i<=count($view['file']); $i++) {
if ($view['file'][$i]['view']) {
//echo $view['file'][$i]['view'];
echo get_view_thumbnail($view['file'][$i]['view']);
}
echo get_file_thumbnail($view['file'][$i]);
}
echo "</div>\n";
+2 -2
View File
@@ -4,8 +4,8 @@ include_once(G5_LIB_PATH.'/thumbnail.lib.php');
// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
add_stylesheet('<link rel="stylesheet" href="'.$latest_skin_url.'/style.css">', 0);
$thumb_width = 210;
$thumb_height = 150;
$thumb_width = 297;
$thumb_height = 212;
?>
<div class="pic_li_lt">
@@ -84,10 +84,7 @@ jQuery(function($){
echo "<div id=\"bo_v_img\">\n";
for ($i=0; $i<=count($view['file']); $i++) {
if ($view['file'][$i]['view']) {
//echo $view['file'][$i]['view'];
echo get_view_thumbnail($view['file'][$i]['view']);
}
echo get_file_thumbnail($view['file'][$i]);
}
echo "</div>\n";
}
@@ -86,10 +86,7 @@ jQuery(function($){
echo "<div id=\"bo_v_img\">\n";
for ($i=0; $i<=count($view['file']); $i++) {
if ($view['file'][$i]['view']) {
//echo $view['file'][$i]['view'];
echo get_view_thumbnail($view['file'][$i]['view']);
}
echo get_file_thumbnail($view['file'][$i]);
}
echo "</div>\n";
}
+1 -4
View File
@@ -94,10 +94,7 @@ add_stylesheet('<link rel="stylesheet" href="'.$board_skin_url.'/style.css">', 0
echo "<div id=\"bo_v_img\">\n";
for ($i=0; $i<=count($view['file']); $i++) {
if ($view['file'][$i]['view']) {
//echo $view['file'][$i]['view'];
echo get_view_thumbnail($view['file'][$i]['view']);
}
echo get_file_thumbnail($view['file'][$i]);
}
echo "</div>\n";
+1 -4
View File
@@ -94,10 +94,7 @@ add_stylesheet('<link rel="stylesheet" href="'.$board_skin_url.'/style.css">', 0
echo "<div id=\"bo_v_img\">\n";
for ($i=0; $i<=count($view['file']); $i++) {
if ($view['file'][$i]['view']) {
//echo $view['file'][$i]['view'];
echo get_view_thumbnail($view['file'][$i]['view']);
}
echo get_file_thumbnail($view['file'][$i]);
}
echo "</div>\n";
@@ -4,8 +4,8 @@ include_once(G5_LIB_PATH.'/thumbnail.lib.php');
// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
add_stylesheet('<link rel="stylesheet" href="'.$latest_skin_url.'/style.css">', 0);
$thumb_width = 210;
$thumb_height = 150;
$thumb_width = 297;
$thumb_height = 212;
?>
<div class="pic_li_lt">