<?php
function DateThai($strDate) {
$strYear = date("Y", strtotime($strDate)) + 543;
$strMonth = date("n", strtotime($strDate));
$strDay = date("j", strtotime($strDate));
$strMonthCut = array("", "ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค.");
$strMonthThai = $strMonthCut[$strMonth];
return "$strDay $strMonthThai $strYear";
}
// ป้องกันการแก้ไขค่า GET ใน URL (ตรวจว่าเป็นตัวเลขเท่านั้นสำหรับ ID)
function secure_id($id) {
if (!isset($id) || !is_numeric($id)) {
header("Location: dashboard.php?error=invalid_access");
exit();
}
return (int)$id;
}
?>