Skip to content

Commit

Permalink
로그폴더 검색되지 않도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
thisgun committed Jan 7, 2019
1 parent 72bbc0b commit 953e301
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
41 changes: 41 additions & 0 deletions adm/admin.lib.php
Expand Up @@ -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()
{
Expand Down
2 changes: 1 addition & 1 deletion plugin/lgxpay/lgdacom/XPayClient.php
Expand Up @@ -143,7 +143,7 @@ function json_decode($content, $assoc=false){
// 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);
Expand Down
2 changes: 1 addition & 1 deletion plugin/lgxpay/lgdacom/XPayClient4DB.php
Expand Up @@ -141,7 +141,7 @@ function json_decode($content, $assoc=false){
$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);
Expand Down

0 comments on commit 953e301

Please sign in to comment.