From 79765eb198c301d9316516c08e1057aaf5d15ea1 Mon Sep 17 00:00:00 2001 From: chicpro Date: Tue, 4 Mar 2014 17:13:10 +0900 Subject: [PATCH] =?UTF-8?q?=EC=98=81=EC=B9=B4=ED=8A=B84=20DB=20=EC=9D=B4?= =?UTF-8?q?=EC=A0=84=20=ED=94=84=EB=A1=9C=EA=B7=B8=EB=9E=A8=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yc4_import.php | 194 +++++++++++++ yc4_import_run.php | 695 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 889 insertions(+) create mode 100644 yc4_import.php create mode 100644 yc4_import_run.php diff --git a/yc4_import.php b/yc4_import.php new file mode 100644 index 000000000..0a812e084 --- /dev/null +++ b/yc4_import.php @@ -0,0 +1,194 @@ + + + + + +
+

+ + + +
+ + + +
+ 사이트 내 전체검색 +
+ + + + + +
+ + +
+ + + +
+ + + + +
+
+ +
+ + +
+ + +
+ + +
+
+ +
+
+
+ +
+

+ 이 프로그램은 영카트5 설치 후 바로 실행하셔야만 합니다.
+ 만약 영카트5 사이트를 운영 중에 이 프로그램을 실행하시면 DB 데이터가 망실되거나 데이터의 오류가 발생할 수 있습니다.
+ 또한 중복해서 실행하실 경우에도 DB 데이터의 오류가 발생할 수 있으니 반드시 한번만 실행해 주십시오. +

+

프로그램을 실행하시려면 영카트4의 config.php 파일 경로를 입력하신 후 확인을 클릭해 주십시오.

+ +
+
+ + + +
+
+ +

+ 경로는 영카트5 설치 루트를 기준으로 영카트4의 config.php 파일의 상대경로입니다.
+ 예를 들어 영카트4를 웹루트에 설치하셨고 영카트5를 yc5라는 하위 폴더에 설치하셨다면 입력하실 경로는 ../config.php 입니다. +

+ +
+ + + +
+
+ + + +
+ + +
+
<?php echo G5_VERSION ?>
+
+

+ Copyright © 소유하신 도메인. All rights reserved.
+ 상단으로 +

+
+
+ + + + \ No newline at end of file diff --git a/yc4_import_run.php b/yc4_import_run.php new file mode 100644 index 000000000..83785402b --- /dev/null +++ b/yc4_import_run.php @@ -0,0 +1,695 @@ +'; + +if(empty($_POST)) + alert('올바른 방법으로 이용해 주십시오.', G5_URL); + +if(get_session('yc4_tables_copied') == 'done') + alert('DB 데이터 변환을 이미 실행하였습니다. 중복 실행시 오류가 발생할 수 있습니다.', G5_URL); + +if($is_admin != 'super') + alert('최고관리자로 로그인 후 실행해 주십시오.', G5_URL); + +$g4_config_file = trim($_POST['file_path']); + +if(!$g4_config_file) + alert('config.php 파일의 경로를 입력해 주십시오.'); + +if(!is_file($g4_config_file)) + alert('입력하신 경로에 config.php 파일이 존재하지 않습니다.'); + +$shop_config_file = str_replace('config.php', 'shop.config.php', $g4_config_file); + +if(!is_file($shop_config_file)) + alert('입력하신 경로에 shop.config.php 파일이 존재하지 않습니다.\\nshop.config.php 파일은 config.php 파일과 동일한 위치에 있어야 합니다.'); + +$item_img_path = str_replace('config.php', 'data/item', $g4_config_file); + +if(!file_exists($item_img_path)) + alert('상품이미지 폴더를 확인할 수 없습니다. 상품이미지 폴더의 상대경로가 '.$item_img_path.' 이 아니라면\\nyc4_import_run.php 파일에서 $item_img_path 의 값을 수정하신 후 실행해 주십시오.'); + +$is_euckr = false; +?> + + + + + +
+

