From 953e301096a7a091e37e1ae80b84631112bacf94 Mon Sep 17 00:00:00 2001 From: thisgun Date: Mon, 7 Jan 2019 12:06:13 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A1=9C=EA=B7=B8=ED=8F=B4=EB=8D=94=20?= =?UTF-8?q?=EA=B2=80=EC=83=89=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adm/admin.lib.php | 41 +++++++++++++++++++++++++ plugin/lgxpay/lgdacom/XPayClient.php | 2 +- plugin/lgxpay/lgdacom/XPayClient4DB.php | 2 +- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/adm/admin.lib.php b/adm/admin.lib.php index 1200bb0fc..ececd06ab 100644 --- a/adm/admin.lib.php +++ b/adm/admin.lib.php @@ -379,6 +379,47 @@ function get_sanitize_input($s, $is_html=false){ return $s; } +function check_log_folder($log_path){ + + if( is_writable($log_path) ){ + + // 아파치 서버인 경우 웹에서 해당 폴더 접근 막기 + $htaccess_file = $log_path.'/.htaccess'; + if ( !file_exists( $htaccess_file ) ) { + if ( $handle = @fopen( $htaccess_file, 'w' ) ) { + fwrite( $handle, 'Order deny,allow' . "\n" ); + fwrite( $handle, 'Deny from all' . "\n" ); + fclose( $handle ); + } + } + + // 아파치 서버인 경우 해당 디렉토리 파일 목록 안보이게 하기 + $index_file = $log_path . '/index.php'; + if ( !file_exists( $index_file ) ) { + if ( $handle = @fopen( $index_file, 'w' ) ) { + fwrite( $handle, '' ); + fclose( $handle ); + } + } + } + + // txt 파일과 log 파일을 조회하여 30일이 지난 파일은 삭제합니다. + $txt_files = glob($log_path.'/*.txt'); + $log_files = glob($log_path.'/*.log'); + + $del_files = array_merge($txt_files, $log_files); + + if( $del_files && is_array($del_files) ){ + foreach ($del_files as $del_file) { + $filetime = filemtime($del_file); + // 30일이 지난 파일을 삭제 + if($filetime && $filetime < (G5_SERVER_TIME - 2592000)) { + @unlink($del_file); + } + } + } +} + // POST로 넘어온 토큰과 세션에 저장된 토큰 비교 function check_admin_token() { diff --git a/plugin/lgxpay/lgdacom/XPayClient.php b/plugin/lgxpay/lgdacom/XPayClient.php index 177d0becc..600a9c908 100644 --- a/plugin/lgxpay/lgdacom/XPayClient.php +++ b/plugin/lgxpay/lgdacom/XPayClient.php @@ -143,7 +143,7 @@ class XPayClient // log_dir 재설정 $this->config["log_dir"] = $home_dir."/log"; - $this->log_file = $this->config["log_dir"] . "/log_" . date("Ymd") . ".log"; + $this->log_file = $this->config["log_dir"] . "/log_" . date("Ymd") . '_' . substr(md5(mt_rand()), 0, 12) . ".log"; // make log directory if does not exist if (!file_exists($this->config["log_dir"])) { mkdir($this->config["log_dir"], "0777", true); diff --git a/plugin/lgxpay/lgdacom/XPayClient4DB.php b/plugin/lgxpay/lgdacom/XPayClient4DB.php index c657d68ea..8f3eaefc0 100644 --- a/plugin/lgxpay/lgdacom/XPayClient4DB.php +++ b/plugin/lgxpay/lgdacom/XPayClient4DB.php @@ -141,7 +141,7 @@ class XPayClient $array3 = array($mid => $mertkey); $this->config = $array1 + $array2 + $array3; - $this->log_file = $this->config["log_dir"] . "/log_" . date("Ymd") . ".log"; + $this->log_file = $this->config["log_dir"] . "/log_" . date("Ymd") . '_' . substr(md5(mt_rand()), 0, 12) . ".log"; // make log directory if does not exist if (!file_exists($this->config["log_dir"])) { mkdir($this->config["log_dir"], "0777", true);