상품 스킨 디렉토리 검증 보완
This commit is contained in:
@@ -1,6 +1,45 @@
|
||||
<?php
|
||||
if (!defined('_GNUBOARD_')) exit;
|
||||
|
||||
function get_shop_skin_dirs($is_mobile=false)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$skin_path = $is_mobile ? G5_MOBILE_PATH.'/'.G5_SKIN_DIR : G5_SKIN_PATH;
|
||||
$skins = get_skin_dir('shop', $skin_path);
|
||||
|
||||
if(defined('G5_THEME_PATH') && $config['cf_theme']) {
|
||||
$theme_skin_path = $is_mobile ? G5_THEME_MOBILE_PATH.'/'.G5_SKIN_DIR : G5_THEME_PATH.'/'.G5_SKIN_DIR;
|
||||
$dirs = get_skin_dir('shop', $theme_skin_path);
|
||||
if(!empty($dirs)) {
|
||||
foreach($dirs as $dir) {
|
||||
$skins[] = 'theme/'.$dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $skins;
|
||||
}
|
||||
|
||||
function check_shop_skin_dir($skin_dir, $label, $is_mobile=false)
|
||||
{
|
||||
if( $skin_dir === '' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( preg_match('#\.+(\/|\\\)#', $skin_dir) ){
|
||||
alert($label.' 폴더명에 포함될수 없는 문자가 들어있습니다.');
|
||||
}
|
||||
|
||||
if( ! is_include_path_check($skin_dir, 1) ){
|
||||
alert('오류 : 데이터폴더가 포함된 path 또는 잘못된 path 를 포함할수 없습니다.');
|
||||
}
|
||||
|
||||
if( ! in_array($skin_dir, get_shop_skin_dirs($is_mobile), true) ){
|
||||
alert($label.'을 올바르게 선택해 주십시오.');
|
||||
}
|
||||
}
|
||||
|
||||
// 상품옵션별재고 또는 상품재고에 더하기
|
||||
function add_io_stock($it_id, $ct_qty, $io_id="", $io_type=0)
|
||||
{
|
||||
@@ -241,4 +280,4 @@ function check_order_inicis_tmps(){
|
||||
|
||||
set_cookie('admin_visit_time', G5_SERVER_TIME, 3600); //1시간 간격으로 체크
|
||||
}
|
||||
} //end function check_order_inicis_tmps;
|
||||
} //end function check_order_inicis_tmps;
|
||||
|
||||
@@ -365,32 +365,18 @@ $it_explan = isset($_POST['it_explan']) ? $_POST['it_explan'] : '';
|
||||
if ($it_name == "")
|
||||
alert("상품명을 입력해 주십시오.");
|
||||
|
||||
// 스킨 경로 검증
|
||||
$it_skin = isset($_POST['it_skin']) ? addslashes(strip_tags(clean_xss_attributes(stripslashes($_POST['it_skin'])))) : '';
|
||||
$it_mobile_skin = isset($_POST['it_mobile_skin']) ? addslashes(strip_tags(clean_xss_attributes(stripslashes($_POST['it_mobile_skin'])))) : '';
|
||||
// 상품 스킨은 파일 경로가 아니라 스킨 디렉토리명(basic, theme/basic 등)을 저장한다.
|
||||
$it_skin = isset($_POST['it_skin']) ? trim(strip_tags(clean_xss_attributes(stripslashes($_POST['it_skin'])))) : '';
|
||||
$it_mobile_skin = isset($_POST['it_mobile_skin']) ? trim(strip_tags(clean_xss_attributes(stripslashes($_POST['it_mobile_skin'])))) : '';
|
||||
|
||||
$check_files = array();
|
||||
if( !empty($it_skin) ) $check_files[] = $it_skin;
|
||||
if( !empty($it_mobile_skin) ) $check_files[] = $it_mobile_skin;
|
||||
|
||||
foreach( $check_files as $file ){
|
||||
if( empty($file) ) continue;
|
||||
|
||||
if( preg_match('#\.+(\/|\\\)#', $file) ){
|
||||
alert('스킨파일명에 포함될수 없는 문자가 들어있습니다.');
|
||||
}
|
||||
|
||||
if( ! is_include_path_check($file, 1) ){
|
||||
alert('오류 : 데이터폴더가 포함된 path 또는 잘못된 path 를 포함할수 없습니다.');
|
||||
}
|
||||
|
||||
$file_ext = pathinfo($file, PATHINFO_EXTENSION);
|
||||
|
||||
if( ! $file_ext || ! in_array($file_ext, array('php', 'htm', 'html')) || ! preg_match('/^.*\.(php|htm|html)$/i', $file) ) {
|
||||
alert('스킨 파일 경로의 확장자는 php, htm, html 만 허용합니다.');
|
||||
}
|
||||
if (function_exists('check_shop_skin_dir')) {
|
||||
check_shop_skin_dir($it_skin, 'PC용 스킨');
|
||||
check_shop_skin_dir($it_mobile_skin, '모바일용 스킨', true);
|
||||
}
|
||||
|
||||
$it_skin = addslashes($it_skin);
|
||||
$it_mobile_skin = addslashes($it_mobile_skin);
|
||||
|
||||
$sql_common = " ca_id = '$ca_id',
|
||||
ca_id2 = '$ca_id2',
|
||||
ca_id3 = '$ca_id3',
|
||||
|
||||
@@ -33,13 +33,18 @@ if ($post_act_button == "선택수정") {
|
||||
$p_it_cust_price = (isset($_POST['it_cust_price']) && is_array($_POST['it_cust_price'])) ? strip_tags($_POST['it_cust_price'][$k]) : '';
|
||||
$p_it_price = (isset($_POST['it_price']) && is_array($_POST['it_price'])) ? strip_tags($_POST['it_price'][$k]) : '';
|
||||
$p_it_stock_qty = (isset($_POST['it_stock_qty']) && is_array($_POST['it_stock_qty'])) ? strip_tags($_POST['it_stock_qty'][$k]) : '';
|
||||
$p_it_skin = (isset($_POST['it_skin']) && is_array($_POST['it_skin'])) ? strip_tags($_POST['it_skin'][$k]) : '';
|
||||
$p_it_mobile_skin = (isset($_POST['it_mobile_skin']) && is_array($_POST['it_mobile_skin'])) ? strip_tags($_POST['it_mobile_skin'][$k]) : '';
|
||||
$p_it_skin = (isset($_POST['it_skin']) && is_array($_POST['it_skin'])) ? trim(strip_tags(clean_xss_attributes(stripslashes($_POST['it_skin'][$k])))) : '';
|
||||
$p_it_mobile_skin = (isset($_POST['it_mobile_skin']) && is_array($_POST['it_mobile_skin'])) ? trim(strip_tags(clean_xss_attributes(stripslashes($_POST['it_mobile_skin'][$k])))) : '';
|
||||
$p_it_use = isset($_POST['it_use'][$k]) ? clean_xss_tags($_POST['it_use'][$k], 1, 1) : 0;
|
||||
$p_it_soldout = isset($_POST['it_soldout'][$k]) ? clean_xss_tags($_POST['it_soldout'][$k], 1, 1) : 0;
|
||||
$p_it_order = (isset($_POST['it_order']) && is_array($_POST['it_order'])) ? strip_tags($_POST['it_order'][$k]) : '';
|
||||
$p_it_id = isset($_POST['it_id'][$k]) ? preg_replace('/[^a-z0-9_\-]/i', '', $_POST['it_id'][$k]) : '';
|
||||
|
||||
if (function_exists('check_shop_skin_dir')) {
|
||||
check_shop_skin_dir($p_it_skin, 'PC용 스킨');
|
||||
check_shop_skin_dir($p_it_mobile_skin, '모바일용 스킨', true);
|
||||
}
|
||||
|
||||
if ($is_admin != 'super') { // 최고관리자가 아니면 체크
|
||||
$sql = "select a.it_id, b.ca_mb_id from {$g5['g5_shop_item_table']} a , {$g5['g5_shop_category_table']} b where (a.ca_id = b.ca_id) and a.it_id = '$p_it_id'";
|
||||
$checks = sql_fetch($sql);
|
||||
|
||||
Reference in New Issue
Block a user