+ + + +
+ + + +
+ 사이트 내 전체검색 +
+ + + + + +
+ + +
+ + + +
+ + + + +
+
+ +
+ + +
+ + +
+ + +
+
+ +
+
+
+ +
+
    + $val) { + $sql_common .= $comma . " $key = '".addslashes($val)."' "; + + $comma = ','; + } + + sql_query(" INSERT INTO {$g5['content_table']} SET $sql_common "); + } + echo '
  1. content table 복사
  2. '.PHP_EOL; + + // new win table 복사 + $sql = " select * from {$g4['yc4_new_win_table']} "; + $result = sql_query($sql); + for($i=0; $row=sql_fetch_array($result); $i++) { + if($is_euckr) + $row = array_map('iconv_utf8', $row); + + $comma = ''; + $sql_common = ''; + + foreach($row as $key=>$val) { + if($key == 'nw_id') + continue; + + $sql_common .= $comma . " $key = '".addslashes($val)."' "; + + $comma = ','; + } + + sql_query(" INSERT INTO {$g5['new_win_table']} SET $sql_common "); + } + echo '
  3. new win table 복사
  4. '.PHP_EOL; + + // faq table 복사 + $sql = " select * from {$g4['yc4_faq_table']} "; + $result = sql_query($sql); + for($i=0; $row=sql_fetch_array($result); $i++) { + if($is_euckr) + $row = array_map('iconv_utf8', $row); + + $comma = ''; + $sql_common = ''; + + foreach($row as $key=>$val) { + $sql_common .= $comma . " $key = '".addslashes($val)."' "; + + $comma = ','; + } + + sql_query(" INSERT INTO {$g5['faq_table']} SET $sql_common "); + } + echo '
  5. faq table 복사
  6. '.PHP_EOL; + + // faq master table 복사 + $sql = " select * from {$g4['yc4_faq_master_table']} "; + $result = sql_query($sql); + for($i=0; $row=sql_fetch_array($result); $i++) { + if($is_euckr) + $row = array_map('iconv_utf8', $row); + + $comma = ''; + $sql_common = ''; + + foreach($row as $key=>$val) { + $sql_common .= $comma . " $key = '".addslashes($val)."' "; + + $comma = ','; + } + + sql_query(" INSERT INTO {$g5['faq_master_table']} SET $sql_common "); + } + echo '
  7. faq master table 복사
  8. '.PHP_EOL; + */ + + // banner table 복사 + $sql = " select * from {$g4['yc4_banner_table']} "; + $result = sql_query($sql); + for($i=0; $row=sql_fetch_array($result); $i++) { + if($is_euckr) + $row = array_map('iconv_utf8', $row); + + $comma = ''; + $sql_common = ''; + + foreach($row as $key=>$val) { + if($key == 'bn_id') + continue; + + $sql_common .= $comma . " $key = '".addslashes($val)."' "; + + $comma = ','; + } + + sql_query(" INSERT INTO {$g5['g5_shop_banner_table']} SET $sql_common "); + } + echo '
  9. banner table 복사
  10. '.PHP_EOL; + + // event table 복사 + $sql = " select * from {$g4['yc4_event_table']} "; + $result = sql_query($sql); + for($i=0; $row=sql_fetch_array($result); $i++) { + if($is_euckr) + $row = array_map('iconv_utf8', $row); + + $comma = ''; + $sql_common = ''; + + foreach($row as $key=>$val) { + if($key == 'ev_id') + continue; + + $sql_common .= $comma . " $key = '".addslashes($val)."' "; + + $comma = ','; + } + + sql_query(" INSERT INTO {$g5['g5_shop_event_table']} SET $sql_common "); + } + echo '
  11. event table 복사
  12. '.PHP_EOL; + + // event item table 복사 + $sql = " select * from {$g4['yc4_event_item_table']} "; + $result = sql_query($sql); + for($i=0; $row=sql_fetch_array($result); $i++) { + if($is_euckr) + $row = array_map('iconv_utf8', $row); + + $comma = ''; + $sql_common = ''; + + foreach($row as $key=>$val) { + $sql_common .= $comma . " $key = '".addslashes($val)."' "; + + $comma = ','; + } + + sql_query(" INSERT INTO {$g5['g5_shop_event_item_table']} SET $sql_common "); + } + echo '
  13. event item table 복사
  14. '.PHP_EOL; + + // item ps table 복사 + $sql = " select * from {$g4['yc4_item_ps_table']} "; + $result = sql_query($sql); + for($i=0; $row=sql_fetch_array($result); $i++) { + if($is_euckr) + $row = array_map('iconv_utf8', $row); + + $comma = ''; + $sql_common = ''; + + foreach($row as $key=>$val) { + if($key == 'is_id') + continue; + + if($key == 'is_score') + $val = (int)($val / 2); + + $sql_common .= $comma . " $key = '".addslashes($val)."' "; + + $comma = ','; + } + + sql_query(" INSERT INTO {$g5['g5_shop_item_use_table']} SET $sql_common "); + } + echo '
  15. item ps table 복사
  16. '.PHP_EOL; + + // item qa table 복사 + $sql = " select * from {$g4['yc4_item_qa_table']} "; + $result = sql_query($sql); + for($i=0; $row=sql_fetch_array($result); $i++) { + if($is_euckr) + $row = array_map('iconv_utf8', $row); + + $comma = ''; + $sql_common = ''; + + foreach($row as $key=>$val) { + if($key == 'iq_id') + continue; + + $sql_common .= $comma . " $key = '".addslashes($val)."' "; + + $comma = ','; + } + + sql_query(" INSERT INTO {$g5['g5_shop_item_qa_table']} SET $sql_common "); + } + echo '
  17. item qa table 복사
  18. '.PHP_EOL; + + // item relation table 복사 + $sql = " select * from {$g4['yc4_item_relation_table']} "; + $result = sql_query($sql); + for($i=0; $row=sql_fetch_array($result); $i++) { + if($is_euckr) + $row = array_map('iconv_utf8', $row); + + $comma = ''; + $sql_common = ''; + + foreach($row as $key=>$val) { + $sql_common .= $comma . " $key = '".addslashes($val)."' "; + + $comma = ','; + } + + sql_query(" INSERT INTO {$g5['g5_shop_item_relation_table']} SET $sql_common "); + } + echo '
  19. event item table 복사
  20. '.PHP_EOL; + + // category table 복사 + $sql = " select * from {$g4['yc4_category_table']} "; + $result = sql_query($sql); + $excl_fld = array('ca_skin', 'ca_opt1_subject', 'ca_opt2_subject', 'ca_opt3_subject', 'ca_opt4_subject', 'ca_opt5_subject', 'ca_opt6_subject'); + for($i=0; $row=sql_fetch_array($result); $i++) { + if($is_euckr) + $row = array_map('iconv_utf8', $row); + + $comma = ''; + $sql_common = ''; + + foreach($row as $key=>$val) { + if(in_array($key, $excl_fld)) + continue; + + $sql_common .= $comma . " $key = '".addslashes($val)."' "; + + $comma = ','; + } + + sql_query(" INSERT INTO {$g5['g5_shop_category_table']} SET $sql_common, ca_skin = 'list.10.skin.php' "); + } + echo '
  21. category table 복사
  22. '.PHP_EOL; + + // item table 복사 + $sql = " select * from {$g4['yc4_item_table']} "; + $result = sql_query($sql); + $excl_fld = array('it_opt1_subject', 'it_opt2_subject', 'it_opt3_subject', 'it_opt4_subject', 'it_opt5_subject', 'it_opt6_subject', 'it_opt1', 'it_opt2', 'it_opt3', 'it_opt4', 'it_opt5', 'it_opt6', 'it_amount2', 'it_amount3', 'it_gallery', 'it_explan_html'); + for($i=0; $row=sql_fetch_array($result); $i++) { + if($is_euckr) + $row = array_map('iconv_utf8', $row); + + $comma = ''; + $sql_common = ''; + + foreach($row as $key=>$val) { + if(in_array($key, $excl_fld)) + continue; + + if($key == 'it_amount') + $key = 'it_price'; + + if($key == 'it_cust_amount') + $key = 'it_cust_price'; + + $sql_common .= $comma . " $key = '".addslashes($val)."' "; + + $comma = ','; + } + + // 상품이미지처리 + $idx = 1; + for($k=1; $k<=5; $k++) { + $item_img_file = $item_img_path.'/'.$row['it_id'].'_l'.$k; + if(is_file($item_img_file)) { + $size = @getimagesize($item_img_file); + + if($size[2] < 1 || $size[2] > 16) + continue; + + switch($size[2]) { + case 1: + $ext = 'gif'; + break; + case 2: + $ext = 'jpg'; + break; + case 3: + $ext = 'png'; + break; + case 6: + $ext = 'bmp'; + break; + default: + continue; + break; + } + + // 이미지복사 + @mkdir(G5_DATA_PATH.'/item/'.$row['it_id'], G5_DIR_PERMISSION); + @chmod(G5_DATA_PATH.'/item/'.$row['it_id'], G5_DIR_PERMISSION); + + if(copy($item_img_file, G5_DATA_PATH.'/item/'.$row['it_id'].'/'.$row['it_id'].'_l'.$idx.'.'.$ext)) { + @chmod(G5_DATA_PATH.'/item/'.$row['it_id'].'/'.$row['it_id'].'_l'.$idx.'.'.$ext, G5_FILE_PERMISSION); + $sql_common .= $comma . " it_img{$idx} = '".$row['it_id'].'/'.$row['it_id'].'_l'.$idx.'.'.$ext."' "; + $idx++; + } + } + } + + sql_query(" INSERT INTO {$g5['g5_shop_item_table']} SET $sql_common "); + + // 사용후기의 확인된 건수를 상품테이블에 저장 + update_use_cnt($row['it_id']); + + // 사용후기의 선호도(별) 평균을 상품테이블에 저장 + update_use_avg($row['it_id']); + } + echo '
  23. item table 복사
  24. '.PHP_EOL; + + // order table 복사 + $sql = " select * from {$g4['yc4_order_table']} "; + $result = sql_query($sql); + $excl_fld = array('on_uid', 'od_temp_bank', 'od_temp_card', 'od_temp_hp', 'od_temp_point', 'od_receipt_card', 'od_receipt_bank', 'od_receipt_hp', 'od_bank_time', 'od_card_time', 'od_hp_time', 'od_cancel_card', 'od_dc_amount', 'od_refund_amount', 'dl_id', 'od_escrow1', 'od_escrow2', 'od_escrow3', 'od_cash_no', 'od_cash_receipt_no', 'od_cash_app_time', 'od_cash_reg_stat', 'od_cash_reg_desc', 'od_cash_tr_code', 'od_cash_id_info', 'od_cash', 'od_cash_allthegate_gubun_cd', 'od_cash_allthegate_confirm_no', 'od_cash_allthegate_adm_no', 'od_cash_tgcorp_mxissueno', 'od_cash_inicis_noappl', 'od_cash_inicis_pgauthdate', 'od_cash_inicis_pgauthtime', 'od_cash_inicis_tid', 'od_cash_inicis_ruseopt', 'od_cash_receiptnumber', 'od_cash_kspay_revatransactionno'); + + for($i=0; $row=sql_fetch_array($result); $i++) { + if($is_euckr) + $row = array_map('iconv_utf8', $row); + + $comma = ''; + $sql_common = ''; + + foreach($row as $key=>$val) { + if(in_array($key, $excl_fld)) + continue; + + $sql_common .= $comma . " $key = '".addslashes($val)."' "; + + $comma = ','; + } + + $od_receipt_price = $row['od_receipt_bank'] + $row['od_receipt_card'] + $row['od_receipt_hp']; + $od_refund_price = $row['od_refund_amount']; + $od_receipt_time = $row['od_bank_time']; + if(!is_null_time($row['od_card_time'])) + $od_receipt_time = $row['od_card_time']; + else if(!is_null_time($row['od_hp_time'])) + $od_receipt_time = $row['od_hp_time']; + + // 배송정보 + $od_status = '주문'; + $od_delivery_company = ''; + if($row['dl_id'] && $row['od_invoice']) { + $dl = sql_fetch(" select dl_company from {$g4['yc4_delivery_table']} where dl_id = '{$row['dl_id']}' "); + $od_delivery_company = addslashes($dl['dl_company']); + + $od_status = '배송'; + } + + $sql_common .= $comma . " od_receipt_price = '$od_receipt_price', od_refund_price = '$od_refund_price', od_status = '$od_status', od_delivery_company = '$od_delivery_company', od_receipt_time = '$od_receipt_time' "; + + sql_query(" INSERT INTO {$g5['g5_shop_order_table']} SET $sql_common "); + + // 장바구니자료복사 + $sql2 = " select * from {$g4['yc4_cart_table']} where on_uid = '{$row['on_uid']}' "; + $result2 = sql_query($sql2); + $excl_fld2 = array('ct_id', 'on_uid', 'it_opt1', 'it_opt2', 'it_opt3', 'it_opt4', 'it_opt5', 'it_opt6', 'ct_amount', 'ct_send_cost'); + for($k=0; $row2=sql_fetch_array($result2); $k++) { + if($is_euckr) + $row2 = array_map('iconv_utf8', $row2); + + $comma = ''; + $sql_common2 = ''; + + foreach($row2 as $key=>$val) { + if(in_array($key, $excl_fld2)) + continue; + + $sql_common2 .= $comma . " $key = '".addslashes($val)."' "; + + $comma = ','; + } + + $od_id = $row['od_id']; + + $ct_price = $row2['ct_amount']; + + // 상품명 + $it = sql_fetch(" select it_name from {$g5['g5_shop_item_table']} where it_id = '{$row2['it_id']}' "); + $it_name = addslashes($it['it_name']); + + // 주문옵션 + $ct_option = ''; + $deli = ''; + for($j=1; $j<=6; $j++) { + if($row2['it_opt'.$j]) { + $ct_option .= $deli . $row2['it_opt'.$j]; + } + } + + if($ct_option) + $ct_option = addslashes($ct_option); + + $sql_common2 .= $comma . " ct_price = '$ct_price', it_name = '$it_name', ct_option = '$ct_option' "; + + sql_query(" INSERT INTO {$g5['g5_shop_cart_table']} SET od_id = '$od_id', $sql_common2 , ct_select = '1' "); + } + + // 주문상품의 상태체크 + $cnt1 = sql_fetch(" select count(*) as cnt from {$g5['g5_shop_cart_table']} where od_id = '$od_id' "); + $cnt2 = sql_fetch(" select count(*) as cnt from {$g5['g5_shop_cart_table']} where od_id = '$od_id' and ct_status = '완료' "); + if($cnt1['cnt'] == $cnt2['cnt'] && $cnt2['cnt'] > 0) + $od_status = '완료'; + + // 미수금 등의 정보 + $info = get_order_info($od_id); + + if(!$info) + continue; + + $sql = " update {$g5['g5_shop_order_table']} + set od_cart_price = '{$info['od_cart_price']}', + od_cart_coupon = '{$info['od_cart_coupon']}', + od_coupon = '{$info['od_coupon']}', + od_send_coupon = '{$info['od_send_coupon']}', + od_cancel_price = '{$info['od_cancel_price']}', + od_misu = '{$info['od_misu']}', + od_tax_mny = '{$info['od_tax_mny']}', + od_vat_mny = '{$info['od_vat_mny']}', + od_free_mny = '{$info['od_free_mny']}', + od_status = '$od_status' + where od_id = '$od_id' "; + sql_query($sql); + } + echo '
  25. order table 복사
  26. '.PHP_EOL; + + // wish table 복사 + $sql = " select * from {$g4['yc4_wish_table']} "; + $result = sql_query($sql); + for($i=0; $row=sql_fetch_array($result); $i++) { + if($is_euckr) + $row = array_map('iconv_utf8', $row); + + $comma = ''; + $sql_common = ''; + + foreach($row as $key=>$val) { + if($key == 'wi_id') + continue; + + $sql_common .= $comma . " $key = '".addslashes($val)."' "; + + $comma = ','; + } + + sql_query(" INSERT INTO {$g5['g5_shop_wish_table']} SET $sql_common "); + } + echo '
  27. event item table 복사
  28. '.PHP_EOL; + + echo '
'.PHP_EOL; + + echo '
영카트4 DB 데이터 이전 완료
'.PHP_EOL; + + // 실행완료 세션에 기록 + set_session('yc4_tables_copied', 'done'); + ?> +
+ +
+
+ + + +
+ + +
+
<?php echo G5_VERSION ?>
+
+

+ Copyright © 소유하신 도메인. All rights reserved.
+ 상단으로 +

+
+
+ + + + \ No newline at end of file