초기 커밋: 5130 레거시 시스템
- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경 - DB 연결 하드코딩 → .env 기반으로 변경 - MySQL strict mode DATE 오류 수정
This commit is contained in:
38
insert_logmenu.php
Normal file
38
insert_logmenu.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
header("Content-Type: application/json");
|
||||
|
||||
$menu = isset($_REQUEST['menu']) ? $_REQUEST['menu'] : '';
|
||||
|
||||
$tablename = 'logdata_menu';
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
try {
|
||||
// log 기록
|
||||
$data = date("Y-m-d H:i:s") . " - " . $menu . " - " . $_SESSION["name"];
|
||||
$pdo->beginTransaction();
|
||||
$sql = "INSERT INTO {$DB}.logdata_menu(data) VALUES(?)";
|
||||
$stmh = $pdo->prepare($sql);
|
||||
$stmh->bindValue(1, $data, PDO::PARAM_STR);
|
||||
$stmh->execute();
|
||||
$pdo->commit();
|
||||
|
||||
$response = ['status' => 'success', 'message' => 'Log recorded successfully'];
|
||||
echo json_encode($response, JSON_UNESCAPED_UNICODE);
|
||||
|
||||
} catch (PDOException $Exception) {
|
||||
error_log("오류: " . $Exception->getMessage());
|
||||
http_response_code(500);
|
||||
echo json_encode(['error' => $Exception->getMessage()]);
|
||||
} catch (Exception $e) {
|
||||
error_log("오류: " . $e->getMessage());
|
||||
http_response_code(500);
|
||||
echo json_encode(['error' => $e->getMessage()]);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user