diff --git a/adm/css/admin.css b/adm/css/admin.css index 9057122bb..fd99650f8 100644 --- a/adm/css/admin.css +++ b/adm/css/admin.css @@ -852,21 +852,20 @@ strong.sodr_nonpay {display:block;padding:5px 0;text-align:right} .sevice_1 h4 a{display:inline-block;height:65px;padding:10px 0 0;width:100%} .svc_card{background:url('../img/service_img1.jpg') no-repeat top center;margin-right:13px;} -.svc_card ul li{width:49%;} +.svc_card ul li{width:33%;} .svc_phone {background:url('../img/service_img2.jpg') no-repeat top center;margin-right:13px;} .svc_phone ul li{width:33%;} .svc_ipin {background:url('../img/service_img3.jpg') no-repeat top center;} -.service_2{border-top:1px solid #ebe8e8;float:left;margin-top:30px;border-bottom:1px solid #ebe8e8;} +.service_2{padding-top:15px;clear:both} .service_2 h3{font-size:14px;letter-spacing:-1px;color:#525252;margin:0 0 4px} -.service_2 .svc_a{width:300px;float:left} + .service_2 .svc_a p{color:#898989;line-height:16px;letter-spacing:-1px;} .svc_keyword{clear:both ;} .svc_keyword .svc_a{float:left;width:230px;padding:46px 0 0 15px ;height:120px; } -.service_2 .svc_ri{height:83px;float:left;width:479px} -.service_2 .svc_ri .svc_a{padding:18px 0 0 22px;} +.service_2 .svc_ri .svc_a{padding:25px 0 0 22px;} .service_2 .svc_btn{float:right;} .service_2 .svc_btn a{display:inline-block;width:126px; height:37px;background:#ff3061;color:#fff;line-height:37px;text-align:center;margin:22px 13px 0;} @@ -875,6 +874,7 @@ strong.sodr_nonpay {display:block;padding:5px 0;text-align:right} .svc_keyword .svc_btn{margin:40px 0 0 ;} .svc_keyword .svc_btn a{width:160px;} -.svc_sms{border-right:1px solid #ebe8e8} -.svc_sms .svc_btn2{float:right} -.svc_sms .svc_btn2 a{display:inline-block; width:150px; height:63px; background:#fbfbfb; text-align:center; padding:20px 0 0;} +.svc_sms{border:1px solid #ebe8e8;position:relative;height:83px} +.svc_sms:after{display:block;visibility:hidden;clear:both;content:""} +.svc_sms .svc_btn2{position:absolute;top:0;right:0} +.svc_sms .svc_btn2 a{display:inline-block; width:220px; height:63px; background:#fbfbfb; text-align:center; padding:20px 0 0;} diff --git a/adm/img/svc_btn_06.jpg b/adm/img/svc_btn_06.jpg new file mode 100644 index 000000000..a2647f97a Binary files /dev/null and b/adm/img/svc_btn_06.jpg differ diff --git a/adm/service.php b/adm/service.php index e7b22d3ca..8f223b8ae 100644 --- a/adm/service.php +++ b/adm/service.php @@ -19,7 +19,9 @@ include_once('./admin.head.php'); @@ -47,17 +49,11 @@ include_once('./admin.head.php');

SMS 문자 서비스

-

주문이나 배송시에 상점운영자 또는 고객에게 휴대폰으로
단문메세지 (최대 한글 40자, 영문 80자)를 발송합니다.

+

주문이나 배송시에 상점운영자 또는 고객에게 휴대폰으로 단문메세지 (최대 한글 40자, 영문 80자)를 발송합니다.

아이코드 SMS 서비스 신청하기
-
-
-

디자인 소스 (아사달)

-

이곳을 통하여 아사달 디자인 소스, 시안, 사진등 구입하시면
10% 할인 쿠폰을 매일 선착순 15분께 드립니다.

-
-
디자인소스 구입하기
-
+ diff --git a/adm/shop_admin/configform.php b/adm/shop_admin/configform.php index 3c5610bf9..f1b181f7f 100644 --- a/adm/shop_admin/configform.php +++ b/adm/shop_admin/configform.php @@ -79,12 +79,22 @@ if(!isset($default['de_pg_service'])) { ADD `de_pg_service` varchar(255) NOT NULL DEFAULT '' AFTER `de_sms_hp` ", true); } + +// inicis 필드 추가 +if(!isset($default['de_inicis_mid'])) { + sql_query(" ALTER TABLE `{$g5['g5_shop_default_table']}` + ADD `de_inicis_mid` varchar(255) NOT NULL DEFAULT '' AFTER `de_kcp_site_key`, + ADD `de_inicis_admin_key` varchar(255) NOT NULL DEFAULT '' AFTER `de_inicis_mid` ", true); +} + + // 레이아웃 파일 필드 추가 if(!isset($default['de_include_index'])) { sql_query(" ALTER TABLE `{$g5['g5_shop_default_table']}` ADD `de_include_index` varchar(255) NOT NULL DEFAULT '' AFTER `de_admin_info_email`, ADD `de_include_head` varchar(255) NOT NULL DEFAULT '' AFTER `de_include_index`, ADD `de_include_tail` varchar(255) NOT NULL DEFAULT '' AFTER `de_include_head` ", true); + } ?> @@ -560,12 +570,18 @@ if(!isset($default['de_include_index'])) { - + KCP 가상계좌 입금통보 URL KCP 관리자 > 상점정보관리 > 정보변경 > 공통URL 정보 > 공통URL 변경후에 넣으셔야 상점에 자동으로 입금 통보됩니다."); ?> /settle_kcp_common.php + + KG이니시스 가상계좌 입금통보 URL + + KG이니시스 관리자 > 거래조회 > 가상계좌 > 입금통보방식선택 > URL 수신 설정에 넣으셔야 상점에 자동으로 입금 통보됩니다."); ?> + /settle_inicis_common.php + @@ -662,13 +678,14 @@ if(!isset($default['de_include_index'])) {
- KCP서비스신청하기 + KCP서비스신청하기 @@ -685,10 +702,10 @@ if(!isset($default['de_include_index'])) {
- LG유플러스 서비스신청하기 + LG유플러스 서비스신청하기 - 기본환경설정 > 본인확인 설정의 LG유플러스 상점아이디와 동일합니다."); ?> + 기본환경설정 > 본인확인 설정의 LG유플러스 상점아이디와 동일합니다."); ?> si_ 영문자, 숫자 혼용 @@ -699,6 +716,23 @@ if(!isset($default['de_include_index'])) { + + +
+ KG이니시스 서비스신청하기 + + + + SIR 영문소문자(숫자포함 가능) + + + + + + + + + 에스크로 사용 @@ -1362,15 +1396,20 @@ function fconfig_check(f) $(function() { $(".pg_info_fld").hide(); + $(".pg_vbank_url").hide(); $("._info_fld").show(); + $("#_vbank_url").show(); $(".kcp_info_fld").show(); + $("#kcp_vbank_url").show(); $("#de_pg_service").on("change", function() { var pg = $(this).val(); $(".pg_info_fld:visible").hide(); + $(".pg_vbank_url:visible").hide(); $("."+pg+"_info_fld").show(); + $("#"+pg+"_vbank_url").show(); $(".scf_cardtest").addClass("scf_cardtest_hide"); $("."+pg+"_cardtest").removeClass("scf_cardtest_hide"); $(".scf_cardtest_tip_adm").addClass("scf_cardtest_tip_adm_hide"); @@ -1397,6 +1436,18 @@ $(function() { if($default['de_iche_use'] || $default['de_vbank_use'] || $default['de_hp_use'] || $default['de_card_use']) { // kcp의 경우 pp_cli 체크 if($default['de_pg_service'] == 'kcp') { + if(!extension_loaded('openssl')) { + echo ''.PHP_EOL; + } + + if(!extension_loaded('soap') || !class_exists('SOAPClient')) { + echo ''.PHP_EOL; + } + $is_linux = true; if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') $is_linux = false; @@ -1430,6 +1481,47 @@ if($default['de_iche_use'] || $default['de_vbank_use'] || $default['de_hp_use'] } } } + + // 이니시스의 경우 log 디렉토리 체크 + if($default['de_pg_service'] == 'inicis') { + if (!function_exists('xml_set_element_handler')) { + echo ''.PHP_EOL; + } + + if (!function_exists('openssl_get_publickey')) { + echo ''.PHP_EOL; + } + + if (!function_exists('socket_create')) { + echo ''.PHP_EOL; + } + + if (!function_exists('mcrypt_cbc')) { + echo ''.PHP_EOL; + } + + $log_path = G5_SHOP_PATH.'/inicis/log'; + + if(!is_dir($log_path)) { + echo ''.PHP_EOL; + } else { + if(!is_writable($log_path)) { + echo ''.PHP_EOL; + } + } + } } include_once (G5_ADMIN_PATH.'/admin.tail.php'); diff --git a/adm/shop_admin/configformupdate.php b/adm/shop_admin/configformupdate.php index 892314262..ef9f69acb 100644 --- a/adm/shop_admin/configformupdate.php +++ b/adm/shop_admin/configformupdate.php @@ -148,6 +148,8 @@ $sql = " update {$g5['g5_shop_default_table']} de_pg_service = '$de_pg_service', de_kcp_mid = '$de_kcp_mid', de_kcp_site_key = '$de_kcp_site_key', + de_inicis_mid = '$de_inicis_mid', + de_inicis_admin_key = '$de_inicis_admin_key', de_iche_use = '$de_iche_use', de_sms_cont1 = '$de_sms_cont1', de_sms_cont2 = '$de_sms_cont2', diff --git a/adm/shop_admin/orderdelivery.php b/adm/shop_admin/orderdelivery.php index 5fabb820b..5ae0289e5 100644 --- a/adm/shop_admin/orderdelivery.php +++ b/adm/shop_admin/orderdelivery.php @@ -37,10 +37,8 @@ include_once(G5_PATH.'/head.sub.php'); - -
diff --git a/adm/shop_admin/orderform.php b/adm/shop_admin/orderform.php index d99f693d7..99aed396b 100644 --- a/adm/shop_admin/orderform.php +++ b/adm/shop_admin/orderform.php @@ -442,6 +442,10 @@ add_javascript(G5_POSTCODE_JS, 0); //다음 주소 js $pg_test .= ' 테스트 '; } break; + case 'inicis': + $pg_url = 'https://iniweb.inicis.com/'; + $pg_test = 'KG이니시스'; + break; default: $pg_url = 'http://admin8.kcp.co.kr'; $pg_test = 'KCP'; @@ -543,6 +547,9 @@ add_javascript(G5_POSTCODE_JS, 0); //다음 주소 js break; } $cash_receipt_script = 'javascript:showCashReceipts(\''.$LGD_MID.'\',\''.$od['od_id'].'\',\''.$od['od_casseqno'].'\',\''.$trade_type.'\',\''.$CST_PLATFORM.'\');'; + } else if($od['od_pg'] == 'inicis') { + $cash = unserialize($od['od_cash_info']); + $cash_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/Cash_mCmReceipt.jsp?noTid='.$cash['TID'].'&clpaymethod=22\',\'showreceipt\',\'width=380,height=540,scrollbars=no,resizable=no\');'; } else { require G5_SHOP_PATH.'/settle_kcp.inc.php'; diff --git a/adm/shop_admin/orderformcartupdate.php b/adm/shop_admin/orderformcartupdate.php index 7fdf9e729..e4ce7ade7 100644 --- a/adm/shop_admin/orderformcartupdate.php +++ b/adm/shop_admin/orderformcartupdate.php @@ -210,6 +210,49 @@ if (in_array($_POST['ct_status'], $status_cancel)) { $pg_res_msg = $xpay->Response_Msg(); } break; + case 'inicis': + include_once(G5_SHOP_PATH.'/settle_inicis.inc.php'); + $cancel_msg = iconv_euckr('쇼핑몰 운영자 승인 취소'); + + /********************* + * 3. 취소 정보 설정 * + *********************/ + $inipay->SetField("type", "cancel"); // 고정 (절대 수정 불가) + $inipay->SetField("mid", $default['de_inicis_mid']); // 상점아이디 + /************************************************************************************************** + * admin 은 키패스워드 변수명입니다. 수정하시면 안됩니다. 1111의 부분만 수정해서 사용하시기 바랍니다. + * 키패스워드는 상점관리자 페이지(https://iniweb.inicis.com)의 비밀번호가 아닙니다. 주의해 주시기 바랍니다. + * 키패스워드는 숫자 4자리로만 구성됩니다. 이 값은 키파일 발급시 결정됩니다. + * 키패스워드 값을 확인하시려면 상점측에 발급된 키파일 안의 readme.txt 파일을 참조해 주십시오. + **************************************************************************************************/ + $inipay->SetField("admin", $default['de_inicis_admin_key']); //비대칭 사용키 키패스워드 + $inipay->SetField("tid", $od['od_tno']); // 취소할 거래의 거래아이디 + $inipay->SetField("cancelmsg", $cancel_msg); // 취소사유 + + /**************** + * 4. 취소 요청 * + ****************/ + $inipay->startAction(); + + /**************************************************************** + * 5. 취소 결과 * + * * + * 결과코드 : $inipay->getResult('ResultCode') ("00"이면 취소 성공) * + * 결과내용 : $inipay->getResult('ResultMsg') (취소결과에 대한 설명) * + * 취소날짜 : $inipay->getResult('CancelDate') (YYYYMMDD) * + * 취소시각 : $inipay->getResult('CancelTime') (HHMMSS) * + * 현금영수증 취소 승인번호 : $inipay->getResult('CSHR_CancelNum') * + * (현금영수증 발급 취소시에만 리턴됨) * + ****************************************************************/ + + $res_cd = $inipay->getResult('ResultCode'); + $res_msg = $inipay->getResult('ResultMsg'); + + if($res_cd != '00') { + $pg_res_cd = $res_cd; + $pg_res_msg = iconv_utf8($res_msg); + } + break; default: include_once(G5_SHOP_PATH.'/settle_kcp.inc.php'); require_once(G5_SHOP_PATH.'/kcp/pp_ax_hub_lib.php'); @@ -313,21 +356,19 @@ if($cancel_change) { $sql .= " where od_id = '$od_id' "; sql_query($sql); -// 신용카드 취소 때 오류가 있으면 알림 -if($pg_cancel == 1 && $pg_res_cd && $pg_res_msg) { - echo ''; -} - $qstr = "sort1=$sort1&sort2=$sort2&sel_field=$sel_field&search=$search&page=$page"; $url = "./orderform.php?od_id=$od_id&$qstr"; -// 1.06.06 -$od = sql_fetch(" select od_receipt_point from {$g5['g5_shop_order_table']} where od_id = '$od_id' "); -if ($od['od_receipt_point']) - alert("포인트로 결제한 주문은,\\n\\n주문상태 변경으로 인해 포인트의 가감이 발생하는 경우\\n\\n회원관리 > 포인트관리에서 수작업으로 포인트를 맞추어 주셔야 합니다.", $url); -else - goto_url($url); +// 신용카드 취소 때 오류가 있으면 알림 +if($pg_cancel == 1 && $pg_res_cd && $pg_res_msg) { + alert('오류코드 : '.$pg_res_cd.' 오류내용 : '.$pg_res_msg, $url); +} else { + // 1.06.06 + $od = sql_fetch(" select od_receipt_point from {$g5['g5_shop_order_table']} where od_id = '$od_id' "); + if ($od['od_receipt_point']) + alert("포인트로 결제한 주문은,\\n\\n주문상태 변경으로 인해 포인트의 가감이 발생하는 경우\\n\\n회원관리 > 포인트관리에서 수작업으로 포인트를 맞추어 주셔야 합니다.", $url); + else + goto_url($url); +} ?> diff --git a/adm/shop_admin/orderpartcancel.php b/adm/shop_admin/orderpartcancel.php index 1db4bdffe..c1e0345c4 100644 --- a/adm/shop_admin/orderpartcancel.php +++ b/adm/shop_admin/orderpartcancel.php @@ -10,6 +10,9 @@ $od = sql_fetch($sql); if(!$od['od_id']) alert_close('주문정보가 존해하지 않습니다.'); +if($od['od_pg'] == 'inicis' && $od['od_settle_case'] == '계좌이체') + alert_close('KG이니시스는 신용카드만 부분취소가 가능합니다.'); + if($od['od_settle_case'] == '계좌이체' && substr($od['od_receipt_time'], 0, 10) >= G5_TIME_YMD) alert_close('실시간 계좌이체건의 부분취소 요청은 결제일 익일에 가능합니다.'); diff --git a/adm/shop_admin/personalpayform.php b/adm/shop_admin/personalpayform.php index e14fa7d01..5ae284f70 100644 --- a/adm/shop_admin/personalpayform.php +++ b/adm/shop_admin/personalpayform.php @@ -208,6 +208,9 @@ if(!sql_query(" select pp_cash from {$g5['g5_shop_personalpay_table']} limit 1 " break; } $cash_receipt_script = 'javascript:showCashReceipts(\''.$LGD_MID.'\',\''.$pp['pp_id'].'\',\''.$pp['pp_casseqno'].'\',\''.$trade_type.'\',\''.$CST_PLATFORM.'\');'; + } else if($pp['pp_pg'] == 'inicis') { + $cash = unserialize($pp['pp_cash_info']); + $cash_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/Cash_mCmReceipt.jsp?noTid='.$cash['TID'].'&clpaymethod=22\',\'showreceipt\',\'width=380,height=540,scrollbars=no,resizable=no\');'; } else { require G5_SHOP_PATH.'/settle_kcp.inc.php'; diff --git a/head.sub.php b/head.sub.php index 449f875d4..6c6daf87f 100644 --- a/head.sub.php +++ b/head.sub.php @@ -103,7 +103,7 @@ if(!defined('G5_IS_ADMIN')) echo $config['cf_add_script']; ?> -> +> "); diff --git a/install/library.check.php b/install/library.check.php index ea9c21013..c01d9643e 100644 --- a/install/library.check.php +++ b/install/library.check.php @@ -6,16 +6,4 @@ if(!extension_loaded('gd') || !function_exists('gd_info')) { echo 'alert("'.G5_VERSION.'의 정상적인 사용을 위해서는 GD 라이브러리가 필요합니다.\nGD 라이브러리가 없을 경우 자동등록방지 문자와 썸네일 기능이 작동하지 않습니다.");'.PHP_EOL; echo ''.PHP_EOL; } - -if(!extension_loaded('openssl')) { - echo ''.PHP_EOL; -} - -if(!extension_loaded('soap') || !class_exists('SOAPClient')) { - echo ''.PHP_EOL; -} ?> \ No newline at end of file diff --git a/lib/json.lib.php b/lib/json.lib.php new file mode 100644 index 000000000..37fa82b10 --- /dev/null +++ b/lib/json.lib.php @@ -0,0 +1,79 @@ + $v) $result[] = json_encode($k).':'.json_encode($v); + return '{' . join(',', $result) . '}'; + } + } +} + +if(!function_exists('json_decode')) +{ + function json_decode($json) + { + $comment = false; + $out = '$x='; + for ($i=0; $i \ No newline at end of file diff --git a/mobile/shop/event.php b/mobile/shop/event.php index da4f8e698..7762cda23 100644 --- a/mobile/shop/event.php +++ b/mobile/shop/event.php @@ -72,7 +72,7 @@ else 쇼핑몰 설치 후 이용해 주십시오.

'); +define('_SHOP_', true); +?> \ No newline at end of file diff --git a/mobile/shop/inicis/orderform.1.php b/mobile/shop/inicis/orderform.1.php new file mode 100644 index 000000000..bfdaab703 --- /dev/null +++ b/mobile/shop/inicis/orderform.1.php @@ -0,0 +1,26 @@ + + +
+ + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/mobile/shop/inicis/orderform.2.php b/mobile/shop/inicis/orderform.2.php new file mode 100644 index 000000000..7a6b88275 --- /dev/null +++ b/mobile/shop/inicis/orderform.2.php @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + 취소 +
\ No newline at end of file diff --git a/mobile/shop/inicis/orderform.3.php b/mobile/shop/inicis/orderform.3.php new file mode 100644 index 000000000..d054abec9 --- /dev/null +++ b/mobile/shop/inicis/orderform.3.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/mobile/shop/inicis/pay_approval.php b/mobile/shop/inicis/pay_approval.php new file mode 100644 index 000000000..96ec1fec6 --- /dev/null +++ b/mobile/shop/inicis/pay_approval.php @@ -0,0 +1,105 @@ + $default['de_inicis_mid'], + 'P_TID' => $_REQUEST['P_TID'] + ); + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $_REQUEST['P_REQ_URL']); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + $return = curl_exec($ch); + + if(!$return) + alert('KG이니시스와 통신 오류로 결제등록 요청을 완료하지 못했습니다.\\n결제등록 요청을 다시 시도해 주십시오.', $page_return_url); + + // 결과를 배열로 변환 + parse_str($return, $ret); + $PAY = array_map('trim', $ret); + + if($PAY['P_STATUS'] != '00') + alert('오류 : '.iconv_utf8($PAY['P_RMESG1']).' 코드 : '.$PAY['P_STATUS'], $page_return_url); + + // TID, AMT 를 세션으로 주문완료 페이지 전달 + $hash = md5($PAY['P_TID'].$PAY['P_MID'].$PAY['P_AMT']); + set_session('P_TID', $PAY['P_TID']); + set_session('P_AMT', $PAY['P_AMT']); + set_session('P_HASH', $hash); +} + +$g5['title'] = 'KG 이니시스 결제'; +$g5['body_script'] = ' onload="setPAYResult();"'; +include_once(G5_PATH.'/head.sub.php'); + +$exclude = array('res_cd', 'P_HASH', 'P_TYPE', 'P_AUTH_DT', 'P_AUTH_NO', 'P_HPP_CORP', 'P_APPL_NUM', 'P_VACT_NUM', 'P_VACT_NAME', 'P_VACT_BANK', 'P_CARD_ISSUER', 'P_UNAME'); + +echo '
'.PHP_EOL; + +foreach($data as $key=>$value) { + if(in_array($key, $exclude)) + continue; + + echo ''.PHP_EOL; +} + +echo ''.PHP_EOL; +echo ''.PHP_EOL; +echo ''.PHP_EOL; +echo ''.PHP_EOL; +echo ''.PHP_EOL; +echo ''.PHP_EOL; +echo ''.PHP_EOL; +echo ''.PHP_EOL; +echo ''.PHP_EOL; +echo ''.PHP_EOL; +echo ''.PHP_EOL; +echo ''.PHP_EOL; + +echo '
'.PHP_EOL; +?> + +
+ + 주문완료 중입니다. 잠시만 기다려 주십시오. +
+ + + + \ No newline at end of file diff --git a/mobile/shop/inicis/pay_result.php b/mobile/shop/inicis/pay_result.php new file mode 100644 index 000000000..61c361b02 --- /dev/null +++ b/mobile/shop/inicis/pay_result.php @@ -0,0 +1,41 @@ + \ No newline at end of file diff --git a/mobile/shop/inicis/pay_return.php b/mobile/shop/inicis/pay_return.php new file mode 100644 index 000000000..12bc21677 --- /dev/null +++ b/mobile/shop/inicis/pay_return.php @@ -0,0 +1,84 @@ +'.PHP_EOL; + +foreach($data as $key=>$value) { + if(in_array($key, $exclude)) + continue; + + echo ''.PHP_EOL; +} + +echo ''.PHP_EOL; +echo ''.PHP_EOL; +echo ''.PHP_EOL; +echo ''.PHP_EOL; +echo ''.PHP_EOL; + +echo ''.PHP_EOL; +?> + + + + + + \ No newline at end of file diff --git a/mobile/shop/inicis/settle_common.php b/mobile/shop/inicis/settle_common.php new file mode 100644 index 000000000..3486c2237 --- /dev/null +++ b/mobile/shop/inicis/settle_common.php @@ -0,0 +1,215 @@ + $PageCall_time, + "P_TID" => $P_TID, + "P_MID" => $P_MID, + "P_AUTH_DT" => $P_AUTH_DT, + "P_STATUS" => $P_STATUS, + "P_TYPE" => $P_TYPE, + "P_OID" => $P_OID, + "P_FN_CD1" => $P_FN_CD1, + "P_FN_CD2" => $P_FN_CD2, + "P_FN_NM" => $P_FN_NM, + "P_AMT" => $P_AMT, + "P_UNAME" => $P_UNAME, + "P_RMESG1" => $P_RMESG1, + "P_RMESG2" => $P_RMESG2, + "P_NOTI" => $P_NOTI, + "P_AUTH_NO" => $P_AUTH_NO + ); + + // 결과 incis log 테이블 기록 + if($P_TYPE == 'BANK') { + $sql = " insert into {$g5['g5_shop_inicis_log_table']} + set oid = '$P_OID', + P_TID = '$P_TID', + P_MID = '$P_MID', + P_AUTH_DT = '$P_AUTH_DT', + P_STATUS = '$P_STATUS', + P_TYPE = '$P_TYPE', + P_OID = '$P_OID', + P_FN_NM = '".iconv_utf8($P_FN_NM)."', + P_AMT = '$P_AMT', + P_RMESG1 = '".iconv_utf8($P_RMESG1)."' "; + @sql_query($sql); + } + + // 결제처리에 관한 로그 기록 + //writeLog($value); + + /*********************************************************************************** + ' 위에서 상점 데이터베이스에 등록 성공유무에 따라서 성공시에는 "OK"를 이니시스로 실패시는 "FAIL" 을 + ' 리턴하셔야합니다. 아래 조건에 데이터베이스 성공시 받는 FLAG 변수를 넣으세요 + ' (주의) OK를 리턴하지 않으시면 이니시스 지불 서버는 "OK"를 수신할때까지 계속 재전송을 시도합니다 + ' 기타 다른 형태의 echo "" 는 하지 않으시기 바랍니다 + '***********************************************************************************/ + + echo 'OK'; + +} + +function writeLog($msg) +{ + $file = G5_SHOP_PATH."/inicis/log/noti_input_".date("Ymd").".log"; + + if(!($fp = fopen($path.$file, "a+"))) return 0; + + ob_start(); + print_r($msg); + $ob_msg = ob_get_contents(); + ob_clean(); + + if(fwrite($fp, " ".$ob_msg."\n") === FALSE) + { + fclose($fp); + return 0; + } + fclose($fp); + return 1; +} +?> diff --git a/mobile/shop/kcp/approval_key.js b/mobile/shop/kcp/approval_key.js index 022665865..c9a99fb10 100644 --- a/mobile/shop/kcp/approval_key.js +++ b/mobile/shop/kcp/approval_key.js @@ -89,7 +89,6 @@ else { alert("실패 되었습니다.[" + txt[3].replace(/^\s*/,'').replace(/\s*$/,'') + "]"); - window.close(); } } } diff --git a/mobile/shop/kcp/order_approval_form.php b/mobile/shop/kcp/order_approval_form.php index 0e79a7251..1b25eb461 100644 --- a/mobile/shop/kcp/order_approval_form.php +++ b/mobile/shop/kcp/order_approval_form.php @@ -104,6 +104,14 @@ $ActionResult = ''; break; } + + if(get_session('ss_personalpay_id') && get_session('ss_personalpay_hash')) { + $js_return_url = G5_SHOP_URL.'/personalpayform.php?pp_id='.get_session('ss_personalpay_id'); + } else { + $js_return_url = G5_SHOP_URL.'/orderform.php'; + if(get_session('ss_direct')) + $js_return_url .= '?sw_direct=1'; + } ?> @@ -112,7 +120,9 @@ - + + + - - - - - - - - -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - - diff --git a/mobile/shop/kcp/pp_ax_hub.php b/mobile/shop/kcp/pp_ax_hub.php index fc7c3f9b7..09ccc7bbd 100644 --- a/mobile/shop/kcp/pp_ax_hub.php +++ b/mobile/shop/kcp/pp_ax_hub.php @@ -161,7 +161,15 @@ openwin.close(); "; */ - alert("$res_cd : $res_msg"); + if(isset($_POST['pp_id']) && $_POST['pp_id']) { + $page_return_url = G5_SHOP_URL.'/personalpayform.php?pp_id='.get_session('ss_personalpay_id'); + } else { + $page_return_url = G5_SHOP_URL.'/orderform.php'; + if(get_session('ss_direct')) + $page_return_url .= '?sw_direct=1'; + } + + alert("$res_cd : $res_msg", $page_return_url); exit; } diff --git a/mobile/shop/lg/returnurl.php b/mobile/shop/lg/returnurl.php index 306ab9883..ce35b9392 100644 --- a/mobile/shop/lg/returnurl.php +++ b/mobile/shop/lg/returnurl.php @@ -7,38 +7,76 @@ xpay_approval.php 에서 세션에 저장했던 파라미터 값이 유효한지 */ if(!isset($_SESSION['PAYREQ_MAP'])){ - alert_close('세션이 만료 되었거나 유효하지 않은 요청 입니다.'); + alert('세션이 만료 되었거나 유효하지 않은 요청 입니다.', G5_SHOP_URL); } $payReqMap = $_SESSION['PAYREQ_MAP']; //결제 요청시, Session에 저장했던 파라미터 MAP $g5['title'] = 'LG 유플러스 eCredit서비스 결제'; -$g5['body_script'] = 'onload="setLGDResult();"'; +$g5['body_script'] = ' onload="setLGDResult();"'; include_once(G5_PATH.'/head.sub.php'); $LGD_RESPCODE = $_REQUEST['LGD_RESPCODE']; $LGD_RESPMSG = $_REQUEST['LGD_RESPMSG']; $LGD_PAYKEY = ''; +$LGD_OID = $payReqMap['LGD_OID']; + +$sql = " select * from {$g5['g5_shop_order_data_table']} where od_id = '$LGD_OID' "; +$row = sql_fetch($sql); + +$data = unserialize($row['dt_data']); + +if(isset($data['pp_id']) && $data['pp_id']) { + $order_action_url = G5_HTTPS_MSHOP_URL.'/personalpayformupdate.php'; + $page_return_url = G5_SHOP_URL.'/personalpayform.php?pp_id='.$data['pp_id']; +} else { + $order_action_url = G5_HTTPS_MSHOP_URL.'/orderformupdate.php'; + $page_return_url = G5_SHOP_URL.'/orderform.php'; + if($_SESSION['ss_direct']) + $page_return_url .= '?sw_direct=1'; +} + if($LGD_RESPCODE == '0000') { $LGD_PAYKEY = $_REQUEST['LGD_PAYKEY']; $payReqMap['LGD_RESPCODE'] = $LGD_RESPCODE; $payReqMap['LGD_RESPMSG'] = $LGD_RESPMSG; $payReqMap['LGD_PAYKEY'] = $LGD_PAYKEY; } else { - alert_close('LGD_RESPCODE:' . $LGD_RESPCODE . ' ,LGD_RESPMSG:' . $LGD_RESPMSG); //인증 실패에 대한 처리 로직 추가 + alert('LGD_RESPCODE:' . $LGD_RESPCODE . ' ,LGD_RESPMSG:' . $LGD_RESPMSG, $page_return_url); //인증 실패에 대한 처리 로직 추가 } ?> +'.PHP_EOL; + +foreach($data as $key=>$value) { + if(in_array($key, $exclude)) + continue; + + echo ''.PHP_EOL; +} + +echo ''.PHP_EOL; +echo ''.PHP_EOL; + +echo ''.PHP_EOL; +?> + +
+
+ + 주문완료 중입니다. 잠시만 기다려 주십시오. +
+
+ diff --git a/mobile/shop/lg/xpay_approval.php b/mobile/shop/lg/xpay_approval.php index 626af8bed..be45cf87b 100644 --- a/mobile/shop/lg/xpay_approval.php +++ b/mobile/shop/lg/xpay_approval.php @@ -24,7 +24,7 @@ $LGD_KVPMISPWAPURL = G5_MSHOP_URL.'/lg/mispwapurl.php?LGD_OID='.$LGD_OID; $LGD_KVPMISPCANCELURL = G5_MSHOP_URL.'/lg/cancel_url.php'; $LGD_MTRANSFERWAPURL = G5_MSHOP_URL.'/lg/returnurl.php'; $LGD_MTRANSFERCANCELURL = G5_MSHOP_URL.'/lg/cancel_url.php'; -$LGD_MTRANSFERNOTEURL = G5_MSHOP_URL.'/note_url.php'; +$LGD_MTRANSFERNOTEURL = G5_MSHOP_URL.'/lg/note_url.php'; if(preg_match('/iPhone|iPad/', $_SERVER['HTTP_USER_AGENT'])) $LGD_MTRANSFERAUTOAPPYN = 'N'; else @@ -130,7 +130,7 @@ $payReqMap['LGD_PAYKEY'] = ""; $_SESSION['PAYREQ_MAP'] = $payReqMap; $g5['title'] = 'LG 유플러스 eCredit서비스 결제'; -$g5['body_script'] = 'onload="launchCrossPlatform();"'; +$g5['body_script'] = ' onload="launchCrossPlatform();"'; include_once(G5_PATH.'/head.sub.php'); ?> diff --git a/mobile/shop/orderform.php b/mobile/shop/orderform.php index 3ac4b333a..3d0a8cb50 100644 --- a/mobile/shop/orderform.php +++ b/mobile/shop/orderform.php @@ -32,6 +32,10 @@ require_once(G5_MSHOP_PATH.'/settle_'.$default['de_pg_service'].'.inc.php'); // 결제등록 요청시 사용할 입금마감일 $ipgm_date = date("Ymd", (G5_SERVER_TIME + 86400 * 5)); $tablet_size = "1.0"; // 화면 사이즈 조정 - 기기화면에 맞게 수정(갤럭시탭,아이패드 - 1.85, 스마트폰 - 1.0) + +// 개인결제번호제거 +set_session('ss_personalpay_id', ''); +set_session('ss_personalpay_hash', ''); ?>
@@ -93,7 +97,7 @@ ob_start(); { //$goods = addslashes($row[it_name]); //$goods = get_text($row[it_name]); - $goods = preg_replace("/\'|\"|\||\,|\&|\;/", "", $row['it_name']); + $goods = preg_replace("/\?|\'|\"|\||\,|\&|\;/", "", $row['it_name']); $goods_it_id = $row['it_id']; } $goods_count++; @@ -1194,10 +1198,61 @@ function pay_approval() f.LGD_TAXFREEAMOUNT.value = pf.comm_free_mny.value; + + var paymethod = ""; + var width = 330; + var height = 480; + var xpos = (screen.width - width) / 2; + var ypos = (screen.width - height) / 2; + var position = "top=" + ypos + ",left=" + xpos; + var features = position + ", width=320, height=440"; + switch(settle_method) { + case "계좌이체": + paymethod = "bank"; + break; + case "가상계좌": + paymethod = "vbank"; + break; + case "휴대폰": + paymethod = "mobile"; + break; + case "신용카드": + paymethod = "wcard"; + break; + } + f.P_AMT.value = f.good_mny.value; + f.P_UNAME.value = pf.od_name.value; + f.P_MOBILE.value = pf.od_hp.value; + f.P_EMAIL.value = pf.od_email.value; + + f.P_TAX.value = pf.comm_vat_mny.value; + f.P_TAXFREE = pf.comm_free_mny.value; + + f.P_RETURN_URL.value = ""; + f.action = "https://mobile.inicis.com/smart/" + paymethod + "/"; - var new_win = window.open("about:blank", "tar_opener", "scrollbars=yes,resizable=yes"); - f.target = "tar_opener"; + //var new_win = window.open("about:blank", "tar_opener", "scrollbars=yes,resizable=yes"); + //f.target = "tar_opener"; + + // 주문 정보 임시저장 + var order_data = $(pf).serialize(); + var save_result = ""; + $.ajax({ + type: "POST", + data: order_data, + url: g5_url+"/shop/ajax.orderdatasave.php", + cache: false, + async: false, + success: function(data) { + save_result = data; + } + }); + + if(save_result) { + alert(save_result); + return false; + } f.submit(); } diff --git a/mobile/shop/orderformupdate.php b/mobile/shop/orderformupdate.php index c66a8c9ef..a22f5a7b1 100644 --- a/mobile/shop/orderformupdate.php +++ b/mobile/shop/orderformupdate.php @@ -2,13 +2,20 @@ include_once('./_common.php'); include_once(G5_LIB_PATH.'/mailer.lib.php'); +$page_return_url = G5_SHOP_URL.'/orderform.php'; +if(get_session('ss_direct')) + $page_return_url .= '?sw_direct=1'; + // 결제등록 완료 체크 if($od_settle_case != '무통장') { if($default['de_pg_service'] == 'kcp' && ($_POST['tran_cd'] == '' || $_POST['enc_info'] == '' || $_POST['enc_data'] == '')) - alert('결제등록 요청 후 주문해 주십시오.'); + alert('결제등록 요청 후 주문해 주십시오.', $page_return_url); if($default['de_pg_service'] == 'lg' && !$_POST['LGD_PAYKEY']) - alert('결제등록 요청 후 주문해 주십시오.'); + alert('결제등록 요청 후 주문해 주십시오.', $page_return_url); + + if($default['de_pg_service'] == 'inicis' && !$_POST['P_HASH']) + alert('결제등록 요청 후 주문해 주십시오.', $page_return_url); } // 장바구니가 비어있는가? @@ -51,7 +58,7 @@ if($i == 0) if ($error != "") { $error .= "다른 고객님께서 {$od_name}님 보다 먼저 주문하신 경우입니다. 불편을 끼쳐 죄송합니다."; - alert($error); + alert($error, $page_return_url); } $i_price = (int)$_POST['od_price']; @@ -263,7 +270,7 @@ if (($i_temp_point > (int)$temp_point || $i_temp_point < 0) && $config['cf_use_p if ($od_temp_point) { if ($member['mb_point'] < $od_temp_point) - alert('회원님의 포인트가 부족하여 포인트로 결제 할 수 없습니다.'); + alert('회원님의 포인트가 부족하여 포인트로 결제 할 수 없습니다.', $page_return_url); } $i_price = $i_price + $i_send_cost + $i_send_cost2 - $i_temp_point - $i_send_coupon; @@ -286,6 +293,9 @@ else if ($od_settle_case == "계좌이체") case 'lg': include G5_SHOP_PATH.'/lg/xpay_result.php'; break; + case 'inicis': + include G5_MSHOP_PATH.'/inicis/pay_result.php'; + break; default: include G5_MSHOP_PATH.'/kcp/pp_ax_hub.php'; $bank_name = iconv("cp949", "utf-8", $bank_name); @@ -310,6 +320,9 @@ else if ($od_settle_case == "가상계좌") case 'lg': include G5_SHOP_PATH.'/lg/xpay_result.php'; break; + case 'inicis': + include G5_MSHOP_PATH.'/inicis/pay_result.php'; + break; default: include G5_MSHOP_PATH.'/kcp/pp_ax_hub.php'; $bankname = iconv("cp949", "utf-8", $bankname); @@ -319,6 +332,7 @@ else if ($od_settle_case == "가상계좌") $od_receipt_point = $i_temp_point; $od_tno = $tno; + $od_app_no = $app_no; $od_receipt_price = 0; $od_bank_account = $bankname.' '.$account; $od_deposit_name = $depositor; @@ -331,6 +345,9 @@ else if ($od_settle_case == "휴대폰") case 'lg': include G5_SHOP_PATH.'/lg/xpay_result.php'; break; + case 'inicis': + include G5_MSHOP_PATH.'/inicis/pay_result.php'; + break; default: include G5_MSHOP_PATH.'/kcp/pp_ax_hub.php'; break; @@ -352,6 +369,9 @@ else if ($od_settle_case == "신용카드") case 'lg': include G5_SHOP_PATH.'/lg/xpay_result.php'; break; + case 'inicis': + include G5_MSHOP_PATH.'/inicis/pay_result.php'; + break; default: include G5_MSHOP_PATH.'/kcp/pp_ax_hub.php'; $card_name = iconv("cp949", "utf-8", $card_name); @@ -382,6 +402,9 @@ if($tno) { case 'lg': include G5_SHOP_PATH.'/lg/xpay_cancel.php'; break; + case 'inicis': + include G5_SHOP_PATH.'/inicis/inipay_cancel.php'; + break; default: include G5_SHOP_PATH.'/kcp/pp_ax_hub_cancel.php'; break; @@ -498,6 +521,9 @@ if(!$result) { case 'lg': include G5_SHOP_PATH.'/lg/xpay_cancel.php'; break; + case 'inicis': + include G5_SHOP_PATH.'/inicis/inipay_cancel.php'; + break; default: include G5_SHOP_PATH.'/kcp/pp_ax_hub_cancel.php'; break; @@ -534,6 +560,9 @@ if(!$result) { case 'lg': include G5_SHOP_PATH.'/lg/xpay_cancel.php'; break; + case 'inicis': + include G5_SHOP_PATH.'/inicis/inipay_cancel.php'; + break; default: include G5_SHOP_PATH.'/kcp/pp_ax_hub_cancel.php'; break; @@ -687,6 +716,10 @@ if($config['cf_sms_use'] && ($default['de_sms_use2'] || $default['de_sms_use3']) $uid = md5($od_id.G5_TIME_YMDHIS.$REMOTE_ADDR); set_session('ss_orderview_uid', $uid); +// 주문 정보 임시 데이터 삭제 +$sql = " delete from {$g5['g5_shop_order_data_table']} where od_id = '$od_id' and dt_pg = '$od_pg' "; +sql_query($sql); + // 주문번호제거 set_session('ss_order_id', ''); diff --git a/mobile/shop/orderinquiryview.php b/mobile/shop/orderinquiryview.php index 82acdddcf..610462630 100644 --- a/mobile/shop/orderinquiryview.php +++ b/mobile/shop/orderinquiryview.php @@ -332,6 +332,8 @@ if($od['od_pg'] == 'lg') { $LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY); $hp_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');'; + } else if($od['od_pg'] == 'inicis') { + $hp_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/mCmReceipt_head.jsp?noTid='.$od['od_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');'; } else { $hp_receipt_script = 'window.open(\''.G5_BILL_RECEIPT_URL.'mcash_bill&tno='.$od['od_tno'].'&order_no='.$od['od_id'].'&trade_mony='.$od['od_receipt_price'].'\', \'winreceipt\', \'width=500,height=690,scrollbars=yes,resizable=yes\');'; } @@ -349,6 +351,8 @@ if($od['od_pg'] == 'lg') { $LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY); $card_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');'; + } else if($od['od_pg'] == 'inicis') { + $card_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/mCmReceipt_head.jsp?noTid='.$od['od_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');'; } else { $card_receipt_script = 'window.open(\''.G5_BILL_RECEIPT_URL.'card_bill&tno='.$od['od_tno'].'&order_no='.$od['od_id'].'&trade_mony='.$od['od_receipt_price'].'\', \'winreceipt\', \'width=470,height=815,scrollbars=yes,resizable=yes\');'; } @@ -410,6 +414,9 @@ if($od['od_pg'] == 'lg') { break; } $cash_receipt_script = 'javascript:showCashReceipts(\''.$LGD_MID.'\',\''.$od['od_id'].'\',\''.$od['od_casseqno'].'\',\''.$trade_type.'\',\''.$CST_PLATFORM.'\');'; + } else if($od['od_pg'] == 'inicis') { + $cash = unserialize($od['od_cash_info']); + $cash_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/Cash_mCmReceipt.jsp?noTid='.$cash['TID'].'&clpaymethod=22\',\'showreceipt\',\'width=380,height=540,scrollbars=no,resizable=no\');'; } else { require_once G5_SHOP_PATH.'/settle_kcp.inc.php'; diff --git a/mobile/shop/personalpayform.php b/mobile/shop/personalpayform.php index 93ed80cd4..4e23b76be 100644 --- a/mobile/shop/personalpayform.php +++ b/mobile/shop/personalpayform.php @@ -207,10 +207,61 @@ function pay_approval() f.LGD_TAXFREEAMOUNT.value = pf.comm_free_mny.value; + + var paymethod = ""; + var width = 330; + var height = 480; + var xpos = (screen.width - width) / 2; + var ypos = (screen.width - height) / 2; + var position = "top=" + ypos + ",left=" + xpos; + var features = position + ", width=320, height=440"; + switch(settle_method) { + case "계좌이체": + paymethod = "bank"; + break; + case "가상계좌": + paymethod = "vbank"; + break; + case "휴대폰": + paymethod = "mobile"; + break; + case "신용카드": + paymethod = "wcard"; + break; + } + f.P_AMT.value = f.good_mny.value; + f.P_UNAME.value = pf.pp_name.value; + f.P_MOBILE.value = pf.pp_hp.value; + f.P_EMAIL.value = pf.pp_email.value; + + f.P_TAX.value = pf.comm_vat_mny.value; + f.P_TAXFREE = pf.comm_free_mny.value; + + f.P_RETURN_URL.value = ""; + f.action = "https://mobile.inicis.com/smart/" + paymethod + "/"; - var new_win = window.open("about:blank", "tar_opener", "scrollbars=yes,resizable=yes"); - f.target = "tar_opener"; + //var new_win = window.open("about:blank", "tar_opener", "scrollbars=yes,resizable=yes"); + //f.target = "tar_opener"; + + // 주문 정보 임시저장 + var order_data = $(pf).serialize(); + var save_result = ""; + $.ajax({ + type: "POST", + data: order_data, + url: g5_url+"/shop/ajax.orderdatasave.php", + cache: false, + async: false, + success: function(data) { + save_result = data; + } + }); + + if(save_result) { + alert(save_result); + return false; + } f.submit(); } diff --git a/mobile/shop/personalpayformupdate.php b/mobile/shop/personalpayformupdate.php index e6ddf5701..c5e0f8d5d 100644 --- a/mobile/shop/personalpayformupdate.php +++ b/mobile/shop/personalpayformupdate.php @@ -2,22 +2,27 @@ include_once('./_common.php'); include_once(G5_LIB_PATH.'/mailer.lib.php'); +$page_return_url = G5_SHOP_URL.'/personalpayform.php?pp_id='.get_session('ss_personalpay_id'); + // 결제등록 완료 체크 if($default['de_pg_service'] == 'kcp' && ($_POST['tran_cd'] == '' || $_POST['enc_info'] == '' || $_POST['enc_data'] == '')) - alert('결제등록 요청 후 주문해 주십시오.'); + alert('결제등록 요청 후 주문해 주십시오.', $page_return_url); if($default['de_pg_service'] == 'lg' && !$_POST['LGD_PAYKEY']) - alert('결제등록 요청 후 주문해 주십시오.'); + alert('결제등록 요청 후 주문해 주십시오.', $page_return_url); + +if($default['de_pg_service'] == 'inicis' && !$_POST['P_HASH']) + alert('결제등록 요청 후 주문해 주십시오.', $page_return_url); // 개인결제 정보 $pp_check = false; $sql = " select * from {$g5['g5_shop_personalpay_table']} where pp_id = '{$_POST['pp_id']}' and pp_use = '1' "; $pp = sql_fetch($sql); if(!$pp['pp_id']) - alert('개인결제 정보가 존재하지 않습니다.'); + alert('개인결제 정보가 존재하지 않습니다.', G5_SHOP_URL.'/personalpay.php'); if($pp['pp_tno']) - alert('이미 결제하신 개인결제 내역입니다.'); + alert('이미 결제하신 개인결제 내역입니다.', G5_SHOP_URL); $hash_data = md5($_POST['pp_id'].$_POST['good_mny'].$pp['pp_time']); if($_POST['pp_id'] != get_session('ss_personalpay_id') || $hash_data != get_session('ss_personalpay_hash')) @@ -29,6 +34,9 @@ if ($pp_settle_case == "계좌이체") case 'lg': include G5_SHOP_PATH.'/lg/xpay_result.php'; break; + case 'inicis': + include G5_MSHOP_PATH.'/inicis/pay_result.php'; + break; default: include G5_MSHOP_PATH.'/kcp/pp_ax_hub.php'; $bank_name = iconv("cp949", "utf-8", $bank_name); @@ -48,6 +56,9 @@ else if ($pp_settle_case == "가상계좌") case 'lg': include G5_SHOP_PATH.'/lg/xpay_result.php'; break; + case 'inicis': + include G5_MSHOP_PATH.'/inicis/pay_result.php'; + break; default: include G5_MSHOP_PATH.'/kcp/pp_ax_hub.php'; $bankname = iconv("cp949", "utf-8", $bankname); @@ -56,6 +67,7 @@ else if ($pp_settle_case == "가상계좌") } $pp_tno = $tno; + $pp_app_no = $app_no; $pp_receipt_price = 0; $pp_bank_account = $bankname.' '.$account; $pp_deposit_name = $depositor; @@ -67,6 +79,9 @@ else if ($pp_settle_case == "휴대폰") case 'lg': include G5_SHOP_PATH.'/lg/xpay_result.php'; break; + case 'inicis': + include G5_MSHOP_PATH.'/inicis/pay_result.php'; + break; default: include G5_MSHOP_PATH.'/kcp/pp_ax_hub.php'; break; @@ -84,6 +99,9 @@ else if ($pp_settle_case == "신용카드") case 'lg': include G5_SHOP_PATH.'/lg/xpay_result.php'; break; + case 'inicis': + include G5_MSHOP_PATH.'/inicis/pay_result.php'; + break; default: include G5_MSHOP_PATH.'/kcp/pp_ax_hub.php'; $card_name = iconv("cp949", "utf-8", $card_name); @@ -91,6 +109,7 @@ else if ($pp_settle_case == "신용카드") } $pp_tno = $tno; + $pp_app_no = $app_no; $pp_receipt_price = $amount; $pp_receipt_time = preg_replace("/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/", "\\1-\\2-\\3 \\4:\\5:\\6", $app_time); $pp_bank_account = $card_name; @@ -139,6 +158,9 @@ if(!$result) { case 'lg': include G5_SHOP_PATH.'/lg/xpay_cancel.php'; break; + case 'inicis': + include G5_SHOP_PATH.'/inicis/inipay_cancel.php'; + break; default: include G5_SHOP_PATH.'/kcp/pp_ax_hub_cancel.php'; break; @@ -174,6 +196,9 @@ if($pp_receipt_price > 0 && $pp['pp_id'] && $pp['od_id']) { case 'lg': include G5_SHOP_PATH.'/lg/xpay_cancel.php'; break; + case 'inicis': + include G5_SHOP_PATH.'/inicis/inipay_cancel.php'; + break; default: include G5_SHOP_PATH.'/kcp/pp_ax_hub_cancel.php'; break; @@ -201,6 +226,10 @@ if($pp_receipt_price > 0 && $pp['pp_id'] && $pp['od_id']) { } } +// 주문 정보 임시 데이터 삭제 +$sql = " delete from {$g5['g5_shop_order_data_table']} where od_id = '{$pp['pp_id']}' and dt_pg = '$pp_pg' "; +sql_query($sql); + // 개인결제번호제거 set_session('ss_personalpay_id', ''); set_session('ss_personalpay_hash', ''); diff --git a/mobile/shop/personalpayresult.php b/mobile/shop/personalpayresult.php index e9927dc67..5336697b5 100644 --- a/mobile/shop/personalpayresult.php +++ b/mobile/shop/personalpayresult.php @@ -141,6 +141,8 @@ if($pp['pp_pg'] == 'lg') { $LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY); $hp_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');'; + } else if($pp['pp_pg'] == 'inicis') { + $hp_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/mCmReceipt_head.jsp?noTid='.$pp['pp_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');'; } else { $hp_receipt_script = 'window.open(\''.G5_BILL_RECEIPT_URL.'mcash_bill&tno='.$pp['pp_tno'].'&order_no='.$pp['pp_id'].'&trade_mony='.$pp['pp_receipt_price'].'\', \'winreceipt\', \'width=500,height=690,scrollbars=yes,resizable=yes\');'; } @@ -158,6 +160,8 @@ if($pp['pp_pg'] == 'lg') { $LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY); $card_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');'; + } else if($pp['pp_pg'] == 'inicis') { + $card_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/mCmReceipt_head.jsp?noTid='.$pp['pp_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');'; } else { $card_receipt_script = 'window.open(\''.G5_BILL_RECEIPT_URL.'card_bill&tno='.$pp['pp_tno'].'&order_no='.$pp['pp_id'].'&trade_mony='.$pp['pp_receipt_price'].'\', \'winreceipt\', \'width=470,height=815,scrollbars=yes,resizable=yes\');'; } @@ -209,6 +213,9 @@ if($pp['pp_pg'] == 'lg') { break; } $cash_receipt_script = 'javascript:showCashReceipts(\''.$LGD_MID.'\',\''.$pp['pp_id'].'\',\''.$pp['pp_casseqno'].'\',\''.$trade_type.'\',\''.$CST_PLATFORM.'\');'; + } else if($pp['pp_pg'] == 'inicis') { + $cash = unserialize($pp['pp_cash_info']); + $cash_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/Cash_mCmReceipt.jsp?noTid='.$cash['TID'].'&clpaymethod=22\',\'showreceipt\',\'width=380,height=540,scrollbars=no,resizable=no\');'; } else { require_once G5_SHOP_PATH.'/settle_kcp.inc.php'; diff --git a/mobile/shop/settle_inicis.inc.php b/mobile/shop/settle_inicis.inc.php new file mode 100644 index 000000000..0c8ea4265 --- /dev/null +++ b/mobile/shop/settle_inicis.inc.php @@ -0,0 +1,97 @@ + '기업은행', + '04' => '국민은행', + '05' => '외환은행', + '07' => '수협중앙회', + '11' => '농협중앙회', + '20' => '우리은행', + '23' => 'SC 제일은행', + '31' => '대구은행', + '32' => '부산은행', + '34' => '광주은행', + '37' => '전북은행', + '39' => '경남은행', + '53' => '한국씨티은행', + '71' => '우체국', + '81' => '하나은행', + '88' => '신한은행', + 'D1' => '동양종합금융증권', + 'D2' => '현대증권', + 'D3' => '미래에셋증권', + 'D4' => '한국투자증권', + 'D5' => '우리투자증권', + 'D6' => '하이투자증권', + 'D7' => 'HMC 투자증권', + 'D8' => 'SK 증권', + 'D9' => '대신증권', + 'DA' => '하나대투증권', + 'DB' => '굿모닝신한증권', + 'DC' => '동부증권', + 'DD' => '유진투자증권', + 'DE' => '메리츠증권', + 'DF' => '신영증권' +); + +$CARD_CODE = array( + '01' => '외환', + '03' => '롯데', + '04' => '현대', + '06' => '국민', + '11' => 'BC', + '12' => '삼성', + '14' => '신한', + '15' => '한미', + '16' => 'NH', + '17' => '하나 SK', + '21' => '해외비자', + '22' => '해외마스터', + '23' => 'JCB', + '24' => '해외아멕스', + '25' => '해외다이너스' +); + +$PAY_METHOD = array( + 'ISP' => '신용카드', + 'CARD' => '신용카드', + 'BANK' => '계좌이체', + 'MOBILE' => '휴대폰', + 'VBANK' => '가상계좌' +); + +$noti_url = G5_MSHOP_URL.'/inicis/settle_common.php'; +$next_url = G5_MSHOP_URL.'/inicis/pay_approval.php'; +$return_url = G5_MSHOP_URL.'/inicis/pay_return.php?oid='; +?> \ No newline at end of file diff --git a/orderupgrade.php b/orderupgrade.php index 5110371cd..16ba05bec 100644 --- a/orderupgrade.php +++ b/orderupgrade.php @@ -46,6 +46,23 @@ if(!sql_query(" select ct_select_time from {$g5['g5_shop_cart_table']} limit 1 " ADD `ct_select_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `ct_select` ", true); } +// 모바일 이니시스 계좌이체 결과 전달을 위한 테이블 추가 +if(!sql_query(" DESCRIBE {$g5['g5_shop_inicis_log_table']} ", false)) { + sql_query(" CREATE TABLE IF NOT EXISTS `{$g5['g5_shop_inicis_log_table']}` ( + `oid` bigint(20) unsigned NOT NULL, + `P_TID` varchar(255) NOT NULL DEFAULT '', + `P_MID` varchar(255) NOT NULL DEFAULT '', + `P_AUTH_DT` varchar(255) NOT NULL DEFAULT '', + `P_STATUS` varchar(255) NOT NULL DEFAULT '', + `P_TYPE` varchar(255) NOT NULL DEFAULT '', + `P_OID` varchar(255) NOT NULL DEFAULT '', + `P_FN_NM` varchar(255) NOT NULL DEFAULT '', + `P_AMT` int(11) NOT NULL DEFAULT '0', + `P_RMESG1` varchar(255) NOT NULL DEFAULT '', + PRIMARY KEY (`oid`) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ", true); +} + // cart 테이블 index 추가 if(!sql_fetch(" show keys from {$g5['g5_shop_cart_table']} where Key_name = 'ct_status' ")) { sql_query(" ALTER TABLE `{$g5['g5_shop_cart_table']}` @@ -53,7 +70,18 @@ if(!sql_fetch(" show keys from {$g5['g5_shop_cart_table']} where Key_name = 'ct_ ADD INDEX `ct_status` (`ct_status`) ", true); } -echo '

장바구니 테이블 업그레이드 완료!

'; +// 결제정보 임시저장 테이블 추가 +if(isset($g5['g5_shop_order_data_table']) && !sql_query(" DESCRIBE {$g5['g5_shop_order_data_table']} ", false)) { + sql_query(" CREATE TABLE IF NOT EXISTS `{$g5['g5_shop_order_data_table']}` ( + `od_id` bigint(20) unsigned NOT NULL, + `dt_pg` varchar(255) NOT NULL DEFAULT '', + `dt_data` text NOT NULL, + `dt_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + KEY `od_id` (`od_id`) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8;", true); +} + +echo '

테이블 업그레이드 완료!

'; include_once(G5_PATH.'/tail.sub.php'); ?> \ No newline at end of file diff --git a/shop/ajax.orderdatasave.php b/shop/ajax.orderdatasave.php new file mode 100644 index 000000000..86d147067 --- /dev/null +++ b/shop/ajax.orderdatasave.php @@ -0,0 +1,29 @@ + \ No newline at end of file diff --git a/shop/inicis/_common.php b/shop/inicis/_common.php new file mode 100644 index 000000000..bad54a5d7 --- /dev/null +++ b/shop/inicis/_common.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/shop/inicis/encryptdata.php b/shop/inicis/encryptdata.php new file mode 100644 index 000000000..4f69a8a2f --- /dev/null +++ b/shop/inicis/encryptdata.php @@ -0,0 +1,65 @@ +SetField("type", "chkfake"); // 고정 (절대 수정 불가) +$inipay->SetField("enctype","asym"); //asym:비대칭, symm:대칭(현재 asym으로 고정) +/************************************************************************************************** + * admin 은 키패스워드 변수명입니다. 수정하시면 안됩니다. 1111의 부분만 수정해서 사용하시기 바랍니다. + * 키패스워드는 상점관리자 페이지(https://iniweb.inicis.com)의 비밀번호가 아닙니다. 주의해 주시기 바랍니다. + * 키패스워드는 숫자 4자리로만 구성됩니다. 이 값은 키파일 발급시 결정됩니다. + * 키패스워드 값을 확인하시려면 상점측에 발급된 키파일 안의 readme.txt 파일을 참조해 주십시오. + **************************************************************************************************/ +$inipay->SetField("admin", $default['de_inicis_admin_key']); // 키패스워드(키발급시 생성, 상점관리자 패스워드와 상관없음) +$inipay->SetField("checkopt", "false"); //base64함:false, base64안함:true(현재 false로 고정) + +//필수항목 : mid, price, nointerest, quotabase +//추가가능 : INIregno, oid +//*주의* : 추가가능한 항목중 암호화 대상항목에 추가한 필드는 반드시 hidden 필드에선 제거하고 +// SESSION이나 DB를 이용해 다음페이지(INIsecureresult.php)로 전달/셋팅되어야 합니다. +$inipay->SetField("mid", $default['de_inicis_mid']); // 상점아이디 +$inipay->SetField("price", $price); // 가격 +$inipay->SetField("nointerest", $inipay_nointerest); // 무이자여부(no:일반, yes:무이자) +$inipay->SetField("quotabase", $inipay_quotabase);//할부기간 + +/******************************** + * 4. 암호화 대상/값을 암호화함 * + ********************************/ +$inipay->startAction(); + +/********************* + * 5. 암호화 결과 * + *********************/ +if( $inipay->GetResult("ResultCode") != "00" ) +{ + die('{"error":"'.$inipay->GetResult("ResultMsg").'"}'); +} + +/********************* + * 6. 세션정보 저장 * + *********************/ +set_session('INI_MID', $default['de_inicis_mid']); //상점ID +set_session('INI_ADMIN', $default['de_inicis_admin_key']); // 키패스워드(키발급시 생성, 상점관리자 패스워드와 상관없음) +set_session('INI_PRICE', $price); //가격 +set_session('INI_RN', $inipay->GetResult("rn")); //고정 (절대 수정 불가) +set_session('INI_ENCTYPE', $inipay->GetResult("enctype")); //고정 (절대 수정 불가) + +$ini_encfield = $inipay->GetResult("encfield"); +$ini_certid = $inipay->GetResult("certid"); + +$result = array( + 'error' => '', + 'ini_encfield' => $ini_encfield, + 'ini_certid' => $ini_certid +); + +die(json_encode($result)); + +//die('{"error":"", "ini_encfield":"'.$ini_encfield.'", "ini_certid":"'.$ini_certid.'"}'); +?> \ No newline at end of file diff --git a/shop/inicis/escrow.register.php b/shop/inicis/escrow.register.php new file mode 100644 index 000000000..01a804d57 --- /dev/null +++ b/shop/inicis/escrow.register.php @@ -0,0 +1,115 @@ + 'korex', + '아주택배' => 'ajutb', + 'KT로지스' => 'ktlogistics', + '현대택배' => 'hyundai', + 'CJ대한통운' => 'cjgls', + '한진택배' => 'hanjin', + '트라넷' => 'tranet', + '하나로택배' => 'Hanaro', + '사가와익스프레스' => 'Sagawa', + 'SEDEX' => 'sedex', + 'KGB택배' => 'kgbls', + '로젠택배' => 'kgb', + 'KG옐로우캡택배' => 'yellow', + '삼성HTH' => 'hth', + '동부택배' => 'dongbu', + '우체국' => 'EPOST', + '우편등기' => 'registpost', + '기타택배' => '9999' +); + +$dlv_exName = $escrow_corp; +$dlv_exCode = $exCode[$dlv_exName]; +if(!$dlv_exCode) + $dlv_exCode = '9999'; + +/********************* + * 3. 지불 정보 설정 * + *********************/ +$inipay->SetField("tid", $escrow_tno); // 거래아이디 +$inipay->SetField("mid", $default['de_inicis_mid']); // 상점아이디 +/************************************************************************************************** + * admin 은 키패스워드 변수명입니다. 수정하시면 안됩니다. 1111의 부분만 수정해서 사용하시기 바랍니다. + * 키패스워드는 상점관리자 페이지(https://iniweb.inicis.com)의 비밀번호가 아닙니다. 주의해 주시기 바랍니다. + * 키패스워드는 숫자 4자리로만 구성됩니다. 이 값은 키파일 발급시 결정됩니다. + * 키패스워드 값을 확인하시려면 상점측에 발급된 키파일 안의 readme.txt 파일을 참조해 주십시오. + **************************************************************************************************/ +$inipay->SetField("admin", $default['de_inicis_admin_key']); // 키패스워드(상점아이디에 따라 변경) +$inipay->SetField("type", "escrow"); // 고정 (절대 수정 불가) +$inipay->SetField("escrowtype", "dlv"); // 고정 (절대 수정 불가) +$inipay->SetField("dlv_ip", getenv("REMOTE_ADDR")); // 고정 + +$inipay->SetField("oid", $oid); +$inipay->SetField("soid", "1"); +//$inipay->SetField("dlv_date", $dlv_date); +//$inipay->SetField("dlv_time", $dlv_time); +$inipay->SetField("dlv_report", $EscrowType); +$inipay->SetField("dlv_invoice", $invoice); +$inipay->SetField("dlv_name", $member['mb_id']); + +$inipay->SetField("dlv_excode", $dlv_exCode); +$inipay->SetField("dlv_exname", $dlv_exName); +$inipay->SetField("dlv_charge", $dlv_charge); + +$inipay->SetField("dlv_invoiceday", G5_TIME_YMDHIS); +$inipay->SetField("dlv_sendname", $sendName); +$inipay->SetField("dlv_sendpost", $sendPost); +$inipay->SetField("dlv_sendaddr1", $sendAddr1); +$inipay->SetField("dlv_sendaddr2", $sendAddr2); +$inipay->SetField("dlv_sendtel", $sendTel); + +$inipay->SetField("dlv_recvname", $recvName); +$inipay->SetField("dlv_recvpost", $recvPost); +$inipay->SetField("dlv_recvaddr", $recvAddr); +$inipay->SetField("dlv_recvtel", $recvTel); + +$inipay->SetField("dlv_goodscode", $goodsCode); +$inipay->SetField("dlv_goods", $goods); +$inipay->SetField("dlv_goodscnt", $goodCnt); +$inipay->SetField("price", $price); +$inipay->SetField("dlv_reserved1", $reserved1); +$inipay->SetField("dlv_reserved2", $reserved2); +$inipay->SetField("dlv_reserved3", $reserved3); + +$inipay->SetField("pgn", $pgn); + +/********************* + * 3. 배송 등록 요청 * + *********************/ +$inipay->startAction(); + + +/********************** + * 4. 배송 등록 결과 * + **********************/ + + $tid = $inipay->GetResult("tid"); // 거래번호 + $resultCode = $inipay->GetResult("ResultCode"); // 결과코드 ("00"이면 지불 성공) + $resultMsg = $inipay->GetResult("ResultMsg"); // 결과내용 (지불결과에 대한 설명) + $dlv_date = $inipay->GetResult("DLV_Date"); + $dlv_time = $inipay->GetResult("DLV_Time"); +?> \ No newline at end of file diff --git a/shop/inicis/inipay_cancel.php b/shop/inicis/inipay_cancel.php new file mode 100644 index 000000000..d25ea2a0e --- /dev/null +++ b/shop/inicis/inipay_cancel.php @@ -0,0 +1,29 @@ +GetResult("TID"); + $inipay->SetField("type", "cancel"); // 고정 + $inipay->SetField("tid", $TID); // 고정 + $inipay->SetField("cancelmsg", "DB FAIL"); // 취소사유 + $inipay->startAction(); + if($inipay->GetResult('ResultCode') == "00") + { + $inipay->MakeTXErrMsg(MERCHANT_DB_ERR,"Merchant DB FAIL"); + } +} +?> \ No newline at end of file diff --git a/shop/inicis/inipay_result.php b/shop/inicis/inipay_result.php new file mode 100644 index 000000000..a43f53b29 --- /dev/null +++ b/shop/inicis/inipay_result.php @@ -0,0 +1,216 @@ + 구매자의 세션을 반드시 체크하도록하여 부정거래를 방지하여 주십시요. + * + * http://www.inicis.com + * Copyright (C) 2006 Inicis Co., Ltd. All rights reserved. + */ + + include_once(G5_SHOP_PATH.'/settle_inicis.inc.php'); + +/********************* + * 3. 지불 정보 설정 * +*********************/ +if($default['de_tax_flag_use']) { // 복합과세 사용 때 + $inipay->SetXPath("INIpay/GoodsInfo/Tax", $_POST['comm_vat_mny']); // 부가세 금액 + $inipay->SetXPath("INIpay/GoodsInfo/TaxFree", $_POST['comm_free_mny']); // 면세 금액 +} +$inipay->SetField("type", "securepay"); // 고정 (절대 수정 불가) +$inipay->SetField("pgid", "INIphp".$pgid); // 고정 (절대 수정 불가) +$inipay->SetField("subpgip", "203.238.3.10"); // 고정 (절대 수정 불가) +$inipay->SetField("admin", get_session('INI_ADMIN')); // 키패스워드(상점아이디에 따라 변경) +$inipay->SetField("uid", $uid); // INIpay User ID (절대 수정 불가) +$inipay->SetField("goodname", iconv_euckr($goodname)); // 상품명 +$inipay->SetField("currency", $currency); // 화폐단위 + +$inipay->SetField("mid", get_session('INI_MID')); // 상점아이디 +$inipay->SetField("rn", get_session('INI_RN')); // 웹페이지 위변조용 RN값 +$inipay->SetField("price", get_session('INI_PRICE')); // 가격 +$inipay->SetField("enctype", get_session('INI_ENCTYPE')); // 고정 (절대 수정 불가) + + + /*---------------------------------------------------------------------------------------- +price 등의 중요데이터는 +브라우저상의 위변조여부를 반드시 확인하셔야 합니다. + +결제 요청페이지에서 요청된 금액과 +실제 결제가 이루어질 금액을 반드시 비교하여 처리하십시오. + +설치 메뉴얼 2장의 결제 처리페이지 작성부분의 보안경고 부분을 확인하시기 바랍니다. +적용참조문서: 이니시스홈페이지->가맹점기술지원자료실->기타자료실 의 + '결제 처리 페이지 상에 결제 금액 변조 유무에 대한 체크' 문서를 참조하시기 바랍니다. +예제) +원 상품 가격 변수를 OriginalPrice 하고 원 가격 정보를 리턴하는 함수를 Return_OrgPrice()라 가정하면 +다음 같이 적용하여 원가격과 웹브라우저에서 Post되어 넘어온 가격을 비교 한다. + +$OriginalPrice = Return_OrgPrice(); +$PostPrice = $_SESSION['INI_PRICE']; +if ( $OriginalPrice != $PostPrice ) +{ + //결제 진행을 중단하고 금액 변경 가능성에 대한 메시지 출력 처리 + //처리 종료 +} + +----------------------------------------------------------------------------------------*/ +$inipay->SetField("buyername", iconv_euckr($buyername)); // 구매자 명 +$inipay->SetField("buyertel", $buyertel); // 구매자 연락처(휴대폰 번호 또는 유선전화번호) +$inipay->SetField("buyeremail", $buyeremail); // 구매자 이메일 주소 +$inipay->SetField("paymethod", $paymethod); // 지불방법 (절대 수정 불가) +$inipay->SetField("encrypted", $encrypted); // 암호문 +$inipay->SetField("sessionkey", $sessionkey); // 암호문 +$inipay->SetField("url", G5_URL); // 실제 서비스되는 상점 SITE URL로 변경할것 +$inipay->SetField("cardcode", $cardcode); // 카드코드 리턴 +$inipay->SetField("parentemail", $parentemail); // 보호자 이메일 주소(핸드폰 , 전화결제시에 14세 미만의 고객이 결제하면 부모 이메일로 결제 내용통보 의무, 다른결제 수단 사용시에 삭제 가능) + +/*-----------------------------------------------------------------* + * 수취인 정보 * * + *-----------------------------------------------------------------* + * 실물배송을 하는 상점의 경우에 사용되는 필드들이며 * + * 아래의 값들은 INIsecurepay.html 페이지에서 포스트 되도록 * + * 필드를 만들어 주도록 하십시요. * + * 컨텐츠 제공업체의 경우 삭제하셔도 무방합니다. * + *-----------------------------------------------------------------*/ +$inipay->SetField("recvname", iconv_euckr($recvname)); // 수취인 명 +$inipay->SetField("recvtel", $recvtel); // 수취인 연락처 +$inipay->SetField("recvaddr", iconv_euckr($recvaddr)); // 수취인 주소 +$inipay->SetField("recvpostnum", $recvpostnum); // 수취인 우편번호 +$inipay->SetField("recvmsg", $recvmsg); // 전달 메세지 + +$inipay->SetField("joincard", $joincard); // 제휴카드코드 +$inipay->SetField("joinexpire", $joinexpire); // 제휴카드유효기간 +$inipay->SetField("id_customer", $id_customer); //user_id + + +/**************** + * 4. 지불 요청 * + ****************/ +$inipay->startAction(); + +/**************************************************************************************************************** + * 5. 결제 결과 + * + * 1 모든 결제 수단에 공통되는 결제 결과 데이터 + * 거래번호 : $inipay->GetResult('TID') + * 결과코드 : $inipay->GetResult('ResultCode') ("00"이면 지불 성공) + * 결과내용 : $inipay->GetResult('ResultMsg') (지불결과에 대한 설명) + * 지불방법 : $inipay->GetResult('PayMethod') (매뉴얼 참조) + * 상점주문번호 : $inipay->GetResult('MOID') + * 결제완료금액 : $inipay->GetResult('TotPrice') + * + * 결제 되는 금액 =>원상품가격과 결제결과금액과 비교하여 금액이 동일하지 않다면 + * 결제 금액의 위변조가 의심됨으로 정상적인 처리가 되지않도록 처리 바랍니다. (해당 거래 취소 처리) + * + * + * 2. 신용카드,ISP,핸드폰, 전화 결제, 은행계좌이체, OK CASH BAG Point 결제 결과 데이터 + * (무통장입금 , 문화 상품권 포함) + * 이니시스 승인날짜 : $inipay->GetResult('ApplDate') (YYYYMMDD) + * 이니시스 승인시각 : $inipay->GetResult('ApplTime') (HHMMSS) + * + * 3. 신용카드 결제 결과 데이터 + * + * 신용카드 승인번호 : $inipay->GetResult('ApplNum') + * 할부기간 : $inipay->GetResult('CARD_Quota') + * 무이자할부 여부 : $inipay->GetResult('CARD_Interest') ("1"이면 무이자할부) + * 신용카드사 코드 : $inipay->GetResult('CARD_Code') (매뉴얼 참조) + * 카드발급사 코드 : $inipay->GetResult('CARD_BankCode') (매뉴얼 참조) + * 본인인증 수행여부 : $inipay->GetResult('CARD_AuthType') ("00"이면 수행) + * 각종 이벤트 적용 여부 : $inipay->GetResult('EventCode') + * + * ** 달러결제 시 통화코드와 환률 정보 ** + * 해당 통화코드 : $inipay->GetResult('OrgCurrency') + * 환율 : $inipay->GetResult('ExchangeRate') + * + * 아래는 "신용카드 및 OK CASH BAG 복합결제" 또는"신용카드 지불시에 OK CASH BAG적립"시에 추가되는 데이터 + * OK Cashbag 적립 승인번호 : $inipay->GetResult('OCB_SaveApplNum') + * OK Cashbag 사용 승인번호 : $inipay->GetResult('OCB_PayApplNum') + * OK Cashbag 승인일시 : $inipay->GetResult('OCB_ApplDate') (YYYYMMDDHHMMSS) + * OCB 카드번호 : $inipay->GetResult('OCB_Num') + * OK Cashbag 복합결재시 신용카드 지불금액 : $inipay->GetResult('CARD_ApplPrice') + * OK Cashbag 복합결재시 포인트 지불금액 : $inipay->GetResult('OCB_PayPrice') + * + * 4. 실시간 계좌이체 결제 결과 데이터 + * + * 은행코드 : $inipay->GetResult('ACCT_BankCode') + * 현금영수증 발행결과코드 : $inipay->GetResult('CSHR_ResultCode') + * 현금영수증 발행구분코드 : $inipay->GetResult('CSHR_Type') + * * + * 5. OK CASH BAG 결제수단을 이용시에만 결제 결과 데이터 + * OK Cashbag 적립 승인번호 : $inipay->GetResult('OCB_SaveApplNum') + * OK Cashbag 사용 승인번호 : $inipay->GetResult('OCB_PayApplNum') + * OK Cashbag 승인일시 : $inipay->GetResult('OCB_ApplDate') (YYYYMMDDHHMMSS) + * OCB 카드번호 : $inipay->GetResult('OCB_Num') + * + * 6. 무통장 입금 결제 결과 데이터 * + * 가상계좌 채번에 사용된 주민번호 : $inipay->GetResult('VACT_RegNum') * + * 가상계좌 번호 : $inipay->GetResult('VACT_Num') * + * 입금할 은행 코드 : $inipay->GetResult('VACT_BankCode') * + * 입금예정일 : $inipay->GetResult('VACT_Date') (YYYYMMDD) * + * 송금자 명 : $inipay->GetResult('VACT_InputName') * + * 예금주 명 : $inipay->GetResult('VACT_Name') * + * * + * 7. 핸드폰, 전화 결제 결과 데이터( "실패 내역 자세히 보기"에서 필요 , 상점에서는 필요없는 정보임) * + * 전화결제 사업자 코드 : $inipay->GetResult('HPP_GWCode') * + * * + * 8. 핸드폰 결제 결과 데이터 * + * 휴대폰 번호 : $inipay->GetResult('HPP_Num') (핸드폰 결제에 사용된 휴대폰번호) * + * * + * 9. 전화 결제 결과 데이터 * +* 전화번호 : $inipay->GetResult('ARSB_Num') (전화결제에 사용된 전화번호) * +* * +* 10. 문화 상품권 결제 결과 데이터 * +* 컬쳐 랜드 ID : $inipay->GetResult('CULT_UserID') * +* * +* 11. K-merce 상품권 결제 결과 데이터 (K-merce ID, 틴캐시 아이디 공통사용) * +* K-merce ID : $inipay->GetResult('CULT_UserID') * +* * +* 12. 모든 결제 수단에 대해 결제 실패시에만 결제 결과 데이터 * +* 에러코드 : $inipay->GetResult('ResultErrorCode') * +* * +* 13.현금영수증 발급 결과코드 (은행계좌이체시에만 리턴) * +* $inipay->GetResult('CSHR_ResultCode') * +* * +* 14.틴캐시 잔액 데이터 * +* $inipay->GetResult('TEEN_Remains') * +* 틴캐시 ID : $inipay->GetResult('CULT_UserID') * +* 15.게임문화 상품권 * +* 사용 카드 갯수 : $inipay->GetResult('GAMG_Cnt') * +* * +****************************************************************************************************************/ + +if( $inipay->GetResult("ResultCode") == "00" ) { + //최종결제요청 결과 성공 DB처리 + $tno = $inipay->GetResult('TID'); + $amount = $inipay->GetResult('TotPrice'); + $app_time = $inipay->GetResult('ApplDate').$inipay->GetResult('ApplTime'); + $pay_method = $inipay->GetResult('PayMethod'); + $pay_type = $PAY_METHOD[$pay_method]; + $depositor = iconv_utf8($inipay->GetResult('VACT_InputName')); + $commid = ''; + $mobile_no = $inipay->GetResult('HPP_Num'); + $app_no = $inipay->GetResult('ApplNum'); + $card_name = $CARD_CODE[$inipay->GetResult('CARD_Code')]; + if ($default['de_escrow_use'] == 1) + $escw_yn = 'Y'; + switch($pay_type) { + case '계좌이체': + $bank_name = $BANK_CODE[$inipay->GetResult('ACCT_BankCode')]; + break; + case '가상계좌': + $bankname = $BANK_CODE[$inipay->GetResult('VACT_BankCode')]; + $account = $inipay->GetResult('VACT_Num').' '.iconv_utf8($inipay->GetResult('VACT_Name')); + $app_no = $inipay->GetResult('VACT_Num'); + break; + default: + break; + } +} else { + alert(iconv_utf8($inipay->GetResult("ResultMsg")).' 코드 : '.$inipay->GetResult("ResultCode")); +} + +?> \ No newline at end of file diff --git a/shop/inicis/key/INIpayTest/keypass.enc b/shop/inicis/key/INIpayTest/keypass.enc new file mode 100644 index 000000000..d6583cb9a --- /dev/null +++ b/shop/inicis/key/INIpayTest/keypass.enc @@ -0,0 +1 @@ +pm/4rSNJdLw= diff --git a/shop/inicis/key/INIpayTest/mcert.pem b/shop/inicis/key/INIpayTest/mcert.pem new file mode 100644 index 000000000..00ce5d78a --- /dev/null +++ b/shop/inicis/key/INIpayTest/mcert.pem @@ -0,0 +1,16 @@ +-----BEGIN CERTIFICATE----- +MIICmzCCAgQCAQAwDQYJKoZIhvcNAQEEBQAwgZUxCzAJBgNVBAYTAktSMRUwEwYD +VQQIDAzrjIDtlZzrr7zqta0xDTALBgNVBAcTBG51bGwxGjAYBgNVBAoMESjso7wp +7J2064uI7Iuc7IqkMQswCQYDVQQLEwJFQzETMBEGA1UEAxMKSU5JcGF5VGVzdDEi +MCAGCgmSJomT8ixkAQMUEmx5dGFrNzFAaW5pY2lzLmNvbTAeFw0wNDAzMTUxMDAx +MjNaFw0wNTAzMTUxMDAxMjNaMIGVMQswCQYDVQQGEwJLUjEVMBMGA1UECAwM64yA +7ZWc66+86rWtMQ0wCwYDVQQHEwRudWxsMRowGAYDVQQKDBEo7KO8KeydtOuLiOyL +nOyKpDELMAkGA1UECxMCRUMxEzARBgNVBAMTCklOSXBheVRlc3QxIjAgBgoJkiaJ +k/IsZAEDFBJseXRhazcxQGluaWNpcy5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0A +MIGJAoGBAP6a/WaRyDMxHDgKHtahbZTnv+cayR0b052y2sCAGdgMc6CK0GxyvudV +KR7mltKhexur/ikaPKXXApK+SlXUvwNS7pdQ13BTNCeLlEg0WLjGoVi9n96AcjR/ +QqlmkFaVAQQe9X95uwAcCoIrkErrpFJNPhppTXfsPH8YpzegogPnAgMBAAEwDQYJ +KoZIhvcNAQEEBQADgYEAvmKuNAD7oPxOfRxj1EyBrKt2YdrhzMTvZXz7IIGCeKf0 +tsAKiuxuh20i6zWbD4N+twZvDYG23DFBsLb5Iw3pft5RK9OOVZJ8+ChAaDFHBa4a +RzLDmsdD9NsF7UfYb0KXFUnZMTW5ZKirWUq21MdQiqVNhuLs0zy2hAqABBwhICk= +-----END CERTIFICATE----- diff --git a/shop/inicis/key/INIpayTest/mpriv.pem b/shop/inicis/key/INIpayTest/mpriv.pem new file mode 100644 index 000000000..39f960a71 --- /dev/null +++ b/shop/inicis/key/INIpayTest/mpriv.pem @@ -0,0 +1,18 @@ +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: DES-EDE3-CBC,1E6B60D94624128F + ++9VjCYsbhvQIrQVWRmTV1dBc3HpHbjDrnwEu8znuxO9dgN7ZKKahSOo/iZv9tzWr +SpEnbaGiRivO7/jTfJxgcy7wqjV+jYiwpBzL640JdOditUMoIxx3Rzxq+Dheuz13 +1dwt6f3d11zzXjIA5eQQXf1dBTjNCrxhAHqtHccWc5eP1QScQA+KdDAT+vQ6qTVq +aZOI+7BkfWt5YMYBienXwEZSK5ZJ0GU91xSwDApIwsq7E7JGBExPIXGJeZ/RDAVN +sKuO5Ny0JBNJN2Lym39Nb9lF0sKAedMiQNfaEnRqG37fh4H1ONo9NTYilENCIrg6 +tgYw/G9FrY8UvNLBsdUEUSV3bSqlRXZxP2TcPPrpYVbYZ1CQAH3fhVjAo9dpSNeI +KuGv3x+JAkuJ+SjhANUU+ChOm27tF7scUxDTfwzTGfyB3P1UFHDwf0nWMU5cuJRY +1+DLxEVL9FaZmonf5SZdf14Ln8a0cVdm+5rujFpFecSaw9K6gNFUvu6qF6CLx9/O +UgcL90Ga+EvMG1iWyCFGvbr53r4i776JG+rVergIcgT5winvYpKiOS9AOV5NXPPI +ev5PCXmDbnalmK6IrgrV0bAJD3d+NcN9JGFSx+GYKlw4OTrz/hxxuojPW6em4cfi +mEIl5JIiLoC2BqM+Jcs8UMq0TOS8Pcki4O05H9Juws5nh6+d5d2p2BcvkXc+SWF7 +ClfjMZDaniMzPZr1dQj5XFZwptN6jATYL/4u1CpXYKi3N6TwHbOtQD/2l4e+DNPR +JsSAW8ftyLAK0QJUTLhvA9Np9pzmO4hE7LfeRKBKpoU2PwKyXoO+PA== +-----END RSA PRIVATE KEY----- diff --git a/shop/inicis/key/INIpayTest/readme.txt b/shop/inicis/key/INIpayTest/readme.txt new file mode 100644 index 000000000..d7174692a --- /dev/null +++ b/shop/inicis/key/INIpayTest/readme.txt @@ -0,0 +1,10 @@ +Ű 3 - mcert.pem, mpriv.pem, keypass.enc - +"key/{̵}/" Ͻ α׷ ҽ + ݿϽʽÿ(޴ ). + +̵ : INIpayTest +Űн : 1111 + Ʈ н : 1111 + + Ʈ https://iniweb.inicis.com̸, +α ̵ ̵Դϴ. diff --git a/shop/inicis/key/iniescrow0/keypass.enc b/shop/inicis/key/iniescrow0/keypass.enc new file mode 100644 index 000000000..e4205d8ef --- /dev/null +++ b/shop/inicis/key/iniescrow0/keypass.enc @@ -0,0 +1 @@ +pm/4rSNJdLw= diff --git a/shop/inicis/key/iniescrow0/mcert.pem b/shop/inicis/key/iniescrow0/mcert.pem new file mode 100644 index 000000000..77304aebd --- /dev/null +++ b/shop/inicis/key/iniescrow0/mcert.pem @@ -0,0 +1,17 @@ +-----BEGIN CERTIFICATE----- +MIICnTCCAgYCAQAwDQYJKoZIhvcNAQEEBQAwgZYxCzAJBgNVBAYTAktSMRUwEwYD +VQQIDAzrjIDtlZzrr7zqta0xDTALBgNVBAcTBG51bGwxGjAYBgNVBAoMESjso7wp +7J2064uI7Iuc7IqkMQswCQYDVQQLEwJFQzETMBEGA1UEAxMKaW5pZXNjcm93MDEj +MCEGCgmSJomT8ixkAQMUE2RkYWVtaXJpQGluaWNpcy5jb20wHhcNMDgwMTE2MDQ0 +MTU1WhcNMDkwMTE1MDQ0MTU1WjCBljELMAkGA1UEBhMCS1IxFTATBgNVBAgMDOuM +gO2VnOuvvOq1rTENMAsGA1UEBxMEbnVsbDEaMBgGA1UECgwRKOyjvCnsnbTri4js +i5zsiqQxCzAJBgNVBAsTAkVDMRMwEQYDVQQDEwppbmllc2Nyb3cwMSMwIQYKCZIm +iZPyLGQBAxQTZGRhZW1pcmlAaW5pY2lzLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOB +jQAwgYkCgYEAxElWzHNgDFZpwNvPGbWtA0PKTDPfeP1r7xE/k2n2XMzBFQFxbjSC +EBKbQzFRVbNJv4Jyon/OzlywSR3A1DYMm5Oy9Vh3OOrH2FiYxMXClp7MynnmFEug +ysHuYOHlMnoEfI5k8h9hIXlYbRFDLdY7IxVzqkaYJ37HX01Apuxo8sUCAwEAATAN +BgkqhkiG9w0BAQQFAAOBgQCPrVeBW8+anq3CORMYU5TX1tfrYeCzLFH2hkDJF0Rr +1xWxgjhdFZxtBtYSbxr3UKFe6/EWrlv7k37LoM8ORYcNZun+Rd1jz5xwTOjLBTsd +UGwgUpgBLB1z9GoZgaeJJOm7BFUE0Jp7laI0zWkpWeova2RUT1PODnQMvRNi2d88 +vQ== +-----END CERTIFICATE----- diff --git a/shop/inicis/key/iniescrow0/mpriv.pem b/shop/inicis/key/iniescrow0/mpriv.pem new file mode 100644 index 000000000..ba54f77b2 --- /dev/null +++ b/shop/inicis/key/iniescrow0/mpriv.pem @@ -0,0 +1,18 @@ +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: DES-EDE3-CBC,FBB268FC75417BD4 + +G4/3WRZg/9peL3ym0S2LsTWvFkSCT/Co+qcCeKBunQ1UPH/pVyQjW0oxtmjBpBfp +YFNJmc5mEhwV30uKXLEYP6bhpHKlLDQWv926+UBIkSZ4cOkm9JNZUETlb+tlSgIN +i5l5KLaX198rGlQAEYX+TxTaxlfXxoBiXkoqxs64Jn0RApy1SPTXKjLffXHP2Yk5 +q3jOZ4z4REdnmkH5NYuRHz6cyRr4XdmvPFMwBpzOL08go6yToYfYRvyO4hf2T1Kl +ug1ws6e1HNSm1t3PrZP2kj1oIQef80/DQf9eu1mOP0VQD1GlQSydt2+kAdEBba4d +FIlpO3oGCbCB1UhBOBCllFlXvd4sqj1inZhHS/g9R0vAwAPVpsssXYnWL2qnb+zj +gfSyk+ao56sOBIwhyFXX9IdLcFKMGVQDrxZhDxVieStwk9iVK4zGZW+clS+TzFY7 +8qPDP53vXenumSnVq11Mj5gKwJzy40wGm61bQR1B5ldJJW7978Njahh0T0ZCxu48 +n5H0FbVu9wrILehWxEI5IrXAAGbRYDlurSSvHtOX1qL0WvJa4EQD9De3u8kqD3Yx +soKJqII277UQBpPuyyE+eP1F+7i4cQdfCU31sK1LMz/wiJxRrG1CiOpV1FH22ABy +vxAh1gpTRgYHvNVWG37P9rYbrW2UcM4cjhbgOzTLhrThxteAgosaXWowc/lcobSB +G444RQXVPZEetqt2In2kBr7UmE2WuvM0CrC6sD336K2t0q/5HLPLntGozdadZ4F5 +OS8Oi8I9Ygiqwz95JSUaOfETGZ6RpGRJXL9ysimBeEDuQmQ2lxtkZA== +-----END RSA PRIVATE KEY----- diff --git a/shop/inicis/key/iniescrow0/readme.txt b/shop/inicis/key/iniescrow0/readme.txt new file mode 100644 index 000000000..f4b770416 --- /dev/null +++ b/shop/inicis/key/iniescrow0/readme.txt @@ -0,0 +1,19 @@ + +please read this README.TXT file + +ZIP file contains following 3 files. + - mcert.pem + - mpriv.pem + - keypass.enc + +Copy these 3 files to directory [key/iniescrow0]. + +Merchant ID : iniescrow0 +Key Password : 1111 +Admin Password: 1111 + +please visit https://iniweb.inicis.com +for your Merchant Administration. +This site provides your payment transaction details and account details by calculation period. + +You can also log on this site using your Merchant ID(iniescrow0). diff --git a/shop/inicis/key/keypass.enc b/shop/inicis/key/keypass.enc new file mode 100644 index 000000000..e4205d8ef --- /dev/null +++ b/shop/inicis/key/keypass.enc @@ -0,0 +1 @@ +pm/4rSNJdLw= diff --git a/shop/inicis/key/mcert.pem b/shop/inicis/key/mcert.pem new file mode 100644 index 000000000..70baf94e5 --- /dev/null +++ b/shop/inicis/key/mcert.pem @@ -0,0 +1,17 @@ +-----BEGIN CERTIFICATE----- +MIICtDCCAhwCAQAwDQYJKoZIhvcNAQEEBQAwgaExCzAJBgNVBAYTAktSMRUwEwYD +VQQIDAzrjIDtlZzrr7zqta0xDTALBgNVBAcTBG51bGwxJTAjBgNVBAoMHFNL7Luk +666k64uI7LyA7J207IWY7KaIKOyjvCkxCzAJBgNVBAsTAkVDMRMwEQYDVQQDEwpD +eXdvcmxkMDE0MSMwIQYKCZImiZPyLGQBAxQTc3VuZ21vY2tAaW5pY2lzLmNvbTAe +Fw0wNzExMTIwNjExMzBaFw0wODExMTEwNjExMzBaMIGhMQswCQYDVQQGEwJLUjEV +MBMGA1UECAwM64yA7ZWc66+86rWtMQ0wCwYDVQQHEwRudWxsMSUwIwYDVQQKDBxT +S+y7pOuupOuLiOy8gOydtOyFmOymiCjso7wpMQswCQYDVQQLEwJFQzETMBEGA1UE +AxMKQ3l3b3JsZDAxNDEjMCEGCgmSJomT8ixkAQMUE3N1bmdtb2NrQGluaWNpcy5j +b20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAV0zuTBHq1SZWArRHCNz1jlU +WUyTK3Gv6BGq3J6Tly/o6g51Nbjcu2TYMXLIhMgsqDPeJzOnXbSvnh3FWgAMcFm/ +EZEs9oKw+jkiPfIEeSc7KZThqDm1oG4FgJZrXim6Y3jlLLaW1h0WyapCV2u60759 +LX8YzmmFmUuXGZOb5s7DAgMBAAEwDQYJKoZIhvcNAQEEBQADgYIAAN4AumokztkK +z5UBScG4Ccvu3nwcuFlCqzDUm9xnZyfy96RIjTJjVelkLwk6NFPqbDEyDLmHm6fe +Zus+fvZBKQAyHigfuS/RVitcup52OkWCZerbcWsziX8Pzqb/MHu19Elt+y/QYe5x +ysyIsZn47Bp+7kbQtlMjJecXGEFfmoi1 +-----END CERTIFICATE----- diff --git a/shop/inicis/key/mpriv.pem b/shop/inicis/key/mpriv.pem new file mode 100644 index 000000000..3d30395f3 --- /dev/null +++ b/shop/inicis/key/mpriv.pem @@ -0,0 +1,18 @@ +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: DES-EDE3-CBC,6B92FB59B7AB8A00 + +NSplji6yUKrk1LXAid9TcBIOSkA+oE+5b52s7GaebioGsGSMIW7RrK8VHWlTOpxs +GnFkTNg3ALZucdhYiAdm6vzaGmmJogoPnmpevs2JIDl3rkgcQH0AVU6nkKg9EcuP +QP/2DknfqzNO46fTMjUIRSrJ7AauDz6836Mm3GVNl7cA42ecM7xHSVK3ZvCvpTrJ +A9ik1zWZbzCIKg/mgMJkHu8xO8K9GKQAY1OM0KxK+oqS/Txmi6RplCHlrTAR+Ahb +J3W8vG3tCu6orlczvPYEnB0a1E/dycDPziBFm6nVAk8cb+yPbZnl/Nqfu6nvPsSx +iJYJR9YZ6L5i/IIhBc8tjNWeDB1KLsXZY41B//D/pjr9nfFUcJex8uPpOA0+GnGz +EhDT8j/WMylgAxKKIYjFqE7HnMQ+n+ZZqLKO6JLdu3HHNz0QC7nz/SZtEMw/of4e +1DlFHDTLTg0vJxwuLSBHVQN3H7SiFbxc/U5UmZEEVPprwbS9m0ok9JmBdfCv8iqu +vuJiYc3HCdJaTRu0U3fJM33yr//BrZxXw0RjABePprcQDf590Vws8tygc/L5voF6 +lw8JYXuWKuRn4soNKwhrLL9YvQ0FNy1ITS2MpKGNYRPp5l3YCKO19y1dLMwrA33k +SL1laFxrXLDaaE7MJZ8VD9hIymnn0aivtJHelW9DNoWJdI/DgTNKRhgT2TWBqR09 +VVCCKF3RLAQMvOFq/49A68px8/xHKxd6pYis/l8BONlZBMYRyIgjZ0IU81pmvHm+ +8UphsgRGx1ZvNtP0ApnTMF9DdpPN6vkxmpDWTe93HWJTp3TV1wyZPA== +-----END RSA PRIVATE KEY----- diff --git a/shop/inicis/key/pgcert.pem b/shop/inicis/key/pgcert.pem new file mode 100644 index 000000000..745cd7c38 --- /dev/null +++ b/shop/inicis/key/pgcert.pem @@ -0,0 +1,21 @@ +-----BEGIN CERTIFICATE----- +MIIDcTCCAtqgAwIBAgIBHjANBgkqhkiG9w0BAQQFADCBiDELMAkGA1UEBhMCS1Ix +DjAMBgNVBAgTBVNlb3VsMRgwFgYDVQQKEw9JbmljaXMgQ28sIEx0ZC4xDzANBgNV +BAsTBklOSXBheTEfMB0GA1UEAxMWSU5JcGF5IFBheW1lbnQgR2F0ZXdheTEdMBsG +CSqGSIb3DQEJARYOZGV2QGluaWNpcy5jb20wHhcNMDcwOTA2MDYxNTI0WhcNMTcw +OTAzMDYxNTI0WjCBiDELMAkGA1UEBhMCS1IxDjAMBgNVBAgTBVNlb3VsMRgwFgYD +VQQKEw9JbmljaXMgQ28sIEx0ZC4xDzANBgNVBAsTBklOSXBheTEfMB0GA1UEAxMW +SU5JcGF5IFBheW1lbnQgR2F0ZXdheTEdMBsGCSqGSIb3DQEJARYOZGV2QGluaWNp +cy5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAOC8v1rxqoo7tonq7t4d +c3FVfIlLyA9ku+l9+d5pUQrbiUXDe8NoJZnoSyud4WhOUrN2ZpzNmjGxuPquYrT/ +LkXoR+ib9OAhFBp7izstjHEA+oUNTVO24MRRvOHWWaLrCeTNX9PeaZl9ploojyHc +Uxm5/gIlPEojiaWNc3HVnb55AgMBAAGjgegwgeUwHQYDVR0OBBYEFGgqMfJUMSUQ +pjyGnurepI+NUf6JMIG1BgNVHSMEga0wgaqAFGgqMfJUMSUQpjyGnurepI+NUf6J +oYGOpIGLMIGIMQswCQYDVQQGEwJLUjEOMAwGA1UECBMFU2VvdWwxGDAWBgNVBAoT +D0luaWNpcyBDbywgTHRkLjEPMA0GA1UECxMGSU5JcGF5MR8wHQYDVQQDExZJTklw +YXkgUGF5bWVudCBHYXRld2F5MR0wGwYJKoZIhvcNAQkBFg5kZXZAaW5pY2lzLmNv +bYIBHjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUAA4GBANUj8vYzU2Q9pebQ +yX+6U9e36DeO/+15iDgU2PRK63uPaEa6vMqN2ibI8twolZB2t2oqIRgO44Hf3Nyf +1XKNzCP1eRF1XreGOnrPZtJ5UeUs3RNBqvQkIAdSW80jkXw0i/7i95BYxRIJWSIE +2fLjemy6r8gAQgWRAPv32F0xwRRT +-----END CERTIFICATE----- \ No newline at end of file diff --git a/shop/inicis/key/readme.txt b/shop/inicis/key/readme.txt new file mode 100644 index 000000000..d8d53d59f --- /dev/null +++ b/shop/inicis/key/readme.txt @@ -0,0 +1,19 @@ + +please read this README.TXT file + +ZIP file contains following 3 files. + - mcert.pem + - mpriv.pem + - keypass.enc + +Copy these 3 files to directory [key/Cyworld014]. + +Merchant ID : Cyworld014 +Key Password : 1111 +Admin Password: 1111 + +please visit https://iniweb.inicis.com +for your Merchant Administration. +This site provides your payment transaction details and account details by calculation period. + +You can also log on this site using your Merchant ID(Cyworld014). diff --git a/shop/inicis/key/rndseed.binary b/shop/inicis/key/rndseed.binary new file mode 100644 index 000000000..6d7bc5219 Binary files /dev/null and b/shop/inicis/key/rndseed.binary differ diff --git a/shop/inicis/libs/INICls.php b/shop/inicis/libs/INICls.php new file mode 100644 index 000000000..088d41a57 --- /dev/null +++ b/shop/inicis/libs/INICls.php @@ -0,0 +1,1339 @@ +debug_msg = array("", "CRITICAL", "ERROR", "NOTICE", "4", "INFO", "6", "DEBUG", "8"); + $this->debug_mode = $request["debug"]; + $this->type = $request["type"]; + $this->log = $request["log"]; + $this->homedir = $request["inipayhome"]; + $this->mid = $request["mid"]; + $this->starttime = GetMicroTime(); + $this->mergelog = $request["mergelog"]; + } + + function StartLog() { + if ($this->log == "false") + return true; + + if ($this->type == "chkfake") + $type = "securepay"; + else + $type = $this->type; + if ($this->mergelog == "1") + $logfile = $this->homedir . "/log/" . PROGRAM . "_" . $type . "_mergelog_" . date("ymd") . ".log"; + else + $logfile = $this->homedir . "/log/" . PROGRAM . "_" . $type . "_" . $this->mid . "_" . date("ymd") . ".log"; + $this->handle = fopen($logfile, "a+"); + if (!$this->handle) + return false; + $this->WriteLog(INFO, "START " . PROGRAM . " " . $this->type . " (V" . VERSION . "-" . BUILDDATE . ")(OS:" . php_uname('s') . php_uname('r') . ",PHP:" . phpversion() . ")"); + return true; + } + + function WriteLog($debug, $data) { + if ($this->log == "false" || !$this->handle) + return; + + if (!$this->debug_mode && $debug >= DEBUG) + return; + + $pfx = $this->debug_msg[$debug] . "\t[" . SetTimestamp() . "] <" . getmypid() . "> "; + if (is_array($data)) { + foreach ($data as $key => $val) { + fwrite($this->handle, $pfx . $key . ":" . $val . "\r\n"); + } + } else { + fwrite($this->handle, $pfx . $data . "\r\n"); + } + fflush($this->handle); + } + + function CloseLog($msg) { + if ($this->log == "false") + return; + + $laptime = GetMicroTime() - $this->starttime; + $this->WriteLog(INFO, "END " . $this->type . " " . $msg . " Laptime:[" . round($laptime, 3) . "sec]"); + $this->WriteLog(INFO, "==============================================================="); + fclose($this->handle); + } + +} + +/* ----------------------------------------------------- */ +/* Data Class */ +/* -TID Generate Function */ +/* -Data Encrypt Function */ +/* -Check Field Function */ +/* ----------------------------------------------------- */ + +class INIData { + + //---------------------------- + //Common + //---------------------------- + var $m_Type; + var $m_EscrowType; + var $m_ErrCode; + var $m_ErrMsg; + var $m_EncBody; + var $m_PG1; + var $m_PG2; + var $m_PG1IP; + var $m_PG2IP; + //---------------------------- + //IFD ûʵ + //---------------------------- + var $m_sCmd; + var $m_sCrypto; + var $m_sTID; + var $m_sPayMethod; + var $m_MPubSN; + var $m_PIPGPubSN; + var $m_TXPGPubSN; + var $m_TXVersion; + var $m_sMsg; + var $m_sHead; + var $m_sBody; + var $m_sTail; + var $m_sEncrypted; + var $m_sSessionKey; + //---------------------------- + //IFD ʵ + //---------------------------- + var $m_FlgCrypto; + var $m_FlgSign; + var $m_Cmd; + var $m_Body; + //Xml Data + var $m_Xml = array(); + var $m_REQUEST = array(); + var $m_REQUEST2 = array(); //User Defined Entity + var $m_RESULT = array(); //Encrypted ʵ hash table + var $m_RESULT2 = array(); //PG Added Entity + + function INIData($request, $request2) { + $this->m_Xml = NULL; + + $this->m_REQUEST = $request; + $this->m_REQUEST2 = $request2; + + $this->m_Type = $this->m_REQUEST["type"]; + if ($this->m_Type == TYPE_SECUREPAY || $this->m_Type == TYPE_AUTH) { + $this->m_sCmd = CMD_REQ_PAY; + $this->m_sCrypto = FLAG_CRYPTO_RC4; + } else if ($this->m_Type == TYPE_CANCEL) { + $this->m_sCmd = CMD_REQ_CAN; + $this->m_sCrypto = FLAG_CRYPTO_3DES; + } else if ($this->m_Type == TYPE_INQUIRY) { + $this->m_sCmd = CMS_REQ_INQR; + $this->m_sCrypto = FLAG_CRYPTO_3DES; + } else if ($this->m_Type == TYPE_OPENSUB) { + $this->m_sCmd = CMS_REQ_OPEN_SUB; + $this->m_sCrypto = FLAG_CRYPTO_3DES; + } + // κȯ ߰ + else if (( $this->m_Type == TYPE_REPAY) || ( $this->m_Type == TYPE_VACCTREPAY)) { + $this->m_sCmd = CMD_REQ_PRTC; + $this->m_sCrypto = FLAG_CRYPTO_3DES; + } else if ($this->m_Type == TYPE_CAPTURE) { + $this->m_sCmd = CMD_REQ_CAP; + $this->m_sCrypto = FLAG_CRYPTO_3DES; + } else if ($this->m_Type == TYPE_ESCROW) { + $this->m_EscrowType = $this->m_REQUEST["escrowtype"]; + if ($this->m_EscrowType == TYPE_ESCROW_DLV) { + $this->m_sCmd = CMD_REQ_DLV; + $this->m_sCrypto = FLAG_CRYPTO_3DES; + } else if ($this->m_EscrowType == TYPE_ESCROW_CNF) { + parse_str($this->m_REQUEST["encrypted"]); + if ($iniescr_type == "1") {//confirm + $this->m_EscrowType = TYPE_ESCROW_CNF; + $this->m_sCmd = CMD_REQ_CNF; + $this->m_sCrypto = FLAG_CRYPTO_RC4; + } else if ($iniescr_type == "2") {//deny + $this->m_EscrowType = TYPE_ESCROW_DNY; + $this->m_sCmd = CMD_REQ_DNY; + $this->m_sCrypto = FLAG_CRYPTO_RC4; + } + } else if ($this->m_EscrowType == TYPE_ESCROW_DNY_CNF) { + $this->m_sCmd = CMD_REQ_DNY_CNF; + $this->m_sCrypto = FLAG_CRYPTO_3DES; + } + } else if ($this->m_Type == TYPE_REFUND) { //ȯ(09.08.05) + $this->m_sCmd = CMD_REQ_RFD; + $this->m_sCrypto = FLAG_CRYPTO_3DES; + } else { + $this->m_sCmd = CMD_REQ_PAY; + $this->m_sCrypto = FLAG_CRYPTO_3DES; + } + $this->m_sPayMethod = $this->m_REQUEST["paymethod"]; + + $this->m_TXVersion = sprintf("%-4.4s", VERSION) . + sprintf("B%-6.6s", BUILDDATE) . + sprintf("%-5.5s", $this->m_Type) . + sprintf("%-10.10s", php_uname('s')) . + sprintf("%-3.3s", "PHP") . //modulescript + sprintf("%-10.10s", "chkfake") . //moduledesc + sprintf("%-30.30s", php_uname('r') . "PHP:" . phpversion()) //ETCINFO + ; + } + + function CheckField() { + //--------------------------------- + // + //--------------------------------- + if (trim($this->m_REQUEST["inipayhome"]) == "") { + $this->m_ErrCode = NULL_DIR_ERR; + $this->m_ErrMsg = "inipayhome"; + return false; + } + if (trim($this->m_REQUEST["mid"]) == "") { + $this->m_ErrCode = NULL_MID_ERR; + $this->m_ErrMsg = "mid"; + return false; + } + if (trim($this->m_REQUEST["type"]) == "") { + $this->m_ErrCode = NULL_TYPE_ERR; + $this->m_ErrMsg = "type"; + return false; + } + if (trim($this->m_REQUEST["admin"]) == "") { + $this->m_ErrCode = NULL_KEYPW_ERR; + $this->m_ErrMsg = "admin"; + return false; + } + //--------------------------------- + //type + //--------------------------------- + if ($this->m_Type == TYPE_SECUREPAY) { + /* + //delete UIP(2009.01.21) + if( trim($this->m_REQUEST["uip"]) == "") + { + $this->m_ErrCode = NULL_UIP_ERR; + $this->m_ErrMsg = "uip"; + return false; + } + */ + if (trim($this->m_REQUEST["url"]) == "") { + $this->m_ErrCode = NULL_URL_ERR; + $this->m_ErrMsg = "url"; + return false; + } + if (trim($this->m_REQUEST["price"]) == "") { + $this->m_ErrCode = NULL_PRICE_ERR; + $this->m_ErrMsg = "price"; + return false; + } + if (trim($this->m_REQUEST["currency"]) == "") { + $this->m_ErrCode = NULL_CURRENCY_ERR; + $this->m_ErrMsg = "currency"; + return false; + } + if (trim($this->m_REQUEST["paymethod"]) == "") { + $this->m_ErrCode = NULL_PAYMETHOD_ERR; + $this->m_ErrMsg = "paymethod"; + return false; + } + if (trim($this->m_REQUEST["goodname"]) == "") { + $this->m_ErrCode = NULL_GOODNAME_ERR; + $this->m_ErrMsg = "goodname"; + return false; + } + if (trim($this->m_REQUEST["buyername"]) == "") { + $this->m_ErrCode = NULL_BUYERNAME_ERR; + $this->m_ErrMsg = "buyername"; + return false; + } + if (trim($this->m_REQUEST["buyertel"]) == "") { + $this->m_ErrCode = NULL_BUYERTEL_ERR; + $this->m_ErrMsg = "buyertel"; + return false; + } + if (trim($this->m_REQUEST["buyeremail"]) == "") { + $this->m_ErrCode = NULL_BUYEREMAIL_ERR; + $this->m_ErrMsg = "buyeremail"; + return false; + } + if (trim($this->m_REQUEST["sessionkey"]) == "") { + $this->m_ErrCode = NULL_SESSIONKEY_ERR; + $this->m_ErrMsg = "sessionkey"; + return false; + } + if (trim($this->m_REQUEST["encrypted"]) == "") { + $this->m_ErrCode = NULL_ENCRYPTED_ERR; + $this->m_ErrMsg = "encrypted"; + return false; + } + } else if ($this->m_Type == TYPE_CANCEL) { + if (trim($this->m_REQUEST["tid"]) == "") { + $this->m_ErrCode = NULL_TID_ERR; + $this->m_ErrMsg = "tid"; + return false; + } + } + // κȯҵ κȯ ߰ + else if (( $this->m_Type == TYPE_REPAY ) || ( $this->m_Type == TYPE_VACCTREPAY )) { + if (trim($this->m_REQUEST["oldtid"]) == "") { + $this->m_ErrCode = NULL_TID_ERR; + $this->m_ErrMsg = "oldtid"; + return false; + } + if (trim($this->m_REQUEST["price"]) == "") { + $this->m_ErrCode = NULL_PRICE_ERR; + $this->m_ErrMsg = "price"; + return false; + } + if (trim($this->m_REQUEST["confirm_price"]) == "") { + $this->m_ErrCode = NULL_CONFIRM_PRICE_ERR; + $this->m_ErrMsg = "confirm_price"; + return false; + } + + // κȯ ȣ,ڵ,ָ ʼ + if ($this->m_Type == TYPE_VACCTREPAY) { + if (trim($this->m_REQUEST["refundacctnum"]) == "") { + $this->m_ErrCode = NULL_FIELD_REFUNDACCTNUM; + $this->m_ErrMsg = "ȯҰ¹ȣ"; + return false; + } + if (trim($this->m_REQUEST["refundbankcode"]) == "") { + $this->m_ErrCode = NULL_FIELD_REFUNDBANKCODE; + $this->m_ErrMsg = "ȯڵ"; + return false; + } + if (trim($this->m_REQUEST["refundacctname"]) == "") { + $this->m_ErrCode = NULL_FIELD_REFUNDACCTNAME; + $this->m_ErrMsg = "ȯҰּ"; + return false; + } + } + } else if ($this->m_Type == TYPE_CHKFAKE) { + if (trim($this->m_REQUEST["nointerest"]) == "") { + $this->m_ErrCode = NULL_NOINTEREST_ERR; + $this->m_ErrMsg = "nointerest"; + return false; + } + if (trim($this->m_REQUEST["quotabase"]) == "") { + $this->m_ErrCode = NULL_QUOTABASE_ERR; + $this->m_ErrMsg = "quotabase"; + return false; + } + } else if ($this->m_Type == TYPE_REFUND) { + if (trim($this->m_REQUEST["tid"]) == "") { + $this->m_ErrCode = NULL_TID_ERR; + $this->m_ErrMsg = "tid"; + return false; + } + if (trim($this->m_REQUEST["racctnum"]) == "") { + $this->m_ErrCode = NULL_FIELD_REFUNDACCTNUM; + $this->m_ErrMsg = "ȯҰ¹ȣ"; + return false; + } + if (trim($this->m_REQUEST["rbankcode"]) == "") { + $this->m_ErrCode = NULL_FIELD_REFUNDBANKCODE; + $this->m_ErrMsg = "ȯڵ"; + return false; + } + if (trim($this->m_REQUEST["racctname"]) == "") { + $this->m_ErrCode = NULL_FIELD_REFUNDACCTNAME; + $this->m_ErrMsg = "ȯҰּ"; + return false; + } + } + return true; + } + + function MakeRN() { + list($usec, $sec) = explode(" ", microtime()); + $datestr = date("YmdHis", $sec) . substr($usec, 2, 3); //YYYYMMDDHHMMSSSSS + return Base64Encode($datestr . rand(10000, 99999)); + } + + function MakeTID() { + list($usec, $sec) = explode(" ", microtime()); + $datestr = date("YmdHis", $sec) . substr($usec, 2, 3); //YYYYMMDDHHMMSSSSS + + $datestr_con = substr($datestr, 0, 14) . substr($datestr, 15, 2); //YYYYMMDDHHMMSSxSS ߰ x (milli second ù° ڸ) + + mt_srand(getmypid() * mt_rand(1, 999)); //mt_rand ϱ srand seed , seed key = pid * mt_rand(1,999) + //pgid + mid + 16ڸ ¥ ð + random_key 4ڸ (seed) + $this->m_sTID = $this->m_REQUEST["pgid"] . $this->m_REQUEST["mid"] . $datestr_con . mt_rand(1000, 9999); + if (strlen($this->m_sTID) != TID_LEN) { + return false; + } + $this->m_REQUEST["tid"] = $this->m_sTID; + return true; + } + + function GenRand($length, $nullOk, $ascii = false) { + # mt_srand( 99999 ); + $out = ''; + for ($i = 0; $i < $length; $i++) + $out .= chr(mt_rand($nullOk ? 0 : 1, $ascii ? 127 : 255 )); + return $out; + } + + function MakeEncrypt($INICrypto) { + //generate key/iv + $key = $this->GenRand(MAX_KEY_LEN, true); + $iv = $this->GenRand(MAX_IV_LEN, true); + + //make XML + $xml = new XML(); + if ($this->m_Type == TYPE_FORMPAY) { + + } else if ($this->m_Type == TYPE_RECEIPT) { + $PI = $xml->add_node("", PAYMENTINFO); + $PM = $xml->add_node($PI, PAYMENT); + $CS = $xml->add_node($PM, NM_CSHR); + $PD = $xml->add_node($CS, TX_CSHR_APPLPRICE, $this->m_REQUEST["cr_price"]); + $PD = $xml->add_node($CS, TX_CSHR_SUPPLYPRICE, $this->m_REQUEST["sup_price"]); + $PD = $xml->add_node($CS, TX_CSHR_TAX, $this->m_REQUEST["tax"]); + $PD = $xml->add_node($CS, TX_CSHR_SERVICEPRICE, $this->m_REQUEST["srvc_price"]); + $PD = $xml->add_node($CS, TX_CSHR_TYPE, $this->m_REQUEST["useopt"]); + $PD = $xml->add_node($CS, TX_CSHR_REGNUM, $this->m_REQUEST["reg_num"]); + $PD = $xml->add_node($CS, TX_CSHR_COMPANYNUM, $this->m_REQUEST["companynumber"]); + /* + $PD = $xml->add_node($CS, TX_CSHR_OPENMARKET, $this->m_REQUEST[""] ); + $PD = $xml->add_node($CS, TX_CSHR_SUBCNT, $this->m_REQUEST[""] ); + $PD = $xml->add_node($CS, TX_CSHR_SUBCOMPANYNAME1, $this->m_REQUEST[""] ); + $PD = $xml->add_node($CS, TX_CSHR_SUBCOMPANYNUM1, $this->m_REQUEST[""] ); + $PD = $xml->add_node($CS, TX_CSHR_SUBREGNUM1, $this->m_REQUEST[""] ); + $PD = $xml->add_node($CS, TX_CSHR_SUBMID1, $this->m_REQUEST[""] ); + $PD = $xml->add_node($CS, TX_CSHR_SUBAPPLPRICE1, $this->m_REQUEST[""] ); + $PD = $xml->add_node($CS, TX_CSHR_SUBSERVICEPRICE1, $this->m_REQUEST[""] ); + */ + } else if ($this->m_Type == TYPE_CANCEL) { + $CI = $xml->add_node("", CANCELINFO); + $CD = $xml->add_node($CI, TX_CANCELTID, $this->m_REQUEST["tid"]); + $CD = $xml->add_node($CI, TX_CANCELMSG, $this->m_REQUEST["cancelmsg"], array("urlencode" => "1")); + $CD = $xml->add_node($CI, TX_CANCELREASON, $this->m_REQUEST["cancelcode"]); + $this->AddUserDefinedEntity(CANCELINFO, "", $xml, $CI); + } else if ($this->m_Type == TYPE_REPAY) { + //PartCancelInfo(ROOT) + $CI = $xml->add_node("", PARTCANCELINFO); + $CD = $xml->add_node($CI, TX_PRTC_TID, $this->m_REQUEST["oldtid"]); + $CD = $xml->add_node($CI, TX_PRTC_PRICE, $this->m_REQUEST["price"]); + $CD = $xml->add_node($CI, TX_PRTC_REMAINS, $this->m_REQUEST["confirm_price"]); + $CD = $xml->add_node($CI, TX_PRTC_QUOTA, $this->m_REQUEST["cardquota"]); + $CD = $xml->add_node($CI, TX_PRTC_INTEREST, $this->m_REQUEST["quotainterest"]); + //Iü κҽ ¹ȣ ּ 2011-10-06 + $CD = $xml->add_node($CI, TX_PRTC_NOACCT, $this->m_REQUEST["no_acct"]); + $CD = $xml->add_node($CI, TX_PRTC_NMACCT, $this->m_REQUEST["nm_acct"], array("urlencode" => "1")); + //, ߰ 2014-07-23 by jung.ks + //$CD = $xml->add_node($CI, TX_PRTC_TAX, $this->m_REQUEST["tax"] ); + //$CD = $xml->add_node($CI, TX_PRTC_TAXFREE, $this->m_REQUEST["taxfree"] ); + + $this->AddUserDefinedEntity(PARTCANCELINFO, "", $xml, $CI); + } + // κȯ + else if ($this->m_Type == TYPE_VACCTREPAY) { + //PartCancelInfo(ROOT) + $CI = $xml->add_node("", PARTCANCELINFO); + $CD = $xml->add_node($CI, TX_PRTC_TID, $this->m_REQUEST["oldtid"]); + $CD = $xml->add_node($CI, TX_PRTC_PRICE, $this->m_REQUEST["price"]); + $CD = $xml->add_node($CI, TX_PRTC_REMAINS, $this->m_REQUEST["confirm_price"]); + $CD = $xml->add_node($CI, TX_PRTC_QUOTA, $this->m_REQUEST["cardquota"]); + $CD = $xml->add_node($CI, TX_PRTC_INTEREST, $this->m_REQUEST["quotainterest"]); + $CD = $xml->add_node($CI, TX_PRTC_NOACCT, $this->m_REQUEST["refundacctnum"]); + $CD = $xml->add_node($CI, TX_PRTC_NMACCT, $this->m_REQUEST["refundacctname"], array("urlencode" => "1")); + $CD = $xml->add_node($CI, TX_PRTC_REFUNDFLGREMIT, $this->m_REQUEST["refundflgremit"]); + $CD = $xml->add_node($CI, TX_PRTC_REFUNDBANKCODE, $this->m_REQUEST["refundbankcode"]); + $this->AddUserDefinedEntity(PARTCANCELINFO, "", $xml, $CI); + } else if ($this->m_Type == TYPE_CAPTURE) { + $CI = $xml->add_node("", CAPTUREINFO); + $CD = $xml->add_node($CI, TX_CAPTURETID, $this->m_REQUEST["tid"]); + $this->AddUserDefinedEntity(CAPTUREINFO, "", $xml, $CI); + } else if ($this->m_Type == TYPE_ESCROW) { + if ($this->m_EscrowType == TYPE_ESCROW_DLV) { + $EI = $xml->add_node("", ESCROWINFO); + $EC = $xml->add_node($EI, ESCROW_DELIVERY); + $ED = $xml->add_node($EC, "DLV_Oid", $this->m_REQUEST["oid"], array("urlencode" => "1")); + $ED = $xml->add_node($EC, "DLV_SOid", $this->m_REQUEST["soid"], array("urlencode" => "1")); + $ED = $xml->add_node($EC, "DLV_Name", $this->m_REQUEST["dlv_name"], array("urlencode" => "1")); + $ED = $xml->add_node($EC, "DLV_IP", $this->m_REQUEST["dlv_ip"], array("urlencode" => "1")); + $ED = $xml->add_node($EC, "DLV_MAC", $this->m_REQUEST["dlv_mac"], array("urlencode" => "1")); + $ED = $xml->add_node($EC, "DLV_Report", $this->m_REQUEST["dlv_report"], array("urlencode" => "1")); + $ED = $xml->add_node($EC, "DLV_SendName", $this->m_REQUEST["dlv_sendname"], array("urlencode" => "1")); + $ED = $xml->add_node($EC, "DLV_SendPost", $this->m_REQUEST["dlv_sendpost"], array("urlencode" => "1")); + $ED = $xml->add_node($EC, "DLV_SendAddr1", $this->m_REQUEST["dlv_sendaddr1"], array("urlencode" => "1")); + $ED = $xml->add_node($EC, "DLV_SendAddr2", $this->m_REQUEST["dlv_sendaddr2"], array("urlencode" => "1")); + $ED = $xml->add_node($EC, "DLV_SendTel", $this->m_REQUEST["dlv_sendtel"], array("urlencode" => "1")); + $ED = $xml->add_node($EC, "DLV_RecvName", $this->m_REQUEST["dlv_recvname"], array("urlencode" => "1")); + $ED = $xml->add_node($EC, "DLV_RecvPost", $this->m_REQUEST["dlv_recvpost"], array("urlencode" => "1")); + $ED = $xml->add_node($EC, "DLV_RecvAddr", $this->m_REQUEST["dlv_recvaddr"], array("urlencode" => "1")); + $ED = $xml->add_node($EC, "DLV_RecvTel", $this->m_REQUEST["dlv_recvtel"], array("urlencode" => "1")); + $ED = $xml->add_node($EC, "DLV_ExCode", $this->m_REQUEST["dlv_excode"], array("urlencode" => "1")); + $ED = $xml->add_node($EC, "DLV_ExName", $this->m_REQUEST["dlv_exname"], array("urlencode" => "1")); + $ED = $xml->add_node($EC, "DLV_Invoice", $this->m_REQUEST["dlv_invoice"], array("urlencode" => "1")); + $ED = $xml->add_node($EC, "DLV_Charge", $this->m_REQUEST["dlv_charge"], array("urlencode" => "1")); + $ED = $xml->add_node($EC, "DLV_InvoiceDay", $this->m_REQUEST["dlv_invoiceday"], array("urlencode" => "1")); + $ED = $xml->add_node($EC, "DLV_GoodsCode", $this->m_REQUEST["dlv_goodscode"], array("urlencode" => "1")); + $ED = $xml->add_node($EC, "DLV_Goods", $this->m_REQUEST["dlv_goods"], array("urlencode" => "1")); + $ED = $xml->add_node($EC, "DLV_GoodsCnt", $this->m_REQUEST["dlv_goodscnt"], array("urlencode" => "1")); + $ED = $xml->add_node($EC, "DLV_Price", $this->m_REQUEST["price"], array("urlencode" => "1")); + $ED = $xml->add_node($EC, "DLV_Reserved1", $this->m_REQUEST["dlv_reserved1"], array("urlencode" => "1")); + $ED = $xml->add_node($EC, "DLV_Reserved2", $this->m_REQUEST["dlv_reserved2"], array("urlencode" => "1")); + $ED = $xml->add_node($EC, "DLV_Reserved3", $this->m_REQUEST["dlv_reserved3"], array("urlencode" => "1")); + } else if ($this->m_EscrowType == TYPE_ESCROW_CNF) { + //PluginIn!! + } else if ($this->m_EscrowType == TYPE_ESCROW_DNY) { + //PluginIn!! + } else if ($this->m_EscrowType == TYPE_ESCROW_DNY_CNF) { + $EI = $xml->add_node("", ESCROWINFO); + $EC = $xml->add_node($EI, ESCROW_DENYCONFIRM); + $ED = $xml->add_node($EC, "DCNF_Name", $this->m_REQUEST["dcnf_name"], array("urlencode" => "1")); + } + } else if ($this->m_Type == TYPE_REFUND) { + $CI = $xml->add_node("", CANCELINFO); + $CD = $xml->add_node($CI, TX_CANCELTID, $this->m_REQUEST["tid"]); + $CD = $xml->add_node($CI, TX_CANCELMSG, $this->m_REQUEST["cancelmsg"], array("urlencode" => "1")); + $CD = $xml->add_node($CI, TX_REFUNDACCTNUM, $this->m_REQUEST["racctnum"]); + $CD = $xml->add_node($CI, TX_REFUNDBANKCODE, $this->m_REQUEST["rbankcode"]); + $CD = $xml->add_node($CI, TX_REFUNDACCTNAME, $this->m_REQUEST["racctname"], array("urlencode" => "1")); + $this->AddUserDefinedEntity(CANCELINFO, "", $xml, $CI); + } else if ($this->m_Type == TYPE_INQUIRY) { + $CI = $xml->add_node("", INQUIRYINFO); + $CD = $xml->add_node($CI, TX_INQR_TID, $this->m_REQUEST["tid"]); + //$this->AddUserDefinedEntity( INQUIRYINFO, "", $xml, $CI ); + } else if ($this->m_Type == TYPE_OPENSUB) { + $OI = $xml->add_node("", OPENSUBINFO); + $OD = $xml->add_node($OI, TX_OPENREG_TID, $this->m_REQUEST["oldtid"]); + $OD = $xml->add_node($OI, TX_OPENREG_MID, $this->m_REQUEST["mid"]); + //$this->AddUserDefinedEntity( INQUIRYINFO, "", $xml, $CI ); + } + $this->m_EncBody = $xml->make_xml(); + + //encrypt body by SYMM + if (( $rtv = $INICrypto->SymmEncrypt($this->m_EncBody, $this->m_sEncrypted, $key, $iv)) != OK) + return $rtv; + + //encrypt key/iv by ASYMM + if (!$INICrypto->RSAPGPubEncrypt($key, $this->m_sSessionKey)) + return ENC_RSA_ERR; + + $this->m_sSessionKey = Base64Encode($this->m_sSessionKey . $iv); + + return OK; + } + + function MakeHead() { + $this->m_sHead = sprintf("%05d", strlen($this->m_sBody)); + $this->m_sHead .= sprintf("%05d", strlen($this->m_sTail)); + $this->m_sHead .= sprintf("%s", $this->m_sCrypto); + $this->m_sHead .= sprintf("%5s", FLAG_SIGN_SHA1); + $this->m_sHead .= sprintf("%20s", $this->m_MPubSN); + $this->m_sHead .= sprintf("%20s", $this->m_PIPGPubSN); + $this->m_sHead .= sprintf("%20s", $this->m_TXPGPubSN); + $this->m_sHead .= sprintf("%4s", $this->m_sCmd); + $this->m_sHead .= sprintf("%10s", $this->m_REQUEST["mid"]); + if ($this->m_Type == TYPE_RECEIPT) + $this->m_sHead .= sprintf("%20s", $this->m_REQUEST["cr_price"]); + else + $this->m_sHead .= sprintf("%20s", $this->m_REQUEST["price"]); + $this->m_sHead .= sprintf("%40s", $this->m_REQUEST["tid"]); + + $this->m_sMsg = $this->m_sHead . $this->m_sBody . $this->m_sTail; + return true; + } + + /* + /* Add User Defined Entity + /* Sample + /* $inipay->SetXPath("INIpay/GoodsInfo/UserDefined1","value1"); + /* $inipay->SetXPath("INIpay/GoodsInfo/UserDefined2","value2"); + /* $inipay->SetXPath("INIpay/GoodsInfo/Goods/UserDefined3","value3"); + /* $inipay->SetXPath("INIpay/GoodsInfo/Goods/UserDefined4","value4"); + /* $inipay->SetXPath("INIpay/BuyerInfo/UserDefined5","value5"); + /* $inipay->SetXPath("INIpay/BuyerInfo/UserDefined6","value6"); + /* $inipay->SetXPath("INIpay/PaymentInfo/Payment/UserDefined7","value7"); + /* $inipay->SetXPath("INIpay/PaymentInfo/Payment/UserDefined8","value8"); + /* $inipay->SetXPath("INIpay/ManageInfo/UserDefined9","value9"); + /* $inipay->SetXPath("INIpay/ReservedInfo/UserDefined10","value10"); + */ + + // + function AddUserDefinedEntity($info_node, $downnode, $xml, $upnode) { + foreach ($this->m_REQUEST2 as $key => $val) { + $node = explode('/', $key); + $node_cnt = count($node); + + if ($node_cnt < 3) + continue; //minumum 3 + if ($node[1] != $info_node) + continue; + if ($node_cnt == 3 && $downnode != "") + continue; + if ($node_cnt == 4 && $downnode != $node[2]) + continue; + + $last_node = substr(strrchr($key, '/'), 1); + $xml->add_node($upnode, $last_node, $val, array("urlencode" => "1")); + } + } + + function MakeBody() { + $xml = new XML(); + + //ROOT(INIpay) ROOT ROOTINFO 2011-05-23 + $root = $xml->add_node("", ROOTINFO); + + if ($this->m_Type == TYPE_SECUREPAY || $this->m_Type == TYPE_RECEIPT) { + //GoodsInfo + //ٱ ߰(2010.04.13) + //==goodscnt (ٱ ƴҰ) ⺻ 1 + $tGoodCnt = ($this->m_REQUEST["goodscnt"] != null && (int) $this->m_REQUEST["goodscnt"] > 0 ) ? $this->m_REQUEST["goodscnt"] : 1; + + $GI = $xml->add_node($root, GOODSINFO); + //ٱ ߰(2010.04.13) + //==TX_GOOSCNT $tGoodCnt Է + //$GP = $xml->add_node($GI, TX_GOOSCNT, "1" ); + $GP = $xml->add_node($GI, TX_GOOSCNT, $tGoodCnt); + $GP = $xml->add_node($GI, TX_MOID, $this->m_REQUEST["oid"], array("urlencode" => "1")); + $GP = $xml->add_node($GI, TX_CURRENCY, $this->m_REQUEST["currency"]); + $GP = $xml->add_node($GI, TX_TAX, $this->m_REQUEST["tax"]); + $GP = $xml->add_node($GI, TX_TAXFREE, $this->m_REQUEST["taxfree"]); + $this->AddUserDefinedEntity(GOODSINFO, "", $xml, $GI); + + //ٱ ߰(2010.04.13) [START] + //==ٱ XML ߰ + $iGoodCnt = 1; + while ($iGoodCnt <= $tGoodCnt) { + if ($this->m_REQUEST["smid_" . $iGoodCnt] != "" && strlen($this->m_REQUEST["smid_" . $iGoodCnt]) > 0) { + $GS = $xml->add_node($GI, GOODS); + $GD = $xml->add_node($GS, TX_SMID, $this->m_REQUEST["smid_" . $iGoodCnt]); + $GD = $xml->add_node($GS, TX_GOODSNAME, $this->m_REQUEST["goodsname_" . $iGoodCnt], array("urlencode" => "1")); + $GD = $xml->add_node($GS, TX_GOODSCNTS, $this->m_REQUEST["goodscnts_" . $iGoodCnt]); + if ($this->m_Type == TYPE_SECUREPAY) + $GD = $xml->add_node($GS, TX_GOODSPRICE, $this->m_REQUEST["goodsprice_" . $iGoodCnt]); + if ($this->m_Type == TYPE_RECEIPT) + $GD = $xml->add_node($GS, TX_GOODSPRICE, $this->m_REQUEST["cr_price"]); + } + else { + $GS = $xml->add_node($GI, GOODS); + $GD = $xml->add_node($GS, TX_SMID, $this->m_REQUEST["mid"]); + $GD = $xml->add_node($GS, TX_GOODSNAME, $this->m_REQUEST["goodname"], array("urlencode" => "1")); + + if ($this->m_Type == TYPE_SECUREPAY) + $GD = $xml->add_node($GS, TX_GOODSPRICE, $this->m_REQUEST["price"]); + if ($this->m_Type == TYPE_RECEIPT) + $GD = $xml->add_node($GS, TX_GOODSPRICE, $this->m_REQUEST["cr_price"]); + } + $iGoodCnt++; + } + //ٱ ߰(2010.04.13) [END] + + $this->AddUserDefinedEntity(GOODSINFO, GOODS, $xml, $GS); + //BuyerInfo + $BI = $xml->add_node($root, BUYERINFO); + $BP = $xml->add_node($BI, TX_BUYERNAME, $this->m_REQUEST["buyername"], array("urlencode" => "1")); + $BP = $xml->add_node($BI, TX_BUYERTEL, $this->m_REQUEST["buyertel"]); + $BP = $xml->add_node($BI, TX_BUYEREMAIL, $this->m_REQUEST["buyeremail"], array("urlencode" => "1")); + $BP = $xml->add_node($BI, TX_PARENTEMAIL, $this->m_REQUEST["parentemail"], array("urlencode" => "1")); + $BP = $xml->add_node($BI, TX_RECVNAME, $this->m_REQUEST["recvname"], array("urlencode" => "1")); + $BP = $xml->add_node($BI, TX_RECVTEL, $this->m_REQUEST["recvtel"], array("urlencode" => "1")); + $BP = $xml->add_node($BI, TX_RECVMSG, $this->m_REQUEST["recvmsg"], array("urlencode" => "1")); + $BP = $xml->add_node($BI, TX_RECVADDR, $this->m_REQUEST["recvaddr"], array("urlencode" => "1")); + $BP = $xml->add_node($BI, TX_RECVPOSTNUM, $this->m_REQUEST["recvpostnum"], array("urlencode" => "1")); + $this->AddUserDefinedEntity(BUYERINFO, "", $xml, $BI); + //PaymentInfo + $PI = $xml->add_node($root, PAYMENTINFO); + $PM = $xml->add_node($PI, PAYMENT); + $PD = $xml->add_node($PM, TX_PAYMETHOD, $this->m_REQUEST["paymethod"]); + $PD = $xml->add_node($PM, TX_JOINCARD, $this->m_REQUEST["joincard"]); + $PD = $xml->add_node($PM, TX_JOINEXPIRE, $this->m_REQUEST["joinexpire"]); + $PD = $xml->add_node($PM, TX_MAILORDER, $this->m_REQUEST["mailorder"]); + if ($this->m_Type == TYPE_SECUREPAY) { + $PD = $xml->add_node($PM, TX_SESSIONKEY, $this->m_REQUEST["sessionkey"]); + $PD = $xml->add_node($PM, TX_ENCRYPTED, $this->m_REQUEST["encrypted"], array("urlencode" => "1")); + } + if ($this->m_Type == TYPE_RECEIPT) { + $PD = $xml->add_node($PM, TX_SESSIONKEY, $this->m_sSessionKey); + $PD = $xml->add_node($PM, TX_ENCRYPTED, $this->m_sEncrypted); + } + $this->AddUserDefinedEntity(PAYMENTINFO, PAYMENT, $xml, $PM); + } else if ($this->m_Type == TYPE_CANCEL) { + //CancelInfo + $CI = $xml->add_node($root, CANCELINFO); + $CD = $xml->add_node($CI, TX_SESSIONKEY, $this->m_sSessionKey); + $CD = $xml->add_node($CI, TX_ENCRYPTED, $this->m_sEncrypted); + } + // κȯ߰ + else if (( $this->m_Type == TYPE_REPAY ) || ( $this->m_Type == TYPE_VACCTREPAY )) { + //PartCancelInfo + $CI = $xml->add_node($root, PARTCANCELINFO); + $CD = $xml->add_node($CI, TX_SESSIONKEY, $this->m_sSessionKey); + $CD = $xml->add_node($CI, TX_ENCRYPTED, $this->m_sEncrypted); + if ($this->m_Type == TYPE_REPAY) { + $CIG = $xml->add_node($root, GOODSINFO); + $CDG = $xml->add_node($CIG, TX_PRTC_TAX, $this->m_REQUEST["tax"]); + $CDG = $xml->add_node($CIG, TX_PRTC_TAXFREE, $this->m_REQUEST["taxfree"]); + $CDG = $xml->add_node($CIG, TX_PRTC_CURRENCY, $this->m_REQUEST["currency"]); + } + } else if ($this->m_Type == TYPE_CAPTURE) { + //CaptureInfo + $CI = $xml->add_node($root, CAPTUREINFO); + $CD = $xml->add_node($CI, TX_SESSIONKEY, $this->m_sSessionKey); + $CD = $xml->add_node($CI, TX_ENCRYPTED, $this->m_sEncrypted); + } else if ($this->m_Type == TYPE_ESCROW) { + //EscrowInfo + $CI = $xml->add_node($root, ESCROWINFO); + if ($this->m_EscrowType == TYPE_ESCROW_DLV || $this->m_EscrowType == TYPE_ESCROW_DNY_CNF) { + $CD = $xml->add_node($CI, TX_SESSIONKEY, $this->m_sSessionKey); + $CD = $xml->add_node($CI, TX_ENCRYPTED, $this->m_sEncrypted); + } else if ($this->m_EscrowType == TYPE_ESCROW_CNF || $this->m_EscrowType == TYPE_ESCROW_DNY) { + $CD = $xml->add_node($CI, TX_SESSIONKEY, $this->m_REQUEST["sessionkey"]); + $CD = $xml->add_node($CI, TX_ENCRYPTED, $this->m_REQUEST["encrypted"], array("urlencode" => "1")); + } + } else if ($this->m_Type == TYPE_REFUND) { + //CancelInfo + $CI = $xml->add_node($root, CANCELINFO); + $CD = $xml->add_node($CI, TX_SESSIONKEY, $this->m_sSessionKey); + $CD = $xml->add_node($CI, TX_ENCRYPTED, $this->m_sEncrypted); + } else if ($this->m_Type == TYPE_INQUIRY) { + //CancelInfo + $CI = $xml->add_node($root, INQUIRYINFO); + $CD = $xml->add_node($CI, TX_SESSIONKEY, $this->m_sSessionKey); + $CD = $xml->add_node($CI, TX_ENCRYPTED, $this->m_sEncrypted); + } else if ($this->m_Type == TYPE_OPENSUB) { + //GoodsInfo + //ٱ ߰(2010.04.13) + //==goodscnt (ٱ ƴҰ) ⺻ 1 + $tSubCnt = ($this->m_REQUEST["subcnt"] != null && (int) $this->m_REQUEST["subcnt"] > 0 ) ? $this->m_REQUEST["subcnt"] : 1; + + $OI = $xml->add_node($root, OPENSUBINFO); + + $OD = $xml->add_node($OI, TX_SESSIONKEY, $this->m_sSessionKey); + $OD = $xml->add_node($OI, TX_ENCRYPTED, $this->m_sEncrypted); + + $OD = $xml->add_node($OI, TX_OPENREG_SUBCNT, $tSubCnt); + + $iSubCnt = 1; + while ($iSubCnt <= $tSubCnt) { + $SG = $xml->add_node($OI, TX_OPENREG_SUBGOODS, "", array("no" => $iSubCnt)); + + $SD = $xml->add_node($SG, TX_OPENREG_SUBCOMPNO, $this->m_REQUEST["subcompno_" . $iSubCnt]); + $SD = $xml->add_node($SG, TX_OPENREG_SUBCOMPNM, $this->m_REQUEST["subcompnm_" . $iSubCnt], array("urlencode" => "1")); + $SD = $xml->add_node($SG, TX_OPENREG_SUBPRSUPPLY, $this->m_REQUEST["subprsupply_" . $iSubCnt]); + $SD = $xml->add_node($SG, TX_OPENREG_SUBPRFREE, $this->m_REQUEST["subprfree_" . $iSubCnt]); + $SD = $xml->add_node($SG, TX_OPENREG_SUBPRTAX, $this->m_REQUEST["subprtax_" . $iSubCnt]); + $SD = $xml->add_node($SG, TX_OPENREG_SUBPRSERVICE, $this->m_REQUEST["subprservice_" . $iSubCnt]); + $SD = $xml->add_node($SG, TX_OPENREG_SUBPRICE, $this->m_REQUEST["subprice_" . $iSubCnt]); + + $iSubCnt++; + } + //ٱ ߰(2010.04.13) [END] + $this->AddUserDefinedEntity(OPENSUBINFO, "", $xml, $OI); + } + //ReservedInfo + $RI = $xml->add_node($root, RESERVEDINFO); + $RD = $xml->add_node($RI, TX_MRESERVED1, $this->m_REQUEST["mreserved1"]); + $RD = $xml->add_node($RI, TX_MRESERVED2, $this->m_REQUEST["mreserved2"]); + $RD = $xml->add_node($RI, TX_MRESERVED3, $this->m_REQUEST["mreserved3"]); + $this->AddUserDefinedEntity(RESERVEDINFO, "", $xml, $RI); + + //ManageInfo + $MI = $xml->add_node($root, MANAGEINFO); + $MD = $xml->add_node($MI, TX_LANGUAGE, $this->m_REQUEST["language"]); + $MD = $xml->add_node($MI, TX_URL, $this->m_REQUEST["url"], array("urlencode" => "1")); + $MD = $xml->add_node($MI, TX_TXVERSION, $this->m_TXVersion); + //delete UIP(2009.01.21) + //$MD = $xml->add_node($MI, TX_TXUSERIP, $this->m_REQUEST["uip"] ); + $MD = $xml->add_node($MI, TX_TXUSERID, $this->m_REQUEST["id_customer"], array("urlencode" => "1")); + $MD = $xml->add_node($MI, TX_TXREGNUM, $this->m_REQUEST["id_regnum"]); + + //Ack, rn + if ($this->m_Type == TYPE_SECUREPAY || $this->m_Type == TYPE_OCBSAVE || + $this->m_Type == TYPE_FORMPAY || $this->m_Type == TYPE_RECEIPT + ) { + $MD = $xml->add_node($MI, TX_ACK, "1"); + if ($this->m_REQUEST["rn"] != "") + $MD = $xml->add_node($MI, TX_RN, $this->m_REQUEST["rn"]); + } + $this->AddUserDefinedEntity(MANAGEINFO, "", $xml, $MI); + + $this->m_sBody = $xml->make_xml(); + + return true; + } + + function ParseHead($head) { + $iLen = BODY_LEN + TAIL_LEN; + if (strlen($head) != MSGHEADER_LEN) + return RESULT_MSG_FORMAT_ERR; + + $this->m_FlgCrypto = substr($head, $iLen, FLGCRYPTO_LEN); + $iLen += FLGCRYPTO_LEN; + $this->m_FlgSign = substr($head, $iLen, FLGSIGN_LEN); + $iLen += FLGSIGN_LEN; + $this->m_MPubSN = substr($head, $iLen, MPUBSN_LEN); + $iLen += MPUBSN_LEN; + $this->m_PIPGPubSN = substr($head, $iLen, PIPGPUBSN_LEN); + $iLen += PIPGPUBSN_LEN; + $this->m_TXPGPubSN = substr($head, $iLen, TXPGPUBSN_LEN); + $iLen += TXPGPUBSN_LEN; + $this->m_Cmd = substr($head, $iLen, CMD_LEN); + $iLen += CMD_LEN; + $this->m_RESULT[NM_MID] = substr($head, $iLen, MID_LEN); + $iLen += MID_LEN; + $this->m_RESULT[NM_TOTPRICE] = substr($head, $iLen, TOTPRICE_LEN); + $iLen += TOTPRICE_LEN; + $this->m_RESULT[NM_TID] = substr($head, $iLen, TID_LEN); + + return OK; + } + + function ParseBody($body, &$encrypted, &$sessionkey) { + $xml = new XML(); + if (($rtv = $xml->load_xml("", $body)) != OK) + return $rtv; + + $this->m_Xml = $xml->xml_node; + + //GOODSINFO + $this->m_RESULT[NM_MOID] = $this->GetXMLData(MOID); + + //PAYMENTINFO + //ŸҼ paymethod ʾ ӽ÷ û Paymethod ü + //PG ִ PayMethod ûPaymethod ! + $this->m_RESULT[NM_PAYMETHOD] = $this->m_sPayMethod; + + $ResultCode = $this->GetXMLData("ResultCode"); + //if( substr($ResultCode,2, 4) == "0000" ) + if (strcmp(substr($ResultCode, 2, 4), "0000") == 0) { + $this->m_RESULT[NM_RESULTCODE] = "00"; + $this->m_RESULT[NM_RESULTMSG] = $this->GetXMLData("ResultMsg"); + } else { + $this->m_RESULT[NM_RESULTCODE] = "01"; + $this->m_RESULT[NM_ERRORCODE] = $ResultCode; + $this->m_RESULT[NM_RESULTMSG] = "[" . $ResultCode . "|" . $this->GetXMLData("ResultMsg") . "]"; + } + $encrypted = $this->GetXMLData("Encrypted"); + $sessionkey = $this->GetXMLData("SessionKey"); + return OK; + } + + function ParseDecrypt($decrypted) { + $xml = new XML(); + if (($rtv = $xml->load_xml("", $decrypted)) != OK) + return $rtv; + + $this->m_Xml = array_merge($this->m_Xml, $xml->xml_node); + + if ($this->m_Type == TYPE_SECUREPAY || $this->m_Type == TYPE_RECEIPT) { + //γ¥(ApplDate), νð(ApplTime), ιȣ(ApplNum) !!(OCB, ݿ ) + //ISP, CARD CARD assign. / ISP , CARD ˰ !!!-_- + if ($this->m_sPayMethod == NM_TX_CARD) { + $this->m_RESULT[APPLDATE] = $this->GetXMLData(CARD_APPLDATE); + $this->m_RESULT[APPLTIME] = $this->GetXMLData(CARD_APPLTIME); + $this->m_RESULT[APPLNUM] = $this->GetXMLData(CARD_APPLNUM); + $this->m_RESULT[CARD_NUM] = $this->GetXMLData(CARD_NUM); + $this->m_RESULT[CARD_EXPIRE] = $this->GetXMLData(CARD_EXPIRE); + $this->m_RESULT[CARD_BANKCODE] = $this->GetXMLData(CARD_BANKCODE); + $this->m_RESULT[CARD_CODE] = $this->GetXMLData(CARD_CODE); + $this->m_RESULT[CARD_APPLPRICE] = $this->GetXMLData(CARD_APPLPRICE); + $this->m_RESULT[CARD_QUOTA] = $this->GetXMLData(CARD_QUOTA); + $this->m_RESULT[CARD_INTEREST] = $this->GetXMLData(CARD_INTEREST); + $this->m_RESULT[CARD_POINT] = $this->GetXMLData(CARD_POINT); + $this->m_RESULT[CARD_AUTHTYPE] = $this->GetXMLData(CARD_AUTHTYPE); + $this->m_RESULT[CARD_REGNUM] = $this->GetXMLData(CARD_REGNUM); + $this->m_RESULT[CARD_TERMINALNUM] = $this->GetXMLData(CARD_TERMINALNUM); + $this->m_RESULT[CARD_MEMBERNUM] = $this->GetXMLData(CARD_MEMBERNUM); + $this->m_RESULT[CARD_PURCHASECODE] = $this->GetXMLData(CARD_PURCHASECODE); + } else if ($this->m_sPayMethod == NM_TX_ISP) { + $this->m_RESULT[APPLDATE] = $this->GetXMLData(ISP_APPLDATE); + $this->m_RESULT[APPLTIME] = $this->GetXMLData(ISP_APPLTIME); + $this->m_RESULT[APPLNUM] = $this->GetXMLData(ISP_APPLNUM); + $this->m_RESULT[CARD_NUM] = $this->GetXMLData(ISP_CARDNUM); + $this->m_RESULT[CARD_EXPIRE] = $this->GetXMLData(ISP_EXPIRE); + $this->m_RESULT[CARD_BANKCODE] = $this->GetXMLData(ISP_BANKCODE); + $this->m_RESULT[CARD_CODE] = $this->GetXMLData(ISP_CARDCODE); + $this->m_RESULT[CARD_APPLPRICE] = $this->GetXMLData(ISP_APPLPRICE); + $this->m_RESULT[CARD_QUOTA] = $this->GetXMLData(ISP_QUOTA); + $this->m_RESULT[CARD_INTEREST] = $this->GetXMLData(ISP_INTEREST); + $this->m_RESULT[CARD_POINT] = $this->GetXMLData(ISP_POINT); + $this->m_RESULT[CARD_TERMINALNUM] = $this->GetXMLData(ISP_TERMINALNUM); + $this->m_RESULT[CARD_MEMBERNUM] = $this->GetXMLData(ISP_MEMBERNUM); + $this->m_RESULT[CARD_PURCHASECODE] = $this->GetXMLData(ISP_PURCHASECODE); + } else if ($this->m_sPayMethod == NM_TX_CSHR) { + $this->m_RESULT[APPLDATE] = $this->GetXMLData(CSHR_APPLDATE); + $this->m_RESULT[APPLTIME] = $this->GetXMLData(CSHR_APPLTIME); + $this->m_RESULT[APPLNUM] = $this->GetXMLData(CSHR_APPLNUM); + } else if ($this->m_sPayMethod == NM_TX_ACCT) { + $this->m_RESULT[APPLDATE] = $this->GetXMLData(ACCT_APPLDATE); + $this->m_RESULT[APPLTIME] = $this->GetXMLData(ACCT_APPLTIME); + $this->m_RESULT[APPLNUM] = $this->GetXMLData(ACCT_APPLNUM); + } else if ($this->m_sPayMethod == NM_TX_HPP) { + $this->m_RESULT[APPLDATE] = $this->GetXMLData(HPP_APPLDATE); + $this->m_RESULT[APPLTIME] = $this->GetXMLData(HPP_APPLTIME); + $this->m_RESULT[APPLNUM] = $this->GetXMLData(HPP_APPLNUM); + } else if ($this->m_sPayMethod == NM_TX_VACT) { + $this->m_RESULT[APPLDATE] = $this->GetXMLData(VACT_APPLDATE); + $this->m_RESULT[APPLTIME] = $this->GetXMLData(VACT_APPLTIME); + } else if ($this->m_sPayMethod == NM_TX_ARSB) { + $this->m_RESULT[APPLDATE] = $this->GetXMLData(ARSB_APPLDATE); + $this->m_RESULT[APPLTIME] = $this->GetXMLData(ARSB_APPLTIME); + $this->m_RESULT[APPLNUM] = $this->GetXMLData(ARSB_APPLNUM); + } else if ($this->m_sPayMethod == NM_TX_PHNB) { + $this->m_RESULT[APPLDATE] = $this->GetXMLData(PHNB_APPLDATE); + $this->m_RESULT[APPLTIME] = $this->GetXMLData(PHNB_APPLTIME); + $this->m_RESULT[APPLNUM] = $this->GetXMLData(PHNB_APPLNUM); + } else if ($this->m_sPayMethod == NM_TX_CULT) { + $this->m_RESULT[APPLDATE] = $this->GetXMLData(CULT_APPLDATE); + $this->m_RESULT[APPLTIME] = $this->GetXMLData(CULT_APPLTIME); + $this->m_RESULT[APPLNUM] = $this->GetXMLData(CULT_APPLNUM); + } else if ($this->m_sPayMethod == NM_TX_GAMG) { + $this->m_RESULT[APPLDATE] = $this->GetXMLData(GAMG_APPLDATE); + $this->m_RESULT[APPLTIME] = $this->GetXMLData(GAMG_APPLTIME); + $this->m_RESULT[APPLNUM] = $this->GetXMLData(GAMG_APPLNUM); + $this->m_RESULT[GAMG_CNT] = $this->GetXMLData(GAMG_CNT); + //ӹȭǰ Multi + MakePathGAMG($this->m_RESULT[GAMG_CNT]); + for ($i = 1; $i <= $this->m_RESULT[GAMG_CNT]; $i++) { + $this->m_RESULT[constant("GAMG_NUM$i")] = $this->GetXMLData(constant("GAMG_NUM$i")); + $this->m_RESULT[constant("GAMG_REMAINS$i")] = $this->GetXMLData(constant("GAMG_REMAINS$i")); + $this->m_RESULT[constant("GAMG_ERRMSG$i")] = $this->GetXMLData(constant("GAMG_ERRMSG$i")); + } + $this->m_RESULT[GAMG_APPLPRICE] = $this->GetXMLData(GAMG_APPLPRICE); + $this->m_RESULT[GAMG_NUM] = $this->GetXMLData(GAMG_NUM); + $this->m_RESULT[GAMG_RESULTCODE] = $this->GetXMLData(GAMG_RESULTCODE); + $this->m_RESULT[GAMG_RESULTMSG] = $this->GetXMLData(GAMG_RESULTMSG); + } else if ($this->m_sPayMethod == NM_TX_EDUG) { + $this->m_RESULT[APPLDATE] = $this->GetXMLData(EDUG_APPLDATE); + $this->m_RESULT[APPLTIME] = $this->GetXMLData(EDUG_APPLTIME); + $this->m_RESULT[APPLNUM] = $this->GetXMLData(EDUG_APPLNUM); + } else if ($this->m_sPayMethod == NM_TX_TEEN) { + $this->m_RESULT[APPLDATE] = $this->GetXMLData(TEEN_APPLDATE); + $this->m_RESULT[APPLTIME] = $this->GetXMLData(TEEN_APPLTIME); + $this->m_RESULT[APPLNUM] = $this->GetXMLData(TEEN_APPLNUM); + } + } else if ($this->m_Type == TYPE_INQUIRY) { + $this->m_RESULT[INQR_TID] = $this->GetXMLData(INQR_TID); + $this->m_RESULT[INQR_PRICE] = $this->GetXMLData(INQR_Price); + $this->m_RESULT[INQR_STATUS] = $this->GetXMLData(INQR_Status); + } + + return OK; + } + + function GTHR($err_code, $err_msg) { + //Set + $data["mid"] = $this->m_REQUEST["mid"]; + $data["paymethod"] = $this->m_REQUEST["paymethod"]; + //delete UIP(2009.01.21) + //$data["user_ip"] = $this->m_REQUEST["uip"]; + $data["tx_version"] = $this->m_TXVersion; + $data["err_code"] = $err_code; + $data["err_msg"] = $err_msg; + + // add tid / type (2014-12-09 by jungc) + $data["tid"] = $this->m_sTID; + $data["type"] = $this->m_Type; + + //Send + $qs = "ctype=TX&"; + foreach ($data as $key => $val) + $qs .= $key . '=' . urlencode($val) . '&'; + + $fp = fsockopen(G_SERVER, G_PORT, $errno, $errstr, G_TIMEOUT_CONNECT); + if ($fp) { + $out = "GET " . G_CGI . "?" . $qs . " HTTP/1.0\r\n"; + $out .= "Host: " . G_SERVER . "\r\n"; + $out .= "Connection: Close\r\n\r\n"; + fwrite($fp, $out); + fclose($fp); + } + } + + function ParsePIEncrypted() { + parse_str($this->m_REQUEST["encrypted"]); + $this->m_PIPGPubSN = $CertVer; + $this->m_PG1 = $pg1; + $this->m_PG2 = $pg2; + $this->m_PG1IP = $pg1ip; + $this->m_PG2IP = $pg2ip; + } + + // Xpath Ȱ´. Ѵ ߴ!! + // added by ddaemiri, 2007.09.03 + function GetXMLData($node) { + $content = $this->m_Xml[$node . "[1]"]["text"]; + if ($this->m_Xml[$node . "[1]"]["attr"]["urlencode"] == "1") + $content = urldecode($content); + return $content; + } + +} + +/* ----------------------------------------------------- */ +/* Crypto Class */ +/* PHP4.2 & OpenSSL ʿ) */ +/* ----------------------------------------------------- */ + +class INICrypto { + + var $homedir; + var $mid; + var $admin; + var $pgpubkeyid = NULL; + var $mprivkeyid = NULL; + var $mkey; + + function INICrypto($request) { + $this->homedir = $request["inipayhome"]; + $this->mid = $request["mid"]; + $this->admin = $request["admin"]; + $this->mkey = $request["mkey"]; + } + + function LoadPGPubKey(&$pg_pubcert_SN) { + $fp = fopen($this->homedir . "/key/pgcert.pem", "r"); + if (!$fp) + return NULL_PGCERT_FP_ERR; + $pub_key = fread($fp, 8192); + if (!$pub_key) { + fclose($fp); + return NULL_PGCERT_FP_ERR; + } + fclose($fp); + + $this->pgpubkeyid = openssl_get_publickey($pub_key); + if (!$this->pgpubkeyid) + return NULL_PGCERT_ERR; + + $pg_pubcert = openssl_x509_parse($pub_key); + if (!$pg_pubcert) + return NULL_X509_ERR; //The structure of the returned data is (deliberately) not yet documented + $pg_pubcert_SN = $pg_pubcert["serialNumber"]; + + return OK; + } + + function UpdatePGPubKey($pgpubkey) { + $f_org = $this->homedir . "/key/pgcert.pem"; + $f_new = $this->homedir . "/key/.pgcert.pem.tmp"; + $fp = fopen($f_new, "w"); + if (!$fp) + return PGPUB_UPDATE_ERR; + fwrite($fp, $pgpubkey); + fclose($fp); + + //rename + if (!rename($f_new, $f_org)) + return PGPUB_UPDATE_ERR; + return OK; + } + + function LoadMPubKey(&$m_pubcert_SN) { + if ($this->mkey == "1") + $fp = fopen($this->homedir . "/key/mkey/mcert.pem", "r"); + else + $fp = fopen($this->homedir . "/key/" . $this->mid . "/mcert.pem", "r"); + if (!$fp) + return NULL_MCERT_FP_ERR; + $pub_key = fread($fp, 8192); + if (!$pub_key) { + fclose($fp); + return NULL_MCERT_FP_ERR; + } + fclose($fp); + + $m_pubcert = openssl_x509_parse($pub_key); + if (!$m_pubcert) + return NULL_X509_ERR; //The structure of the returned data is (deliberately) not yet documented + $m_pubcert_SN = $m_pubcert["serialNumber"]; + + return OK; + } + + function LoadMPrivKey() { + /* + //get keypw + $fp=fopen( $this->homedir . "/key/" . $this->mid . "/keypass.enc", "r"); + if( !$fp ) return GET_KEYPW_FILE_OPEN_ERR; + $enckey=fread($fp, 8192); + if( !$enckey ) return GET_KEYPW_FILE_OPEN_ERR; + fclose($fp); + if( !$this->SymmDecrypt( base64_decode($enckey), &$keypwd, $this->admin, IV ) ) + return GET_KEYPW_DECRYPT_FINAL_ERR; + */ + $keypwd = $this->admin; + + //load mpriv key + if ($this->mkey == "1") + $fp = fopen($this->homedir . "/key/mkey/mpriv.pem", "r"); + else + $fp = fopen($this->homedir . "/key/" . $this->mid . "/mpriv.pem", "r"); + if (!$fp) + return PRIVKEY_FILE_OPEN_ERR; + $priv_key = fread($fp, 8192); + if (!$priv_key) { + fclose($fp); + return PRIVKEY_FILE_OPEN_ERR; + } + fclose($fp); + $this->mprivkeyid = openssl_get_privatekey($priv_key, $keypwd); + if (!$this->mprivkeyid) + //return INVALID_KEYPASS_ERR; + return GET_KEYPW_DECRYPT_FINAL_ERR; + return OK; + } + + function Sign($body, &$sign) { + if (!openssl_sign($body, $sign, $this->mprivkeyid)) //default:SHA1 + return SIGN_FINAL_ERR; + $sign = Base64Encode($sign); + return OK; + } + + function Verify($body, $tail) { + $rtv = openssl_verify($body, base64_decode($tail), $this->pgpubkeyid); + if (!$rtv) + return SIGN_CHECK_ERR; + return OK; + } + + function Decrypt($sessionkey, $encrypted, &$decrypted) { + $dec_sesskey = base64_decode($sessionkey); + $src = substr($dec_sesskey, 0, strlen($dec_sesskey) - MAX_IV_LEN); + if (!$this->RSAMPrivDecrypt($src, $key)) + return DEC_RSA_ERR; + $iv = substr($dec_sesskey, strlen($dec_sesskey) - MAX_IV_LEN, MAX_IV_LEN); + if (!$this->SymmDecrypt(base64_decode($encrypted), $decrypted, $key, $iv)) + return DEC_FINAL_ERR; + return OK; + } + + function SymmEncrypt($src_data, &$enc_data, $key, $iv) { + $size = mcrypt_get_block_size(MCRYPT_3DES, MCRYPT_MODE_CBC); + $src_data = $this->pkcs5_pad($src_data, $size); + $cipher = mcrypt_module_open(MCRYPT_3DES, '', MCRYPT_MODE_CBC, ''); + mcrypt_generic_init($cipher, $key, $iv); + $enc_data = mcrypt_generic($cipher, $src_data); + mcrypt_generic_deinit($cipher); + mcrypt_module_close($cipher); + + if (!$enc_data) + return ENC_FINAL_ERR; + $enc_data = Base64Encode($enc_data); + + return OK; + } + + function SymmDecrypt($enc_data, &$dec_data, $key, $iv) { + $cipher = mcrypt_module_open(MCRYPT_3DES, '', MCRYPT_MODE_CBC, ''); + mcrypt_generic_init($cipher, $key, $iv); + $dec_data = mdecrypt_generic($cipher, $enc_data); + mcrypt_generic_deinit($cipher); + mcrypt_module_close($cipher); + + if (!$dec_data) + return false; + $dec_data = $this->remove_ctrl($dec_data); + return true; + } + + function RSAMPrivDecrypt($enc_data, &$dec_data) { + return openssl_private_decrypt($enc_data, $dec_data, $this->mprivkeyid); + } + + function RSAMPrivEncrypt($org_data, &$enc_data) { + if (!openssl_private_encrypt($org_data, $enc_data, $this->mprivkeyid)) + return false; + $enc_data = Base64Encode($enc_data); + return true; + } + + function RSAPGPubEncrypt($org_data, &$enc_data) { + return openssl_public_encrypt($org_data, $enc_data, $this->pgpubkeyid); + } + + function FreePubKey() { + if ($this->pgpubkeyid) + openssl_free_key($this->pgpubkeyid); + } + + function FreePrivKey() { + if ($this->mprivkeyid) + openssl_free_key($this->mprivkeyid); + } + + function FreeAllKey() { + $this->FreePubKey(); + $this->FreePrivKey(); + } + + function remove_ctrl($string) { + for ($i = 0; $i < strlen($string); $i++) { + $chr = $string{$i}; + $ord = ord($chr); + if ($ord < 10) + $string{$i} = ""; + else + $string{$i} = $chr; + } + return trim($string); + } + + function pkcs5_pad($text, $blocksize) { + $pad = $blocksize - (strlen($text) % $blocksize); + return $text . str_repeat(chr($pad), $pad); + } + + function pkcs5_unpad($text) { + $pad = ord($text{strlen($text) - 1}); + if ($pad > strlen($text)) + return false; + if (strspn($text, chr($pad), strlen($text) - $pad) != $pad) + return false; + return substr($text, 0, -1 * $pad); + } + + function MakeIMStr($pt, $key) { + if (get_magic_quotes_gpc()) { + $key = stripslashes($key); + $pt = stripslashes($pt); + } + return substr(chunk_split(base64_encode($this->IMstr($key, $pt)), 64, "\n"), 0, -1); + } + + function IMstr($pwd, $data) { + $key[] = ''; + $box[] = ''; + $cipher = ''; + + $pwd_length = strlen($pwd); + $data_length = strlen($data); + + for ($i = 0; $i < 256; $i++) { + $key[$i] = ord($pwd[$i % $pwd_length]); + $box[$i] = $i; + } + for ($j = $i = 0; $i < 256; $i++) { + $j = ($j + $box[$i] + $key[$i]) % 256; + $tmp = $box[$i]; + $box[$i] = $box[$j]; + $box[$j] = $tmp; + } + for ($a = $j = $i = 0; $i < $data_length; $i++) { + $a = ($a + 1) % 256; + $j = ($j + $box[$a]) % 256; + $tmp = $box[$a]; + $box[$a] = $box[$j]; + $box[$j] = $tmp; + $k = $box[(($box[$a] + $box[$j]) % 256)]; + $cipher .= chr(ord($data[$i]) ^ $k); + } + return $cipher; + } + +} +?> + diff --git a/shop/inicis/libs/INIDFN.php b/shop/inicis/libs/INIDFN.php new file mode 100644 index 000000000..b26026231 --- /dev/null +++ b/shop/inicis/libs/INIDFN.php @@ -0,0 +1,671 @@ +5001 ҽ ,׷ ó ) + * @date 2008.03.12 + * @buildno 5016 + * @note pg1ip, pg2ip ߰/ ŷ drpg õ + * @date 2008.04.02 + * @buildno 5017 + * @note 1)chkfake Ķ α (ߺ) + * 2)call-time pass-by-reference => pass-by-value + * @date 2009.01.12 + * @buildno 5019 + * @note delete UIP + * @date 2009.01.21 + * @note add mkey/mergelog ( for Makeshop ) + * @date 2009.02.24 + * @note 1)define MKEY deprecated 2009.02.19 ( Makeshop ʱ ѹ. 񽺵ǰ ִ ) + * 2)Makeshop PG Updrade γ 2009.02.19 (interface mkey ޾ óϰ ) + * 3)Makeshop PG Updrade γ 2009.02.24 (interface mergelog ޾ óϰ ) + * @date 2009.05.07 + * @note add BUILDDATE in TXVersion + * @date 2009.08.05 + * @buildno 5030 + * @note add vacct refund + * @date 2009.12.16 + * @buildno 5030 + * @note add recv info + * @date 2010.07.14 + * @note add Tax, TaxFree info(TX_TAX, TX_TAXFREE) + * @date 2010.09.09 + * @note ҿû PG (->IP, INILib.php) + * @note BUILDDATE update(100414 -> 100909) + * @note 2011.05.23 5030 XML ELEMENT ROOT ROOTINFO + * @buildno 5032 + * @note 2012.07.09 ŷȸ ߰ (TYPE_INQUIRY) + * @note 2012.07.09 PHP ini error display setting ߰ + * @buildno 5036 + * @note 2014.12.09 add gather parameter tid, type + */ +ini_set('error_reporting', E_ALL ^ E_NOTICE); +ini_set('display_errors', 'Off'); + +/* GLOBAL */ +define("PROGRAM", "INIPHP"); +define("LANG", "PHP"); +define("VERSION", "5036"); +define("BUILDDATE", "141209"); +define("TID_LEN", 40); +define("MAX_KEY_LEN", 24); +define("MAX_IV_LEN", 8); + +/* TIMEOUT */ +define("TIMEOUT_CONNECT", 5); +define("TIMEOUT_WRITE", 2); +define("TIMEOUT_READ", 20); +define("G_TIMEOUT_CONNECT", 2); +define("DNS_LOOKUP_TIMEOUT", 5); + +/* LOG LEVEL */ +define("CRITICAL", 1); +define("ERROR", 2); +define("NOTICE", 3); +define("INFO", 5); +define("DEBUG", 7); + +/* SERVER INFO */ +define("PG_HOST", "pg.inicis.com"); +define("DRPG_HOST", "drpg.inicis.com"); +define("PG_IP", "203.238.37.3"); +define("DRPG_IP", "211.219.96.180"); +define("PG_PORT", 34049); +define("G_SERVER", "gthr.inicis.com"); +define("G_CGI", "/cgi-bin/g.cgi"); +define("G_PORT", 80); + +define("OK", "0"); + +define("IV", "Initiative Tech"); +define("IMHK", "SFBQSU5JTkZPUk1BVElPTg=="); +define("IMHV", "SU5JQ0lTIENJUEhFUi4uLg=="); +define("IMJK", "UkVHSVNUX05PX1JDNEtFWQ=="); +define("IMJV", "UkVHSVNUX05PX1JDNElW"); + +//define for mkey +//deprecated 2009.02.19 ( Makeshop ʱ ѹ. 񽺵ǰ ִ ) +//Makeshop PG Updrade γ 2009.02.19 (interface mkey ޾ óϰ ) +//define("MKEY", 1); +//non block connect immediate return check code/str +define("ERRSTR_INPROGRESS", "Operation now in progress"); +define("ERRCODE_INPROGRESS_LINUX", 115); +define("ERRCODE_INPROGRESS_FREEBSD", 36); +define("ERRCODE_INPROGRESS_WIN", 10035); + +//------------------------------------------------------ +// IFD Header +//------------------------------------------------------ +define("MSGHEADER_LEN", 150); +define("BODY_LEN", 5); +define("TAIL_LEN", 5); +define("FLGCRYPTO_LEN", 1); +define("FLGSIGN_LEN", 5); +define("MPUBSN_LEN", 20); +define("PIPGPUBSN_LEN", 20); +define("TXPGPUBSN_LEN", 20); +define("CMD_LEN", 4); +define("MID_LEN", 10); +define("TOTPRICE_LEN", 20); +define("TID_LEN", 40); + + +//------------------------------------------------------ +// IFD CMD +//------------------------------------------------------ +define("CMD_REQ_PAY", "0200"); +define("CMD_RES_PAY", "0210"); +define("CMD_REQ_CAP", "0300"); +define("CMD_RES_CAP", "0310"); +define("CMD_REQ_CAN", "0420"); +define("CMD_RES_CAN", "0430"); +define("CMD_REQ_NETC", "0520"); +define("CMD_RES_NETC", "0530"); +define("CMD_REQ_PRTC", "0620"); +define("CMD_RES_PRTC", "0630"); +define("CMD_REQ_ACK", "0800"); +define("CMD_RES_ACK", "0810"); +//üũ +//added 2008.01.08 +define("CMD_REQ_DLV", "3020"); //۵ +define("CMD_REQ_CNF", "3030"); //Ȯ +define("CMD_REQ_DNY", "3040"); //Ű +define("CMD_REQ_DNY_CNF", "3080"); //Ȯ +define("CMD_REQ_DLV_NETC", "3520"); //۵ϸ +define("CMD_REQ_CNF_NETC", "3530"); //Ȯθ +define("CMD_REQ_DNY_NETC", "3540"); //Ű +//ȯ(09.08.05) +define("CMD_REQ_RFD", "0421"); +define("CMD_RES_RFD", "0431"); + +//ŷȸ(12.04.20) +define("CMS_REQ_INQR", "0900"); +define("CMS_RES_INQR", "0910"); + +//(14.03.06) +define("CMS_REQ_OPEN_SUB", "1040"); +define("CMS_RES_OPEN_SUB", "1041"); + +//------------------------------------------------------ +// HEADER FLAGS +//------------------------------------------------------ +define("FLAG_TEST", "T"); +define("FLAG_REAL", "R"); +define("FLAG_CRYPTO_NONE", "N"); +define("FLAG_CRYPTO_SEED", "S"); +define("FLAG_CRYPTO_RC4", "R"); +define("FLAG_CRYPTO_3DES", "D"); +define("FLAG_SIGN_SHA", "SHA"); +define("FLAG_SIGN_SHA1", "SHA1"); +define("FLAG_SIGN_MD5", "MD5"); + +//------------------------------------------------------ +//TYPE(񽺺) +//------------------------------------------------------ +define("TYPE_SECUREPAY", "securepay"); +define("TYPE_CANCEL", "cancel"); +define("TYPE_FORMPAY", "formpay"); +define("TYPE_RECEIPT", "receipt"); +define("TYPE_REPAY", "repay"); +define("TYPE_ESCROW", "escrow"); //üũ! +define("TYPE_CONFIRM", "confirm"); +define("TYPE_OCBQUERY", "ocbquery"); +define("TYPE_OCBSAVE", "ocbsave"); +define("TYPE_OCBPOINT", "OCBPoint"); +define("TYPE_AUTH", "auth"); +define("TYPE_AUTHBILL", "auth_bill"); +define("TYPE_CAPTURE", "capture"); +define("TYPE_CMS", "CMS"); +define("TYPE_VBANK", "VBank"); +define("TYPE_REQREALBILL", "reqrealbill"); +define("TYPE_FORMAUTH", "formauth"); +define("TYPE_CHKFAKE", "chkfake"); +//ȯ(09.08.05) +define("TYPE_REFUND", "refund"); +//ºκȯ(12.06.05) +define("TYPE_VACCTREPAY", "vacctrepay"); +//ŷȸ(12.04.20) +define("TYPE_INQUIRY", "inquiry"); +//(14.03.06) +define("TYPE_OPENSUB", "opensub"); +//------------------------------------------------------ +//EscrowType(üũ Ÿ) +//added 2008.01.08 +//------------------------------------------------------ +define("TYPE_ESCROW_DLV", "dlv"); +define("TYPE_ESCROW_CNF", "confirm"); //Ȯ/(÷) +define("TYPE_ESCROW_DNY", "deny"); // ó,ǹ̾ +define("TYPE_ESCROW_DNY_CNF", "dcnf"); + + +//------------------------------------------------------ +//PayMethod(񽺺, TX) +//------------------------------------------------------ +define("NM_TX_ISP", "VCard"); +define("NM_TX_CARD", "Card"); +define("NM_TX_HPP", "HPP"); +define("NM_TX_ACCT", "DirectBank"); +define("NM_TX_VACT", "VBank"); +define("NM_TX_OCB", "OCBPoint"); +define("NM_TX_CSHR", "CASH"); +define("NM_TX_ARSB", "Ars1588Bill"); +define("NM_TX_PHNB", "PhoneBill"); +define("NM_TX_CULT", "Culture"); +define("NM_TX_GAMG", "DGCL"); +define("NM_TX_EDUG", "EDCL"); +define("NM_TX_TEEN", "TEEN"); +define("NM_TX_ESCR", "Escrow"); + +//------------------------------------------------------ +//PayMethod(񽺺, PG) +//------------------------------------------------------ +define("NM_ISP", "ISP"); +define("NM_CARD", "CARD"); +define("NM_HPP", "HPP"); +define("NM_ACCT", "ACCT"); +define("NM_VACT", "VACT"); +define("NM_OCB", "OCB"); +define("NM_CSHR", "CASH"); +define("NM_ARSB", "ARSB"); +define("NM_PHNB", "PHNB"); +define("NM_CULT", "CULT"); +define("NM_GAMG", "DGCL"); +define("NM_EDUG", "EDCL"); +define("NM_TEEN", "TEEN"); +define("NM_ESCR", "Escrow"); + +//------------------------------------------------------ +//Charset +//------------------------------------------------------ +define("EUCKR", "EUC-KR"); +define("UTF8", "UTF-8"); + +//------------------------------------------------------ +//URL Encoding/Decoding Name +//------------------------------------------------------ +define("URLENCODE", "urlencode"); +define("URLDECODE", "urldecode"); + +//------------------------------------------------------ +//û +//------------------------------------------------------ +define("TX_GOOSCNT", "GoodsCnt"); +define("TX_MOID", "MOID"); +define("TX_CURRENCY", "Currency"); +define("TX_SMID", "SMID"); +define("TX_GOODSCNTS", "GoodsCnts"); +define("TX_GOODSNAME", "GoodsName"); +define("TX_GOODSPRICE", "GoodsPrice"); +define("TX_BUYERNAME", "BuyerName"); +define("TX_BUYEREMAIL", "BuyerEmail"); +define("TX_BUYERTEL", "BuyerTel"); +define("TX_PARENTEMAIL", "ParentEmail"); +define("TX_RECVNAME", "RecvName"); +define("TX_RECVTEL", "RecvTel"); +define("TX_RECVMSG", "RecvMsg"); +define("TX_RECVADDR", "RecvAddr"); +define("TX_RECVPOSTNUM", "RecvPostNum"); +define("TX_TAXFREE", "TaxFree"); +define("TX_TAX", "Tax"); +//PaymentInfo +define("TX_PAYMETHOD", "PayMethod"); +define("TX_JOINCARD", "JoinCard"); +define("TX_JOINEXPIRE", "JoinExpire"); +define("TX_MAILORDER", "MailOrder"); +define("TX_SESSIONKEY", "SessionKey"); +define("TX_ENCRYPTED", "Encrypted"); +//ReservedInfo +define("TX_MRESERVED1", "MReserved1"); +define("TX_MRESERVED2", "MReserved2"); +define("TX_MRESERVED3", "MReserved3"); +//ManageInfo +define("TX_LANGUAGE", "Language"); +define("TX_URL", "URL"); +define("TX_TXVERSION", "TXVersion"); +define("TX_TXUSERIP", "TXUserIP"); +define("TX_TXUSERID", "TXUserID"); +define("TX_TXREGNUM", "TXRegNum"); +define("TX_ACK", "Ack"); +define("TX_RN", "TXRN"); +//CancelInfo +define("TX_CANCELTID", "CancelTID"); +define("TX_CANCELMSG", "CancelMsg"); +define("TX_CANCELREASON", "CancelReason"); //2012-10-19 һڵ ߰ +//ȯ(09.08.05) +define("TX_REFUNDACCTNUM", "RefundAcctNum"); +define("TX_REFUNDBANKCODE", "RefundBankCode"); +define("TX_REFUNDACCTNAME", "RefundAcctName"); +//PartCancelInfo +define("TX_PRTC_TID", "PRTC_TID"); +define("TX_PRTC_PRICE", "PRTC_Price"); +define("TX_PRTC_REMAINS", "PRTC_Remains"); +define("TX_PRTC_QUOTA", "PRTC_Quota"); +define("TX_PRTC_INTEREST", "PRTC_Interest"); +define("TX_PRTC_TAX", "Tax"); +define("TX_PRTC_TAXFREE", "TaxFree"); + +define("TX_PRTC_CURRENCY", "Currency"); + +// Iü κҽ ¹ȣ/ּ߰ 2011-10-06 +define("TX_PRTC_NOACCT", "PRTC_NoAcctFNBC"); +define("TX_PRTC_NMACCT", "PRTC_NmAcctFNBC"); +// κȯ ߰ +define("TX_PRTC_REFUNDFLGREMIT", "PRTC_RefundFlgRemit"); +define("TX_PRTC_REFUNDBANKCODE", "PRTC_RefundBankCode"); +//CaptureInfo +define("TX_CAPTURETID", "CaptureTID"); +//ݿ +define("TX_CSHR_APPLPRICE", "CSHR_ApplPrice"); +define("TX_CSHR_SUPPLYPRICE", "CSHR_SupplyPrice"); +define("TX_CSHR_TAX", "CSHR_Tax"); +define("TX_CSHR_SERVICEPRICE", "CSHR_ServicePrice"); +define("TX_CSHR_REGNUM", "CSHR_RegNum"); +define("TX_CSHR_TYPE", "CSHR_Type"); +define("TX_CSHR_COMPANYNUM", "CSHR_CompanyNum"); +define("TX_CSHR_OPENMARKET", "CSHR_OpenMarket"); +define("TX_CSHR_SUBCNT", "CSHR_SubCnt"); +define("TX_CSHR_SUBCOMPANYNAME1", "CSHR_SubCompanyName1"); +define("TX_CSHR_SUBCOMPANYNUM1", "CSHR_SubCompanyNum1"); +define("TX_CSHR_SUBREGNUM1", "CSHR_SubRegNum1"); +define("TX_CSHR_SUBMID1", "CSHR_SubMID1"); +define("TX_CSHR_SUBAPPLPRICE1", "CSHR_SubApplPrice1"); +define("TX_CSHR_SUBSERVICEPRICE1", "CSHR_SubServicePrice1"); +//ŷȸ(12.04.20) +define("TX_INQR_TID", "INQR_TID"); +//(14.03.06) +define("TX_OPENREG_TID", "OrgTID"); +define("TX_OPENREG_MID", "MID"); +define("TX_OPENREG_SUBCNT", "SubCnt"); +define("TX_OPENREG_SUBGOODS", "SubGoods"); +define("TX_OPENREG_SUBCOMPNO", "SubCompNo"); +define("TX_OPENREG_SUBCOMPNM", "SubCompNm"); +define("TX_OPENREG_SUBPRSUPPLY", "SubPrSupply"); +define("TX_OPENREG_SUBPRFREE", "SubPrFree"); +define("TX_OPENREG_SUBPRTAX", "SubPrTax"); +define("TX_OPENREG_SUBPRSERVICE", "SubPrService"); +define("TX_OPENREG_SUBPRICE", "SubPrice"); + +//------------------------------------------------------ +// +// +// +//------------------------------------------------------ +//HEAD +define("NM_MID", "MID"); +define("NM_TID", "TID"); +define("NM_TOTPRICE", "TotPrice"); + +//BODY +define("NM_GOODSCNT", "GoodsCnt"); +define("NM_MOID", "MOID"); +define("NM_CURRENCY", "Currency"); +define("NM_SMID", "SMID"); +define("NM_GOODSNAME", "GoodsName"); +define("NM_GOODSPRICE", "GoodsPrice"); +define("NM_PAYMETHOD", "PayMethod"); +define("NM_RESULTCODE", "ResultCode"); +define("NM_RESULTERRORCODE", "ResultErrorCode"); +define("NM_RESULTMSG", "ResultMsg"); +define("NM_SESSIONKEY", "SessionKey"); +define("NM_ENCRYPTED", "Encrypted"); +define("NM_CANCELDATE", "CancelDate"); +define("NM_CANCELTIME", "CancelTime"); +define("NM_EVENTCODE", "EventCode"); +define("NM_ORGCURRENCY", "OrgCurrency"); +define("NM_ORGPRICE", "OrgPrice"); +define("NM_EXCHANGERATE", "ExchangeRate"); +define("NM_RESERVEDINFO", "ReservedInfo"); +define("NM_MRESERVED1", "MReserved1"); +define("NM_MRESERVED2", "MReserved2"); +define("NM_MRESERVED3", "MReserved3"); +define("PRTC_TID", "PRTC_TID"); +define("PRTC_PRICE", "PRTC_Price"); +define("PRTC_REMAINS", "PRTC_Remains"); +define("PRTC_QUOTA", "PRTC_Quota"); +define("PRTC_INTEREST", "PRTC_Interest"); +define("PRTC_TYPE", "PRTC_Type"); +define("PRTC_CNT", "PRTC_Cnt"); +define("NM_CAPTUREDATE", "CaptureDate"); +define("NM_CAPTURETIME", "CaptureTime"); + +define("NM_PGPUBKEY", "PGcertKey"); + +//RECV DATA XPATH +//XML XPATH +define("ROOTINFO", "INIpay"); +define("GOODSINFO", "GoodsInfo"); +define("GOODS", "Goods"); +define("BUYERINFO", "BuyerInfo"); +define("PAYMENTINFO", "PaymentInfo"); +define("PAYMENT", "Payment"); +define("MANAGEINFO", "ManageInfo"); +define("RESERVEDINFO", "ReservedInfo"); +//Cancel(NetCancel) +define("CANCELINFO", "CancelInfo"); +//PartCancel Encrypt +define("PARTCANCELINFO", "PartCancelInfo"); +//Capture +define("CAPTUREINFO", "CaptureInfo"); +//ŷȸ(12.04.20) +define("INQUIRYINFO", "InquiryInfo"); +//(14.03.06) +define("OPENSUBINFO", "OpenSubInfo"); +//Escrow +//added 2008.01.09 +define("ESCROWINFO", "EscrowInfo"); +define("ESCROW_DELIVERY", "Delivery"); +define("ESCROW_CONFIRM", "Confirm"); +define("ESCROW_DENY", "Deny"); +define("ESCROW_DENYCONFIRM", "DenyConfirm"); + + +//------------------------------------------------------ +//Auth Encrypt XPATH +//------------------------------------------------------ +//CARD COMMON +define("APPLDATE", "ApplDate"); +define("APPLTIME", "ApplTime"); +define("APPLNUM", "ApplNum"); +//CARD +define("CARD_NUM", "CARD_Num"); +define("CARD_EXPIRE", "CARD_Expire"); +define("CARD_CODE", "CARD_Code"); +define("CARD_APPLPRICE", "CARD_ApplPrice"); +define("CARD_BANKCODE", "CARD_BankCode"); +define("CARD_QUOTA", "CARD_Quota"); +define("CARD_INTEREST", "CARD_Interest"); +define("CARD_POINT", "CARD_Point"); +define("CARD_AUTHTYPE", "CARD_AuthType"); +define("CARD_REGNUM", "CARD_RegNum"); +define("CARD_APPLDATE", "CARD_ApplDate"); +define("CARD_APPLTIME", "CARD_ApplTime"); +define("CARD_APPLNUM", "CARD_ApplNum"); +define("CARD_RESULTCODE", "CARD_ResultCode"); +define("CARD_RESULTMSG", "CARD_ResultMsg"); +define("CARD_TERMINALNUM", "CARD_TerminalNum"); +define("CARD_MEMBERNUM", "CARD_MemberNum"); +define("CARD_PURCHASECODE", "CARD_PurchaseCode"); +//ISP +define("ISP_BANKCODE", "ISP_BankCode"); +define("ISP_QUOTA", "ISP_Quota"); +define("ISP_INTEREST", "ISP_Interest"); +define("ISP_APPLPRICE", "ISP_ApplPrice"); +define("ISP_CARDCODE", "ISP_CardCode"); +define("ISP_CARDNUM", "ISP_CardNum"); +define("ISP_POINT", "ISP_Point"); +define("ISP_APPLDATE", "ISP_ApplDate"); +define("ISP_APPLTIME", "ISP_ApplTime"); +define("ISP_APPLNUM", "ISP_ApplNum"); +define("ISP_RESULTCODE", "ISP_ResultCode"); +define("ISP_RESULTMSG", "ISP_ResultMsg"); +define("ISP_TERMINALNUM", "ISP_TerminalNum"); +define("ISP_MEMBERNUM", "ISP_MemberNum"); +define("ISP_PURCHASECODE", "ISP_PurchaseCode"); +//ACCT +define("ACCT_APPLDATE", "ACCT_ApplDate"); +define("ACCT_APPLTIME", "ACCT_ApplTime"); +define("ACCT_APPLNUM", "ACCT_ApplNum"); +//HPP +define("HPP_APPLDATE", "HPP_ApplDate"); +define("HPP_APPLTIME", "HPP_ApplTime"); +define("HPP_APPLNUM", "HPP_ApplNum"); +//VACT +define("VACT_APPLDATE", "VACT_ApplDate"); +define("VACT_APPLTIME", "VACT_ApplTime"); +//CASH +define("CSHR_APPLDATE", "CSHR_ApplDate"); +define("CSHR_APPLTIME", "CSHR_ApplTime"); +define("CSHR_APPLNUM", "CSHR_ApplNum"); +//ARSB +define("ARSB_APPLDATE", "ARSB_ApplDate"); +define("ARSB_APPLTIME", "ARSB_ApplTime"); +define("ARSB_APPLNUM", "ARSB_ApplNum"); +//PHNB +define("PHNB_APPLDATE", "PHNB_ApplDate"); +define("PHNB_APPLTIME", "PHNB_ApplTime"); +define("PHNB_APPLNUM", "PHNB_ApplNum"); +//CULT +define("CULT_APPLDATE", "CULT_ApplDate"); +define("CULT_APPLTIME", "CULT_ApplTime"); +define("CULT_APPLNUM", "CULT_ApplNum"); +//DGCL +define("GAMG_CNT", "GAMG_Cnt"); +define("GAMG_APPLDATE", "GAMG_ApplDate"); +define("GAMG_APPLTIME", "GAMG_ApplTime"); +define("GAMG_APPLNUM", "GAMG_ApplNum"); + +function MakePathGAMG($cnt) { + for ($i = 1; $i <= $cnt; $i++) { + define("GAMG_NUM$i", "GAMG_Num$i"); + define("GAMG_REMAINS$i", "GAMG_Remains$i"); + define("GAMG_ERRMSG$i", "GAMG_ErrMsg$i"); + } +} + +//EDUG +define("EDUG_APPLDATE", "EDUG_ApplDate"); +define("EDUG_APPLTIME", "EDUG_ApplTime"); +define("EDUG_APPLNUM", "EDUG_ApplNum"); +//TEEN +define("TEEN_APPLDATE", "TEEN_ApplDate"); +define("TEEN_APPLTIME", "TEEN_ApplTime"); +define("TEEN_APPLNUM", "TEEN_ApplNum"); + +//---------------------------------- +//ERROR CODE +//---------------------------------- +//!!TX ߰ !!! +define("NULL_DIR_ERR", "TX9001"); +define("NULL_TYPE_ERR", "TX9002"); +define("NULL_NOINTEREST_ERR", "TX9003"); +define("NULL_QUOTABASE_ERR", "TX9004"); +define("DNS_LOOKUP_ERR", "TX9005"); +define("MERCHANT_DB_ERR", "TX9006"); +define("DNS_LOOKUP_TIMEOUT_ERR", "TX9007"); +define("PGPUB_UPDATE_ERR", "TX9612"); + +//Ϻȣȭ +define("B64DECODE_UPDATE_ERR", "TX9101"); +define("B64DECODE_FINAL_ERR", "TX9102"); +define("B64DECODE_LENGTH_ERR", "TX9103"); +define("GET_KEYPW_EVP_B2K_ERR", "TX9104"); +define("GET_KEYPW_FILE_OPEN_ERR", "TX9105"); +define("GET_KEYPW_FILE_READ_ERR", "TX9106"); +define("GET_KEYPW_DECRYPT_INIT_ERR", "TX9107"); +define("GET_KEYPW_DECRYPT_UPDATE_ERR", "TX9108"); +define("GET_KEYPW_DECRYPT_FINAL_ERR", "TX9109"); +define("ENC_RAND_BYTES_ERR", "TX9110"); +define("ENC_INIT_ERR", "TX9111"); +define("ENC_UPDATE_ERR", "TX9112"); +define("ENC_FINAL_ERR", "TX9113"); +define("ENC_RSA_ERR", "TX9114"); +define("DEC_RSA_ERR", "TX9115"); +define("DEC_CIPHER_ERR", "TX9116"); +define("DEC_INIT_ERR", "TX9117"); +define("DEC_UPDATE_ERR", "TX9118"); +define("DEC_FINAL_ERR", "TX9119"); +define("SIGN_FINAL_ERR", "TX9120"); +define("SIGN_CHECK_ERR", "TX9121"); +define("ENC_NULL_F_ERR", "TX9122"); +define("ENC_INIT_RAND_ERR", "TX9123"); +define("ENC_PUTENV_ERR", "TX9124"); +//ʵüũ +define("NULL_KEYPW_ERR", "TX9201"); +define("NULL_MID_ERR", "TX9202"); +define("NULL_PGID_ERR", "TX9203"); +define("NULL_TID_ERR", "TX9204"); +define("NULL_UIP_ERR", "TX9205"); +define("NULL_URL_ERR", "TX9206"); +define("NULL_PRICE_ERR", "TX9207"); +define("NULL_PRICE1_ERR", "TX9208"); +define("NULL_PRICE2_ERR", "TX9209"); +define("NULL_CARDNUMBER_ERR", "TX9210"); +define("NULL_CARDEXPIRE_ERR", "TX9211"); +define("NULL_ENCRYPTED_ERR", "TX9212"); +define("NULL_CARDQUOTA_ERR", "TX9213"); +define("NULL_QUOTAINTEREST_ERR", "TX9214"); +define("NULL_AUTHENTIFICATION_ERR", "TX9215"); +define("NULL_AUTHFIELD1_ERR", "TX9216"); +define("NULL_AUTHFIELD2_ERR", "TX9217"); +define("NULL_BANKCODE_ERR", "TX9218"); +define("NULL_BANKACCOUNT_ERR", "TX9219"); +define("NULL_REGNUMBER_ERR", "TX9220"); +define("NULL_OCBCARDNUM_ERR", "TX9221"); +define("NULL_OCBPASSWD_ERR", "TX9222"); +define("NULL_PASSWD_ERR", "TX9223"); +define("NULL_CURRENCY_ERR", "TX9224"); +define("NULL_PAYMETHOD_ERR", "TX9225"); +define("NULL_GOODNAME_ERR", "TX9226"); +define("NULL_BUYERNAME_ERR", "TX9227"); +define("NULL_BUYERTEL_ERR", "TX9228"); +define("NULL_BUYEREMAIL_ERR", "TX9229"); +define("NULL_SESSIONKEY_ERR", "TX9230"); +//pgŰ ε +define("NULL_PGCERT_FP_ERR", "TX9231"); +define("NULL_X509_ERR", "TX9232"); +define("NULL_PGCERT_ERR", "TX9233"); + +define("RESULT_MSG_FORMAT_ERR", "TX9234"); + +// ü +define("NULL_PERNO_ERR", "TX9235"); // ֹιȣ +define("NULL_OID_ERR", "TX9236"); // ֹȣ +define("NULL_VCDBANK_ERR", "TX9237"); // ڵ +define("NULL_DTINPUT_ERR", "TX9238"); // Ա +define("NULL_NMINPUT_ERR", "TX9239"); // ۱ +//ǽð +define("NULL_BILLKEY_ERR", "TX9240"); // Ű +define("NULL_CARDPASS_ERR", "TX9241"); // ī +define("NULL_BILLTYPE_ERR", "TX9242"); // Ÿ +// CMS ü +define("NULL_PRICE_ORG_ERR", "TX9250"); // CMS ѱݾ +define("NULL_CMSDAY_ERR", "TX9251"); // CMS +define("NULL_CMSDATEFROM_ERR", "TX9252"); // CMS ݽۿ +define("NULL_CMSDATETO_ERR", "TX9253"); // CMS +// κ +define("NULL_CONFIRM_PRICE_ERR", "TX9260"); // ûݾ +// ݿ +define("NULL_CR_PRICE_ERR", "TX9270"); // ݰ ݾ +define("NULL_SUP_PRICE_ERR", "TX9271"); // ް +define("NULL_TAX_ERR", "TX9272"); // ΰ +define("NULL_SRVC_PRICE_ERR", "TX9273"); // +define("NULL_REG_NUM_ERR", "TX9274"); // ֹιȣ(ڹȣ) +define("NULL_USEOPT_ERR", "TX9275"); // ݿ 뵵 + +define("PRIVKEY_FILE_OPEN_ERR", "TX9301"); +define("INVALID_KEYPASS_ERR", "TX9302"); + +define("MAKE_TID_ERR", "TX9401"); +define("ACK_CHECKSUM_ERR", "TX9402"); +define("NETCANCEL_SOCK_CREATE_ERR", "TX9403"); +define("NETCANCEL_SOCK_SEND_ERR", "TX9404"); +define("NETCANCEL_SOCK_RECV_ERR", "TX9405"); +define("LOG_OPEN_ERR", "TX9406"); +define("LOG_WRITE_ERR", "TX9407"); + +define("SOCK_MAKE_EP_ERR", "TX9501"); +define("SOCK_CONN_ERR", "TX9502"); +define("SOCK_SEND1_ERR", "TX9503"); +define("SOCK_SEND2_ERR", "TX9504"); +define("SOCK_CLOSED_BY_PEER_ERR", "TX9505"); +define("SOCK_RECV1_ERR", "TX9506"); +define("SOCK_RECV2_ERR", "TX9507"); +define("SOCK_RECV_LEN_ERR", "TX9508"); +define("SOCK_TIMEO_ERR", "TX9509"); +define("SOCK_ETC1_ERR", "TX9510"); +define("SOCK_ETC2_ERR", "TX9511"); + +define("NULL_ESCROWTYPE_ERR", "TX6000"); +define("NULL_ESCROWMSG_ERR", "TX6001"); + +define("NULL_FIELD_REFUNDACCTNUM", "TX9245"); +define("NULL_FIELD_REFUNDBANKCODE", "TX9243"); +define("NULL_FIELD_REFUNDACCTNAME", "TX9244"); +?> \ No newline at end of file diff --git a/shop/inicis/libs/INILib.php b/shop/inicis/libs/INILib.php new file mode 100644 index 000000000..e8968ad28 --- /dev/null +++ b/shop/inicis/libs/INILib.php @@ -0,0 +1,795 @@ +UnsetField(); + } + + function UnsetField() + { + unset($this->m_REQUEST); + unset($this->m_RESULT); + } + + /*--------------------------------------------------*/ + /* */ + /* / û Set or Add */ + /* */ + /*--------------------------------------------------*/ + function SetField( $key, $val ) //Default Entity + { + $this->m_REQUEST[$key] = $val; + } + function SetXPath( $xpath, $val ) //User Defined Entity + { + $this->m_REQUEST2[$xpath] = $val; + } + + /*--------------------------------------------------*/ + /* */ + /* / fetch */ + /* */ + /*--------------------------------------------------*/ + function GetResult( $name ) //Default Entity + { + $result = $this->m_RESULT[$name]; + if( $result == "" ) + $result = $this->m_Data->GetXMLData( $name ); + if( $result == "" ) + $result = $this->m_Data->m_RESULT[$name]; + return $result; + } + + /*--------------------------------------------------*/ + /* */ + /* / ó */ + /* */ + /*--------------------------------------------------*/ + function startAction() + { + + /*--------------------------------------------------*/ + /* Overhead Operation */ + /*--------------------------------------------------*/ + $this->m_Data = new INIData( $this->m_REQUEST, $this->m_REQUEST2 ); + + /*--------------------------------------------------*/ + /* Log Start */ + /*--------------------------------------------------*/ + $this->m_Log = new INILog( $this->m_REQUEST ); + if(!$this->m_Log->StartLog()) + { + $this->MakeTXErrMsg( LOG_OPEN_ERR, "α ϴ.[".$this->m_REQUEST["inipayhome"]."]"); + return; + } + + /*--------------------------------------------------*/ + /* Logging Request Parameter */ + /*--------------------------------------------------*/ + $this->m_Log->WriteLog( DEBUG, $this->m_REQUEST ); + + /*--------------------------------------------------*/ + /* Set Type */ + /*--------------------------------------------------*/ + $this->m_type = $this->m_REQUEST["type"]; + + /*--------------------------------------------------*/ + /* Check Field */ + /*--------------------------------------------------*/ + if( !$this->m_Data->CheckField() ) + { + $err_msg = "ʼ׸(".$this->m_Data->m_ErrMsg.") Ǿϴ."; + $this->MakeTXErrMsg( $this->m_Data->m_ErrCode, $err_msg ); + $this->m_Log->WriteLog( ERROR, $err_msg ); + $this->m_Log->CloseLog( $this->GetResult(NM_RESULTMSG) ); + return; + } + $this->m_Log->WriteLog( INFO, "Check Field OK" ); + + /*--------------------------------------------------*/ + // Ű. ⼭ !! + /*--------------------------------------------------*/ + if( $this->m_type == TYPE_CHKFAKE ) + { + return $this->MakeChkFake(); + } + + /*--------------------------------------------------*/ + //Generate TID + /*--------------------------------------------------*/ + if( $this->m_type == TYPE_SECUREPAY || $this->m_type == TYPE_FORMPAY || $this->m_type == TYPE_OCBSAVE || + $this->m_type == TYPE_AUTHBILL || $this->m_type == TYPE_FORMAUTH || $this->m_type == TYPE_REQREALBILL || + $this->m_type == TYPE_REPAY || $this->m_type == TYPE_VACCTREPAY || $this->m_type == TYPE_RECEIPT || $this->m_type == TYPE_AUTH + ) + { + if(!$this->m_Data->MakeTID()) + { + $err_msg = "TID ߽ϴ.::".$this->m_Data->m_sTID; + $this->m_Log->WriteLog( ERROR, $err_msg ); + $this->MakeTXErrMsg( MAKE_TID_ERR, $err_msg ); + $this->m_Log->CloseLog( $this->GetResult(NM_RESULTMSG) ); + return; + } + $this->m_Log->WriteLog( INFO, 'Make TID OK '.$this->m_Data->m_sTID ); + } + + $this->m_Crypto = new INICrypto( $this->m_REQUEST ); + + /*--------------------------------------------------*/ + //PIŰ ε + /*--------------------------------------------------*/ + $this->m_Data->ParsePIEncrypted(); + $this->m_Log->WriteLog( INFO, "PI PUB KEY LOAD OK [".$this->m_Data->m_PIPGPubSN."]" ); + + /*--------------------------------------------------*/ + //PGŰ ε + /*--------------------------------------------------*/ + if( ($rtv = $this->m_Crypto->LoadPGPubKey( $pg_cert_SN )) != OK) + { + $err_msg = "PGŰ ε"; + $this->m_Log->WriteLog( ERROR, $err_msg ); + $this->MakeTXErrMsg( $rtv, $err_msg ); + $this->m_Log->CloseLog( $this->GetResult(NM_RESULTMSG) ); + return; + } + $this->m_Data->m_TXPGPubSN = $pg_cert_SN; + $this->m_Log->WriteLog( INFO, "PG PUB KEY LOAD OK [".$this->m_Data->m_TXPGPubSN."]" ); + + /*--------------------------------------------------*/ + //Ű ε + /*--------------------------------------------------*/ + if( ($rtv = $this->m_Crypto->LoadMPrivKey()) != OK ) + { + $err_msg = "Ű ε"; + $this->m_Log->WriteLog( ERROR, $err_msg ); + $this->MakeTXErrMsg( $rtv, $err_msg ); + $this->m_Log->CloseLog( $this->GetResult(NM_RESULTMSG) ); + $this->m_Crypto->FreePubKey(); + return; + } + $this->m_Log->WriteLog( INFO, "MERCHANT PRIV KEY LOAD OK" ); + + /*--------------------------------------------------*/ + // Ű ε(SN ˱!!) + /*--------------------------------------------------*/ + if( ($rtv = $this->m_Crypto->LoadMPubKey( $m_cert_SN )) != OK) + { + $err_msg = "Ű ε"; + $this->m_Log->WriteLog( ERROR, $err_msg ); + $this->MakeTXErrMsg( $rtv, $err_msg ); + $this->m_Log->CloseLog( $this->GetResult(NM_RESULTMSG) ); + return; + } + $this->m_Data->m_MPubSN = $m_cert_SN; + $this->m_Log->WriteLog( INFO, "MERCHANT PUB KEY LOAD OK [".$this->m_Data->m_MPubSN."]" ); + + /*--------------------------------------------------*/ + // ȣȭ( formpay, cancel, repay, recept, inquiry, opensub) + /*--------------------------------------------------*/ + if( $this->m_type == TYPE_CANCEL || $this->m_type == TYPE_REPAY || $this->m_type == TYPE_VACCTREPAY || + $this->m_type == TYPE_FORMPAY || $this->m_type == TYPE_RECEIPT || + $this->m_type == TYPE_CAPTURE || $this->m_type == TYPE_INQUIRY || $this->m_type == TYPE_OPENSUB || + ($this->m_type == TYPE_ESCROW && $this->m_Data->m_EscrowType == TYPE_ESCROW_DLV ) || + ($this->m_type == TYPE_ESCROW && $this->m_Data->m_EscrowType == TYPE_ESCROW_DNY_CNF ) || + $this->m_type == TYPE_REFUND + ) + { + if( ($rtv = $this->m_Data->MakeEncrypt( $this->m_Crypto )) != OK ) + { + $err_msg = "ȣȭ "; + $this->m_Log->WriteLog( ERROR, $err_msg ); + $this->MakeTXErrMsg( $rtv, $err_msg ); + $this->m_Log->CloseLog( $this->GetResult(NM_RESULTMSG) ); + return; + } + //$this->m_Log->WriteLog( DEBUG, "MAKE ENCRYPT OK" ); + $this->m_Log->WriteLog( DEBUG, "MAKE ENCRYPT OK[".$this->m_Data->m_EncBody."]" ); + } + + /*--------------------------------------------------*/ + //(Body) + /*--------------------------------------------------*/ + $this->m_Data->MakeBody(); + $this->m_Log->WriteLog( INFO, "MAKE BODY OK" ); + //$this->m_Log->WriteLog( INFO, "MAKE BODY OK[".$this->m_Data->m_sBody."]" ); + + /*--------------------------------------------------*/ + //(sign) + /*--------------------------------------------------*/ + if( ($rtv = $this->m_Crypto->Sign( $this->m_Data->m_sBody, $sign )) != OK ) + { + $err_msg = "ν"; + $this->m_Log->WriteLog( ERROR, $err_msg ); + $this->MakeTXErrMsg( $rtv, $err_msg ); + $this->m_Log->CloseLog( $this->GetResult(NM_RESULTMSG) ); + $this->m_Crypto->FreeAllKey(); + return; + } + $this->m_Data->m_sTail = $sign; + $this->m_Log->WriteLog( INFO, "SIGN OK" ); + //$this->m_Log->WriteLog( INFO, "SIGN OK[".$sign."]" ); + + /*--------------------------------------------------*/ + //(Head) + /*--------------------------------------------------*/ + $this->m_Data->MakeHead(); + $this->m_Log->WriteLog( INFO, "MAKE HEAD OK" ); + //$this->m_Log->WriteLog( INFO, "MAKE HEAD OK[".$head."]" ); + + $this->m_Log->WriteLog( INFO, "MSG_TO_PG:[".$this->m_Data->m_sMsg."]" ); + + /*--------------------------------------------------*/ + //ϻ + /*--------------------------------------------------*/ + //DRPG , added 07.11.15 + //ҽ-PG (->IP), edited 10.09.09 + if( $this->m_type == TYPE_SECUREPAY ) + { + if( $this->m_REQUEST["pgn"] == "" ) + $host = $this->m_Data->m_PG1; + else + $host = $this->m_REQUEST["pgn"]; + } + else + { + if( $this->m_REQUEST["pgn"] == "" ) + { + if( $this->m_cancelRC == 1 ) + $host = DRPG_IP; + else + $host = PG_IP; + } + else + $host = $this->m_REQUEST["pgn"]; + } + + $this->m_Socket = new INISocket($host); + if( ($rtv = $this->m_Socket->DNSLookup()) != OK ) + { + $err_msg = "[".$host."]DNS LOOKUP (MAIN)".$this->m_Socket->getErr(); + $this->m_Log->WriteLog( ERROR, $err_msg ); + $this->MakeTXErrMsg( $rtv, $err_msg ); + if( $this->m_type == TYPE_SECUREPAY ) //PIϰ, PI ִ pg1ip! + { + $this->m_Socket->ip = $this->m_Data->m_PG1IP; + } + else + { + if( $this->m_cancelRC == 1 ) + $this->m_Socket->ip = DRPG_IP; + else + $this->m_Socket->ip = PG_IP; + } + } + $this->m_Log->WriteLog( INFO, "DNS LOOKUP OK(".$this->m_Socket->host.":".$this->m_Socket->ip.":".$this->m_Socket->port.") laptime:".$this->m_Socket->dns_laptime ); + if( ($rtv = $this->m_Socket->open()) != OK ) + { + $this->m_Socket->close(); + + //PG2 ȯ + $err_msg = "[".$host."Ͽ(MAIN)::PG2 ȯ"; + $this->m_Log->WriteLog( ERROR, $err_msg ); + $this->MakeTXErrMsg( $rtv, $err_msg ); + if( $this->m_type == TYPE_SECUREPAY ) + { + $host = $this->m_Data->m_PG2; + } + else + { + $host = DRPG_HOST; + } + $this->m_Socket = new INISocket($host); + if( ($rtv = $this->m_Socket->DNSLookup()) != OK ) + { + $err_msg = "[".$host."]DNS LOOKUP (MAIN)".$this->m_Socket->getErr(); + $this->m_Log->WriteLog( ERROR, $err_msg ); + $this->MakeTXErrMsg( $rtv, $err_msg ); + if( $this->m_type == TYPE_SECUREPAY ) //PIϰ, PI ִ pg2ip! + { + $this->m_Socket->ip = $this->m_Data->m_PG2IP; + } + else + { + $this->m_Socket->ip = DRPG_IP; + } + } + $this->m_Log->WriteLog( INFO, "DNS LOOKUP OK(".$this->m_Socket->host.":".$this->m_Socket->ip.":".$this->m_Socket->port.") laptime:".$this->m_Socket->dns_laptime ); + if( ($rtv = $this->m_Socket->open()) != OK ) + { + $err_msg = "[".$host."Ͽ(MAIN)::".$this->m_Socket->getErr(); + $this->m_Log->WriteLog( ERROR, $err_msg ); + $this->MakeTXErrMsg( $rtv, $err_msg ); + $this->m_Log->CloseLog( $this->GetResult(NM_RESULTMSG) ); + $this->m_Socket->close(); + $this->m_Crypto->FreeAllKey(); + return; + } + } + $this->m_connIP = $this->m_Socket->ip; + $this->m_Log->WriteLog( INFO, "SOCKET CONNECT OK" ); + + /*--------------------------------------------------*/ + //۽ + /*--------------------------------------------------*/ + if( ($rtv = $this->m_Socket->send($this->m_Data->m_sMsg)) != OK ) + { + $err_msg = "ϼ۽ſ(MAIN)::".$this->m_Socket->getErr(); + $this->m_Log->WriteLog( ERROR, $err_msg ); + $this->MakeTXErrMsg( $rtv, $err_msg ); + $this->m_Log->CloseLog( $this->GetResult(NM_RESULTMSG) ); + $this->m_Crypto->FreeAllKey(); + $this->m_Socket->close(); + return; + } + $this->m_Log->WriteLog( INFO, "SEND OK" ); + + /*--------------------------------------------------*/ + // + /*--------------------------------------------------*/ + if( ($rtv = $this->m_Socket->recv($head, $body, $tail)) != OK ) + { + $err_msg = "ϼſ(MAIN)::".$this->m_Socket->getErr(); + $this->m_Log->WriteLog( ERROR, $err_msg ); + $this->MakeTXErrMsg( $rtv, $err_msg ); + $this->m_Socket->close(); + $this->NetCancel(); + $this->m_Log->CloseLog( $this->GetResult(NM_RESULTMSG) ); + $this->m_Crypto->FreeAllKey(); + return; + } + $this->m_Log->WriteLog( INFO, "RECV OK" ); + $this->m_Log->WriteLog( INFO, "MSG_FROM_PG:[".$head.$body.$tail."]" ); + $this->m_Data->m_Body = $body; + + /*--------------------------------------------------*/ + //Ȯ + /*--------------------------------------------------*/ + if( ($rtv = $this->m_Crypto->Verify( $body, $tail )) != OK ) + { + $err_msg = "VERIFY FAIL"; + $this->m_Log->WriteLog( ERROR, $err_msg ); + $this->MakeTXErrMsg( $rtv, $err_msg ); + $this->m_Socket->close(); + $this->NetCancel(); + $this->m_Log->CloseLog( $this->GetResult(NM_RESULTMSG) ); + $this->m_Crypto->FreeAllKey(); + return; + } + $this->m_Log->WriteLog( INFO, "VERIFY OK" ); + + /*--------------------------------------------------*/ + //Head Ľ + /*--------------------------------------------------*/ + if( ($rtv = $this->m_Data->ParseHead( $head )) != OK ) + { + $err_msg = "(HEAD) Ľ "; + $this->m_Log->WriteLog( ERROR, $err_msg ); + $this->MakeTXErrMsg( $rtv, $err_msg ); + $this->m_Socket->close(); + $this->NetCancel(); + $this->m_Log->CloseLog( $this->GetResult(NM_RESULTMSG) ); + $this->m_Crypto->FreeAllKey(); + return; + } + $this->m_Log->WriteLog( INFO, "PARSE HEAD OK" ); + + /*--------------------------------------------------*/ + //Body Ľ + /*--------------------------------------------------*/ + if( ($rtv = $this->m_Data->ParseBody( $body, $encrypted, $sessionkey )) != OK ) + { + $err_msg = "(Body) Ľ "; + $this->m_Log->WriteLog( ERROR, $err_msg ); + $this->MakeTXErrMsg( $rtv, $err_msg ); + $this->m_Socket->close(); + $this->NetCancel(); + $this->m_Log->CloseLog( $this->GetResult(NM_RESULTMSG) ); + $this->m_Crypto->FreeAllKey(); + return; + } + $this->m_Log->WriteLog( INFO, "PARSE BODY OK" ); + + /*--------------------------------------------------*/ + //ȣȭ + /*--------------------------------------------------*/ + if( $this->m_type == TYPE_SECUREPAY || $this->m_type == TYPE_FORMPAY || $this->m_type == TYPE_OCBSAVE || + $this->m_type == TYPE_CANCEL || $this->m_type == TYPE_AUTHBILL || $this->m_type == TYPE_FORMAUTH || + $this->m_type == TYPE_REQREALBILL || $this->m_type == TYPE_REPAY || $this->m_type == TYPE_VACCTREPAY || $this->m_type == TYPE_RECEIPT || + $this->m_type == TYPE_AUTH || $this->m_type == TYPE_CAPTURE || $this->m_type == TYPE_ESCROW || + $this->m_type == TYPE_REFUND || $this->m_type == TYPE_INQUIRY || $this->m_type == TYPE_OPENSUB + ) + { + if( ($rtv = $this->m_Crypto->Decrypt( $sessionkey, $encrypted, $decrypted )) != OK ) + { + $err_msg = "ȣȭ [".$this->GetResult(NM_RESULTMSG)."]"; + $this->m_Log->WriteLog( ERROR, $err_msg ); + $this->MakeTXErrMsg( $rtv, $err_msg ); + $this->m_Socket->close(); + $this->NetCancel(); + $this->m_Log->CloseLog( $this->GetResult(NM_RESULTMSG) ); + $this->m_Crypto->FreeAllKey(); + return; + } + $this->m_Log->WriteLog( INFO, "DECRYPT OK" ); + $this->m_Log->WriteLog( DEBUG, "DECRYPT MSG:[".$decrypted."]" ); + + //Parse Decrypt + $this->m_Data->ParseDecrypt( $decrypted ); + $this->m_Log->WriteLog( INFO, "DECRYPT PARSE OK" ); + } + + /*--------------------------------------------------*/ + //Assign Interface Variables + /*--------------------------------------------------*/ + $this->m_RESULT = $this->m_Data->m_RESULT; + + /*--------------------------------------------------*/ + //ACK + /*--------------------------------------------------*/ + //if( $this->GetResult(NM_RESULTCODE) == "00" && + if( (strcmp($this->GetResult(NM_RESULTCODE),"00") == 0) && + ( $this->m_type == TYPE_SECUREPAY || $this->m_type == TYPE_OCBSAVE || + $this->m_type == TYPE_FORMPAY || $this->m_type == TYPE_RECEIPT + ) + ) + { + $this->m_Log->WriteLog( INFO, "WAIT ACK INVOKING" ); + if( ($rtv = $this->Ack()) != OK ) + { + //ERROR + $err_msg = "ACK "; + $this->m_Log->WriteLog( ERROR, $err_msg ); + $this->MakeTXErrMsg( $rtv, $err_msg ); + $this->m_Socket->close(); + $this->NetCancel(); + $this->m_Log->CloseLog( $this->GetResult(NM_RESULTMSG) ); + $this->m_Crypto->FreeAllKey(); + return; + } + $this->m_Log->WriteLog( INFO, "SUCCESS ACK INVOKING" ); + } + /*--------------------------------------------------*/ + //PG Ű ٲ Ű UPDATE + /*--------------------------------------------------*/ + $pgpubkey = $this->m_Data->GetXMLData( NM_PGPUBKEY ); + if( $pgpubkey != "" ) + { + if( ($rtv = $this->m_Crypto->UpdatePGPubKey( $pgpubkey )) != OK ) + { + $err_msg = "PGŰ Ʈ "; + $this->m_Log->WriteLog( ERROR, $err_msg ); + $this->m_Data->GTHR( $rtv, $err_msg ); + } + else + $this->m_Log->WriteLog( INFO, "PGPubKey UPDATED!!" ); + } + + $this->m_Log->CloseLog( $this->GetResult(NM_RESULTMSG) ); + $this->m_Crypto->FreeAllKey(); + $this->m_Socket->close(); + + /*--------------------------------------------------*/ + //ҽ-ŷÿ DRPG õ + //2008.04.01 + /*--------------------------------------------------*/ + if( $this->GetResult(NM_RESULTCODE) == "01" && ($this->m_type == TYPE_CANCEL || $this->m_type == TYPE_INQUIRY) && $this->m_cancelRC == 0 ) + { + if( intval($this->GetResult(NM_ERRORCODE)) > 400000 && substr( $this->GetResult(NM_ERRORCODE), 3, 3 ) == "623" ) + { + $this->m_cancelRC = 1; + $this->startAction(); + } + } + + return; + + } // End of StartAction + + /*--------------------------------------------------*/ + /* */ + /* Ÿ */ + /* */ + /*--------------------------------------------------*/ + function MakeChkFake() + { + $this->m_Crypto = new INICrypto( $this->m_REQUEST ); + + /*--------------------------------------------------*/ + //Ű ε + /*--------------------------------------------------*/ + if( ($rtv = $this->m_Crypto->LoadMPrivKey()) != OK ) + { + $err_msg = "Ű ε"; + $this->m_Log->WriteLog( ERROR, $err_msg ); + $this->MakeTXErrMsg( $rtv, $err_msg ); + $this->m_Log->CloseLog( $this->GetResult(NM_RESULTMSG) ); + $this->m_Crypto->FreePubKey(); + return; + } + $this->m_Log->WriteLog( INFO, "MERCHANT PRIV KEY LOAD OK" ); + + /*--------------------------------------------------*/ + // Ű ε(SN ˱!!) + /*--------------------------------------------------*/ + if( ($rtv = $this->m_Crypto->LoadMPubKey( $m_cert_SN )) != OK) + { + $err_msg = "Ű ε"; + $this->m_Log->WriteLog( ERROR, $err_msg ); + $this->MakeTXErrMsg( $rtv, $err_msg ); + $this->m_Log->CloseLog( $this->GetResult(NM_RESULTMSG) ); + return; + } + $this->m_Log->WriteLog( INFO, "MERCHANT PUB KEY LOAD OK [".$this->m_Data->m_MPubSN."]" ); + + foreach ($this->m_REQUEST as $key => $val) + { + if( $key == "inipayhome" || $key == "type" || $key == "debug" || + $key == "admin" || $key == "checkopt" || $key == "enctype" ) + continue; + if( $key == "mid" ) + $temp1 .= $key."=".$val."&"; //msg + else + $temp2 .= $key."=".$val."&"; //hashmsg + } + //Make RN + $this->m_RESULT["rn"] = $this->m_Data->MakeRN(); + $temp1 .= "rn=".$this->m_RESULT["rn"]."&"; + + $checkMsg = $temp1; + $checkHashMsg = $temp2; + + $retHashStr = Base64Encode(sha1( $checkHashMsg, TRUE )); + $checkMsg .= "data=".$retHashStr; + + $HashMid = Base64Encode(sha1( $this->m_REQUEST["mid"], TRUE )); + + $this->m_Crypto->RSAMPrivEncrypt( $checkMsg, $RSATemp ); + $this->m_RESULT["encfield"] = "enc=".$RSATemp."&src=".Base64Encode($checkHashMsg); + $this->m_RESULT["certid"] = $HashMid.$m_cert_SN; + + $this->m_Log->WriteLog( INFO, "CHKFAKE KEY MAKE OK:".$this->m_RESULT["rn"] ); + + $this->m_Log->CloseLog( $this->GetResult(NM_RESULTMSG) ); + $this->m_Crypto->FreeAllKey(); + $this->m_RESULT[NM_RESULTCODE] = "00"; + return; + } + + /*--------------------------------------------------*/ + /* */ + /* ó Ȯ ޼ */ + /* */ + /*--------------------------------------------------*/ + function Ack() + { + //ACK Data + $this->m_Data->m_sBody = ""; + $this->m_Data->m_sTail = ""; + $this->m_Data->m_sCmd = CMD_REQ_ACK; + + //(Head) + $this->m_Data->MakeHead(); + $this->m_Log->WriteLog( DEBUG, "MAKE HEAD OK" ); + //$this->m_Log->WriteLog( DEBUG, "MSG_TO_PG:[".$this->m_Data->m_sMsg."]" ); + + //Send + if( ($rtv = $this->m_Socket->send($this->m_Data->m_sMsg)) != OK ) + { + $err_msg = "ACK ۿ"; + $this->m_Log->WriteLog( ERROR, $err_msg ); + return ACK_CHECKSUM_ERR; + } + //$this->m_Log->WriteLog( DEBUG, "SEND OK" ); + + if( ($rtv = $this->m_Socket->recv($head, $body, $tail)) != OK ) + { + $err_msg = "ACK ſ(ACK)"; + $this->m_Log->WriteLog( ERROR, $err_msg ); + return ACK_CHECKSUM_ERR; + } + //$this->m_Log->WriteLog( DEBUG, "RECV OK" ); + //$this->m_Log->WriteLog( INFO, "MSG_FROM_PG:[".$recv."]" ); + return OK; + } + + /*--------------------------------------------------*/ + /* */ + /* ޼ */ + /* */ + /*--------------------------------------------------*/ + function NetCancel() + { + $this->m_Log->WriteLog( INFO, "WAIT NETCANCEL INVOKING" ); + + if ( $this->m_type == TYPE_CANCEL || $this->m_type == TYPE_REPAY || $this->m_type == TYPE_VACCTREPAY || $this->m_type == TYPE_RECEIPT || + $this->m_type == TYPE_CONFIRM || $this->m_type == TYPE_OCBQUERY || $this->m_type == TYPE_ESCROW || + $this->m_type == TYPE_CAPTURE || $this->m_type == TYPE_AUTH || $this->m_type == TYPE_AUTHBILL || + ($this->m_type == TYPE_ESCROW && $this->m_Data->m_EscrowType == TYPE_ESCROW_DNY_CNF ) || + $this->m_type == TYPE_NETCANCEL + ) + { + $this->m_Log->WriteLog( INFO, "DON'T NEED NETCANCEL" ); + return true; + } + + //NetCancel Data + $this->m_Data->m_REQUEST["cancelmsg"] = ""; + $body = ""; + $sign = ""; + + $this->m_Data->m_Type = TYPE_CANCEL; // .Ʋ..~ + + //added escrow netcancel, 08.03.11 + if( $this->m_type == TYPE_ESCROW && $this->m_Data->m_EscrowType == TYPE_ESCROW_DLV ) + $this->m_Data->m_sCmd = CMD_REQ_DLV_NETC; + else if($this->m_type == TYPE_ESCROW && $this->m_Data->m_EscrowType == TYPE_ESCROW_CNF ) + $this->m_Data->m_sCmd = CMD_REQ_CNF_NETC; + else if($this->m_type == TYPE_ESCROW && $this->m_Data->m_EscrowType == TYPE_ESCROW_DNY ) + $this->m_Data->m_sCmd = CMD_REQ_DNY_NETC; + else + $this->m_Data->m_sCmd = CMD_REQ_NETC; + + $this->m_Data->m_sCrypto = FLAG_CRYPTO_3DES; + + //ȣȭ + if( ($rtv = $this->m_Data->MakeEncrypt( $this->m_Crypto )) != OK ) + { + $err_msg = "ȣȭ "; + $this->m_Log->WriteLog( ERROR, $err_msg ); + //$this->MakeTXErrMsg( $rtv, $err_msg ); + return; + } + $this->m_Log->WriteLog( DEBUG, "MAKE ENCRYPT OK[".$this->m_Data->m_EncBody."]" ); + + //(Body) + $this->m_Data->MakeBody(); + $this->m_Log->WriteLog( INFO, "MAKE BODY OK" ); + + //(sign) + if( ($rtv = $this->m_Crypto->Sign( $this->m_Data->m_sBody, $sign )) != OK ) + { + $err_msg = "ν"; + $this->m_Log->WriteLog( ERROR, $err_msg ); + //$this->MakeTXErrMsg( $rtv, $err_msg ); + return false; + } + $this->m_Data->m_sTail = $sign; + $this->m_Log->WriteLog( INFO, "SIGN OK" ); + + //(Head) + $this->m_Data->MakeHead(); + $this->m_Log->WriteLog( INFO, "MAKE HEAD OK" ); + + $this->m_Log->WriteLog( DEBUG, "MSG_TO_PG:[".$this->m_Data->m_sMsg."]" ); + + //ϻ + $this->m_Socket = new INISocket(""); + $this->m_Socket->ip = $this->m_connIP; // IP , 08.03.12 + if( ($rtv = $this->m_Socket->open()) != OK ) + { + $err_msg = "[".$this->m_Socket->ip."]Ͽ(NETC)::".$this->m_Socket->getErr(); + $this->m_Log->WriteLog( ERROR, $err_msg ); + //$this->MakeTXErrMsg( $rtv, $err_msg ); + $this->m_Log->CloseLog( $this->GetResult(NM_RESULTMSG) ); + $this->m_Socket->close(); + $this->m_Crypto->FreeAllKey(); + return; + } + $this->m_Log->WriteLog( INFO, "SOCKET CONNECT OK::".$this->m_Socket->ip ); + + //۽ + if( ($rtv = $this->m_Socket->send($this->m_Data->m_sMsg)) != OK ) + { + $err_msg = "ϼ۽ſ(NETC)".$this->m_Socket->getErr(); + $this->m_Log->WriteLog( ERROR, $err_msg ); + //$this->MakeTXErrMsg( $rtv, $err_msg ); + $this->m_Socket->close(); + return false; + } + $this->m_Log->WriteLog( INFO, "SEND OK" ); + + // + if( ($rtv = $this->m_Socket->recv($head, $body, $tail)) != OK ) + { + $err_msg = "ϼſ(NETC)"; + $this->m_Log->WriteLog( ERROR, $err_msg ); + //$this->MakeTXErrMsg( $rtv, $err_msg ); + $this->m_Socket->close(); + return false; + } + $this->m_Log->WriteLog( INFO, "RECV OK" ); + $this->m_Log->WriteLog( DEBUG, "MSG_FROM_PG:[".$head.$body.$tail."]" ); + + //Ȯ + if( ($rtv = $this->m_Crypto->Verify( $body, $tail )) != OK ) + { + $err_msg = "VERIFY FAIL"; + $this->m_Log->WriteLog( ERROR, $err_msg ); + //$this->MakeTXErrMsg( $rtv, $err_msg ); + $this->m_Socket->close(); + return false; + } + $this->m_Log->WriteLog( INFO, "VERIFY OK" ); + + // Ľ ʴ´!!!! + //׳ ⼭ ǰϴ.-_-;; + //Head Ľ + if( ($rtv = $this->m_Data->ParseHead( $head )) != OK ) + { + $err_msg = "(HEAD) Ľ "; + $this->m_Log->WriteLog( ERROR, $err_msg ); + //$this->MakeTXErrMsg( $rtv, $err_msg ); + $this->m_Socket->close(); + return; + } + //Body Ľ + if( ($rtv = $this->m_Data->ParseBody( $body, $encrypted, $sessionkey )) != OK ) + { + $err_msg = "(Body) Ľ "; + $this->m_Log->WriteLog( ERROR, $err_msg ); + //$this->MakeTXErrMsg( $rtv, $err_msg ); + $this->m_Socket->close(); + return; + } + + //if( $this->GetResult(NM_RESULTCODE) == "00" ) + if(strcmp($this->GetResult(NM_RESULTCODE),"00") == 0) + $this->m_Log->WriteLog( INFO, "SUCCESS NETCANCEL" ); + else + $this->m_Log->WriteLog( ERROR, "ERROR NETCANCEL[".$this->GetResult(NM_RESULTMSG)."]" ); + return true; + } + + function MakeIMStr($s, $t) + { + $this->m_Crypto = new INICrypto( $this->m_REQUEST ); + if( $t == "H" ) + return $this->m_Crypto->MakeIMStr($s, base64_decode(IMHK)); + else if( $t == "J" ) + return $this->m_Crypto->MakeIMStr($s, base64_decode(IMJK)); + } + + /*--------------------------------------------------*/ + /* */ + /* ޼ Make */ + /* */ + /*--------------------------------------------------*/ + function MakeTXErrMsg($err_code, $err_msg) + { + $this->m_RESULT[NM_RESULTCODE] = "01"; + $this->m_RESULT[NM_RESULTERRORCODE] = $err_code; + $this->m_RESULT[NM_RESULTMSG] = "[".$err_code."|".$err_msg."]"; + $this->m_Data->GTHR( $err_code, $err_msg ); + return; + } + +} + +?> diff --git a/shop/inicis/libs/INISoc.php b/shop/inicis/libs/INISoc.php new file mode 100644 index 000000000..23d607957 --- /dev/null +++ b/shop/inicis/libs/INISoc.php @@ -0,0 +1,251 @@ +hnd); + if($errCode!=0) + { + //Connection reset by peer + if($errCode==104) + $this->bConnected = false; + $errMsg = socket_strerror($errCode); + $this->sSocErr = "(".$errCode.")(".$errMsg.")"; + socket_clear_error($this->hnd); + } + elseif (strlen($msg)) + { + $this->sSocErr = $errMsg; + } + return false; + } + + function INISocket($host) + { + $this->family = AF_INET; + $this->type = SOCK_STREAM; + $this->protocol = SOL_TCP; + $this->hnd = @socket_create($this->family,$this->type,$this->protocol); + $this->error(); + $this->sBuffer = false; + $this->ip = null; + $this->host = $host; + $this->port = PG_PORT; + } + + function DNSLookUP() + { + $starttime=GetMicroTime(); + $ip = @gethostbyname($this->host); + if($ip) + { + $this->ip = $ip; + } + else + { + $this->error("Hostname ".$this->host." could not be resolved"); + return DNS_LOOKUP_ERR; + } + + $this->dns_laptime=round(GetMicroTime()-$starttime, 3); + if( $this->dns_laptime > DNS_LOOKUP_TIMEOUT ) + return DNS_LOOKUP_TIMEOUT_ERR; + + return OK; + } + + function open() + { + //Connect timeout Trickkkkkkkkk ##2. NONBLOCKING NEED , less CPU clocking!!^^ + //modified by ddaemiri, 2007.08.30 + + socket_set_nonblock($this->hnd); + if (!@socket_connect($this->hnd, $this->ip, $this->port)) + { + $err = socket_last_error($this->hnd); + $err_str = socket_strerror($err); + if ($err == 106) //EISCONN + { + $this->bConnected = true; + socket_set_block($this->hnd); + return OK; + } + //EINPROGRESS( Linux:115, Window Socket:10035, FreeBSD4.10:36, OS üũ Ұؼ strε ˻ ) + if ($err != ERRCODE_INPROGRESS_LINUX && $err != ERRCODE_INPROGRESS_WIN && + $err != ERRCODE_INPROGRESS_FREEBSD && $err_str != ERRSTR_INPROGRESS ) + { + $this->error(); + socket_close($this->hnd); + return SOCK_CONN_ERR; + } + } + + $read = array($this->hnd); + $write = array($this->hnd); + $rtv = @socket_select($read,$write,$except=NULL,TIMEOUT_CONNECT); + if( $rtv == 0 ) //TIMEOUT + { + $this->error(); + socket_close($this->hnd); + return SOCK_TIMEO_ERR; + } + else if ( $rtv === FALSE ) + { + $this->error(); + socket_close($this->hnd); + return SOCK_ETC1_ERR; + } + if( in_array($this->hnd,$read) || in_array($this->hnd,$write)) + { + if(@socket_get_option($this->hnd, SOL_SOCKET, SO_ERROR) === FALSE) + { + $this->error(); + socket_close($this->hnd); + return SOCK_ETC2_ERR; + } + } + $this->bConnected = true; + socket_set_block($this->hnd); + return OK; + } + function close() + { + //if(!$this->bConnected) return; + @socket_shutdown($this->hnd,2); + @socket_close($this->hnd); + } + + function send($sBuf) + { + if(!$this->bConnected) + { + $this->error("Socket error. Cannot send data on a closed socket."); + return SOCK_SEND1_ERR; + } + + $vWrite = array($this->hnd); + + while(($rtv = @socket_select($vRead = null,$vWrite ,$vExcept = null, TIMEOUT_WRITE)) === FALSE); + + if( $rtv == 0 ) + { + $this->error(); + //return SOCK_TIMEO_ERR; + return SOCK_CONN_ERR; //modify 2008.04.01 + } + if( $rtv === FALSE ) + { + $this->error(); + return SOCK_SEND2_ERR; + } + + $tmpBuf = strlen($sBuf) ? $sBuf : $this->sBuffer; + $iBufLen = strlen($tmpBuf); + $res = @socket_send($this->hnd,$tmpBuf,$iBufLen,0); + + if($res === FALSE) + { + $this->error(); + return SOCK_SEND2_ERR; + } + elseif ($res < $iBufLen) + { + $tmpBuf = substr($tmpBuf,$res); + $this->send($tmpBuf); + } + return OK; + } + function WaitRecv( &$recv_buf, $nleft ) + { + $recv_buf = null; + $read = array($this->hnd); + $buf = null; + while( $nleft > 0 ) + { + $rtv = @socket_select($read,$write=NULL,$except=NULL,TIMEOUT_READ); + if( $rtv == 0 ) + { + $this->error(); + return SOCK_TIMEO_ERR; + } + else if ( $rtv === FALSE ) + { + $this->error(); + return SOCK_ETC1_ERR; + } + + if(!in_array($this->hnd,$read)) + { + $this->error(); + return SOCK_RECV1_ERR; + } + if($buf = @socket_read($this->hnd, $nleft)) + { + $recv_buf .= $buf; + } + else + { + $this->error(); + return SOCK_RECV1_ERR; + } + $nleft -= strlen( $buf ); + } + return OK; + } + function recv(&$head, &$body, &$tail) + { + if(!$this->bConnected) + { + $this->error("Socket error. Cannot read any data on a closed socket."); + return SOCK_RECV1_ERR; + } + + //------------------------------------------------------ + //head + //------------------------------------------------------ + if( ($rtv = $this->WaitRecv( $head, MSGHEADER_LEN)) != OK ) return $rtv; + + if( $head == "" ) return SOCK_RECV2_ERR; + $body_len = intval(substr( $head, 0, BODY_LEN )); + $tail_len = intval(substr( $head, BODY_LEN, TAIL_LEN )); + + //------------------------------------------------------ + //body + //------------------------------------------------------ + if( ($rtv = $this->WaitRecv( $body, $body_len)) != OK ) return $rtv; + + //------------------------------------------------------ + //tail + //------------------------------------------------------ + if( ($rtv = $this->WaitRecv( $tail, $tail_len)) != OK ) return $rtv; + + return OK; + } + function getErr() + { + return $this->sSocErr; + } + +} + + +?> diff --git a/shop/inicis/libs/INIXml.php b/shop/inicis/libs/INIXml.php new file mode 100644 index 000000000..2a0a20614 --- /dev/null +++ b/shop/inicis/libs/INIXml.php @@ -0,0 +1,3495 @@ + version 1.0 | +// | Copyright (c) 2001 Michael P. Mehl. All rights reserved. | +// +----------------------------------------------------------------------+ +// | Latest releases are available at http://phpxml.org/. For feedback or | +// | bug reports, please contact the author at mpm@phpxml.org. Thanks! | +// +----------------------------------------------------------------------+ +// | The contents of this file are subject to the Mozilla Public License | +// | Version 1.1 (the "License"); you may not use this file except in | +// | compliance with the License. You may obtain a copy of the License at | +// | http://www.mozilla.org/MPL/ | +// | | +// | Software distributed under the License is distributed on an "AS IS" | +// | basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See | +// | the License for the specific language governing rights and | +// | limitations under the License. | +// | | +// | The Original Code is . | +// | | +// | The Initial Developer of the Original Code is Michael P. Mehl. | +// | Portions created by Michael P. Mehl are Copyright (C) 2001 Michael | +// | P. Mehl. All Rights Reserved. | +// +----------------------------------------------------------------------+ +// | Authors: | +// | Michael P. Mehl | +// +----------------------------------------------------------------------+ +// + +/** +* Class for accessing XML data through the XPath language. +* +* This class offers methods for accessing the nodes of a XML document using +* the XPath language. You can add or remove nodes, set or modify their +* content and their attributes. No additional PHP extensions like DOM XML +* or something similar are required to use these features. +* +* @link http://www.phpxml.org/ Latest release of this class +* @link http://www.w3.org/TR/xpath W3C XPath Recommendation +* @copyright Copyright (c) 2001 Michael P. Mehl. All rights reserved. +* @author Michael P. Mehl +* @version 1.0 (2001-03-08) +* @access public +*/ + +/** + * + * ش ̺귯 Ǿ ȵ˴ϴ. + * Ƿ ڵ忡 å ڿ ˷帳ϴ. + * + */ + +class XML +{ + /** + * List of all document nodes. + * + * This array contains a list of all document nodes saved as an + * associative array. + * + * @access private + * @var array + */ + var $nodes = array(); + + /** + * List of document node IDs. + * + * This array contains a list of all IDs of all document nodes that + * are used for counting when adding a new node. + * + * @access private + * @var array + */ + var $ids = array(); + + /** + * Current document path. + * + * This variable saves the current path while parsing a XML file and adding + * the nodes being read from the file. + * + * @access private + * @var string + */ + var $path = ""; + + /** + * Current document position. + * + * This variable counts the current document position while parsing a XML + * file and adding the nodes being read from the file. + * + * @access private + * @var int + */ + var $position = 0; + + /** + * Path of the document root. + * + * This string contains the full path to the node that acts as the root + * node of the whole document. + * + * @access private + * @var string + */ + var $root = ""; + + /** + * Current XPath expression. + * + * This string contains the full XPath expression being parsed currently. + * + * @access private + * @var string + */ + var $xpath = ""; + + /** + * List of entities to be converted. + * + * This array contains a list of entities to be converted when an XPath + * expression is evaluated. + * + * @access private + * @var array + */ + var $entities = array ( "&" => "&", "<" => "<", ">" => ">", + "'" => "&apos", '"' => """ ); + + /** + * List of supported XPath axes. + * + * This array contains a list of all valid axes that can be evaluated in an + * XPath expression. + * + * @access private + * @var array + */ + var $axes = array ( "child", "descendant", "parent", "ancestor", + "following-sibling", "preceding-sibling", "following", "preceding", + "attribute", "namespace", "self", "descendant-or-self", + "ancestor-or-self" ); + + /** + * List of supported XPath functions. + * + * This array contains a list of all valid functions that can be evaluated + * in an XPath expression. + * + * @access private + * @var array + */ + var $functions = array ( "last", "position", "count", "id", "name", + "string", "concat", "starts-with", "contains", "substring-before", + "substring-after", "substring", "string-length", "translate", + "boolean", "not", "true", "false", "lang", "number", "sum", "floor", + "ceiling", "round", "text" ); + + /** + * List of supported XPath operators. + * + * This array contains a list of all valid operators that can be evaluated + * in a predicate of an XPath expression. The list is ordered by the + * precedence of the operators (lowest precedence first). + * + * @access private + * @var array + */ + var $operators = array( " or ", " and ", "=", "!=", "<=", "<", ">=", ">", + "+", "-", "*", " div ", " mod " ); + + + var $xml_node = array(); + + /** + * Constructor of the class. + * + * This constructor initializes the class and, when a filename is given, + * tries to read and parse the given file. + * + * @access public + * @author Michael P. Mehl + * @param string $file Path and name of the file to read and parsed. + * @see load_xml() + */ + //modify by ddaemiri, 2007.05.28 + //load_file -> load_xml string Է¹ . + function XML ( $file = "" ) + { + // Check whether a file was given. + if ( !empty($file) ) + { + // Load the XML file. + return $this->load_xml($file, ""); + } + } + + /** + * Reads a file and parses the XML data. + * + * This method reads the content of a XML file, tries to parse its + * content and upon success stores the information retrieved from + * the file into an array. + * + * @access public + * @author Michael P. Mehl + * @param string $file Path and name of the file to be read and parsed. + * @see handle_start_element(), handle_end_element(), + * handle_character_data() + */ + //modify by ddaemiri, 2007.05.28 + //load_file -> load_xml string Է¹ . + function load_xml ( $file, $str ) + { + // Check whether the file exists and is readable. + if ( (file_exists($file) && is_readable($file)) || $str != "") + { + // Read the content of the file. + if( $str == "" ) + $content = implode("", file($file)); + else + $content = $str; + + // Check whether content has been read. + if ( !empty($content) ) + { + // Create an XML parser. + $parser = xml_parser_create(); + + // Set the options for parsing the XML data. + xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); + xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); + + // Set the object for the parser. + xml_set_object($parser, $this); + + // Set the element handlers for the parser. + xml_set_element_handler($parser, "handle_start_element", "handle_end_element"); + xml_set_character_data_handler($parser, "handle_character_data"); + + // Parse the XML file. + if ( !xml_parse($parser, $content, true) ) + { + // Display an error message. + $this->display_error("XML error in file %s, line %d: %s", + $file, xml_get_current_line_number($parser), + xml_error_string(xml_get_error_code($parser))); + } + + // Free the parser. + xml_parser_free($parser); + + return OK; + } + } + else + { + // Display an error message. + //$this->display_error("File %s could not be found or read.", $file); + return RESULT_MSG_FORMAT_ERR; + } + } + + //modify by ddaemiri, 2007.05.28 + //charset ߰( header ) + function make_xml ( $highlight = array(), $root = "", $level = 0, $charset = "UTF-8" ) + { + // header ߰ + $header = ""."\n"; + $body = $this->get_xml( $highlight, $root, $level ); + return $header.$body; + } + + /** + * Generates a XML file with the content of the current document. + * + * This method creates a string containing the XML data being read + * and modified by this class before. This string can be used to save + * a modified document back to a file or doing other nice things with + * it. + * + * @access public + * @author Michael P. Mehl + * @param array $highlight Array containing a list of full document + * paths of nodes to be highlighted by ... tags + * in the generated XML string. + * @param string $root While doing a recursion with this method, this + * parameter is used for internal purpose. + * @param int $level While doing a recursion with this method, this + * parameter is used for internal purpose. + * @return string The returned string contains well-formed XML data + * representing the content of this document. + * @see load_xml(), evaluate(), get_content() + */ + //modify by ddaemiri, 2007.05.28 + //get_file -> get_xml Լ̸ . + function get_xml ( $highlight = array(), $root = "", $level = 0 ) + { + + // Create a string to save the generated XML data. + $xml = ""; + + // Create two strings containing the tags for highlighting a node. + $highlight_start = ""; + $highlight_end = ""; + + // Generate a string to be displayed before the tags. + $before = ""; + + // Calculate the amount of whitespaces to display. + for ( $i = 0; $i < ( $level * 2 ); $i++ ) + { + // Add a whitespaces to the string. + $before .= " "; + } + + // Check whether a root node is given. + if ( empty($root) ) + { + // Set it to the document root. + $root = $this->root; + } + + // Check whether the node is selected. + $selected = in_array($root, $highlight); + + // Now add the whitespaces to the XML data. + $xml .= $before; + + // Check whether the node is selected. + if ( $selected ) + { + // Add the highlight code to the XML data. + $xml .= $highlight_start; + } + + // Now open the tag. + $xml .= "<".$this->nodes[$root]["name"]; + + // Check whether there are attributes for this node. + if ( count($this->nodes[$root]["attributes"]) > 0 ) + { + // Run through all attributes. + foreach ( $this->nodes[$root]["attributes"] as $key => $value ) + { + // Check whether this attribute is highlighted. + if ( in_array($root."/attribute::".$key, $highlight) ) + { + // Add the highlight code to the XML data. + $xml .= $highlight_start; + } + + // Add the attribute to the XML data. + $xml .= " ".$key."=\"".trim(stripslashes($value))."\""; + + // Check whether this attribute is highlighted. + if ( in_array($root."/attribute::".$key, $highlight) ) + { + // Add the highlight code to the XML data. + $xml .= $highlight_end; + } + } + } + + // Check whether the node contains character data or has children. + if ( $this->nodes[$root]["text"] == "" && + !isset($this->nodes[$root]["children"]) ) + { + // Add the end to the tag. + $xml .= "/"; + } + + // Close the tag. + //$xml .= ">\n"; + $xml .= ">"; + + // Check whether the node is selected. + if ( $selected ) + { + // Add the highlight code to the XML data. + $xml .= $highlight_end; + } + + // Check whether the node contains character data. + if ( $this->nodes[$root]["text"] != "" ) + { + // Add the character data to the XML data. + //$xml .= $before." ".$this->nodes[$root]["text"]."\n"; + //$xml .= $before.$this->nodes[$root]["text"]; + $xml .= $this->nodes[$root]["text"]; + } + + // Check whether the node has children. + if ( isset($this->nodes[$root]["children"]) ) + { + // Run through all children with different names. + foreach ( $this->nodes[$root]["children"] as $child => $pos ) + { + // Run through all children with the same name. + for ( $i = 1; $i <= $pos; $i++ ) + { + // Generate the full path of the child. + $fullchild = $root."/".$child."[".$i."]"; + + // Add the child's XML data to the existing data. + $xml .= "\n\t".$this->get_xml($highlight, $fullchild, $level + 1); + } + } + } + + // Check whether there are attributes for this node. + if ( $this->nodes[$root]["text"] != "" || + isset($this->nodes[$root]["children"]) ) + { + // Add the whitespaces to the XML data. + //$xml .= $before; + + // Check whether the node is selected. + if ( $selected ) + { + // Add the highlight code to the XML data. + $xml .= $highlight_start; + } + + // Add the closing tag. + $xml .= "nodes[$root]["name"].">"; + + // Check whether the node is selected. + if ( $selected ) + { + // Add the highlight code to the XML data. + $xml .= $highlight_end; + } + + // Add a linebreak. + //$xml .= "\n"; + } + + // Return the XML data. + return $xml; + } + + /** + * Adds a new node to the XML document. + * + * This method adds a new node to the tree of nodes of the XML document + * being handled by this class. The new node is created according to the + * parameters passed to this method. + * + * @access public + * @author Michael P. Mehl + * @param string $content Full path of the parent, to which the new + * node should be added as a child. + * @param string $name Name of the new node. + * @return string The string returned by this method will contain the + * full document path of the created node. + * @see remove_node(), evaluate() + */ + function add_node ( $context, $name, $value="", $attr_arr=NULL ) + { + // Check whether a name for this element is already set. + if ( empty($this->root) ) + { + // Use this tag as the root element. + $this->root = "/".$name."[1]"; + } + + // Calculate the full path for this element. + $path = $context."/".$name; + + // Set the relative context and the position. + $position = ++$this->ids[$path]; + $relative = $name."[".$position."]"; + + // Calculate the full path. + $fullpath = $context."/".$relative; + + // Calculate the context position, which is the position of this + // element within elements of the same name in the parent node. + $this->nodes[$fullpath]["context-position"] = $position; + + // Calculate the position for the following and preceding axis + // detection. + $this->nodes[$fullpath]["document-position"] = + $this->nodes[$context]["document-position"] + 1; + + // Save the information about the node. + $this->nodes[$fullpath]["name"] = $name; + $this->nodes[$fullpath]["text"] = ""; + $this->nodes[$fullpath]["parent"] = $context; + + // Add this element to the element count array. + if ( !$this->nodes[$context]["children"][$name] ) + { + // Set the default name. + $this->nodes[$context]["children"][$name] = 1; + } + else + { + // Calculate the name. + $this->nodes[$context]["children"][$name] = + $this->nodes[$context]["children"][$name] + 1; + } + + if( $value != "" && is_array($attr_arr) ) + { + $this->set_attributes($fullpath, $attr_arr); + if( $attr_arr["urlencode"] == "1" ) + $value = urlencode( $value); + } + if( $value != "" ) + { + $this->set_content($fullpath, $value); + } + + // Return the path of the new node. + return $fullpath; + } + + /** + * Removes a node from the XML document. + * + * This method removes a node from the tree of nodes of the XML document. + * If the node is a document node, all children of the node and its + * character data will be removed. If the node is an attribute node, + * only this attribute will be removed, the node to which the attribute + * belongs as well as its children will remain unmodified. + * + * @access public + * @author Michael P. Mehl + * @param string $node Full path of the node to be removed. + * @see add_node(), evaluate() + */ + function remove_node ( $node ) + { + // Check whether the node is an attribute node. + if ( preg_match("/attribute::/", $node) ) + { + // Get the path to the attribute node's parent. + $parent = $this->prestr($node, "/attribute::"); + + // Get the name of the attribute. + $attribute = $this->afterstr($node, "/attribute::"); + + // Check whether the attribute exists. + if ( isset($this->nodes[$parent]["attributes"][$attribute]) ) + { + // Create a new array. + $new = array(); + + // Run through the existing attributes. + foreach ( $this->nodes[$parent]["attributes"] + as $key => $value ) + { + // Check whether it's the attribute to remove. + if ( $key != $attribute ) + { + // Add it to the new array again. + $new[$key] = $value; + } + } + + // Save the new attributes. + $this->nodes[$parent]["attributes"] = $new; + } + } + else + { + // Create an associative array, which contains information about + // all nodes that required to be renamed. + $rename = array(); + + // Get the name, the parent and the siblings of current node. + $name = $this->nodes[$node]["name"]; + $parent = $this->nodes[$node]["parent"]; + $siblings = $this->nodes[$parent]["children"][$name]; + + // Decrease the number of children. + $this->nodes[$parent]["children"][$name]--; + + // Create a counter for renumbering the siblings. + $counter = 1; + + // Now run through the siblings. + for ( $i = 1; $i <= $siblings; $i++ ) + { + // Create the name of the sibling. + $sibling = $parent."/".$name."[".$i."]"; + + // Check whether it's the name of the current node. + if ( $sibling != $node ) + { + // Create the new name for the sibling. + $new = $parent."/".$name."[".$counter."]"; + + // Increase the counter. + $counter++; + + // Add the old and the new name to the list of nodes + // to be renamed. + $rename[$sibling] = $new; + } + } + + // Create an array for saving the new node-list. + $nodes = array(); + + // Now run through through the existing nodes. + foreach ( $this->nodes as $name => $values ) + { + // Check the position of the path of the node to be deleted + // in the path of the current node. + $position = strpos($name, $node); + + // Check whether it's not the node to be deleted. + if ( $position === false ) + { + // Run through the array of nodes to be renamed. + foreach ( $rename as $old => $new ) + { + // Check whether this node and it's parent requires to + // be renamed. + $name = str_replace($old, $new, $name); + $values["parent"] = str_replace($old, $new, + $values["parent"]); + } + + // Add the node to the list of nodes. + $nodes[$name] = $values; + } + } + + // Save the new array of nodes. + $this->nodes = $nodes; + } + } + + /** + * Add content to a node. + * + * This method adds content to a node. If it's an attribute node, then + * the value of the attribute will be set, otherwise the character data of + * the node will be set. The content is appended to existing content, + * so nothing will be overwritten. + * + * @access public + * @author Michael P. Mehl + * @param string $path Full document path of the node. + * @param string $value String containing the content to be added. + * @see get_content(), evaluate() + */ + function add_content ( $path, $value ) + { + // Check whether it's an attribute node. + if ( preg_match("/attribute::/", $path) ) + { + // Get the path to the attribute node's parent. + $parent = $this->prestr($path, "/attribute::"); + + // Get the parent node. + $parent = $this->nodes[$parent]; + + // Get the name of the attribute. + $attribute = $this->afterstr($path, "/attribute::"); + + // Set the attribute. + $parent["attributes"][$attribute] .= $value; + } + else + { + // Set the character data of the node. + $this->nodes[$path]["text"] .= $value; + } + } + + /** + * Set the content of a node. + * + * This method sets the content of a node. If it's an attribute node, then + * the value of the attribute will be set, otherwise the character data of + * the node will be set. Existing content will be overwritten. + * + * @access public + * @author Michael P. Mehl + * @param string $path Full document path of the node. + * @param string $value String containing the content to be set. + * @see get_content(), evaluate() + */ + function set_content ( $path, $value ) + { + // Check whether it's an attribute node. + if ( preg_match("/attribute::/", $path) ) + { + // Get the path to the attribute node's parent. + $parent = $this->prestr($path, "/attribute::"); + + // Get the parent node. + $parent = $this->nodes[$parent]; + + // Get the name of the attribute. + $attribute = $this->afterstr($path, "/attribute::"); + + // Set the attribute. + $parent["attributes"][$attribute] = $value; + } + else + { + // Set the character data of the node. + $this->nodes[$path]["text"] = strtr($value, $this->entities); + } + } + + /** + * Retrieves the content of a node. + * + * This method retrieves the content of a node. If it's an attribute + * node, then the value of the attribute will be retrieved, otherwise + * it'll be the character data of the node. + * + * @access public + * @author Michael P. Mehl + * @param string $path Full document path of the node, from which the + * content should be retrieved. + * @return string The returned string contains either the value or the + * character data of the node. + * @see set_content(), evaluate() + */ + function get_content ( $path ) + { + // Check whether it's an attribute node. + if ( preg_match("/attribute::/", $path) ) + { + // Get the path to the attribute node's parent. + $parent = $this->prestr($path, "/attribute::"); + + // Get the parent node. + $parent = $this->nodes[$parent]; + + // Get the name of the attribute. + $attribute = $this->afterstr($path, "/attribute::"); + + // Get the attribute. + $attribute = $parent["attributes"][$attribute]; + + // Return the value of the attribute. + return $attribute; + } + else + { + // Return the cdata of the node. + return stripslashes($this->nodes[$path]["text"]); + } + } + + /** + * Add attributes to a node. + * + * This method adds attributes to a node. Existing attributes will not be + * overwritten. + * + * @access public + * @author Michael P. Mehl + * @param string $path Full document path of the node, the attributes + * should be added to. + * @param array $attributes Associative array containing the new + * attributes for the node. + * @see set_content(), get_content() + */ + function add_attributes ( $path, $attributes ) + { + // Add the attributes to the node. + $this->nodes[$path]["attributes"] = array_merge($attributes, + $this->nodes[$path]["attributes"]); + } + + /** + * Sets the attributes of a node. + * + * This method sets the attributes of a node and overwrites all existing + * attributes by doing this. + * + * @access public + * @author Michael P. Mehl + * @param string $path Full document path of the node, the attributes + * of which should be set. + * @param array $attributes Associative array containing the new + * attributes for the node. + * @see set_content(), get_content() + */ + function set_attributes ( $path, $attributes ) + { + // Set the attributes of the node. + $this->nodes[$path]["attributes"] = $attributes; + } + + /** + * Retrieves a list of all attributes of a node. + * + * This method retrieves a list of all attributes of the node specified in + * the argument. + * + * @access public + * @author Michael P. Mehl + * @param string $path Full document path of the node, from which the + * list of attributes should be retrieved. + * @return array The returned associative array contains the all + * attributes of the specified node. + * @see get_content(), $nodes, $ids + */ + function get_attributes ( $path ) + { + // Return the attributes of the node. + return $this->nodes[$path]["attributes"]; + } + + /** + * Retrieves the name of a document node. + * + * This method retrieves the name of document node specified in the + * argument. + * + * @access public + * @author Michael P. Mehl + * @param string $path Full document path of the node, from which the + * name should be retrieved. + * @return string The returned array contains the name of the specified + * node. + * @see get_content(), $nodes, $ids + */ + function get_name ( $path ) + { + // Return the name of the node. + return $this->nodes[$path]["name"]; + } + + /** + * Evaluates an XPath expression. + * + * This method tries to evaluate an XPath expression by parsing it. A + * XML document has to be read before this method is able to work. + * + * @access public + * @author Michael P. Mehl + * @param string $path XPath expression to be evaluated. + * @param string $context Full path of a document node, starting + * from which the XPath expression should be evaluated. + * @return array The returned array contains a list of the full + * document paths of all nodes that match the evaluated + * XPath expression. + * @see $nodes, $ids + */ + function evaluate ( $path, $context = "" ) + { + // Remove slashes and quote signs. + $path = stripslashes($path); + $path = str_replace("\"", "", $path); + $path = str_replace("'", "", $path); + + // Split the paths into different paths. + $paths = $this->split_paths($path); + + // Create an empty set to save the result. + $result = array(); + + // Run through all paths. + foreach ( $paths as $path ) + { + // Trim the path. + $path = trim($path); + + // Save the current path. + $this->xpath = $path; + + // Convert all entities. + $path = strtr($path, array_flip($this->entities)); + + // Split the path at every slash. + $steps = $this->split_steps($path); + + // Check whether the first element is empty. + if ( empty($steps[0]) ) + { + // Remove the first and empty element. + array_shift($steps); + } + + // Start to evaluate the steps. + $nodes = $this->evaluate_step($context, $steps); + + // Remove duplicated nodes. + $nodes = array_unique($nodes); + + // Add the nodes to the result set. + $result = array_merge($result, $nodes); + } + + // Return the result. + return $result; + } + + /** + * Handles opening XML tags while parsing. + * + * While parsing a XML document for each opening tag this method is + * called. It'll add the tag found to the tree of document nodes. + * + * @access private + * @author Michael P. Mehl + * @param int $parser Handler for accessing the current XML parser. + * @param string $name Name of the opening tag found in the document. + * @param array $attributes Associative array containing a list of + * all attributes of the tag found in the document. + * @see handle_end_element(), handle_character_data(), $nodes, $ids + */ + function handle_start_element ( $parser, $name, $attributes ) + { + // Add a node. + $this->path = $this->add_node($this->path, $name); + + // Set the attributes. + // Xpath Ȱ´. Ѵ ߴ!! + // modifyed by ddaemiri, 2007.09.03 + // $this->set_attributes($this->path, $attributes); + + // add array, added by ddaemiri, 2007.09.03 + $arr = preg_split( "/[\/]+/", $this->path, -1, PREG_SPLIT_NO_EMPTY ); + $this->xml_node[$arr[count($arr)-1]]["attr"] = $attributes; + } + + /** + * Handles closing XML tags while parsing. + * + * While parsing a XML document for each closing tag this method is + * called. + * + * @access private + * @author Michael P. Mehl + * @param int $parser Handler for accessing the current XML parser. + * @param string $name Name of the closing tag found in the document. + * @see handle_start_element(), handle_character_data(), $nodes, $ids + */ + function handle_end_element ( $parser, $name ) + { + // Jump back to the parent element. + $this->path = substr($this->path, 0, strrpos($this->path, "/")); + } + + /** + * Handles character data while parsing. + * + * While parsing a XML document for each character data this method + * is called. It'll add the character data to the document tree. + * + * @access private + * @author Michael P. Mehl + * @param int $parser Handler for accessing the current XML parser. + * @param string $text Character data found in the document. + * @see handle_start_element(), handle_end_element(), $nodes, $ids + */ + function handle_character_data ( $parser, $text ) + { + // Replace entities. + $text = strtr($text, $this->entities); + + // Save the text. + // Xpath Ȱ´. Ѵ ߴ!! + // modifyed by ddaemiri, 2007.09.03 + //$this->add_content($this->path, addslashes(trim($text))); + + // add array, added by ddaemiri, 2007.09.03 + $arr = preg_split( "/[\/]+/", $this->path, -1, PREG_SPLIT_NO_EMPTY ); + //edited by ddaemiri. libexpat \n иڷ ν + //$this->xml_node[$arr[count($arr)-1]]["text"] = addslashes(trim($text)); + $this->xml_node[$arr[count($arr)-1]]["text"] = $this->xml_node[$arr[count($arr)-1]]["text"].addslashes(trim($text)); + } + + /** + * Splits an XPath expression into its different expressions. + * + * This method splits an XPath expression. Each expression can consists of + * list of expression being separated from each other by a | character. + * + * @access private + * @author Michael P. Mehl + * @param string $expression The complete expression to be splitted + * into its different expressions. + * @return array The array returned from this method contains a list + * of all expressions found in the expression passed to this + * method as a parameter. + * @see evalute() + */ + function split_paths ( $expression ) + { + // Create an empty array. + $paths = array(); + + // Save the position of the slash. + $position = -1; + + // Run through the expression. + do + { + // Search for a slash. + $position = $this->search_string($expression, "|"); + + // Check whether a | was found. + if ( $position >= 0 ) + { + // Get the left part of the expression. + $left = substr($expression, 0, $position); + $right = substr($expression, $position + 1); + + // Add the left value to the steps. + $paths[] = $left; + + // Reduce the expression to the right part. + $expression = $right; + } + } + while ( $position > -1 ); + + // Add the remaing expression to the list of steps. + $paths[] = $expression; + + // Return the steps. + return $paths; + } + + /** + * Splits an XPath expression into its different steps. + * + * This method splits an XPath expression. Each expression can consists of + * list of steps being separated from each other by a / character. + * + * @access private + * @author Michael P. Mehl + * @param string $expression The complete expression to be splitted + * into its different steps. + * @return array The array returned from this method contains a list + * of all steps found in the expression passed to this + * method as a parameter. + * @see evalute() + */ + function split_steps ( $expression ) + { + // Create an empty array. + $steps = array(); + + // Replace a double slashes, because they'll cause problems otherwise. + $expression = str_replace("//@", "/descendant::*/@", $expression); + $expression = str_replace("//", "/descendant::", $expression); + + // Save the position of the slash. + $position = -1; + + // Run through the expression. + do + { + // Search for a slash. + $position = $this->search_string($expression, "/"); + + // Check whether a slash was found. + if ( $position >= 0 ) + { + // Get the left part of the expression. + $left = substr($expression, 0, $position); + $right = substr($expression, $position + 1); + + // Add the left value to the steps. + $steps[] = $left; + + // Reduce the expression to the right part. + $expression = $right; + } + } + while ( $position > -1 ); + + // Add the remaing expression to the list of steps. + $steps[] = $expression; + + // Return the steps. + return $steps; + } + + /** + * Retrieves axis information from an XPath expression step. + * + * This method tries to extract the name of the axis and its node-test + * from a given step of an XPath expression at a given node. + * + * @access private + * @author Michael P. Mehl + * @param string $step String containing a step of an XPath expression. + * @param string $node Full document path of the node on which the + * step is executed. + * @return array This method returns an array containing information + * about the axis found in the step. + * @see evaluate_step() + */ + function get_axis ( $step, $node ) + { + // Create an array to save the axis information. + $axis = array( + "axis" => "", + "node-test" => "", + "predicate" => array() + ); + + // Check whether there are predicates. + if ( preg_match("/\[/", $step) ) + { + // Get the predicates. + $predicates = substr($step, strpos($step, "[")); + + // Reduce the step. + $step = $this->prestr($step, "["); + + // Try to split the predicates. + $predicates = str_replace("][", "]|[", $predicates); + $predicates = explode("|", $predicates); + + // Run through all predicates. + foreach ( $predicates as $predicate ) + { + // Remove the brackets. + $predicate = substr($predicate, 1, strlen($predicate) - 2); + + // Add the predicate to the list of predicates. + $axis["predicate"][] = $predicate; + } + } + + // Check whether the axis is given in plain text. + if ( $this->search_string($step, "::") > -1 ) + { + // Split the step to extract axis and node-test. + $axis["axis"] = $this->prestr($step, "::"); + $axis["node-test"] = $this->afterstr($step, "::"); + } + else + { + // Check whether the step is empty. + if ( empty($step) ) + { + // Set it to the default value. + $step = "."; + } + + // Check whether is an abbreviated syntax. + if ( $step == "*" ) + { + // Use the child axis and select all children. + $axis["axis"] = "child"; + $axis["node-test"] = "*"; + } + //elseif ( ereg("\(", $step) ) + //elseif ( preg_match("\(", $step) ) + elseif ( preg_match("/\(/", $step) ) + { + // Check whether it's a function. + if ( $this->is_function($this->prestr($step, "(")) ) + { + // Get the position of the first bracket. + $start = strpos($step, "("); + $end = strpos($step, ")", $start); + + // Get everything before, between and after the brackets. + $before = substr($step, 0, $start); + $between = substr($step, $start + 1, $end - $start - 1); + $after = substr($step, $end + 1); + + // Trim each string. + $before = trim($before); + $between = trim($between); + $after = trim($after); + + // Save the evaluated function. + $axis["axis"] = "function"; + $axis["node-test"] = $this->evaluate_function($before, + $between, $node); + } + else + { + // Use the child axis and a function. + $axis["axis"] = "child"; + $axis["node-test"] = $step; + } + } + //elseif ( eregi("^@", $step) ) + //elseif ( preg_match("^@/i", $step) ) + elseif ( preg_match("/^@/i", $step) ) + { + // Use the attribute axis and select the attribute. + $axis["axis"] = "attribute"; + $axis["node-test"] = substr($step, 1); + } + //elseif ( eregi("\]$", $step) ) + //elseif ( preg_match("\]$/i", $step) ) + elseif ( preg_match("/\]$/i", $step) ) + { + // Use the child axis and select a position. + $axis["axis"] = "child"; + $axis["node-test"] = substr($step, strpos($step, "[")); + } + elseif ( $step == "." ) + { + // Select the self axis. + $axis["axis"] = "self"; + $axis["node-test"] = "*"; + } + elseif ( $step == ".." ) + { + // Select the parent axis. + $axis["axis"] = "parent"; + $axis["node-test"] = "*"; + } + //elseif ( ereg("^[a-zA-Z0-9\-_]+$", $step) ) + //elseif ( preg_match("^[a-zA-Z0-9\-_]+$", $step) ) + elseif ( preg_match("/^[a-zA-Z0-9\-_]+$/", $step) ) + { + // Select the child axis and the child. + $axis["axis"] = "child"; + $axis["node-test"] = $step; + } + else + { + // Use the child axis and a name. + $axis["axis"] = "child"; + $axis["node-test"] = $step; + } + } + + // Check whether it's a valid axis. + if ( !in_array($axis["axis"], array_merge($this->axes, + array("function"))) ) + { + // Display an error message. + $this->display_error("While parsing an XPath expression, in ". + "the step \"%s\" the invalid axis \"%s\" was found.", + str_replace($step, "".$step."", $this->xpath),# + $axis["axis"]); + } + + // Return the axis information. + return $axis; + } + + /** + * Looks for a string within another string. + * + * This method looks for a string within another string. Brackets in the + * string the method is looking through will be respected, which means that + * only if the string the method is looking for is located outside of + * brackets, the search will be successful. + * + * @access private + * @author Michael P. Mehl + * @param string $term String in which the search shall take place. + * @param string $expression String that should be searched. + * @return int This method returns -1 if no string was found, otherwise + * the offset at which the string was found. + * @see evaluate_step() + */ + function search_string ( $term, $expression ) + { + // Create a new counter for the brackets. + $brackets = 0; + + // Run through the string. + for ( $i = 0; $i < strlen($term); $i++ ) + { + // Get the character at the position of the string. + $character = substr($term, $i, 1); + + // Check whether it's a breacket. + if ( ( $character == "(" ) || ( $character == "[" ) ) + { + // Increase the number of brackets. + $brackets++; + } + elseif ( ( $character == ")" ) || ( $character == "]" ) ) + { + // Decrease the number of brackets. + $brackets--; + } + elseif ( $brackets == 0 ) + { + // Check whether we can find the expression at this index. + if ( substr($term, $i, strlen($expression)) == $expression ) + { + // Return the current index. + return $i; + } + } + } + + // Check whether we had a valid number of brackets. + if ( $brackets != 0 ) + { + // Display an error message. + $this->display_error("While parsing an XPath expression, in the ". + "predicate \"%s\", there was an invalid number of brackets.", + str_replace($term, "".$term."", $this->xpath)); + } + + // Nothing was found. + return (-1); + } + + /** + * Checks for a valid function name. + * + * This method check whether an expression contains a valid name of an + * XPath function. + * + * @access private + * @author Michael P. Mehl + * @param string $expression Name of the function to be checked. + * @return boolean This method returns true if the given name is a valid + * XPath function name, otherwise false. + * @see evaluate() + */ + function is_function ( $expression ) + { + // Check whether it's in the list of supported functions. + if ( in_array($expression, $this->functions) ) + { + // It's a function. + return true; + } + else + { + // It's not a function. + return false; + } + } + + /** + * Evaluates a step of an XPath expression. + * + * This method tries to evaluate a step from an XPath expression at a + * specific context. + * + * @access private + * @author Michael P. Mehl + * @param string $context Full document path of the context from + * which starting the step should be evaluated. + * @param array $steps Array containing the remaining steps of the + * current XPath expression. + * @return array This method returns an array containing all nodes + * that are the result of evaluating the given XPath step. + * @see evaluate() + */ + function evaluate_step ( $context, $steps ) + { + // Create an empty array for saving the nodes found. + $nodes = array(); + + // Check whether the context is an array of contexts. + if ( is_array($context) ) + { + // Run through the array. + foreach ( $context as $path ) + { + // Call this method for this single path. + $nodes = array_merge($nodes, + $this->evaluate_step($path, $steps)); + } + } + else + { + // Get this step. + $step = array_shift($steps); + + // Create an array to save the new contexts. + $contexts = array(); + + // Get the axis of the current step. + $axis = $this->get_axis($step, $context); + + // Check whether it's a function. + if ( $axis["axis"] == "function" ) + { + // Check whether an array was return by the function. + if ( is_array($axis["node-test"]) ) + { + // Add the results to the list of contexts. + $contexts = array_merge($contexts, $axis["node-test"]); + } + else + { + // Add the result to the list of contexts. + $contexts[] = $axis["node-test"]; + } + } + else + { + // Create the name of the method. + $method = "handle_axis_".str_replace("-", "_", $axis["axis"]); + + // Check whether the axis handler is defined. + if ( !method_exists($this, $method) ) + { + // Display an error message. + $this->display_error("While parsing an XPath expression, ". + "the axis \"%s\" could not be handled, because this ". + "version does not support this axis.", $axis["axis"]); + } + + // Perform an axis action. + $contexts = call_user_method($method, $this, $axis, $context); + + // Check whether there are predicates. + if ( count($axis["predicate"]) > 0 ) + { + // Check whether each node fits the predicates. + $contexts = $this->check_predicates($contexts, + $axis["predicate"]); + } + } + + // Check whether there are more steps left. + if ( count($steps) > 0 ) + { + // Continue the evaluation of the next steps. + $nodes = $this->evaluate_step($contexts, $steps); + } + else + { + // Save the found contexts. + $nodes = $contexts; + } + } + + // Return the nodes found. + return $nodes; + } + + /** + * Evaluates an XPath function + * + * This method evaluates a given XPath function with its arguments on a + * specific node of the document. + * + * @access private + * @author Michael P. Mehl + * @param string $function Name of the function to be evaluated. + * @param string $arguments String containing the arguments being + * passed to the function. + * @param string $node Full path to the document node on which the + * function should be evaluated. + * @return mixed This method returns the result of the evaluation of + * the function. Depending on the function the type of the + * return value can be different. + * @see evaluate() + */ + function evaluate_function ( $function, $arguments, $node ) + { + // Remove whitespaces. + $function = trim($function); + $arguments = trim($arguments); + + // Create the name of the function handling function. + $method = "handle_function_".str_replace("-", "_", $function); + + // Check whether the function handling function is available. + if ( !method_exists($this, $method) ) + { + // Display an error message. + $this->display_error("While parsing an XPath expression, ". + "the function \"%s\" could not be handled, because this ". + "version does not support this function.", $function); + } + + // Return the result of the function. + return call_user_method($method, $this, $node, $arguments); + } + + /** + * Evaluates a predicate on a node. + * + * This method tries to evaluate a predicate on a given node. + * + * @access private + * @author Michael P. Mehl + * @param string $node Full path of the node on which the predicate + * should be evaluated. + * @param string $predicate String containing the predicate expression + * to be evaluated. + * @return mixed This method is called recursively. The first call should + * return a boolean value, whether the node matches the predicate + * or not. Any call to the method being made during the recursion + * may also return other types for further processing. + * @see evaluate() + */ + function evaluate_predicate ( $node, $predicate ) + { + // Set the default position and the type of the operator. + $position = 0; + $operator = ""; + + // Run through all operators and try to find them. + foreach ( $this->operators as $expression ) + { + // Check whether a position was already found. + if ( $position <= 0 ) + { + // Try to find the operator. + $position = $this->search_string($predicate, $expression); + + // Check whether a operator was found. + if ( $position > 0 ) + { + // Save the operator. + $operator = $expression; + + // Check whether it's the equal operator. + if ( $operator == "=" ) + { + // Also look for other operators containing the + // equal sign. + if ( $this->search_string($predicate, "!=") == + ( $position - 1 ) ) + { + // Get the new position. + $position = $this->search_string($predicate, "!="); + + // Save the new operator. + $operator = "!="; + } + if ( $this->search_string($predicate, "<=") == + ( $position - 1 ) ) + { + // Get the new position. + $position = $this->search_string($predicate, "<="); + + // Save the new operator. + $operator = "<="; + } + if ( $this->search_string($predicate, ">=") == + ( $position - 1 ) ) + { + // Get the new position. + $position = $this->search_string($predicate, ">="); + + // Save the new operator. + $operator = ">="; + } + } + } + } + } + + // Check whether the operator is a - sign. + if ( $operator == "-" ) + { + // Check whether it's not a function containing a - in its name. + foreach ( $this->functions as $function ) + { + // Check whether there's a - sign in the function name. + //if ( ereg("-", $function) ) + //if ( preg_match("-", $function) ) + if ( preg_match("/-/", $function) ) + { + // Get the position of the - in the function name. + $sign = strpos($function, "-"); + + // Extract a substring from the predicate. + $sub = substr($predicate, $position - $sign, + strlen($function)); + + // Check whether it's the function. + if ( $sub == $function ) + { + // Don't use the operator. + $operator = ""; + $position = -1; + } + } + } + } + elseif ( $operator == "*" ) + { + // Get some substrings. + $character = substr($predicate, $position - 1, 1); + $attribute = substr($predicate, $position - 11, 11); + + // Check whether it's an attribute selection. + if ( ( $character == "@" ) || ( $attribute == "attribute::" ) ) + { + // Don't use the operator. + $operator = ""; + $position = -1; + } + } + + // Check whether an operator was found. + if ( $position > 0 ) + { + // Get the left and the right part of the expression. + $left = substr($predicate, 0, $position); + $right = substr($predicate, $position + strlen($operator)); + + // Remove whitespaces. + $left = trim($left); + $right = trim($right); + + // Evaluate the left and the right part. + $left = $this->evaluate_predicate($node, $left); + $right = $this->evaluate_predicate($node, $right); + + // Check the kind of operator. + switch ( $operator ) + { + case " or ": + // Return the two results connected by an "or". + return ( $left or $right ); + + case " and ": + // Return the two results connected by an "and". + return ( $left and $right ); + + case "=": + // Compare the two results. + return ( $left == $right ); + + case "!=": + // Check whether the two results are not equal. + return ( $left != $right ); + + case "<=": + // Compare the two results. + return ( $left <= $right ); + + case "<": + // Compare the two results. + return ( $left < $right ); + + case ">=": + // Compare the two results. + return ( $left >= $right ); + + case ">": + // Compare the two results. + return ( $left > $right ); + + case "+": + // Return the result by adding one result to the other. + return ( $left + $right ); + + case "-": + // Return the result by decrease one result by the other. + return ( $left - $right ); + + case "*": + // Return a multiplication of the two results. + return ( $left * $right ); + + case " div ": + // Return a division of the two results. + if ( $right == 0 ) + { + // Display an error message. + $this->display_error("While parsing an XPath ". + "predicate, a error due a division by zero ". + "occured."); + } + else + { + // Return the result of the division. + return ( $left / $right ); + } + break; + + case " mod ": + // Return a modulo of the two results. + return ( $left % $right ); + } + } + + // Check whether the predicate is a function. + //if ( ereg("\(", $predicate) ) + //if ( preg_match("\(", $predicate) ) + if ( preg_match("/\(/", $predicate) ) + { + // Get the position of the first bracket. + $start = strpos($predicate, "("); + $end = strpos($predicate, ")", $start); + + // Get everything before, between and after the brackets. + $before = substr($predicate, 0, $start); + $between = substr($predicate, $start + 1, $end - $start - 1); + $after = substr($predicate, $end + 1); + + // Trim each string. + $before = trim($before); + $between = trim($between); + $after = trim($after); + + // Check whether there's something after the bracket. + if ( !empty($after) ) + { + // Display an error message. + $this->display_error("While parsing an XPath expression ". + "there was found an error in the predicate \"%s\", ". + "because after a closing bracket there was found ". + "something unknown.", str_replace($predicate, + "".$predicate."", $this->xpath)); + } + + // Check whether it's a function. + if ( empty($before) && empty($after) ) + { + // Evaluate the content of the brackets. + return $this->evaluate_predicate($node, $between); + } + elseif ( $this->is_function($before) ) + { + // Return the evaluated function. + return $this->evaluate_function($before, $between, $node); + } + else + { + // Display an error message. + $this->display_error("While parsing a predicate in an XPath ". + "expression, a function \"%s\" was found, which is not ". + "yet supported by the parser.", str_replace($before, + "".$before."", $this->xpath)); + } + } + + // Check whether the predicate is just a digit. + //if ( ereg("^[0-9]+(\.[0-9]+)?$", $predicate) || ereg("^\.[0-9]+$", $predicate) ) + //if ( preg_match("^[0-9]+(\.[0-9]+)?$", $predicate) || preg_match("^\.[0-9]+$", $predicate) ) + if ( preg_match("/^[0-9]+(\.[0-9]+)?$/", $predicate) || preg_match("/^\.[0-9]+$/", $predicate) ) + { + // Return the value of the digit. + return doubleval($predicate); + } + + // Check whether it's an XPath expression. + $result = $this->evaluate($predicate, $node); + if ( count($result) > 0 ) + { + // Convert the array. + $result = explode("|", implode("|", $result)); + + // Get the value of the first result. + $value = $this->get_content($result[0]); + + // Return the value. + return $value; + } + + // Return the predicate as a string. + return $predicate; + } + + /** + * Checks whether a node matches predicates. + * + * This method checks whether a list of nodes passed to this method match + * a given list of predicates. + * + * @access private + * @author Michael P. Mehl + * @param array $nodes Array of full paths of all nodes to be tested. + * @param array $predicates Array of predicates to use. + * @return array The array returned by this method contains a list of + * all nodes matching the given predicates. + * @see evaluate_step() + */ + function check_predicates ( $nodes, $predicates ) + { + // Create an empty set of nodes. + $result = array(); + + // Run through all nodes. + foreach ( $nodes as $node ) + { + // Create a variable whether to add this node to the node-set. + $add = true; + + // Run through all predicates. + foreach ( $predicates as $predicate ) + { + // Check whether the predicate is just an number. + //if ( ereg("^[0-9]+$", $predicate) ) + //if ( preg_match("^[0-9]+$", $predicate) ) + if ( preg_match("/^[0-9]+$/", $predicate) ) + { + // Enhance the predicate. + $predicate .= "=position()"; + } + + // Do the predicate check. + $check = $this->evaluate_predicate($node, $predicate); + + // Check whether it's a string. + if ( is_string($check) && ( ( $check == "" ) || + ( $check == $predicate ) ) ) + { + // Set the result to false. + $check = false; + } + + // Check whether it's an integer. + if ( is_int($check) ) + { + // Check whether it's the current position. + if ( $check == $this->handle_function_position($node, "") ) + { + // Set it to true. + $check = true; + } + else + { + // Set it to false. + $check = false; + } + } + + // Check whether the predicate is OK for this node. + $add = $add && $check; + } + + // Check whether to add this node to the node-set. + if ( $add ) + { + // Add the node to the node-set. + $result[] = $node; + } + } + + // Return the array of nodes. + return $result; + } + + /** + * Checks whether a node matches a node-test. + * + * This method checks whether a node in the document matches a given + * node-test. + * + * @access private + * @author Michael P. Mehl + * @param string $context Full path of the node, which should be tested + * for matching the node-test. + * @param string $node_test String containing the node-test for the + * node. + * @return boolean This method returns true if the node matches the + * node-test, otherwise false. + * @see evaluate() + */ + function check_node_test ( $context, $node_test ) + { + // Check whether it's a function. + //if ( ereg("\(", $node_test) ) + if ( preg_match("/\(/", $node_test) ) + { + // Get the type of function to use. + $function = $this->prestr($node_test, "("); + + // Check whether the node fits the method. + switch ( $function ) + { + case "node": + // Add this node to the list of nodes. + return true; + + case "text": + // Check whether the node has some text. + if ( !empty($this->nodes[$context]["text"]) ) + { + // Add this node to the list of nodes. + return true; + } + break; + + case "comment": + // Check whether the node has some comment. + if ( !empty($this->nodes[$context]["comment"]) ) + { + // Add this node to the list of nodes. + return true; + } + break; + + case "processing-instruction": + // Get the literal argument. + $literal = $this->afterstr($axis["node-test"], "("); + + // Cut the literal. + $literal = substr($literal, 0, strlen($literal) - 1); + + // Check whether a literal was given. + if ( !empty($literal) ) + { + // Check whether the node's processing instructions + // are matching the literals given. + if ( $this->nodes[$context] + ["processing-instructions"] == $literal ) + { + // Add this node to the node-set. + return true; + } + } + else + { + // Check whether the node has processing + // instructions. + if ( !empty($this->nodes[$context] + ["processing-instructions"]) ) + { + // Add this node to the node-set. + return true; + } + } + break; + + default: + // Display an error message. + $this->display_error("While parsing an XPath ". + "expression there was found an undefined ". + "function called \"%s\".", + str_replace($function, "".$function."", + $this->xpath)); + } + } + elseif ( $node_test == "*" ) + { + // Add this node to the node-set. + return true; + } + //elseif ( ereg("^[a-zA-Z0-9\-_]+", $node_test) ) + //elseif ( preg_match("^[a-zA-Z0-9\-_]+", $node_test) ) + elseif ( preg_match("/^[a-zA-Z0-9\-_]+/", $node_test) ) + { + // Check whether the node-test can be fulfilled. + if ( $this->nodes[$context]["name"] == $node_test ) + { + // Add this node to the node-set. + return true; + } + } + else + { + // Display an error message. + $this->display_error("While parsing the XPath expression \"%s\" ". + "an empty and therefore invalid node-test has been found.", + $this->xpath); + } + + // Don't add this context. + return false; + } + + /** + * Handles the XPath child axis. + * + * This method handles the XPath child axis. + * + * @access private + * @author Michael P. Mehl + * @param array $axis Array containing information about the axis. + * @param string $context Node from which starting the axis should + * be processed. + * @return array This method returns an array containing all nodes + * that were found during the evaluation of the given axis. + * @see evaluate() + */ + function handle_axis_child ( $axis, $context ) + { + // Create an empty node-set. + $nodes = array(); + + // Get a list of all children. + $children = $this->nodes[$context]["children"]; + + // Check whether there are children. + if ( !empty($children) ) + { + // Run through all children. + foreach ( $children as $child_name => $child_position ) + { + // Run through all childs with this name. + for ( $i = 1; $i <= $child_position; $i++ ) + { + // Create the path of the child. + $child = $context."/".$child_name."[".$i."]"; + + // Check whether + if ( $this->check_node_test($child, $axis["node-test"]) ) + { + // Add the child to the node-set. + $nodes[] = $child; + } + } + } + } + + // Return the nodeset. + return $nodes; + } + + /** + * Handles the XPath parent axis. + * + * This method handles the XPath parent axis. + * + * @access private + * @author Michael P. Mehl + * @param array $axis Array containing information about the axis. + * @param string $context Node from which starting the axis should + * be processed. + * @return array This method returns an array containing all nodes + * that were found during the evaluation of the given axis. + * @see evaluate() + */ + function handle_axis_parent ( $axis, $context ) + { + // Create an empty node-set. + $nodes = array(); + + // Check whether the parent matches the node-test. + if ( $this->check_node_test($this->nodes[$context]["parent"], + $axis["node-test"]) ) + { + // Add this node to the list of nodes. + $nodes[] = $this->nodes[$context]["parent"]; + } + + // Return the nodeset. + return $nodes; + } + + /** + * Handles the XPath attribute axis. + * + * This method handles the XPath attribute axis. + * + * @access private + * @author Michael P. Mehl + * @param array $axis Array containing information about the axis. + * @param string $context Node from which starting the axis should + * be processed. + * @return array This method returns an array containing all nodes + * that were found during the evaluation of the given axis. + * @see evaluate() + */ + function handle_axis_attribute ( $axis, $context ) + { + // Create an empty node-set. + $nodes = array(); + + // Check whether all nodes should be selected. + if ( $axis["node-test"] == "*" ) + { + // Check whether there are attributes. + if ( count($this->nodes[$context]["attributes"]) > 0 ) + { + // Run through the attributes. + foreach ( $this->nodes[$context]["attributes"] as + $key => $value ) + { + // Add this node to the node-set. + $nodes[] = $context."/attribute::".$key; + } + } + } + elseif ( !empty($this->nodes[$context]["attributes"] + [$axis["node-test"]]) ) + { + // Add this node to the node-set. + $nodes[] = $context."/attribute::".$axis["node-test"]; + } + + // Return the nodeset. + return $nodes; + } + + /** + * Handles the XPath self axis. + * + * This method handles the XPath self axis. + * + * @access private + * @author Michael P. Mehl + * @param array $axis Array containing information about the axis. + * @param string $context Node from which starting the axis should + * be processed. + * @return array This method returns an array containing all nodes + * that were found during the evaluation of the given axis. + * @see evaluate() + */ + function handle_axis_self ( $axis, $context ) + { + // Create an empty node-set. + $nodes = array(); + + // Check whether the context match the node-test. + if ( $this->check_node_test($context, $axis["node-test"]) ) + { + // Add this node to the node-set. + $nodes[] = $context; + } + + // Return the nodeset. + return $nodes; + } + + /** + * Handles the XPath descendant axis. + * + * This method handles the XPath descendant axis. + * + * @access private + * @author Michael P. Mehl + * @param array $axis Array containing information about the axis. + * @param string $context Node from which starting the axis should + * be processed. + * @return array This method returns an array containing all nodes + * that were found during the evaluation of the given axis. + * @see evaluate() + */ + function handle_axis_descendant ( $axis, $context ) + { + // Create an empty node-set. + $nodes = array(); + + // Check whether the current node has children. + if ( count($this->nodes[$context]["children"]) > 0 ) + { + // Get a list of children. + $children = $this->nodes[$context]["children"]; + + // Run through all children. + foreach ( $children as $child_name => $child_position ) + { + // Run through all children of this name. + for ( $i = 1; $i <= $child_position; $i++ ) + { + // Create the full path for the children. + $child = $context."/".$child_name."[".$i."]"; + + // Check whether the child matches the node-test. + if ( $this->check_node_test($child, $axis["node-test"]) ) + { + // Add the child to the list of nodes. + $nodes[] = $child; + } + + // Recurse to the next level. + $nodes = array_merge($nodes, + $this->handle_axis_descendant($axis, $child)); + } + } + } + + // Return the nodeset. + return $nodes; + } + + /** + * Handles the XPath ancestor axis. + * + * This method handles the XPath ancestor axis. + * + * @access private + * @author Michael P. Mehl + * @param array $axis Array containing information about the axis. + * @param string $context Node from which starting the axis should + * be processed. + * @return array This method returns an array containing all nodes + * that were found during the evaluation of the given axis. + * @see evaluate() + */ + function handle_axis_ancestor ( $axis, $context ) + { + // Create an empty node-set. + $nodes = array(); + + // Get the parent of the current node. + $parent = $this->nodes[$context]["parent"]; + + // Check whether the parent isn't empty. + if ( !empty($parent) ) + { + // Check whether the parent matches the node-test. + if ( $this->check_node_test($parent, $axis["node-test"]) ) + { + // Add the parent to the list of nodes. + $nodes[] = $parent; + } + + // Handle all other ancestors. + $nodes = array_merge($nodes, + $this->handle_axis_ancestor($axis, $parent)); + } + + // Return the nodeset. + return $nodes; + } + + /** + * Handles the XPath namespace axis. + * + * This method handles the XPath namespace axis. + * + * @access private + * @author Michael P. Mehl + * @param array $axis Array containing information about the axis. + * @param string $context Node from which starting the axis should + * be processed. + * @return array This method returns an array containing all nodes + * that were found during the evaluation of the given axis. + * @see evaluate() + */ + function handle_axis_namespace ( $axis, $context ) + { + // Create an empty node-set. + $nodes = array(); + + // Check whether all nodes should be selected. + if ( !empty($this->nodes[$context]["namespace"]) ) + { + // Add this node to the node-set. + $nodes[] = $context; + } + + // Return the nodeset. + return $nodes; + } + + /** + * Handles the XPath following axis. + * + * This method handles the XPath following axis. + * + * @access private + * @author Michael P. Mehl + * @param array $axis Array containing information about the axis. + * @param string $context Node from which starting the axis should + * be processed. + * @return array This method returns an array containing all nodes + * that were found during the evaluation of the given axis. + * @see evaluate() + */ + function handle_axis_following ( $axis, $context ) + { + // Create an empty node-set. + $nodes = array(); + + // Get the current document position. + $position = $this->nodes[$context]["document-position"]; + + // Create a flag, whether we already found the context node. + $found = false; + + // Run through all nodes of the document. + foreach ( $this->nodes as $node => $data ) + { + // Check whether the context node has already been found. + if ( $found ) + { + // Check whether the position is correct. + if ( $this->nodes[$node]["document-position"] == $position ) + { + // Check whether the node fits the node-test. + if ( $this->check_node_test($node, $axis["node-test"]) ) + { + // Add the node to the list of nodes. + $nodes[] = $node; + } + } + } + + // Check whether this is the context node. + if ( $node == $context ) + { + // After this we'll look for more nodes. + $found = true; + } + } + + // Return the nodeset. + return $nodes; + } + + /** + * Handles the XPath preceding axis. + * + * This method handles the XPath preceding axis. + * + * @access private + * @author Michael P. Mehl + * @param array $axis Array containing information about the axis. + * @param string $context Node from which starting the axis should + * be processed. + * @return array This method returns an array containing all nodes + * that were found during the evaluation of the given axis. + * @see evaluate() + */ + function handle_axis_preceding ( $axis, $context ) + { + // Create an empty node-set. + $nodes = array(); + + // Get the current document position. + $position = $this->nodes[$context]["document-position"]; + + // Create a flag, whether we already found the context node. + $found = true; + + // Run through all nodes of the document. + foreach ( $this->nodes as $node => $data ) + { + // Check whether this is the context node. + if ( $node == $context ) + { + // After this we won't look for more nodes. + $found = false; + } + + // Check whether the context node has already been found. + if ( $found ) + { + // Check whether the position is correct. + if ( $this->nodes[$node]["document-position"] == $position ) + { + // Check whether the node fits the node-test. + if ( $this->check_node_test($node, $axis["node-test"]) ) + { + // Add the node to the list of nodes. + $nodes[] = $node; + } + } + } + } + + // Return the nodeset. + return $nodes; + } + + /** + * Handles the XPath following-sibling axis. + * + * This method handles the XPath following-sibling axis. + * + * @access private + * @author Michael P. Mehl + * @param array $axis Array containing information about the axis. + * @param string $context Node from which starting the axis should + * be processed. + * @return array This method returns an array containing all nodes + * that were found during the evaluation of the given axis. + * @see evaluate() + */ + function handle_axis_following_sibling ( $axis, $context ) + { + // Create an empty node-set. + $nodes = array(); + + // Get all children from the parent. + $siblings = $this->handle_axis_child($axis, + $this->nodes[$context]["parent"]); + + // Create a flag whether the context node was already found. + $found = false; + + // Run through all siblings. + foreach ( $siblings as $sibling ) + { + // Check whether the context node was already found. + if ( $found ) + { + // Check whether the sibling is a real sibling. + if ( $this->nodes[$sibling]["name"] == + $this->nodes[$context]["name"] ) + { + // Check whether the sibling matches the node-test. + if ( $this->check_node_test($sibling, $axis["node-test"]) ) + { + // Add the sibling to the list of nodes. + $nodes[] = $sibling; + } + } + } + + // Check whether this is the context node. + if ( $sibling == $context ) + { + // Continue looking for other siblings. + $found = true; + } + } + + // Return the nodeset. + return $nodes; + } + + /** + * Handles the XPath preceding-sibling axis. + * + * This method handles the XPath preceding-sibling axis. + * + * @access private + * @author Michael P. Mehl + * @param array $axis Array containing information about the axis. + * @param string $context Node from which starting the axis should + * be processed. + * @return array This method returns an array containing all nodes + * that were found during the evaluation of the given axis. + * @see evaluate() + */ + function handle_axis_preceding_sibling ( $axis, $context ) + { + // Create an empty node-set. + $nodes = array(); + + // Get all children from the parent. + $siblings = $this->handle_axis_child($axis, + $this->nodes[$context]["parent"]); + + // Create a flag whether the context node was already found. + $found = true; + + // Run through all siblings. + foreach ( $siblings as $sibling ) + { + // Check whether this is the context node. + if ( $sibling == $context ) + { + // Don't continue looking for other siblings. + $found = false; + } + + // Check whether the context node was already found. + if ( $found ) + { + // Check whether the sibling is a real sibling. + if ( $this->nodes[$sibling]["name"] == + $this->nodes[$context]["name"] ) + { + // Check whether the sibling matches the node-test. + if ( $this->check_node_test($sibling, $axis["node-test"]) ) + { + // Add the sibling to the list of nodes. + $nodes[] = $sibling; + } + } + } + } + + // Return the nodeset. + return $nodes; + } + + /** + * Handles the XPath descendant-or-self axis. + * + * This method handles the XPath descendant-or-self axis. + * + * @access private + * @author Michael P. Mehl + * @param array $axis Array containing information about the axis. + * @param string $context Node from which starting the axis should + * be processed. + * @return array This method returns an array containing all nodes + * that were found during the evaluation of the given axis. + * @see evaluate() + */ + function handle_axis_descendant_or_self ( $axis, $context ) + { + // Create an empty node-set. + $nodes = array(); + + // Read the nodes. + $nodes = array_merge( + $this->handle_axis_descendant($axis, $context), + $this->handle_axis_self($axis, $context)); + + // Return the nodeset. + return $nodes; + } + + /** + * Handles the XPath ancestor-or-self axis. + * + * This method handles the XPath ancestor-or-self axis. + * + * @access private + * @author Michael P. Mehl + * @param array $axis Array containing information about the axis. + * @param string $context Node from which starting the axis should + * be processed. + * @return array This method returns an array containing all nodes + * that were found during the evaluation of the given axis. + * @see evaluate() + */ + function handle_axis_ancestor_or_self ( $axis, $context ) + { + // Create an empty node-set. + $nodes = array(); + + // Read the nodes. + $nodes = array_merge( + $this->handle_axis_ancestor($axis, $context), + $this->handle_axis_self($axis, $context)); + + // Return the nodeset. + return $nodes; + } + + /** + * Handles the XPath function last. + * + * This method handles the XPath function last. + * + * @access private + * @author Michael P. Mehl + * @param string $node Full path of the node on which the function + * should be processed. + * @param string $arguments String containing the arguments that were + * passed to the function. + * @return mixed Depending on the type of function being processed this + * method returns different types. + * @see evaluate() + */ + function handle_function_last ( $node, $arguments ) + { + // Calculate the size of the context. + $parent = $this->nodes[$node]["parent"]; + $children = $this->nodes[$parent]["children"]; + $context = $children[$this->nodes[$node]["name"]]; + + // Return the size. + return $context; + } + + /** + * Handles the XPath function position. + * + * This method handles the XPath function position. + * + * @access private + * @author Michael P. Mehl + * @param string $node Full path of the node on which the function + * should be processed. + * @param string $arguments String containing the arguments that were + * passed to the function. + * @return mixed Depending on the type of function being processed this + * method returns different types. + * @see evaluate() + */ + function handle_function_position ( $node, $arguments ) + { + // return the context-position. + return $this->nodes[$node]["context-position"]; + } + + /** + * Handles the XPath function count. + * + * This method handles the XPath function count. + * + * @access private + * @author Michael P. Mehl + * @param string $node Full path of the node on which the function + * should be processed. + * @param string $arguments String containing the arguments that were + * passed to the function. + * @return mixed Depending on the type of function being processed this + * method returns different types. + * @see evaluate() + */ + function handle_function_count ( $node, $arguments ) + { + // Evaluate the argument of the method as an XPath and return + // the number of results. + return count($this->evaluate($arguments, $node)); + } + + /** + * Handles the XPath function id. + * + * This method handles the XPath function id. + * + * @access private + * @author Michael P. Mehl + * @param string $node Full path of the node on which the function + * should be processed. + * @param string $arguments String containing the arguments that were + * passed to the function. + * @return mixed Depending on the type of function being processed this + * method returns different types. + * @see evaluate() + */ + function handle_function_id ( $node, $arguments ) + { + // Trim the arguments. + $arguments = trim($arguments); + + // Now split the arguments. + $arguments = explode(" ", $arguments); + + // Check whether + + // Create a list of nodes. + $nodes = array(); + + // Run through all document node. + foreach ( $this->nodes as $node => $position ) + { + // Check whether the node has the ID we're looking for. + if ( in_array($this->nodes[$node]["attributes"]["id"], + $arguments) ) + { + // Add this node to the list of nodes. + $nodes[] = $node; + } + } + + // Return the list of nodes. + return $nodes; + } + + /** + * Handles the XPath function name. + * + * This method handles the XPath function name. + * + * @access private + * @author Michael P. Mehl + * @param string $node Full path of the node on which the function + * should be processed. + * @param string $arguments String containing the arguments that were + * passed to the function. + * @return mixed Depending on the type of function being processed this + * method returns different types. + * @see evaluate() + */ + function handle_function_name ( $node, $arguments ) + { + // Return the name of the node. + return $this->nodes[$node]["name"]; + } + + /** + * Handles the XPath function string. + * + * This method handles the XPath function string. + * + * @access private + * @author Michael P. Mehl + * @param string $node Full path of the node on which the function + * should be processed. + * @param string $arguments String containing the arguments that were + * passed to the function. + * @return mixed Depending on the type of function being processed this + * method returns different types. + * @see evaluate() + */ + function handle_function_string ( $node, $arguments ) + { + // Check what type of parameter is given + //if ( ereg("^[0-9]+(\.[0-9]+)?$", $arguments) || ereg("^\.[0-9]+$", $arguments) ) + //if ( preg_match("^[0-9]+(\.[0-9]+)?$", $arguments) || preg_match("^\.[0-9]+$", $arguments) ) + if ( preg_match("/^[0-9]+(\.[0-9]+)?$/", $arguments) || preg_match("/^\.[0-9]+$/", $arguments) ) + { + // Convert the digits to a number. + $number = doubleval($arguments); + + // Return the number. + return strval($number); + } + elseif ( is_bool($arguments) ) + { + // Check whether it's true. + if ( $arguments == true ) + { + // Return true as a string. + return "true"; + } + else + { + // Return false as a string. + return "false"; + } + } + elseif ( !empty($arguments) ) + { + // Use the argument as an XPath. + $result = $this->evaluate($arguments, $node); + + // Get the first argument. + $result = explode("|", implode("|", $result)); + + // Return the first result as a string. + return $result[0]; + } + elseif ( empty($arguments) ) + { + // Return the current node. + return $node; + } + else + { + // Return an empty string. + return ""; + } + } + + /** + * Handles the XPath function concat. + * + * This method handles the XPath function concat. + * + * @access private + * @author Michael P. Mehl + * @param string $node Full path of the node on which the function + * should be processed. + * @param string $arguments String containing the arguments that were + * passed to the function. + * @return mixed Depending on the type of function being processed this + * method returns different types. + * @see evaluate() + */ + function handle_function_concat ( $node, $arguments ) + { + // Split the arguments. + $arguments = explode(",", $arguments); + + // Run through each argument and evaluate it. + for ( $i = 0; $i < sizeof($arguments); $i++ ) + { + // Trim each argument. + $arguments[$i] = trim($arguments[$i]); + + // Evaluate it. + $arguments[$i] = $this->evaluate_predicate($node, $arguments[$i]); + } + + // Put the string together. + $arguments = implode("", $arguments); + + // Return the string. + return $arguments; + } + + /** + * Handles the XPath function starts-with. + * + * This method handles the XPath function starts-with. + * + * @access private + * @author Michael P. Mehl + * @param string $node Full path of the node on which the function + * should be processed. + * @param string $arguments String containing the arguments that were + * passed to the function. + * @return mixed Depending on the type of function being processed this + * method returns different types. + * @see evaluate() + */ + function handle_function_starts_with ( $node, $arguments ) + { + // Get the arguments. + $first = trim($this->prestr($arguments, ",")); + $second = trim($this->afterstr($arguments, ",")); + + // Evaluate each argument. + $first = $this->evaluate_predicate($node, $first); + $second = $this->evaluate_predicate($node, $second); + + // Check whether the first string starts with the second one. + //if ( ereg("^".$second, $first) ) + //if ( preg_match("^".$second, $first) ) + if ( preg_match("/^".$second."/", $first) ) + { + // Return true. + return true; + } + else + { + // Return false. + return false; + } + } + + /** + * Handles the XPath function contains. + * + * This method handles the XPath function contains. + * + * @access private + * @author Michael P. Mehl + * @param string $node Full path of the node on which the function + * should be processed. + * @param string $arguments String containing the arguments that were + * passed to the function. + * @return mixed Depending on the type of function being processed this + * method returns different types. + * @see evaluate() + */ + function handle_function_contains ( $node, $arguments ) + { + // Get the arguments. + $first = trim($this->prestr($arguments, ",")); + $second = trim($this->afterstr($arguments, ",")); + + // Evaluate each argument. + $first = $this->evaluate_predicate($node, $first); + $second = $this->evaluate_predicate($node, $second); + + // Check whether the first string starts with the second one. + //if ( ereg($second, $first) ) + //if ( preg_match($second, $first) ) + if ( preg_match("/^".$second."/", $first) ) + { + // Return true. + return true; + } + else + { + // Return false. + return false; + } + } + + /** + * Handles the XPath function substring-before. + * + * This method handles the XPath function substring-before. + * + * @access private + * @author Michael P. Mehl + * @param string $node Full path of the node on which the function + * should be processed. + * @param string $arguments String containing the arguments that were + * passed to the function. + * @return mixed Depending on the type of function being processed this + * method returns different types. + * @see evaluate() + */ + function handle_function_substring_before ( $node, $arguments ) + { + // Get the arguments. + $first = trim($this->prestr($arguments, ",")); + $second = trim($this->afterstr($arguments, ",")); + + // Evaluate each argument. + $first = $this->evaluate_predicate($node, $first); + $second = $this->evaluate_predicate($node, $second); + + // Return the substring. + return $this->prestr(strval($first), strval($second)); + } + + /** + * Handles the XPath function substring-after. + * + * This method handles the XPath function substring-after. + * + * @access private + * @author Michael P. Mehl + * @param string $node Full path of the node on which the function + * should be processed. + * @param string $arguments String containing the arguments that were + * passed to the function. + * @return mixed Depending on the type of function being processed this + * method returns different types. + * @see evaluate() + */ + function handle_function_substring_after ( $node, $arguments ) + { + // Get the arguments. + $first = trim($this->prestr($arguments, ",")); + $second = trim($this->afterstr($arguments, ",")); + + // Evaluate each argument. + $first = $this->evaluate_predicate($node, $first); + $second = $this->evaluate_predicate($node, $second); + + // Return the substring. + return $this->afterstr(strval($first), strval($second)); + } + + /** + * Handles the XPath function substring. + * + * This method handles the XPath function substring. + * + * @access private + * @author Michael P. Mehl + * @param string $node Full path of the node on which the function + * should be processed. + * @param string $arguments String containing the arguments that were + * passed to the function. + * @return mixed Depending on the type of function being processed this + * method returns different types. + * @see evaluate() + */ + function handle_function_substring ( $node, $arguments ) + { + // Split the arguments. + $arguments = explode(",", $arguments); + + // Run through all arguments. + for ( $i = 0; $i < sizeof($arguments); $i++ ) + { + // Trim the string. + $arguments[$i] = trim($arguments[$i]); + + // Evaluate each argument. + $arguments[$i] = $this->evaluate_predicate($node, $arguments[$i]); + } + + // Check whether a third argument was given. + if ( !empty($arguments[2]) ) + { + // Return the substring. + return substr(strval($arguments[0]), $arguments[1] - 1, + $arguments[2]); + } + else + { + // Return the substring. + return substr(strval($arguments[0]), $arguments[1] - 1); + } + } + + /** + * Handles the XPath function string-length. + * + * This method handles the XPath function string-length. + * + * @access private + * @author Michael P. Mehl + * @param string $node Full path of the node on which the function + * should be processed. + * @param string $arguments String containing the arguments that were + * passed to the function. + * @return mixed Depending on the type of function being processed this + * method returns different types. + * @see evaluate() + */ + function handle_function_string_length ( $node, $arguments ) + { + // Trim the argument. + $arguments = trim($arguments); + + // Evaluate the argument. + $arguments = $this->evaluate_predicate($node, $arguments); + + // Return the length of the string. + return strlen(strval($arguments)); + } + + /** + * Handles the XPath function translate. + * + * This method handles the XPath function translate. + * + * @access private + * @author Michael P. Mehl + * @param string $node Full path of the node on which the function + * should be processed. + * @param string $arguments String containing the arguments that were + * passed to the function. + * @return mixed Depending on the type of function being processed this + * method returns different types. + * @see evaluate() + */ + function handle_function_translate ( $node, $arguments ) + { + // Split the arguments. + $arguments = explode(",", $arguments); + + // Run through all arguments. + for ( $i = 0; $i < sizeof($arguments); $i++ ) + { + // Trim the argument. + $arguments[$i] = trim($arguments[$i]); + + // Evaluate the argument. + $arguments[$i] = $this->evaluate_predicate($node, $arguments[$i]); + } + + // Return the translated string. + return strtr($arguments[0], $arguments[1], $arguments[2]); + } + + /** + * Handles the XPath function boolean. + * + * This method handles the XPath function boolean. + * + * @access private + * @author Michael P. Mehl + * @param string $node Full path of the node on which the function + * should be processed. + * @param string $arguments String containing the arguments that were + * passed to the function. + * @return mixed Depending on the type of function being processed this + * method returns different types. + * @see evaluate() + */ + function handle_function_boolean ( $node, $arguments ) + { + // Trim the arguments. + $arguments = trim($arguments); + + // Check what type of parameter is given + //if ( ereg("^[0-9]+(\.[0-9]+)?$", $arguments) || ereg("^\.[0-9]+$", $arguments) ) + //if ( preg_match("^[0-9]+(\.[0-9]+)?$", $arguments) || preg_match("^\.[0-9]+$", $arguments) ) + if ( preg_match("/^[0-9]+(\.[0-9]+)?$/", $arguments) || preg_match("/^\.[0-9]+$/", $arguments) ) + { + // Convert the digits to a number. + $number = doubleval($arguments); + + // Check whether the number zero. + if ( $number == 0 ) + { + // Return false. + return false; + } + else + { + // Return true. + return true; + } + } + elseif ( empty($arguments) ) + { + // Sorry, there were no arguments. + return false; + } + else + { + // Try to evaluate the argument as an XPath. + $result = $this->evaluate($arguments, $node); + + // Check whether we found something. + if ( count($result) > 0 ) + { + // Return true. + return true; + } + else + { + // Return false. + return false; + } + } + } + + /** + * Handles the XPath function not. + * + * This method handles the XPath function not. + * + * @access private + * @author Michael P. Mehl + * @param string $node Full path of the node on which the function + * should be processed. + * @param string $arguments String containing the arguments that were + * passed to the function. + * @return mixed Depending on the type of function being processed this + * method returns different types. + * @see evaluate() + */ + function handle_function_not ( $node, $arguments ) + { + // Trim the arguments. + $arguments = trim($arguments); + + // Return the negative value of the content of the brackets. + return !$this->evaluate_predicate($node, $arguments); + } + + /** + * Handles the XPath function true. + * + * This method handles the XPath function true. + * + * @access private + * @author Michael P. Mehl + * @param string $node Full path of the node on which the function + * should be processed. + * @param string $arguments String containing the arguments that were + * passed to the function. + * @return mixed Depending on the type of function being processed this + * method returns different types. + * @see evaluate() + */ + function handle_function_true ( $node, $arguments ) + { + // Return true. + return true; + } + + /** + * Handles the XPath function false. + * + * This method handles the XPath function false. + * + * @access private + * @author Michael P. Mehl + * @param string $node Full path of the node on which the function + * should be processed. + * @param string $arguments String containing the arguments that were + * passed to the function. + * @return mixed Depending on the type of function being processed this + * method returns different types. + * @see evaluate() + */ + function handle_function_false ( $node, $arguments ) + { + // Return false. + return false; + } + + /** + * Handles the XPath function lang. + * + * This method handles the XPath function lang. + * + * @access private + * @author Michael P. Mehl + * @param string $node Full path of the node on which the function + * should be processed. + * @param string $arguments String containing the arguments that were + * passed to the function. + * @return mixed Depending on the type of function being processed this + * method returns different types. + * @see evaluate() + */ + function handle_function_lang ( $node, $arguments ) + { + // Trim the arguments. + $arguments = trim($arguments); + + // Check whether the node has an language attribute. + if ( empty($this->nodes[$node]["attributes"]["xml:lang"]) ) + { + // Run through the ancestors. + while ( !empty($node) ) + { + // Select the parent node. + $node = $this->nodes[$node]["parent"]; + + // Check whether there's a language definition. + if ( !empty($this->nodes[$node]["attributes"]["xml:lang"]) ) + { + // Check whether it's the language, the user asks for. + //if ( eregi("^".$arguments, $this->nodes[$node] + // ["attributes"]["xml:lang"]) ) + //if ( preg_match("^/i".$arguments, $this->nodes[$node] + if ( preg_match("/^".$arguments."/i", $this->nodes[$node] + ["attributes"]["xml:lang"]) ) + { + // Return true. + return true; + } + else + { + // Return false. + return false; + } + } + } + + // Return false. + return false; + } + else + { + // Check whether it's the language, the user asks for. + //if ( eregi("^".$arguments, $this->nodes[$node]["attributes"] + // ["xml:lang"]) ) + //if ( preg_match("^/i".$arguments, $this->nodes[$node]["attributes"] + if ( preg_match("/^".$arguments."/i", $this->nodes[$node]["attributes"] + ["xml:lang"]) ) + { + // Return true. + return true; + } + else + { + // Return false. + return false; + } + } + } + + /** + * Handles the XPath function number. + * + * This method handles the XPath function number. + * + * @access private + * @author Michael P. Mehl + * @param string $node Full path of the node on which the function + * should be processed. + * @param string $arguments String containing the arguments that were + * passed to the function. + * @return mixed Depending on the type of function being processed this + * method returns different types. + * @see evaluate() + */ + function handle_function_number ( $node, $arguments ) + { + // Check the type of argument. + //if ( ereg("^[0-9]+(\.[0-9]+)?$", $arguments) || + // ereg("^\.[0-9]+$", $arguments) ) + //if ( preg_match("^[0-9]+(\.[0-9]+)?$", $arguments) || preg_match("^\.[0-9]+$", $arguments) ) + if ( preg_match("/^[0-9]+(\.[0-9]+)?$/", $arguments) || preg_match("/^\.[0-9]+$/", $arguments) ) + { + // Return the argument as a number. + return doubleval($arguments); + } + elseif ( is_bool($arguments) ) + { + // Check whether it's true. + if ( $arguments == true ) + { + // Return 1. + return 1; + } + else + { + // Return 0. + return 0; + } + } + } + + /** + * Handles the XPath function sum. + * + * This method handles the XPath function sum. + * + * @access private + * @author Michael P. Mehl + * @param string $node Full path of the node on which the function + * should be processed. + * @param string $arguments String containing the arguments that were + * passed to the function. + * @return mixed Depending on the type of function being processed this + * method returns different types. + * @see evaluate() + */ + function handle_function_sum ( $node, $arguments ) + { + // Trim the arguments. + $arguments = trim($arguments); + + // Evaluate the arguments as an XPath expression. + $results = $this->evaluate($arguments, $node); + + // Create a variable to save the sum. + $sum = 0; + + // Run through all results. + foreach ( $results as $result ) + { + // Get the value of the node. + $result = $this->get_content($result); + + // Add it to the sum. + $sum += doubleval($result); + } + + // Return the sum. + return $sum; + } + + /** + * Handles the XPath function floor. + * + * This method handles the XPath function floor. + * + * @access private + * @author Michael P. Mehl + * @param string $node Full path of the node on which the function + * should be processed. + * @param string $arguments String containing the arguments that were + * passed to the function. + * @return mixed Depending on the type of function being processed this + * method returns different types. + * @see evaluate() + */ + function handle_function_floor ( $node, $arguments ) + { + // Trim the arguments. + $arguments = trim($arguments); + + // Convert the arguments to a number. + $arguments = doubleval($arguments); + + // Return the result + return floor($arguments); + } + + /** + * Handles the XPath function ceiling. + * + * This method handles the XPath function ceiling. + * + * @access private + * @author Michael P. Mehl + * @param string $node Full path of the node on which the function + * should be processed. + * @param string $arguments String containing the arguments that were + * passed to the function. + * @return mixed Depending on the type of function being processed this + * method returns different types. + * @see evaluate() + */ + function handle_function_ceiling ( $node, $arguments ) + { + // Trim the arguments. + $arguments = trim($arguments); + + // Convert the arguments to a number. + $arguments = doubleval($arguments); + + // Return the result + return ceil($arguments); + } + + /** + * Handles the XPath function round. + * + * This method handles the XPath function round. + * + * @access private + * @author Michael P. Mehl + * @param string $node Full path of the node on which the function + * should be processed. + * @param string $arguments String containing the arguments that were + * passed to the function. + * @return mixed Depending on the type of function being processed this + * method returns different types. + * @see evaluate() + */ + function handle_function_round ( $node, $arguments ) + { + // Trim the arguments. + $arguments = trim($arguments); + + // Convert the arguments to a number. + $arguments = doubleval($arguments); + + // Return the result + return round($arguments); + } + + /** + * Handles the XPath function text. + * + * This method handles the XPath function text. + * + * @access private + * @author Michael P. Mehl + * @param string $node Full path of the node on which the function + * should be processed. + * @param string $arguments String containing the arguments that were + * passed to the function. + * @return mixed Depending on the type of function being processed this + * method returns different types. + * @see evaluate() + */ + function handle_function_text ( $node, $arguments ) + { + // Return the character data of the node. + return $this->nodes[$node]["text"]; + } + + /** + * Retrieves a substring before a delimiter. + * + * This method retrieves everything from a string before a given delimiter, + * not including the delimiter. + * + * @access private + * @author Michael P. Mehl + * @param string $string String, from which the substring should be + * extracted. + * @param string $delimiter String containing the delimiter to use. + * @return string Substring from the original string before the + * delimiter. + * @see afterstr() + */ + function prestr ( $string, $delimiter ) + { + // Return the substring. + return substr($string, 0, strlen($string) - strlen(strstr($string, + "$delimiter"))); + } + + /** + * Retrieves a substring after a delimiter. + * + * This method retrieves everything from a string after a given delimiter, + * not including the delimiter. + * + * @access private + * @author Michael P. Mehl + * @param string $string String, from which the substring should be + * extracted. + * @param string $delimiter String containing the delimiter to use. + * @return string Substring from the original string after the + * delimiter. + * @see prestr() + */ + function afterstr ( $string, $delimiter ) + { + // Return the substring. + return substr($string, + strpos($string, $delimiter) + strlen($delimiter)); + } + + /** + * Displays an error message. + * + * This method displays an error messages and stops the execution of the + * script. This method is called exactly in the same way as the printf + * function. The first argument contains the message and additional + * arguments of various types may be passed to this method to be inserted + * into the message. + * + * @access private + * @author Michael P. Mehl + * @param string $message Error message to be displayed. + */ + function display_error ( $message ) + { + // Check whether more than one argument was given. + if ( func_num_args() > 1 ) + { + // Read all arguments. + $arguments = func_get_args(); + + // Create a new string for the inserting command. + $command = "\$message = sprintf(\$message, "; + + // Run through the array of arguments. + for ( $i = 1; $i < sizeof($arguments); $i++ ) + { + // Add the number of the argument to the command. + $command .= "\$arguments[".$i."], "; + } + + // Replace the last separator. + //$command = eregi_replace(", $", ");", $command); + $command = preg_replace("/, $/i", ");", $command); + + // Execute the command. + eval($command); + } + + // Display the error message. + echo "phpXML error: ".$message; + + // End the execution of this script. + exit; + } + + //added by ddaemiri, 2007.05.28 + //entity ϳ ִٰ !! 迭 ù° . + function get_content_fetch ( $path ) + { + $e = $this->evaluate($path); + $content = $this->get_content($e[0]); + $a = $this->get_attributes_patch( $path, "urlencode" ); + if( $a != "" ) + $content = urldecode( $content ); + return $content; + } + function get_attributes_patch ( $path, $attr ) + { + $e = $this->evaluate($path); + $a = $this->get_attributes($e[0]); + return $a[$attr]; + } + +} + +?> \ No newline at end of file diff --git a/shop/inicis/orderform.1.php b/shop/inicis/orderform.1.php new file mode 100644 index 000000000..d55e1f64c --- /dev/null +++ b/shop/inicis/orderform.1.php @@ -0,0 +1,127 @@ + + + + + + + + \ No newline at end of file diff --git a/shop/inicis/orderform.2.php b/shop/inicis/orderform.2.php new file mode 100644 index 000000000..81eb3b188 --- /dev/null +++ b/shop/inicis/orderform.2.php @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/shop/inicis/orderform.3.php b/shop/inicis/orderform.3.php new file mode 100644 index 000000000..e0dca41bb --- /dev/null +++ b/shop/inicis/orderform.3.php @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/shop/inicis/orderform.4.php b/shop/inicis/orderform.4.php new file mode 100644 index 000000000..d054abec9 --- /dev/null +++ b/shop/inicis/orderform.4.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/shop/inicis/orderform.5.php b/shop/inicis/orderform.5.php new file mode 100644 index 000000000..d054abec9 --- /dev/null +++ b/shop/inicis/orderform.5.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/shop/inicis/orderpartcancel.inc.php b/shop/inicis/orderpartcancel.inc.php new file mode 100644 index 000000000..23d127167 --- /dev/null +++ b/shop/inicis/orderpartcancel.inc.php @@ -0,0 +1,79 @@ +SetField("type", "repay"); // 고정 (절대 수정 불가) +$inipay->SetField("pgid", "INIphpRPAY"); // 고정 (절대 수정 불가) +$inipay->SetField("subpgip", "203.238.3.10"); // 고정 +$inipay->SetField("mid", $default['de_inicis_mid']); // 상점아이디 +$inipay->SetField("admin", $default['de_inicis_admin_key']); //비대칭 사용키 키패스워드 +$inipay->SetField("oldtid", $oldtid); // 취소할 거래의 거래아이디 +$inipay->SetField("currency", $currency); // 화폐단위 +$inipay->SetField("price", $price); // 취소금액 +$inipay->SetField("confirm_price", $confirm_price); // 승인요청금액 +$inipay->SetField("buyeremail", $buyeremail); // 구매자 이메일 주소 +$inipay->SetField("tax", $tax); // 부가세금액 +$inipay->SetField("taxfree", $taxfree); // 비과세금액 + +/****************** + * 4. 재승인 요청 * + ******************/ +$inipay->startAction(); + + +/******************************************************************* + * 5. 재승인 결과 * + * * + * 신거래번호 : $inipay->getResult('TID') * + * 결과코드 : $inipay->getResult('ResultCode') ("00"이면 재승인 성공) * + * 결과내용 : $inipay->getResult('ResultMsg') (재승인결과에 대한 설명) * + * 원거래 번호 : $inipay->getResult('PRTC_TID') * + * 최종결제 금액 : $inipay->getResult('PRTC_Remains') * + * 부분취소 금액 : $inipay->getResult('PRTC_Price') * + * 부분취소,재승인 구분값 : $inipay->getResult('PRTC_Type') * + * ("0" : 재승인, "1" : 부분취소) * + * 부분취소(재승인) 요청횟수 : $inipay->getResult('PRTC_Cnt') * + *******************************************************************/ + + if($inipay->getResult('ResultCode') == '00') { + // 환불금액기록 + $tno = $inipay->getResult('PRTC_TID'); + $re_price = $inipay->getResult('PRTC_Price'); + + $sql = " update {$g5['g5_shop_order_table']} + set od_refund_price = od_refund_price + '$re_price', + od_shop_memo = concat(od_shop_memo, \"$mod_memo\") + where od_id = '{$od['od_id']}' + and od_tno = '$tno' "; + sql_query($sql); + + // 미수금 등의 정보 업데이트 + $info = get_order_info($od_id); + + $sql = " update {$g5['g5_shop_order_table']} + set 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']}' + where od_id = '$od_id' "; + sql_query($sql); + } else { + alert(iconv_utf8($inipay->GetResult("ResultMsg")).' 코드 : '.$inipay->GetResult("ResultCode")); + } +?> \ No newline at end of file diff --git a/shop/inicis/taxsave_form.php b/shop/inicis/taxsave_form.php new file mode 100644 index 000000000..dc49112a8 --- /dev/null +++ b/shop/inicis/taxsave_form.php @@ -0,0 +1,197 @@ + + + + +
+

+ +
+

주문정보

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
주문 번호
상품 정보
주문자 이름
주문자 E-Mail
주문자 전화번호
+
+
+ +
+

현금영수증 발급 정보

+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
원 거래 시각
발행 용도 + + + + +
+ + + ("-" 생략) +
거래금액 총합
공급가액
봉사료
부가가치세
+
+ +
+ + + + +
+ +
+
+ +
\ No newline at end of file diff --git a/shop/inicis/taxsave_result.php b/shop/inicis/taxsave_result.php new file mode 100644 index 000000000..f3db4bbdf --- /dev/null +++ b/shop/inicis/taxsave_result.php @@ -0,0 +1,193 @@ +개인결제 내역이 존재하지 않습니다.

'); + + if($od['pp_cash'] == 1) + alert('이미 등록된 현금영수증 입니다.'); + + $buyername = $od['pp_name']; + $goodname = $od['pp_name'].'님 개인결제'; + $amt_tot = (int)$od['pp_receipt_price']; + $amt_sup = (int)round(($amt_tot * 10) / 11); + $amt_svc = 0; + $amt_tax = (int)($amt_tot - $amt_sup); +} else { + $od = sql_fetch(" select * from {$g5['g5_shop_order_table']} where od_id = '$od_id' "); + if (!$od) + die('

주문서가 존재하지 않습니다.

'); + + if($od['od_cash'] == 1) + alert('이미 등록된 현금영수증 입니다.'); + + $buyername = $od['od_name']; + $goods = get_goods($od['od_id']); + $goodname = $goods['full_name']; + $amt_tot = (int)$od['od_tax_mny'] + (int)$od['od_vat_mny'] + (int)$od['od_free_mny']; + $amt_sup = (int)$od['od_tax_mny'] + (int)$od['od_free_mny']; + $amt_tax = (int)$od['od_vat_mny']; + $amt_svc = 0; +} + + +$reg_num = $id_info; +$useopt = $tr_code; +$currency = 'WON'; + +/********************* + * 3. 발급 정보 설정 * + *********************/ +$inipay->SetField("type" ,"receipt"); // 고정 +$inipay->SetField("pgid" ,"INIphpRECP"); // 고정 +$inipay->SetField("paymethod" ,"CASH"); // 고정 (요청분류) +$inipay->SetField("currency" ,$currency); // 화폐단위 (고정) +/************************************************************************************************** +* admin 은 키패스워드 변수명입니다. 수정하시면 안됩니다. 1111의 부분만 수정해서 사용하시기 바랍니다. +* 키패스워드는 상점관리자 페이지(https://iniweb.inicis.com)의 비밀번호가 아닙니다. 주의해 주시기 바랍니다. +* 키패스워드는 숫자 4자리로만 구성됩니다. 이 값은 키파일 발급시 결정됩니다. +* 키패스워드 값을 확인하시려면 상점측에 발급된 키파일 안의 readme.txt 파일을 참조해 주십시오. +**************************************************************************************************/ +$inipay->SetField("admin" ,$default['de_inicis_admin_key']); // 키패스워드(상점아이디에 따라 변경) +$inipay->SetField("mid" ,$default['de_inicis_mid']); // 상점아이디 +$inipay->SetField("goodname" ,iconv_euckr($goodname)); // 상품명 +$inipay->SetField("cr_price" ,$amt_tot); // 총 현금결제 금액 +$inipay->SetField("sup_price" ,$amt_sup); // 공급가액 +$inipay->SetField("tax" ,$amt_tax); // 부가세 +$inipay->SetField("srvc_price" ,$amt_svc); // 봉사료 +$inipay->SetField("buyername" ,iconv_euckr($buyername)); // 구매자 성명 +$inipay->SetField("buyeremail" ,$buyeremail); // 구매자 이메일 주소 +$inipay->SetField("buyertel" ,$buyertel); // 구매자 전화번호 +$inipay->SetField("reg_num" ,$reg_num); // 현금결제자 주민등록번호 +$inipay->SetField("useopt" ,$useopt); // 현금영수증 발행용도 ("1" - 소비자 소득공제용, "2" - 사업자 지출증빙용) +$inipay->SetField("companynumber" ,$companynumber); // 서브몰 사업자번호 + + +/**************** + * 4. 발급 요청 * + ****************/ +$inipay->startAction(); + + +/******************************************************************************** + * 5. 발급 결과 * + * * + * 결과코드 : $inipay->GetResult('ResultCode') ("00" 이면 발행 성공) * + * 승인번호 : $inipay->GetResult('ApplNum') (현금영수증 발행 승인번호) * + * 승인날짜 : $inipay->GetResult('ApplDate') (YYYYMMDD) * + * 승인시각 : $inipay->GetResult('ApplTime') (HHMMSS) * + * 거래번호 : $inipay->GetResult('TID') * + * 총현금결제 금액 : $inipay->GetResult('CSHR_ApplPrice') * + * 공급가액 : $inipay->GetResult('CSHR_SupplyPrice') * + * 부가세 : $inipay->GetResult('CSHR_Tax') * + * 봉사료 : $inipay->GetResult('CSHR_ServicePrice') * + * 사용구분 : $inipay->GetResult('CSHR_Type') * + ********************************************************************************/ + + +// DB 반영 +if($inipay->GetResult('ResultCode') == '00') { + $cash_no = $inipay->GetResult('ApplNum'); + + $cash = array(); + $cash['TID'] = $inipay->GetResult('TID'); + $cash['ApplNum'] = $inipay->GetResult('ApplNum'); + $cash['ApplDate'] = $inipay->GetResult('ApplDate'); + $cash['ApplTime'] = $inipay->GetResult('ApplTime'); + $cash['CSHR_Type'] = $inipay->GetResult('CSHR_Type'); + $cash_info = serialize($cash); + + if($tx == 'personalpay') { + $sql = " update {$g5['g5_shop_personalpay_table']} + set pp_cash = '1', + pp_cash_no = '$cash_no', + pp_cash_info = '$cash_info' + where pp_id = '$od_id' "; + } else { + $sql = " update {$g5['g5_shop_order_table']} + set od_cash = '1', + od_cash_no = '$cash_no', + od_cash_info = '$cash_info' + where od_id = '$od_id' "; + } + + $result = sql_query($sql, false); + + if(!$result) + include G5_SHOP_PATH.'/inicis/inipay_cancel.php'; +} + +$g5['title'] = '현금영수증 발급'; +include_once(G5_PATH.'/head.sub.php'); +?> + + + +
+

현금영수증 - KG이니시스

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
결과코드GetResult('ResultCode'); ?>
결과 메세지GetResult('ResultMsg')); ?>
현금영수증 거래번호GetResult('TID'); ?>
현금영수증 승인번호GetResult('ApplNum'); ?>
승인시간GetResult('ApplDate').$inipay->GetResult('ApplTime')); ?>
현금영수증 URL + +

영수증 확인은 실 등록의 경우에만 가능합니다.

+
+
+ +
+ + \ No newline at end of file diff --git a/shop/lg/xpay_result.php b/shop/lg/xpay_result.php index e2ffb4a3a..2553be9d8 100644 --- a/shop/lg/xpay_result.php +++ b/shop/lg/xpay_result.php @@ -90,7 +90,19 @@ if ($xpay->TX()) { //최종결제요청 결과 실패 DB처리 //echo "최종결제요청 결과 실패 DB처리하시기 바랍니다.
"; - alert($xpay->Response_Msg().' 코드 : '.$xpay->Response_Code()); + if(G5_IS_MOBILE) { + if(isset($_POST['pp_id']) && $_POST['pp_id']) { + $page_return_url = G5_SHOP_URL.'/personalpayform.php?pp_id='.get_session('ss_personalpay_id'); + } else { + $page_return_url = G5_SHOP_URL.'/orderform.php'; + if(get_session('ss_direct')) + $page_return_url .= '?sw_direct=1'; + } + + alert($xpay->Response_Msg().' 코드 : '.$xpay->Response_Code(), $page_return_url); + } else { + alert($xpay->Response_Msg().' 코드 : '.$xpay->Response_Code()); + } } } else { //2)API 요청실패 화면처리 diff --git a/shop/orderform.php b/shop/orderform.php index 4be4b95f2..317becbff 100644 --- a/shop/orderform.php +++ b/shop/orderform.php @@ -30,10 +30,13 @@ $g5['title'] = '주문서 작성'; if($default['de_iche_use'] || $default['de_vbank_use'] || $default['de_hp_use'] || $default['de_card_use']) { switch($default['de_pg_service']) { case 'lg': - $g5['body_script'] = 'onload="isActiveXOK();"'; + $g5['body_script'] = ' onload="isActiveXOK();"'; + break; + case 'inicis': + $g5['body_script'] = ' onload="javascript:enable_click()"'; break; default: - $g5['body_script'] = 'onload="CheckPayplusInstall();"'; + $g5['body_script'] = ' onload="CheckPayplusInstall();"'; break; } } @@ -1355,6 +1358,25 @@ function forderform_check(f) f.LGD_CUSTOM_FIRSTPAY.value = "무통장"; break; } + + switch(settle_method) + { + case "계좌이체": + f.gopaymethod.value = "onlydbank"; + break; + case "가상계좌": + f.gopaymethod.value = "onlyvbank"; + break; + case "휴대폰": + f.gopaymethod.value = "onlyhpp"; + break; + case "신용카드": + f.gopaymethod.value = "onlycard"; + break; + default: + f.gopaymethod.value = "무통장"; + break; + } // 결제정보설정 @@ -1380,7 +1402,8 @@ function forderform_check(f) } else { return true; } - + + f.LGD_BUYER.value = f.od_name.value; f.LGD_BUYEREMAIL.value = f.od_email.value; f.LGD_BUYERPHONE.value = f.od_hp.value; @@ -1403,6 +1426,24 @@ function forderform_check(f) f.submit(); } + + f.buyername.value = f.od_name.value; + f.buyeremail.value = f.od_email.value; + f.buyertel.value = f.od_hp.value ? f.od_hp.value : f.od_tel.value; + f.recvname.value = f.od_b_name.value; + f.recvtel.value = f.od_b_hp.value ? f.od_b_hp.value : f.od_b_tel.value; + f.recvpostnum.value = f.od_b_zip1.value + f.od_b_zip2.value; + f.recvaddr.value = f.od_b_addr1.value + " " +f.od_b_addr2.value; + + if(f.gopaymethod.value != "무통장") { + if(!set_encrypt_data(f)) + return false; + + return pay(f); + } else { + return true; + } + } // 구매자 정보와 동일합니다. diff --git a/shop/orderformupdate.php b/shop/orderformupdate.php index fe02daf88..119b3967b 100644 --- a/shop/orderformupdate.php +++ b/shop/orderformupdate.php @@ -280,6 +280,9 @@ else if ($od_settle_case == "계좌이체") case 'lg': include G5_SHOP_PATH.'/lg/xpay_result.php'; break; + case 'inicis': + include G5_SHOP_PATH.'/inicis/inipay_result.php'; + break; default: include G5_SHOP_PATH.'/kcp/pp_ax_hub.php'; $bank_name = iconv("cp949", "utf-8", $bank_name); @@ -304,6 +307,10 @@ else if ($od_settle_case == "가상계좌") case 'lg': include G5_SHOP_PATH.'/lg/xpay_result.php'; break; + case 'inicis': + include G5_SHOP_PATH.'/inicis/inipay_result.php'; + $od_app_no = $app_no; + break; default: include G5_SHOP_PATH.'/kcp/pp_ax_hub.php'; $bankname = iconv("cp949", "utf-8", $bankname); @@ -325,6 +332,9 @@ else if ($od_settle_case == "휴대폰") case 'lg': include G5_SHOP_PATH.'/lg/xpay_result.php'; break; + case 'inicis': + include G5_SHOP_PATH.'/inicis/inipay_result.php'; + break; default: include G5_SHOP_PATH.'/kcp/pp_ax_hub.php'; break; @@ -334,7 +344,7 @@ else if ($od_settle_case == "휴대폰") $od_receipt_price = $amount; $od_receipt_point = $i_temp_point; $od_receipt_time = preg_replace("/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/", "\\1-\\2-\\3 \\4:\\5:\\6", $app_time); - $od_bank_account = $commid.' '.$mobile_no; + $od_bank_account = $commid . ($commid ? ' ' : '').$mobile_no; $pg_price = $amount; $od_misu = $i_price - $od_receipt_price; if($od_misu == 0) @@ -346,6 +356,9 @@ else if ($od_settle_case == "신용카드") case 'lg': include G5_SHOP_PATH.'/lg/xpay_result.php'; break; + case 'inicis': + include G5_SHOP_PATH.'/inicis/inipay_result.php'; + break; default: include G5_SHOP_PATH.'/kcp/pp_ax_hub.php'; $card_name = iconv("cp949", "utf-8", $card_name); @@ -376,6 +389,9 @@ if($tno) { case 'lg': include G5_SHOP_PATH.'/lg/xpay_cancel.php'; break; + case 'inicis': + include G5_SHOP_PATH.'/inicis/inipay_cancel.php'; + break; default: include G5_SHOP_PATH.'/kcp/pp_ax_hub_cancel.php'; break; @@ -491,6 +507,9 @@ if(!$result) { case 'lg': include G5_SHOP_PATH.'/lg/xpay_cancel.php'; break; + case 'inicis': + include G5_SHOP_PATH.'/inicis/inipay_cancel.php'; + break; default: include G5_SHOP_PATH.'/kcp/pp_ax_hub_cancel.php'; break; @@ -527,6 +546,9 @@ if(!$result) { case 'lg': include G5_SHOP_PATH.'/lg/xpay_cancel.php'; break; + case 'inicis': + include G5_SHOP_PATH.'/inicis/inipay_cancel.php'; + break; default: include G5_SHOP_PATH.'/kcp/pp_ax_hub_cancel.php'; break; diff --git a/shop/orderinquirycancel.php b/shop/orderinquirycancel.php index 678f255a2..5c269edcf 100644 --- a/shop/orderinquirycancel.php +++ b/shop/orderinquirycancel.php @@ -61,6 +61,48 @@ if($od['od_tno']) { alert($msg); } break; + case 'inicis': + include_once(G5_SHOP_PATH.'/settle_inicis.inc.php'); + $cancel_msg = iconv_euckr('주문자 본인 취소-'.$cancel_memo); + + /********************* + * 3. 취소 정보 설정 * + *********************/ + $inipay->SetField("type", "cancel"); // 고정 (절대 수정 불가) + $inipay->SetField("mid", $default['de_inicis_mid']); // 상점아이디 + /************************************************************************************************** + * admin 은 키패스워드 변수명입니다. 수정하시면 안됩니다. 1111의 부분만 수정해서 사용하시기 바랍니다. + * 키패스워드는 상점관리자 페이지(https://iniweb.inicis.com)의 비밀번호가 아닙니다. 주의해 주시기 바랍니다. + * 키패스워드는 숫자 4자리로만 구성됩니다. 이 값은 키파일 발급시 결정됩니다. + * 키패스워드 값을 확인하시려면 상점측에 발급된 키파일 안의 readme.txt 파일을 참조해 주십시오. + **************************************************************************************************/ + $inipay->SetField("admin", $default['de_inicis_admin_key']); //비대칭 사용키 키패스워드 + $inipay->SetField("tid", $od['od_tno']); // 취소할 거래의 거래아이디 + $inipay->SetField("cancelmsg", $cancel_msg); // 취소사유 + + /**************** + * 4. 취소 요청 * + ****************/ + $inipay->startAction(); + + /**************************************************************** + * 5. 취소 결과 * + * * + * 결과코드 : $inipay->getResult('ResultCode') ("00"이면 취소 성공) * + * 결과내용 : $inipay->getResult('ResultMsg') (취소결과에 대한 설명) * + * 취소날짜 : $inipay->getResult('CancelDate') (YYYYMMDD) * + * 취소시각 : $inipay->getResult('CancelTime') (HHMMSS) * + * 현금영수증 취소 승인번호 : $inipay->getResult('CSHR_CancelNum') * + * (현금영수증 발급 취소시에만 리턴됨) * + ****************************************************************/ + + $res_cd = $inipay->getResult('ResultCode'); + $res_msg = $inipay->getResult('ResultMsg'); + + if($res_cd != '00') { + alert(iconv_utf8($res_msg).' 코드 : '.$res_cd); + } + break; default: require_once('./settle_kcp.inc.php'); diff --git a/shop/orderinquiryview.php b/shop/orderinquiryview.php index b90e47d3f..1e47f5e9a 100644 --- a/shop/orderinquiryview.php +++ b/shop/orderinquiryview.php @@ -349,6 +349,8 @@ if($od['od_pg'] == 'lg') { $LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY); $hp_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');'; + } else if($od['od_pg'] == 'inicis') { + $hp_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/mCmReceipt_head.jsp?noTid='.$od['od_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');'; } else { $hp_receipt_script = 'window.open(\''.G5_BILL_RECEIPT_URL.'mcash_bill&tno='.$od['od_tno'].'&order_no='.$od['od_id'].'&trade_mony='.$od['od_receipt_price'].'\', \'winreceipt\', \'width=500,height=690,scrollbars=yes,resizable=yes\');'; } @@ -366,6 +368,8 @@ if($od['od_pg'] == 'lg') { $LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY); $card_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');'; + } else if($od['od_pg'] == 'inicis') { + $card_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/mCmReceipt_head.jsp?noTid='.$od['od_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');'; } else { $card_receipt_script = 'window.open(\''.G5_BILL_RECEIPT_URL.'card_bill&tno='.$od['od_tno'].'&order_no='.$od['od_id'].'&trade_mony='.$od['od_receipt_price'].'\', \'winreceipt\', \'width=470,height=815,scrollbars=yes,resizable=yes\');'; } @@ -427,6 +431,9 @@ if($od['od_pg'] == 'lg') { break; } $cash_receipt_script = 'javascript:showCashReceipts(\''.$LGD_MID.'\',\''.$od['od_id'].'\',\''.$od['od_casseqno'].'\',\''.$trade_type.'\',\''.$CST_PLATFORM.'\');'; + } else if($od['od_pg'] == 'inicis') { + $cash = unserialize($od['od_cash_info']); + $cash_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/Cash_mCmReceipt.jsp?noTid='.$cash['TID'].'&clpaymethod=22\',\'showreceipt\',\'width=380,height=540,scrollbars=no,resizable=no\');'; } else { require_once G5_SHOP_PATH.'/settle_kcp.inc.php'; diff --git a/shop/personalpayform.php b/shop/personalpayform.php index ec4b30837..39a3eabf3 100644 --- a/shop/personalpayform.php +++ b/shop/personalpayform.php @@ -21,10 +21,13 @@ $g5['title'] = $pp['pp_name'].'님 개인결제'; if($default['de_iche_use'] || $default['de_vbank_use'] || $default['de_hp_use'] || $default['de_card_use']) { switch($default['de_pg_service']) { case 'lg': - $g5['body_script'] = 'onload="isActiveXOK();"'; + $g5['body_script'] = ' onload="isActiveXOK();"'; + break; + case 'inicis': + $g5['body_script'] = ' onload="javascript:enable_click()"'; break; default: - $g5['body_script'] = 'onload="CheckPayplusInstall();"'; + $g5['body_script'] = ' onload="CheckPayplusInstall();"'; break; } } @@ -92,7 +95,7 @@ require_once('./'.$default['de_pg_service'].'/orderform.1.php'); - + @@ -257,6 +260,25 @@ function forderform_check(f) f.LGD_CUSTOM_FIRSTPAY.value = "무통장"; break; } + + switch(settle_method) + { + case "계좌이체": + f.gopaymethod.value = "onlydbank"; + break; + case "가상계좌": + f.gopaymethod.value = "onlyvbank"; + break; + case "휴대폰": + f.gopaymethod.value = "onlyhpp"; + break; + case "신용카드": + f.gopaymethod.value = "onlycard"; + break; + default: + f.gopaymethod.value = "무통장"; + break; + } // 결제정보설정 @@ -279,7 +301,8 @@ function forderform_check(f) } else { return true; } - + + f.LGD_BUYER.value = f.pp_name.value; f.LGD_BUYEREMAIL.value = f.pp_email.value; f.LGD_BUYERPHONE.value = f.pp_hp.value; @@ -292,6 +315,20 @@ function forderform_check(f) f.submit(); } + + f.buyername.value = f.pp_name.value; + f.buyeremail.value = f.pp_email.value; + f.buyertel.value = f.pp_hp.value; + + if(f.gopaymethod.value != "무통장") { + if(!set_encrypt_data(f)) + return false; + + return pay(f); + } else { + return true; + } + } diff --git a/shop/personalpayformupdate.php b/shop/personalpayformupdate.php index 246132fd7..9ed95b8d1 100644 --- a/shop/personalpayformupdate.php +++ b/shop/personalpayformupdate.php @@ -3,7 +3,10 @@ include_once('./_common.php'); include_once(G5_LIB_PATH.'/mailer.lib.php'); if($default['de_pg_service'] == 'lg' && !$_POST['LGD_PAYKEY']) - alert('결제등록 요청 후 주문해 주십시오.'); + alert('결제등록 요청 후 결제해 주십시오.'); + +if($default['de_pg_service'] == 'inicis' && !$_POST['P_HASH']) + alert('결제등록 요청 후 결제해 주십시오.'); // 개인결제 정보 $pp_check = false; @@ -26,6 +29,9 @@ if ($pp_settle_case == "계좌이체") case 'lg': include G5_SHOP_PATH.'/lg/xpay_result.php'; break; + case 'inicis': + include G5_SHOP_PATH.'/inicis/inipay_result.php'; + break; default: include G5_SHOP_PATH.'/kcp/pp_ax_hub.php'; $bank_name = iconv("cp949", "utf-8", $bank_name); @@ -45,6 +51,9 @@ else if ($pp_settle_case == "가상계좌") case 'lg': include G5_SHOP_PATH.'/lg/xpay_result.php'; break; + case 'inicis': + include G5_SHOP_PATH.'/inicis/inipay_result.php'; + break; default: include G5_SHOP_PATH.'/kcp/pp_ax_hub.php'; $bankname = iconv("cp949", "utf-8", $bankname); @@ -64,6 +73,9 @@ else if ($pp_settle_case == "휴대폰") case 'lg': include G5_SHOP_PATH.'/lg/xpay_result.php'; break; + case 'inicis': + include G5_SHOP_PATH.'/inicis/inipay_result.php'; + break; default: include G5_SHOP_PATH.'/kcp/pp_ax_hub.php'; break; @@ -81,6 +93,9 @@ else if ($pp_settle_case == "신용카드") case 'lg': include G5_SHOP_PATH.'/lg/xpay_result.php'; break; + case 'inicis': + include G5_SHOP_PATH.'/inicis/inipay_result.php'; + break; default: include G5_SHOP_PATH.'/kcp/pp_ax_hub.php'; $card_name = iconv("cp949", "utf-8", $card_name); @@ -105,6 +120,9 @@ if((int)$pp['pp_price'] !== (int)$pg_price) { case 'lg': include G5_SHOP_PATH.'/lg/xpay_cancel.php'; break; + case 'inicis': + include G5_SHOP_PATH.'/inicis/inipay_cancel.php'; + break; default: include G5_SHOP_PATH.'/kcp/pp_ax_hub_cancel.php'; break; @@ -139,6 +157,9 @@ if(!$result) { case 'lg': include G5_SHOP_PATH.'/lg/xpay_cancel.php'; break; + case 'inicis': + include G5_SHOP_PATH.'/inicis/inipay_cancel.php'; + break; default: include G5_SHOP_PATH.'/kcp/pp_ax_hub_cancel.php'; break; @@ -174,6 +195,9 @@ if($pp_receipt_price > 0 && $pp['pp_id'] && $pp['od_id']) { case 'lg': include G5_SHOP_PATH.'/lg/xpay_cancel.php'; break; + case 'inicis': + include G5_SHOP_PATH.'/inicis/inipay_cancel.php'; + break; default: include G5_SHOP_PATH.'/kcp/pp_ax_hub_cancel.php'; break; diff --git a/shop/personalpayresult.php b/shop/personalpayresult.php index aa76a7749..76d4ee56a 100644 --- a/shop/personalpayresult.php +++ b/shop/personalpayresult.php @@ -147,6 +147,8 @@ if($pp['pp_pg'] == 'lg') { $LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY); $hp_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');'; + } else if($pp['pp_pg'] == 'inicis') { + $hp_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/mCmReceipt_head.jsp?noTid='.$pp['pp_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');'; } else { $hp_receipt_script = 'window.open(\''.G5_BILL_RECEIPT_URL.'mcash_bill&tno='.$pp['pp_tno'].'&order_no='.$pp['pp_id'].'&trade_mony='.$pp['pp_receipt_price'].'\', \'winreceipt\', \'width=500,height=690,scrollbars=yes,resizable=yes\');'; } @@ -164,6 +166,8 @@ if($pp['pp_pg'] == 'lg') { $LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY); $card_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');'; + } else if($pp['pp_pg'] == 'inicis') { + $card_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/mCmReceipt_head.jsp?noTid='.$pp['pp_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');'; } else { $card_receipt_script = 'window.open(\''.G5_BILL_RECEIPT_URL.'card_bill&tno='.$pp['pp_tno'].'&order_no='.$pp['pp_id'].'&trade_mony='.$pp['pp_receipt_price'].'\', \'winreceipt\', \'width=470,height=815,scrollbars=yes,resizable=yes\');'; } @@ -215,6 +219,9 @@ if($pp['pp_pg'] == 'lg') { break; } $cash_receipt_script = 'javascript:showCashReceipts(\''.$LGD_MID.'\',\''.$pp['pp_id'].'\',\''.$pp['pp_casseqno'].'\',\''.$trade_type.'\',\''.$CST_PLATFORM.'\');'; + } else if($pp['pp_pg'] == 'inicis') { + $cash = unserialize($pp['pp_cash_info']); + $cash_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/Cash_mCmReceipt.jsp?noTid='.$cash['TID'].'&clpaymethod=22\',\'showreceipt\',\'width=380,height=540,scrollbars=no,resizable=no\');'; } else { require_once G5_SHOP_PATH.'/settle_kcp.inc.php'; diff --git a/shop/price2/daum.php b/shop/price2/daum.php index 1ac3076e9..1009bcb95 100644 --- a/shop/price2/daum.php +++ b/shop/price2/daum.php @@ -164,7 +164,7 @@ HEREDOC; $point = get_item_point($row, $row2['io_id']); if($delivery) { - $deliv = $delivery; + $deliv = 1; $deliv2 = $delivery.'원'; } else { $deliv = 0; diff --git a/shop/settle_inicis.inc.php b/shop/settle_inicis.inc.php new file mode 100644 index 000000000..11c832f39 --- /dev/null +++ b/shop/settle_inicis.inc.php @@ -0,0 +1,111 @@ +SetField("inipayhome", G5_SHOP_PATH.'/inicis'); // 이니페이 홈디렉터리(상점수정 필요) +$inipay->SetField("debug", "false"); // 로그모드("true"로 설정하면 상세로그가 생성됨.) + +$inipay_nointerest = 'no'; //무이자여부(no:일반, yes:무이자) +$inipay_quotabase = '선택:일시불:2개월:3개월:4개월:5개월:6개월:7개월:8개월:9개월:10개월:11개월:12개월'; // 할부기간 + +$BANK_CODE = array( + '03' => '기업은행', + '04' => '국민은행', + '05' => '외환은행', + '07' => '수협중앙회', + '11' => '농협중앙회', + '20' => '우리은행', + '23' => 'SC 제일은행', + '31' => '대구은행', + '32' => '부산은행', + '34' => '광주은행', + '37' => '전북은행', + '39' => '경남은행', + '53' => '한국씨티은행', + '71' => '우체국', + '81' => '하나은행', + '88' => '신한은행', + 'D1' => '동양종합금융증권', + 'D2' => '현대증권', + 'D3' => '미래에셋증권', + 'D4' => '한국투자증권', + 'D5' => '우리투자증권', + 'D6' => '하이투자증권', + 'D7' => 'HMC 투자증권', + 'D8' => 'SK 증권', + 'D9' => '대신증권', + 'DA' => '하나대투증권', + 'DB' => '굿모닝신한증권', + 'DC' => '동부증권', + 'DD' => '유진투자증권', + 'DE' => '메리츠증권', + 'DF' => '신영증권' +); + +$CARD_CODE = array( + '01' => '외환', + '03' => '롯데', + '04' => '현대', + '06' => '국민', + '11' => 'BC', + '12' => '삼성', + '14' => '신한', + '15' => '한미', + '16' => 'NH', + '17' => '하나 SK', + '21' => '해외비자', + '22' => '해외마스터', + '23' => 'JCB', + '24' => '해외아멕스', + '25' => '해외다이너스' +); + +$PAY_METHOD = array( + 'VCard' => '신용카드', + 'Card' => '신용카드', + 'DirectBank' => '계좌이체', + 'HPP' => '휴대폰', + 'VBank' => '가상계좌' +); + +// 플러그인 호출 URL +if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on') { + $ini_js_url = 'https://plugin.inicis.com/pay61_secunissl_crossl.js'; +} else { + $ini_js_url = 'http://plugin.inicis.com/pay61_secuni_cross.js'; +} +?> \ No newline at end of file diff --git a/shop/settle_inicis_common.php b/shop/settle_inicis_common.php new file mode 100644 index 000000000..d4a12428f --- /dev/null +++ b/shop/settle_inicis_common.php @@ -0,0 +1,183 @@ +