From 07caa850317e6896e82188440d97899492cc8d5c Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Tue, 25 Sep 2018 03:02:05 +0900 Subject: [PATCH] Update pgkcp.lnk.php --- helper/pgkcp.lnk.php | 45 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/helper/pgkcp.lnk.php b/helper/pgkcp.lnk.php index bd5cd6e..aef9260 100644 --- a/helper/pgkcp.lnk.php +++ b/helper/pgkcp.lnk.php @@ -31,10 +31,51 @@ if(!function_exists("get_pgkcp_config")) { "module_type" => $module_type, ); } else { - set_error("PGKCP Configuration File does not exists."); + set_error("PGKCP configuration file does not exists."); show_errors(); } - + + // check installed platform + $platform = get_pgkcp_platform($pgkcp_config); + if(empty($platform)) { + set_error("pp_cli or pp_cli.exe file not found"); + show_errors(); + } else { + $pgkcp_config['g_conf_platform'] = $platform; + } + return $pgkcp_config; } } + +if(!function_exists("get_pgkcp_platform")) { + function get_pgkcp_platform($config) { + $platform = false; + + $exe_files = array( + "linux" => $config['g_conf_home_dir'] . "/bin/pp_cli", + "windows" => $config['g_conf_home_dir'] . "/bin/pp_cli.exe" + ); + + foreach($exe_files as $k=>$v) { + if(file_exists($v)) { + $platform = $k; + break; + } + } + + return $platform; + } +} + +if(!function_exists("load_pgkcp_library")) { + function load_pgkcp_library() { + $inc_file = get_current_working_dir() . "/vendor/pgkcp/res/pp_cli_hub_lib.php"; + if(file_exists($inc_file)) { + include($inc_file); + } else { + set_error("PGKCP payment library file does not exists."); + show_errors(); + } + } +}