From 78fa0cb41bf2273b675f5fdeb30b32be6934d8d6 Mon Sep 17 00:00:00 2001 From: chicpro Date: Mon, 27 Oct 2014 10:43:46 +0900 Subject: [PATCH] =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=97=85=EB=A1=9C?= =?UTF-8?q?=EB=93=9C=20=EB=B3=B4=EC=95=88=20=EC=98=A4=EB=A5=98=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bbs/write.php | 6 +- bbs/write_update.php | 212 +++++++++++++++++++++---------------------- 2 files changed, 108 insertions(+), 110 deletions(-) diff --git a/bbs/write.php b/bbs/write.php index 6235a4adc..da62a1917 100644 --- a/bbs/write.php +++ b/bbs/write.php @@ -3,9 +3,6 @@ include_once('./_common.php'); include_once(G5_EDITOR_LIB); include_once(G5_CAPTCHA_PATH.'/captcha.lib.php'); -set_session('ss_bo_table', $_REQUEST['bo_table']); -set_session('ss_wr_id', $_REQUEST['wr_id']); - if (!$board['bo_table']) { alert('존재하지 않는 게시판입니다.', G5_URL); } @@ -353,6 +350,9 @@ if ($w == '') { } } +set_session('ss_bo_table', $_REQUEST['bo_table']); +set_session('ss_wr_id', $_REQUEST['wr_id']); + $subject = ""; if (isset($write['wr_subject'])) { $subject = str_replace("\"", """, get_text(cut_str($write['wr_subject'], 255), 0)); diff --git a/bbs/write_update.php b/bbs/write_update.php index 966f85a6a..7adaed4fe 100644 --- a/bbs/write_update.php +++ b/bbs/write_update.php @@ -177,112 +177,6 @@ if ($w == '' || $w == 'r') { if (!isset($_POST['wr_subject']) || !trim($_POST['wr_subject'])) alert('제목을 입력하여 주십시오.'); -// 디렉토리가 없다면 생성합니다. (퍼미션도 변경하구요.) -@mkdir(G5_DATA_PATH.'/file/'.$bo_table, G5_DIR_PERMISSION); -@chmod(G5_DATA_PATH.'/file/'.$bo_table, G5_DIR_PERMISSION); - -$chars_array = array_merge(range(0,9), range('a','z'), range('A','Z')); - -// 가변 파일 업로드 -$file_upload_msg = ''; -$upload = array(); -for ($i=0; $i $board['bo_upload_size']) { - $file_upload_msg .= '\"'.$filename.'\" 파일의 용량('.number_format($filesize).' 바이트)이 게시판에 설정('.number_format($board['bo_upload_size']).' 바이트)된 값보다 크므로 업로드 하지 않습니다.\\n'; - continue; - } - - //=================================================================\ - // 090714 - // 이미지나 플래시 파일에 악성코드를 심어 업로드 하는 경우를 방지 - // 에러메세지는 출력하지 않는다. - //----------------------------------------------------------------- - $timg = @getimagesize($tmp_file); - // image type - if ( preg_match("/\.({$config['cf_image_extension']})$/i", $filename) || - preg_match("/\.({$config['cf_flash_extension']})$/i", $filename) ) { - if ($timg['2'] < 1 || $timg['2'] > 16) - continue; - } - //================================================================= - - $upload[$i]['image'] = $timg; - - // 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']); - // 이미지파일이면 썸네일삭제 - if(preg_match("/\.({$config['cf_image_extension']})$/i", $row['bf_file'])) { - delete_board_thumbnail($bo_table, $row['bf_file']); - } - } - - // 프로그램 원래 파일명 - $upload[$i]['source'] = $filename; - $upload[$i]['filesize'] = $filesize; - - // 아래의 문자열이 들어간 파일은 -x 를 붙여서 웹경로를 알더라도 실행을 하지 못하도록 함 - $filename = preg_replace("/\.(php|phtm|htm|cgi|pl|exe|jsp|asp|inc)/i", "$0-x", $filename); - - shuffle($chars_array); - $shuffle = implode('', $chars_array); - - // 첨부파일 첨부시 첨부파일명에 공백이 포함되어 있으면 일부 PC에서 보이지 않거나 다운로드 되지 않는 현상이 있습니다. (길상여의 님 090925) - $upload[$i]['file'] = abs(ip2long($_SERVER['REMOTE_ADDR'])).'_'.substr($shuffle,0,8).'_'.str_replace('%', '', urlencode(str_replace(' ', '_', $filename))); - - $dest_file = G5_DATA_PATH.'/file/'.$bo_table.'/'.$upload[$i]['file']; - - // 업로드가 안된다면 에러메세지 출력하고 죽어버립니다. - $error_code = move_uploaded_file($tmp_file, $dest_file) or die($_FILES['bf_file']['error'][$i]); - - // 올라간 파일의 퍼미션을 변경합니다. - chmod($dest_file, G5_FILE_PERMISSION); - } -} - if ($w == '' || $w == 'r') { if ($member['mb_id']) { @@ -497,8 +391,112 @@ if (!$group['gr_use_access'] && $board['bo_read_level'] < 2 && !$secret) { naver_syndi_ping($bo_table, $wr_id); } -//------------------------------------------------------------------------------ +// 디렉토리가 없다면 생성합니다. (퍼미션도 변경하구요.) +@mkdir(G5_DATA_PATH.'/file/'.$bo_table, G5_DIR_PERMISSION); +@chmod(G5_DATA_PATH.'/file/'.$bo_table, G5_DIR_PERMISSION); + +$chars_array = array_merge(range(0,9), range('a','z'), range('A','Z')); + // 가변 파일 업로드 +$file_upload_msg = ''; +$upload = array(); +for ($i=0; $i $board['bo_upload_size']) { + $file_upload_msg .= '\"'.$filename.'\" 파일의 용량('.number_format($filesize).' 바이트)이 게시판에 설정('.number_format($board['bo_upload_size']).' 바이트)된 값보다 크므로 업로드 하지 않습니다.\\n'; + continue; + } + + //=================================================================\ + // 090714 + // 이미지나 플래시 파일에 악성코드를 심어 업로드 하는 경우를 방지 + // 에러메세지는 출력하지 않는다. + //----------------------------------------------------------------- + $timg = @getimagesize($tmp_file); + // image type + if ( preg_match("/\.({$config['cf_image_extension']})$/i", $filename) || + preg_match("/\.({$config['cf_flash_extension']})$/i", $filename) ) { + if ($timg['2'] < 1 || $timg['2'] > 16) + continue; + } + //================================================================= + + $upload[$i]['image'] = $timg; + + // 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']); + // 이미지파일이면 썸네일삭제 + if(preg_match("/\.({$config['cf_image_extension']})$/i", $row['bf_file'])) { + delete_board_thumbnail($bo_table, $row['bf_file']); + } + } + + // 프로그램 원래 파일명 + $upload[$i]['source'] = $filename; + $upload[$i]['filesize'] = $filesize; + + // 아래의 문자열이 들어간 파일은 -x 를 붙여서 웹경로를 알더라도 실행을 하지 못하도록 함 + $filename = preg_replace("/\.(php|phtm|htm|cgi|pl|exe|jsp|asp|inc)/i", "$0-x", $filename); + + shuffle($chars_array); + $shuffle = implode('', $chars_array); + + // 첨부파일 첨부시 첨부파일명에 공백이 포함되어 있으면 일부 PC에서 보이지 않거나 다운로드 되지 않는 현상이 있습니다. (길상여의 님 090925) + $upload[$i]['file'] = abs(ip2long($_SERVER['REMOTE_ADDR'])).'_'.substr($shuffle,0,8).'_'.str_replace('%', '', urlencode(str_replace(' ', '_', $filename))); + + $dest_file = G5_DATA_PATH.'/file/'.$bo_table.'/'.$upload[$i]['file']; + + // 업로드가 안된다면 에러메세지 출력하고 죽어버립니다. + $error_code = move_uploaded_file($tmp_file, $dest_file) or die($_FILES['bf_file']['error'][$i]); + + // 올라간 파일의 퍼미션을 변경합니다. + chmod($dest_file, G5_FILE_PERMISSION); + } +} + // 나중에 테이블에 저장하는 이유는 $wr_id 값을 저장해야 하기 때문입니다. for ($i=0; $i