| Server IP : 172.67.187.206 / Your IP : 172.71.28.155 Web Server : Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30 System : Windows NT WIN-ECQAAA40806 6.2 build 9200 (Windows Server 2012 Standard Edition) i586 User : SYSTEM ( 0) PHP Version : 5.6.30 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Inetpub/www/education/ |
Upload File : |
<?php
// การเชื่อมต่อฐานข้อมูล
$servername = "localhost";
$username = "root";
$password = "P@ssw0rdMySQL0";
$dbname = "study_claude";
// สร้างการเชื่อมต่อ
$conn = mysqli_connect($servername, $username, $password, $dbname);
// ตรวจสอบการเชื่อมต่อ
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
// กำหนด charset
mysqli_set_charset($conn, "utf8");
// ฟังก์ชันเข้ารหัส URL
function encode_url($data) {
return base64_encode($data);
}
// ฟังก์ชันถอดรหัส URL
function decode_url($data) {
return base64_decode($data);
}
// ฟังก์ชันป้องกัน SQL Injection
function secure_input($data) {
global $conn;
return mysqli_real_escape_string($conn, trim($data));
}
// เริ่ม session
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
// ฟังก์ชันตรวจสอบการล็อกอิน
function check_login() {
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
exit();
}
}
// ฟังก์ชันตรวจสอบสิทธิ์ admin
function check_admin() {
if (!isset($_SESSION['user_type']) || $_SESSION['user_type'] != 'admin') {
header("Location: dashboard.php");
exit();
}
}
// ฟังก์ชันดึงปีการศึกษาปัจจุบัน
function get_current_academic_year() {
$current_month = date('n');
$current_year = date('Y');
if ($current_month >= 5) {
return ($current_year + 543);
} else {
return ($current_year + 542) . "/" . ($current_year + 543);
}
}
?>