이니시스 웹표준결제 PHP7.1.1_v1.0 모듈 적용

This commit is contained in:
thisgun
2019-09-30 17:44:26 +09:00
parent 2d5128ec4a
commit 75da28aa03
9 changed files with 1451 additions and 1424 deletions

View File

@ -1790,12 +1790,6 @@ if($default['de_iche_use'] || $default['de_vbank_use'] || $default['de_hp_use']
echo '</script>'.PHP_EOL;
}
if (!function_exists('mcrypt_module_open')) {
echo '<script>'.PHP_EOL;
echo 'alert("MCRYPT 관련 함수를 사용할 수 없습니다.\n서버 관리자에게 문의해 주십시오.");'.PHP_EOL;
echo '</script>'.PHP_EOL;
}
$log_path = G5_SHOP_PATH.'/inicis/log';
if(!is_dir($log_path)) {

View File

@ -106,7 +106,7 @@ class INILog {
var $mkey;
var $mergelog;
function INILog($request) {
function __construct($request) {
$this->debug_msg = array("", "CRITICAL", "ERROR", "NOTICE", "4", "INFO", "6", "DEBUG", "8");
$this->debug_mode = $request["debug"];
$this->type = $request["type"];
@ -132,7 +132,7 @@ class INILog {
$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() . ")");
$this->WriteLog(INFO, "START " . PROGRAM . " " . $this->type . " (" . VERSION . "-" . BUILDDATE . ")(OS:" . php_uname('s') . php_uname('r') . ",PHP:" . phpversion() . ")");
return true;
}
@ -218,7 +218,7 @@ class INIData {
var $m_RESULT = array(); //Encrypted 필드 hash table
var $m_RESULT2 = array(); //PG Added Entity
function INIData($request, $request2) {
function __construct($request, $request2) {
$this->m_Xml = NULL;
$this->m_REQUEST = $request;
@ -274,8 +274,8 @@ class INIData {
}
$this->m_sPayMethod = $this->m_REQUEST["paymethod"];
$this->m_TXVersion = sprintf("%-4.4s", VERSION) .
sprintf("B%-6.6s", BUILDDATE) .
$this->m_TXVersion = sprintf("%-6.6s", VERSION) .
sprintf("B%-8.8s", BUILDDATE) .
sprintf("%-5.5s", $this->m_Type) .
sprintf("%-10.10s", php_uname('s')) .
sprintf("%-3.3s", "PHP") . //modulescript
@ -515,6 +515,12 @@ class INIData {
$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"]);
//휴대폰 익월환불 추가
$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_REPAY) {
//PartCancelInfo(ROOT)
@ -598,10 +604,14 @@ class INIData {
$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"));
$CD = $xml->add_node($CI, TX_REFUNDFLGREMIT, $this->m_REQUEST["refundflgremit"]);
$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"]);
$CD = $xml->add_node($CI, TX_INQR_OID, $this->m_REQUEST["oid"], array("urlencode" => "1"));
//$this->AddUserDefinedEntity( INQUIRYINFO, "", $xml, $CI );
} else if ($this->m_Type == TYPE_OPENSUB) {
$OI = $xml->add_node("", OPENSUBINFO);
@ -1085,12 +1095,16 @@ class INICrypto {
var $pgpubkeyid = NULL;
var $mprivkeyid = NULL;
var $mkey;
var $encMethod = "mcrypt";
function INICrypto($request) {
function __construct($request) {
$this->homedir = $request["inipayhome"];
$this->mid = $request["mid"];
$this->admin = $request["admin"];
$this->mkey = $request["mkey"];
if(isset($request['encMethod']) && !empty($request['encMethod'])){
$this->encMethod = strtolower($request['encMethod']);
}
}
function LoadPGPubKey(&$pg_pubcert_SN) {
@ -1212,13 +1226,17 @@ class INICrypto {
}
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($this->encMethod == "openssl"){ //php version >= 5.3
$enc_data = openssl_encrypt($src_data, "DES-EDE3-CBC", $key, OPENSSL_RAW_DATA, $iv);
} else {
$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;
@ -1228,11 +1246,15 @@ class INICrypto {
}
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($this->encMethod == "openssl"){
$dec_data = openssl_decrypt($enc_data, "DES-EDE3-CBC", $key, OPENSSL_RAW_DATA, $iv);
} else {
$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;
@ -1275,7 +1297,7 @@ class INICrypto {
$chr = $string{$i};
$ord = ord($chr);
if ($ord < 10)
$string{$i} = "";
$string{$i} = " ";
else
$string{$i} = $chr;
}
@ -1336,4 +1358,3 @@ class INICrypto {
}
?>

View File

@ -65,6 +65,7 @@
* @note 2012.07.09 PHP ini 파일 error display setting 추가
* @buildno 5036
* @note 2014.12.09 add gather parameter tid, type
* @note 20151113 주문번호 거래조회 추가
*/
ini_set('error_reporting', E_ALL ^ E_NOTICE);
ini_set('display_errors', 'Off');
@ -72,8 +73,8 @@ ini_set('display_errors', 'Off');
/* GLOBAL */
define("PROGRAM", "INIPHP");
define("LANG", "PHP");
define("VERSION", "5036");
define("BUILDDATE", "141209");
define("VERSION", "NV5053");
define("BUILDDATE", "20190404");
define("TID_LEN", 40);
define("MAX_KEY_LEN", 24);
define("MAX_IV_LEN", 8);
@ -93,15 +94,15 @@ define("INFO", 5);
define("DEBUG", 7);
/* SERVER INFO */
define("PG_HOST", "pg.inicis.com");
define("DRPG_HOST", "drpg.inicis.com");
define("PG_HOST", "formpg.inicis.com");
define("PG_IP", "203.238.37.3");
define("DRPG_IP", "211.219.96.180");
define("KSPG_IP", "39.115.212.10");
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");
@ -224,7 +225,6 @@ define("TYPE_ESCROW_CNF", "confirm"); //구매확인/거절(플러그인)
define("TYPE_ESCROW_DNY", "deny"); //위에서 처리됨,의미없음
define("TYPE_ESCROW_DNY_CNF", "dcnf");
//------------------------------------------------------
//PayMethod(서비스별, TX)
//------------------------------------------------------
@ -322,6 +322,8 @@ define("TX_CANCELREASON", "CancelReason"); //2012-10-19 취소사유코드
define("TX_REFUNDACCTNUM", "RefundAcctNum");
define("TX_REFUNDBANKCODE", "RefundBankCode");
define("TX_REFUNDACCTNAME", "RefundAcctName");
define("TX_REFUNDFLGREMIT", "RefundFlgRemit");
//PartCancelInfo
define("TX_PRTC_TID", "PRTC_TID");
define("TX_PRTC_PRICE", "PRTC_Price");
@ -359,6 +361,7 @@ define("TX_CSHR_SUBAPPLPRICE1", "CSHR_SubApplPrice1");
define("TX_CSHR_SUBSERVICEPRICE1", "CSHR_SubServicePrice1");
//거래조회(12.04.20)
define("TX_INQR_TID", "INQR_TID");
define("TX_INQR_OID", "INQR_OID");
//서브몰하위가맹점등록(14.03.06)
define("TX_OPENREG_TID", "OrgTID");
define("TX_OPENREG_MID", "MID");
@ -492,6 +495,7 @@ define("ISP_PURCHASECODE", "ISP_PurchaseCode");
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");

View File

@ -113,6 +113,13 @@ class INIpay50 {
return $this->MakeChkFake();
}
//TID 인입 기반 거래의 경우 TID 를 기록함
$temp_request = array_change_key_case($this->m_REQUEST, CASE_LOWER);
if(isset($temp_request['tid'])){
$this->m_Log->WriteLog(INFO, "INPUT TID > ".$temp_request['tid']);
}
/* -------------------------------------------------- */
//Generate TID
/* -------------------------------------------------- */
@ -227,70 +234,79 @@ class INIpay50 {
$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 . "]");
$this->m_Log->WriteLog(DEBUG, "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"];
//플러그인 에스크로 결제 구분 설정
$is_plugin_escrow = FALSE;
if($this->m_type == TYPE_ESCROW && ($this->m_Data->m_EscrowType == TYPE_ESCROW_CNF || $this->m_Data->m_EscrowType == TYPE_ESCROW_DNY)) $is_plugin_escrow = TRUE;
if($this->m_REQUEST["pgn"] != "") {
$host = $this->m_REQUEST["pgn"];
} else {
if ($this->m_type == TYPE_SECUREPAY || $is_plugin_escrow == TRUE) { //plugin
$host = $this->m_Data->m_PG1;
} else if ($this->m_cancelRC == 1){ //원거래없음
$host = KSPG_IP;
} else {
$host = PG_HOST;
}
}
$this->m_Socket = new INISocket($host);
//1차 NSLOOKUP FAIL
if (($rtv = $this->m_Socket->DNSLookup()) != OK) {
$err_msg = "[" . $host . "]DNS LOOKUP 실패(MAIN)" . $this->m_Socket->getErr();
$err_msg = "[" . $host . "] 1차 DNS LOOKUP 실패" . $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로!
if ($this->m_type == TYPE_SECUREPAY || $is_plugin_escrow == TRUE) {
$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;
if ($this->m_cancelRC == 1) $this->m_Socket->ip = KSPG_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);
$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로 전환";
$err_msg = "[" . $host."(". $this->m_Socket->ip .") 소켓연결오류(1차):: 2차 연결시도";
$this->m_Log->WriteLog(ERROR, $err_msg);
$this->MakeTXErrMsg($rtv, $err_msg);
if ($this->m_type == TYPE_SECUREPAY) {
if ($this->m_type == TYPE_SECUREPAY || $is_plugin_escrow == TRUE) {
$host = $this->m_Data->m_PG2;
} else {
$host = DRPG_HOST;
$host = $this->m_Socket->ip == PG_IP ? KSPG_IP:PG_IP;
}
$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;
}
//SECUREPAY만 2차 NSLOOKUP 진행, 이외는 IP통신
if ($this->m_type == TYPE_SECUREPAY || $is_plugin_escrow == TRUE) {
if (($rtv = $this->m_Socket->DNSLookup()) != OK) {
$err_msg = "[" . $host . "] 2차 DNS LOOKUP 실패" . $this->m_Socket->getErr();
$this->m_Log->WriteLog(ERROR, $err_msg);
$this->MakeTXErrMsg($rtv, $err_msg);
$this->m_Socket->ip = $this->m_Data->m_PG2IP;
}
} else {
$this->m_Socket->ip = $host;
}
$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);
$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();
$err_msg = "[" . $host . "소켓연결오류(2차)::" . $this->m_Socket->getErr();
$this->m_Log->WriteLog(ERROR, $err_msg);
$this->MakeTXErrMsg($rtv, $err_msg);
$this->m_Log->CloseLog($this->GetResult(NM_RESULTMSG));
@ -450,17 +466,6 @@ class INIpay50 {
$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;
}

View File

@ -37,7 +37,7 @@ class INISocket {
return false;
}
function INISocket($host) {
function __construct($host) {
$this->family = AF_INET;
$this->type = SOCK_STREAM;
$this->protocol = SOL_TCP;
@ -52,7 +52,7 @@ class INISocket {
function DNSLookUP() {
$starttime = GetMicroTime();
$ip = @gethostbyname($this->host);
if ($ip) {
if ($ip == PG_IP || $ip == KSPG_IP) {
$this->ip = $ip;
} else {
$this->error("Hostname " . $this->host . " could not be resolved");

View File

@ -186,7 +186,7 @@ class XML {
*/
//modify by ddaemiri, 2007.05.28
//load_file -> load_xml로 파일 및 string 으로 모두 입력받을 수 있음.
function XML($file = "") {
function __construct($file = "") {
// Check whether a file was given.
if (!empty($file)) {
// Load the XML file.
@ -207,6 +207,17 @@ class XML {
* @see handle_start_element(), handle_end_element(),
* handle_character_data()
*/
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);
}
//modify by ddaemiri, 2007.05.28
//load_file -> load_xml로 파일 및 string 으로 모두 입력받을 수 있음.
function load_xml($file, $str) {
@ -216,7 +227,7 @@ class XML {
if ($str == "")
$content = implode("", file($file));
else
$content = $str;
$content = $this->remove_ctrl($str);
// Check whether content has been read.
if (!empty($content)) {
@ -1273,7 +1284,7 @@ class XML {
}
// Perform an axis action.
$contexts = call_user_method($method, $this, $axis, $context);
$contexts = call_user_func(array($this, $method), $axis, $context);
// Check whether there are predicates.
if (count($axis["predicate"]) > 0) {
@ -1331,7 +1342,7 @@ class XML {
}
// Return the result of the function.
return call_user_method($method, $this, $node, $arguments);
return call_user_func(array($this, $method), $axis, $context);
}
/**
@ -3092,21 +3103,9 @@ class XML {
// 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);
//보안 이슈로 eval 함수 제거 20161011 jhkim
array_shift($arguments);
$message = vsprintf($message, $arguments);
}
// Display the error message.

View File

@ -54,6 +54,10 @@ $inipay = new INIpay50;
$inipay->SetField("inipayhome", G5_SHOP_PATH.'/inicis'); // 이니페이 홈디렉터리(상점수정 필요)
$inipay->SetField("debug", "false");
if( ! function_exists('mcrypt_encrypt')) { // mcrypt 관련 함수가 없다면 취소시 openssl로 합니다.
$inipay->SetField("encMethod", "openssl");
}
$util = new INIStdPayUtil();
$timestamp = $util->getTimestamp(); // util에 의해서 자동생성

View File

@ -20,7 +20,7 @@ add_stylesheet('<link rel="stylesheet" href="'.G5_SHOP_SKIN_URL.'/style.css">',
echo '<li>';
$it_name = get_text($row['it_name']);
// 이미지로 할 경우
$it_img = get_it_image($row[it_id], 60, 60, true);
$it_img = get_it_image($row['it_id'], 60, 60, true);
echo '<div class="prd_img">'.$it_img.'</div>';
echo '<a href="'.G5_SHOP_URL.'/item.php?it_id='.$row['it_id'].'">'.$it_name.'</a>';
//echo '<a href="'.G5_SHOP_URL.'/wishlist.php">'.$it_name.'</a>';

View File

@ -20,7 +20,7 @@ add_stylesheet('<link rel="stylesheet" href="'.G5_SHOP_SKIN_URL.'/style.css">',
echo '<li>';
$it_name = get_text($row['it_name']);
// 이미지로 할 경우
$it_img = get_it_image($row[it_id], 60, 60, true);
$it_img = get_it_image($row['it_id'], 60, 60, true);
echo '<div class="prd_img">'.$it_img.'</div>';
echo '<a href="'.G5_SHOP_URL.'/item.php?it_id='.$row['it_id'].'">'.$it_name.'</a>';
//echo '<a href="'.G5_SHOP_URL.'/wishlist.php">'.$it_name.'</a>';