Initial commit

This commit is contained in:
Porawit Dongwang
2026-09-16 23:20:08 +07:00
commit 0041668dbb
32577 changed files with 3687927 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
<?php
// db.php
require_once __DIR__ . '/config.php';
try {
$pdo = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME . ";charset=utf8mb4", DB_USER, DB_PASS);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
} catch (PDOException $e) {
// สำหรับการตั้งค่าเริ่มต้น ถ้ายังไม่มี DB
// die("Database connection failed: " . $e->getMessage());
$pdo = null;
}
function logActivity($pdo, $action, $details) {
if (!$pdo) return;
$stmt = $pdo->prepare("INSERT INTO activity_logs (action_type, action_details) VALUES (?, ?)");
$stmt->execute([$action, $details]);
}
function getSetting($pdo, $key) {
if (!$pdo) return '';
$stmt = $pdo->prepare("SELECT setting_value FROM settings WHERE setting_key = ?");
$stmt->execute([$key]);
return $stmt->fetchColumn();
}