Files
dnssash/adm/order_manage/notification_log.php
2026-06-11 18:47:38 +09:00

81 lines
2.8 KiB
PHP

<?php
$sub_menu = "800700"; // 새로운 메뉴 코드
include_once('./_common.php');
auth_check($auth[$sub_menu], 'r');
$g5['title'] = '알림 로그 관리';
$log_file = G5_PATH . '/log/notification_debug.log';
$action = isset($_POST['action']) ? clean_xss_tags($_POST['action']) : '';
// 로그 파일 비우기 처리
if ($action === 'clear_log' && $_SERVER['REQUEST_METHOD'] === 'POST') {
auth_check($auth[$sub_menu], 'w');
if (file_exists($log_file)) {
// 파일을 0바이트로 만듭니다.
file_put_contents($log_file, '');
alert('알림 로그 파일의 내용을 모두 비웠습니다.', './notification_log.php');
} else {
alert('로그 파일이 존재하지 않습니다.', './notification_log.php');
}
exit;
}
// 로그 파일 내용 읽기
$log_content = '';
if (file_exists($log_file) && filesize($log_file) > 0) {
// 파일을 라인별로 배열로 읽어옵니다.
$lines = file($log_file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
// 배열을 뒤집어 최신 로그가 위로 오게 합니다.
$reversed_lines = array_reverse($lines);
// 다시 문자열로 합칩니다.
$log_content = implode("\n", $reversed_lines);
}
include_once(G5_ADMIN_PATH . '/admin.head.php');
?>
<div class="local_desc01 local_desc">
<p>
시스템에서 발송된 메일 및 SMS의 발송 기록(로그)을 확인합니다.<br>
로그 파일은 <code>/log/notification_debug.log</code> 에 저장되며, 최신 기록이 가장 위에 표시됩니다.
</p>
</div>
<div class="local_ov01 local_ov">
<form name="fclearlog" method="post" action="./notification_log.php" onsubmit="return confirm('정말로 로그 파일의 모든 내용을 삭제하시겠습니까?\n이 작업은 되돌릴 수 없습니다.');">
<input type="hidden" name="action" value="clear_log">
<input type="submit" value="로그 비우기" class="btn btn_02">
</form>
</div>
<section id="sod_fin">
<h2 class="h2_frm">로그 내용</h2>
<div class="tbl_frm01 tbl_wrap">
<textarea id="log_view" readonly style="width: 100%; height: 600px; padding: 10px; border: 1px solid #ccc; background: #f9f9f9; font-family: monospace; font-size: 12px; line-height: 1.5; resize: vertical;"><?php echo htmlspecialchars($log_content); ?></textarea>
</div>
</section>
<?php if (empty($log_content)): ?>
<div class="local_desc02 local_desc">
<p>
로그 파일이 없거나 내용이 비어있습니다.
p>
</div>
<?php endif; ?>
<script>
document.addEventListener('DOMContentLoaded', function() {
const textarea = document.getElementById('log_view');
if (textarea) {
// 페이지 로드 시 스크롤을 맨 위로 이동
textarea.scrollTop = 0;
}
});
</script>
<?php
include_once(G5_ADMIN_PATH . '/admin.tail.php');
?>