PHP Warning count 경고문 코드 수정 및 기타 코드 수정
This commit is contained in:
@ -6,6 +6,10 @@ include_once(G5_PATH.'/head.sub.php');
|
|||||||
|
|
||||||
$filename = preg_replace('/[^A-Za-z0-9 _ .\-\/]/', '', $_GET['fn']);
|
$filename = preg_replace('/[^A-Za-z0-9 _ .\-\/]/', '', $_GET['fn']);
|
||||||
|
|
||||||
|
if(function_exists('clean_relative_paths')){
|
||||||
|
$filename = clean_relative_paths($filename);
|
||||||
|
}
|
||||||
|
|
||||||
$extension = pathinfo($filename, PATHINFO_EXTENSION);
|
$extension = pathinfo($filename, PATHINFO_EXTENSION);
|
||||||
|
|
||||||
if ( ! preg_match('/(jpg|jpeg|png|gif|bmp)$/i', $extension) ){
|
if ( ! preg_match('/(jpg|jpeg|png|gif|bmp)$/i', $extension) ){
|
||||||
|
|||||||
@ -436,7 +436,7 @@ if (!$group['gr_use_access'] && $board['bo_read_level'] < 2 && !$secret) {
|
|||||||
|
|
||||||
// 파일개수 체크
|
// 파일개수 체크
|
||||||
$file_count = 0;
|
$file_count = 0;
|
||||||
$upload_count = count($_FILES['bf_file']['name']);
|
$upload_count = (isset($_FILES['bf_file']['name']) && is_array($_FILES['bf_file']['name'])) ? count($_FILES['bf_file']['name']) : 0;
|
||||||
|
|
||||||
for ($i=0; $i<$upload_count; $i++) {
|
for ($i=0; $i<$upload_count; $i++) {
|
||||||
if($_FILES['bf_file']['name'][$i] && is_uploaded_file($_FILES['bf_file']['tmp_name'][$i]))
|
if($_FILES['bf_file']['name'][$i] && is_uploaded_file($_FILES['bf_file']['tmp_name'][$i]))
|
||||||
@ -461,116 +461,119 @@ $chars_array = array_merge(range(0,9), range('a','z'), range('A','Z'));
|
|||||||
// 가변 파일 업로드
|
// 가변 파일 업로드
|
||||||
$file_upload_msg = '';
|
$file_upload_msg = '';
|
||||||
$upload = array();
|
$upload = array();
|
||||||
for ($i=0; $i<count($_FILES['bf_file']['name']); $i++) {
|
|
||||||
$upload[$i]['file'] = '';
|
|
||||||
$upload[$i]['source'] = '';
|
|
||||||
$upload[$i]['filesize'] = 0;
|
|
||||||
$upload[$i]['image'] = array();
|
|
||||||
$upload[$i]['image'][0] = 0;
|
|
||||||
$upload[$i]['image'][1] = 0;
|
|
||||||
$upload[$i]['image'][2] = 0;
|
|
||||||
$upload[$i]['fileurl'] = '';
|
|
||||||
$upload[$i]['thumburl'] = '';
|
|
||||||
$upload[$i]['storage'] = '';
|
|
||||||
|
|
||||||
// 삭제에 체크가 되어있다면 파일을 삭제합니다.
|
if(isset($_FILES['bf_file']['name']) && is_array($_FILES['bf_file']['name'])) {
|
||||||
if (isset($_POST['bf_file_del'][$i]) && $_POST['bf_file_del'][$i]) {
|
for ($i=0; $i<count($_FILES['bf_file']['name']); $i++) {
|
||||||
$upload[$i]['del_check'] = true;
|
$upload[$i]['file'] = '';
|
||||||
|
$upload[$i]['source'] = '';
|
||||||
|
$upload[$i]['filesize'] = 0;
|
||||||
|
$upload[$i]['image'] = array();
|
||||||
|
$upload[$i]['image'][0] = 0;
|
||||||
|
$upload[$i]['image'][1] = 0;
|
||||||
|
$upload[$i]['image'][2] = 0;
|
||||||
|
$upload[$i]['fileurl'] = '';
|
||||||
|
$upload[$i]['thumburl'] = '';
|
||||||
|
$upload[$i]['storage'] = '';
|
||||||
|
|
||||||
$row = sql_fetch(" select * from {$g5['board_file_table']} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' and bf_no = '{$i}' ");
|
// 삭제에 체크가 되어있다면 파일을 삭제합니다.
|
||||||
|
if (isset($_POST['bf_file_del'][$i]) && $_POST['bf_file_del'][$i]) {
|
||||||
|
$upload[$i]['del_check'] = true;
|
||||||
|
|
||||||
$delete_file = run_replace('delete_file_path', G5_DATA_PATH.'/file/'.$bo_table.'/'.str_replace('../', '', $row['bf_file']), $row);
|
$row = sql_fetch(" select * from {$g5['board_file_table']} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' and bf_no = '{$i}' ");
|
||||||
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']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
$upload[$i]['del_check'] = false;
|
|
||||||
|
|
||||||
$tmp_file = $_FILES['bf_file']['tmp_name'][$i];
|
|
||||||
$filesize = $_FILES['bf_file']['size'][$i];
|
|
||||||
$filename = $_FILES['bf_file']['name'][$i];
|
|
||||||
$filename = get_safe_filename($filename);
|
|
||||||
|
|
||||||
// 서버에 설정된 값보다 큰파일을 업로드 한다면
|
|
||||||
if ($filename) {
|
|
||||||
if ($_FILES['bf_file']['error'][$i] == 1) {
|
|
||||||
$file_upload_msg .= '\"'.$filename.'\" 파일의 용량이 서버에 설정('.$upload_max_filesize.')된 값보다 크므로 업로드 할 수 없습니다.\\n';
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if ($_FILES['bf_file']['error'][$i] != 0) {
|
|
||||||
$file_upload_msg .= '\"'.$filename.'\" 파일이 정상적으로 업로드 되지 않았습니다.\\n';
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_uploaded_file($tmp_file)) {
|
|
||||||
// 관리자가 아니면서 설정한 업로드 사이즈보다 크다면 건너뜀
|
|
||||||
if (!$is_admin && $filesize > $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 * 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);
|
$delete_file = run_replace('delete_file_path', G5_DATA_PATH.'/file/'.$bo_table.'/'.str_replace('../', '', $row['bf_file']), $row);
|
||||||
if( file_exists($delete_file) ){
|
if( file_exists($delete_file) ){
|
||||||
@unlink(G5_DATA_PATH.'/file/'.$bo_table.'/'.$row['bf_file']);
|
@unlink($delete_file);
|
||||||
}
|
}
|
||||||
// 이미지파일이면 썸네일삭제
|
// 썸네일삭제
|
||||||
if(preg_match("/\.({$config['cf_image_extension']})$/i", $row['bf_file'])) {
|
if(preg_match("/\.({$config['cf_image_extension']})$/i", $row['bf_file'])) {
|
||||||
delete_board_thumbnail($bo_table, $row['bf_file']);
|
delete_board_thumbnail($bo_table, $row['bf_file']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
$upload[$i]['del_check'] = false;
|
||||||
|
|
||||||
// 프로그램 원래 파일명
|
$tmp_file = $_FILES['bf_file']['tmp_name'][$i];
|
||||||
$upload[$i]['source'] = $filename;
|
$filesize = $_FILES['bf_file']['size'][$i];
|
||||||
$upload[$i]['filesize'] = $filesize;
|
$filename = $_FILES['bf_file']['name'][$i];
|
||||||
|
$filename = get_safe_filename($filename);
|
||||||
|
|
||||||
// 아래의 문자열이 들어간 파일은 -x 를 붙여서 웹경로를 알더라도 실행을 하지 못하도록 함
|
// 서버에 설정된 값보다 큰파일을 업로드 한다면
|
||||||
$filename = preg_replace("/\.(php|pht|phtm|htm|cgi|pl|exe|jsp|asp|inc)/i", "$0-x", $filename);
|
if ($filename) {
|
||||||
|
if ($_FILES['bf_file']['error'][$i] == 1) {
|
||||||
|
$file_upload_msg .= '\"'.$filename.'\" 파일의 용량이 서버에 설정('.$upload_max_filesize.')된 값보다 크므로 업로드 할 수 없습니다.\\n';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if ($_FILES['bf_file']['error'][$i] != 0) {
|
||||||
|
$file_upload_msg .= '\"'.$filename.'\" 파일이 정상적으로 업로드 되지 않았습니다.\\n';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
shuffle($chars_array);
|
if (is_uploaded_file($tmp_file)) {
|
||||||
$shuffle = implode('', $chars_array);
|
// 관리자가 아니면서 설정한 업로드 사이즈보다 크다면 건너뜀
|
||||||
|
if (!$is_admin && $filesize > $board['bo_upload_size']) {
|
||||||
|
$file_upload_msg .= '\"'.$filename.'\" 파일의 용량('.number_format($filesize).' 바이트)이 게시판에 설정('.number_format($board['bo_upload_size']).' 바이트)된 값보다 크므로 업로드 하지 않습니다.\\n';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// 첨부파일 첨부시 첨부파일명에 공백이 포함되어 있으면 일부 PC에서 보이지 않거나 다운로드 되지 않는 현상이 있습니다. (길상여의 님 090925)
|
//=================================================================\
|
||||||
$upload[$i]['file'] = abs(ip2long($_SERVER['REMOTE_ADDR'])).'_'.substr($shuffle,0,8).'_'.replace_filename($filename);
|
// 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;
|
||||||
|
}
|
||||||
|
//=================================================================
|
||||||
|
|
||||||
$dest_file = G5_DATA_PATH.'/file/'.$bo_table.'/'.$upload[$i]['file'];
|
$upload[$i]['image'] = $timg;
|
||||||
|
|
||||||
// 업로드가 안된다면 에러메세지 출력하고 죽어버립니다.
|
// 4.00.11 - 글답변에서 파일 업로드시 원글의 파일이 삭제되는 오류를 수정
|
||||||
$error_code = move_uploaded_file($tmp_file, $dest_file) or die($_FILES['bf_file']['error'][$i]);
|
if ($w == 'u') {
|
||||||
|
// 존재하는 파일이 있다면 삭제합니다.
|
||||||
|
$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);
|
||||||
chmod($dest_file, G5_FILE_PERMISSION);
|
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']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$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);
|
$upload[$i]['source'] = $filename;
|
||||||
}
|
$upload[$i]['filesize'] = $filesize;
|
||||||
}
|
|
||||||
|
// 아래의 문자열이 들어간 파일은 -x 를 붙여서 웹경로를 알더라도 실행을 하지 못하도록 함
|
||||||
|
$filename = preg_replace("/\.(php|pht|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).'_'.replace_filename($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);
|
||||||
|
|
||||||
|
$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);
|
||||||
|
}
|
||||||
|
} // end for
|
||||||
|
} // end if
|
||||||
|
|
||||||
// 나중에 테이블에 저장하는 이유는 $wr_id 값을 저장해야 하기 때문입니다.
|
// 나중에 테이블에 저장하는 이유는 $wr_id 값을 저장해야 하기 때문입니다.
|
||||||
for ($i=0; $i<count($upload); $i++)
|
for ($i=0; $i<count($upload); $i++)
|
||||||
|
|||||||
@ -17,18 +17,18 @@ function make_mp3()
|
|||||||
}
|
}
|
||||||
|
|
||||||
$ip = sprintf("%u", ip2long($_SERVER['REMOTE_ADDR']));
|
$ip = sprintf("%u", ip2long($_SERVER['REMOTE_ADDR']));
|
||||||
$mp3_file = 'data/cache/kcaptcha-'.$ip.'_'.G5_SERVER_TIME.'.mp3';
|
$mp3_file = 'cache/kcaptcha-'.$ip.'_'.G5_SERVER_TIME.'.mp3';
|
||||||
|
|
||||||
$contents = '';
|
$contents = '';
|
||||||
foreach ($mp3s as $mp3) {
|
foreach ($mp3s as $mp3) {
|
||||||
$contents .= file_get_contents($mp3);
|
$contents .= file_get_contents($mp3);
|
||||||
}
|
}
|
||||||
|
|
||||||
file_put_contents(G5_PATH.'/'.$mp3_file, $contents);
|
file_put_contents(G5_DATA_PATH.'/'.$mp3_file, $contents);
|
||||||
|
|
||||||
// 지난 캡챠 파일 삭제
|
// 지난 캡챠 파일 삭제
|
||||||
if (rand(0,99) == 0) {
|
if (rand(0,99) == 0) {
|
||||||
foreach (glob(G5_PATH.'/data/cache/kcaptcha-*.mp3') as $file) {
|
foreach (glob(G5_DATA_PATH.'/cache/kcaptcha-*.mp3') as $file) {
|
||||||
if (filemtime($file) + 86400 < G5_SERVER_TIME) {
|
if (filemtime($file) + 86400 < G5_SERVER_TIME) {
|
||||||
@unlink($file);
|
@unlink($file);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user