diff --git a/adm/board_form_update.php b/adm/board_form_update.php index caa456a56..af4e30403 100644 --- a/adm/board_form_update.php +++ b/adm/board_form_update.php @@ -62,6 +62,12 @@ if ($check_captcha) { } } +// 저장·검증 전에 경로를 먼저 정규화하여, 검증 이후 경로가 달라지지 않도록 한다. +if (function_exists('filter_input_include_path')) { + $bo_include_head = filter_input_include_path($bo_include_head); + $bo_include_tail = filter_input_include_path($bo_include_tail); +} + if ($file = $bo_include_head) { $file_ext = pathinfo($file, PATHINFO_EXTENSION); @@ -86,9 +92,12 @@ if (!is_include_path_check($bo_include_tail, 1)) { alert('하단 파일 경로에 포함시킬수 없는 문자열이 있습니다.'); } -if (function_exists('filter_input_include_path')) { - $bo_include_head = filter_input_include_path($bo_include_head); - $bo_include_tail = filter_input_include_path($bo_include_tail); +if ($bo_include_head && function_exists('is_content_include_allowed') && !is_content_include_allowed($bo_include_head)) { + alert('상단 파일 경로로 사용할 수 없는 위치입니다.'); +} + +if ($bo_include_tail && function_exists('is_content_include_allowed') && !is_content_include_allowed($bo_include_tail)) { + alert('하단 파일 경로로 사용할 수 없는 위치입니다.'); } $board_path = G5_DATA_PATH . '/file/' . $bo_table; diff --git a/adm/qa_config_update.php b/adm/qa_config_update.php index 3e597c506..62d61b601 100644 --- a/adm/qa_config_update.php +++ b/adm/qa_config_update.php @@ -36,6 +36,12 @@ if ($board && ($qaconfig['qa_include_head'] !== $qa_include_head || $qaconfig['q } } +// 저장·검증 전에 경로를 먼저 정규화하여, 검증 이후 경로가 달라지지 않도록 한다. +if (function_exists('filter_input_include_path')) { + $qa_include_head = filter_input_include_path($qa_include_head); + $qa_include_tail = filter_input_include_path($qa_include_tail); +} + if ($qa_include_head) { $file_ext = pathinfo($qa_include_head, PATHINFO_EXTENSION); @@ -62,9 +68,12 @@ if ($qa_include_tail && !is_include_path_check($qa_include_tail, 1)) { $error_msg = '/data/file/ 또는 /data/editor/ 포함된 문자를 하단 파일 경로에 포함시킬수 없습니다.'; } -if (function_exists('filter_input_include_path')) { - $qa_include_head = filter_input_include_path($qa_include_head); - $qa_include_tail = filter_input_include_path($qa_include_tail); +if ($qa_include_head && function_exists('is_content_include_allowed') && !is_content_include_allowed($qa_include_head)) { + alert('상단 파일 경로로 사용할 수 없는 위치입니다.'); +} + +if ($qa_include_tail && function_exists('is_content_include_allowed') && !is_content_include_allowed($qa_include_tail)) { + alert('하단 파일 경로로 사용할 수 없는 위치입니다.'); } // 분류에 & 나 = 는 사용이 불가하므로 2바이트로 바꾼다. diff --git a/adm/shop_admin/categoryformupdate.php b/adm/shop_admin/categoryformupdate.php index fbf884a82..edaf2e0a3 100644 --- a/adm/shop_admin/categoryformupdate.php +++ b/adm/shop_admin/categoryformupdate.php @@ -6,6 +6,11 @@ auth_check_menu($auth, $sub_menu, "w"); $ca_include_head = isset($_POST['ca_include_head']) ? trim($_POST['ca_include_head']) : ''; $ca_include_tail = isset($_POST['ca_include_tail']) ? trim($_POST['ca_include_tail']) : ''; +// 저장·검증 전에 경로를 먼저 정규화하여, 검증 이후 경로가 달라지지 않도록 한다. +if( function_exists('filter_input_include_path') ){ + $ca_include_head = filter_input_include_path($ca_include_head); + $ca_include_tail = filter_input_include_path($ca_include_tail); +} $ca_id = isset($_REQUEST['ca_id']) ? preg_replace('/[^0-9a-z]/i', '', $_REQUEST['ca_id']) : ''; if( ! $ca_id ){ @@ -93,6 +98,14 @@ if(!is_include_path_check($ca_include_tail, 1)) { alert('하단 파일 경로에 포함시킬수 없는 문자열이 있습니다.'); } +if($ca_include_head && function_exists('is_content_include_allowed') && !is_content_include_allowed($ca_include_head)) { + alert('상단 파일 경로로 사용할 수 없는 위치입니다.'); +} + +if($ca_include_tail && function_exists('is_content_include_allowed') && !is_content_include_allowed($ca_include_tail)) { + alert('하단 파일 경로로 사용할 수 없는 위치입니다.'); +} + $check_keys = array('ca_skin_dir', 'ca_mobile_skin_dir', 'ca_skin', 'ca_mobile_skin'); foreach( $check_keys as $key ){ @@ -101,11 +114,6 @@ foreach( $check_keys as $key ){ } } -if( function_exists('filter_input_include_path') ){ - $ca_include_head = filter_input_include_path($ca_include_head); - $ca_include_tail = filter_input_include_path($ca_include_tail); -} - if ($w == "u" || $w == "d") check_demo(); diff --git a/bbs/board_head.php b/bbs/board_head.php index f02e5cbaa..14d83ba99 100644 --- a/bbs/board_head.php +++ b/bbs/board_head.php @@ -9,7 +9,8 @@ if (G5_IS_MOBILE) { } else { // 상단 파일 경로를 입력하지 않았다면 기본 상단 파일도 include 하지 않음 if (trim($board['bo_include_head'])) { - if (is_include_path_check($board['bo_include_head'])) { //파일경로 체크 + if (is_include_path_check($board['bo_include_head']) + && (!function_exists('is_content_include_allowed') || is_content_include_allowed($board['bo_include_head']))) { //파일경로 체크 @include ($board['bo_include_head']); } else { //파일경로가 올바르지 않으면 기본파일을 가져옴 include_once(G5_BBS_PATH.'/_head.php'); diff --git a/bbs/board_tail.php b/bbs/board_tail.php index cc9365bfc..c3f04403c 100644 --- a/bbs/board_tail.php +++ b/bbs/board_tail.php @@ -10,7 +10,8 @@ if (G5_IS_MOBILE) { echo run_replace('board_content_tail', html_purifier(stripslashes($board['bo_content_tail'])), $board); // 하단 파일 경로를 입력하지 않았다면 기본 하단 파일도 include 하지 않음 if (trim($board['bo_include_tail'])) { - if (is_include_path_check($board['bo_include_tail'])) { //파일경로 체크 + if (is_include_path_check($board['bo_include_tail']) + && (!function_exists('is_content_include_allowed') || is_content_include_allowed($board['bo_include_tail']))) { //파일경로 체크 @include ($board['bo_include_tail']); } else { //파일경로가 올바르지 않으면 기본파일을 가져옴 include_once(G5_BBS_PATH.'/_tail.php'); diff --git a/bbs/qahead.php b/bbs/qahead.php index 0d5f14595..6e2581c5a 100644 --- a/bbs/qahead.php +++ b/bbs/qahead.php @@ -9,7 +9,8 @@ if (G5_IS_MOBILE) { include_once('./_head.php'); echo run_replace('qa_mobile_content_head', conv_content($qaconfig['qa_mobile_content_head'], 1), $qaconfig); } else { - if($qaconfig['qa_include_head'] && is_include_path_check($qaconfig['qa_include_head'])) + if($qaconfig['qa_include_head'] && is_include_path_check($qaconfig['qa_include_head']) + && (!function_exists('is_content_include_allowed') || is_content_include_allowed($qaconfig['qa_include_head']))) @include ($qaconfig['qa_include_head']); else include ('./_head.php'); diff --git a/bbs/qatail.php b/bbs/qatail.php index 07e1c21c0..44b4c3d5e 100644 --- a/bbs/qatail.php +++ b/bbs/qatail.php @@ -7,7 +7,8 @@ if (G5_IS_MOBILE) { include_once('./_tail.php'); } else { echo run_replace('qa_content_tail', conv_content($qaconfig['qa_content_tail'], 1), $qaconfig); - if($qaconfig['qa_include_tail'] && is_include_path_check($qaconfig['qa_include_tail'])) + if($qaconfig['qa_include_tail'] && is_include_path_check($qaconfig['qa_include_tail']) + && (!function_exists('is_content_include_allowed') || is_content_include_allowed($qaconfig['qa_include_tail']))) @include ($qaconfig['qa_include_tail']); else include ('./_tail.php'); diff --git a/shop/item.php b/shop/item.php index 5c4e04478..dab65bf4a 100644 --- a/shop/item.php +++ b/shop/item.php @@ -107,7 +107,8 @@ define('G5_SHOP_CSS_URL', str_replace(G5_PATH, G5_URL, $skin_dir)); $g5['title'] = $it['it_name'].' > '.$it['ca_name']; // 분류 상단 코드가 있으면 출력하고 없으면 기본 상단 코드 출력 -if ($ca['ca_include_head'] && is_include_path_check($ca['ca_include_head'])) +if ($ca['ca_include_head'] && is_include_path_check($ca['ca_include_head']) + && (!function_exists('is_content_include_allowed') || is_content_include_allowed($ca['ca_include_head']))) @include_once($ca['ca_include_head']); else include_once(G5_SHOP_PATH.'/_head.php'); @@ -280,7 +281,8 @@ echo run_replace('shop_it_tail_html', conv_content($it['it_tail_html'], 1), $it) ?> ";