62 lines
2.5 KiB
PHP
62 lines
2.5 KiB
PHP
<?php
|
|
if (!defined('_GNUBOARD_')) exit;
|
|
|
|
class SendLogManager {
|
|
protected $table = 'g5_mail_send_log';
|
|
|
|
public function getTotalCount() {
|
|
$row = sql_fetch("SELECT COUNT(*) as cnt FROM {$this->table}");
|
|
return $row['cnt'] ?? 0;
|
|
}
|
|
|
|
/**
|
|
* [추가] 페이징된 로그 목록을 가져옵니다.
|
|
* @param int $from_record 시작 레코드
|
|
* @param int $page_rows 페이지당 레코드 수
|
|
* @return array
|
|
*/
|
|
public function getPagedList($from_record, $page_rows) {
|
|
$from_record = (int)$from_record;
|
|
$page_rows = (int)$page_rows;
|
|
|
|
$sql = "SELECT * FROM {$this->table} ORDER BY id DESC LIMIT {$from_record}, {$page_rows}";
|
|
$result = sql_query($sql);
|
|
$list = [];
|
|
while($row = sql_fetch_array($result)) {
|
|
$list[] = $row;
|
|
}
|
|
return $list;
|
|
}
|
|
|
|
public function getById($id) {
|
|
$id = (int)$id;
|
|
return sql_fetch("SELECT * FROM {$this->table} WHERE id = '{$id}'");
|
|
}
|
|
|
|
// C:/project/other/saungjin/adm/mail_manage/classes/SendLogManager.php 파일
|
|
|
|
public function addLog($data) {
|
|
global $member;
|
|
|
|
// 넘어온 데이터를 안전하게 처리
|
|
$to_email = sql_real_escape_string($data['to_email']);
|
|
$cc_email = isset($data['cc_email']) ? sql_real_escape_string($data['cc_email']) : '';
|
|
$bcc_email = isset($data['bcc_email']) ? sql_real_escape_string($data['bcc_email']) : '';
|
|
$subject = sql_real_escape_string($data['subject']);
|
|
$body = sql_real_escape_string($data['body']);
|
|
$status = in_array($data['status'], ['success', 'fail']) ? $data['status'] : 'fail';
|
|
$error_msg = isset($data['error_msg']) ? sql_real_escape_string($data['error_msg']) : '';
|
|
$send_time = G5_TIME_YMDHIS;
|
|
$resend_of = isset($data['resend_of']) ? (int)$data['resend_of'] : 'NULL';
|
|
$created_by = $member['mb_id'] ?? 'guest'; // 로그인한 사용자 또는 guest
|
|
|
|
// [수정] install.php의 테이블 구조와 일치하도록 쿼리 수정
|
|
$sql = "INSERT INTO {$this->table}
|
|
(to_email, cc_email,bcc_email, subject, body, status, send_time, created_by, created_at, error_msg, resend_of)
|
|
VALUES
|
|
('{$to_email}', '{$cc_email}', '{$bcc_email}' ,'{$subject}', '{$body}', '{$status}', '{$send_time}', '{$created_by}', '{$send_time}', '{$error_msg}', {$resend_of})";
|
|
|
|
sql_query($sql);
|
|
}
|
|
}
|