403Webshell
Server IP : 104.21.80.248  /  Your IP : 172.71.28.156
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/pr/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /Inetpub/www/pr//user_add.php
<?php
include 'functions.php';
check_login('user');

if(isset($_POST['save_req'])) {
    $type = mysqli_real_escape_string($conn, $_POST['req_type']);
    $cat_id = intval($_POST['cat_id']); // รับค่าประเภทข่าว
    $title = mysqli_real_escape_string($conn, $_POST['title']);
    $details = mysqli_real_escape_string($conn, $_POST['details']);
    $start_date = $_POST['start_date'];
    $end_date = $_POST['end_date'];
    $user_id = $_SESSION['user_id'];
    $created = date('Y-m-d H:i:s');

    // บันทึกข้อมูลหลัก
    $sql = "INSERT INTO requests (user_id, req_type, cat_id, title, details, start_date, end_date, status, created_at) 
            VALUES ('$user_id', '$type', '$cat_id', '$title', '$details', '$start_date', '$end_date', 'pending', '$created')";
    
    if(mysqli_query($conn, $sql)) {
        $req_id = mysqli_insert_id($conn);
        // อัปโหลดรูปภาพ
        if(isset($_FILES['imgs'])) {
            $total_files = count($_FILES['imgs']['name']);
            for($i=0; $i<$total_files; $i++) {
                if($_FILES['imgs']['name'][$i] != "") {
                    $tmp_name = $_FILES['imgs']['tmp_name'][$i];
                    $ext = pathinfo($_FILES['imgs']['name'][$i], PATHINFO_EXTENSION);
                    $new_name = time() . "_$i." . $ext;
                    if(!is_dir('uploads')) mkdir('uploads');
                    move_uploaded_file($tmp_name, "uploads/" . $new_name);
                    mysqli_query($conn, "INSERT INTO request_images (req_id, filename) VALUES ('$req_id', '$new_name')");
                }
            }
        }
        echo "<script>alert('บันทึกข้อมูลเรียบร้อย'); window.location='dashboard.php';</script>";
    } else { echo "<script>alert('Error: " . mysqli_error($conn) . "');</script>"; }
}

echo get_header("เพิ่มความต้องการขึ้นจอโทรทัศน์");
?>

<div class="row justify-content-center">
    <div class="col-md-8">
        <div class="card p-4 shadow-sm border-0 border-top border-primary border-4">
            <h4 class="mb-4 text-primary"><i class="bi bi-tv"></i> แจ้งความต้องการขึ้นจอโทรทัศน์</h4>
            
            <div class="mb-4 text-center">
                <div class="btn-group w-100" role="group">
                    <input type="radio" class="btn-check" name="req_type_ui" id="btn_ready" value="ready" checked onchange="setType('ready')">
                    <label class="btn btn-outline-success" for="btn_ready">มีรูปประชาสัมพันธ์มาแล้ว</label>
                    <input type="radio" class="btn-check" name="req_type_ui" id="btn_design" value="design" onchange="setType('design')">
                    <label class="btn btn-outline-warning" for="btn_design">ต้องการให้แอดมินจัดทำรูป</label>
                </div>
            </div>

            <form method="post" enctype="multipart/form-data">
                <input type="hidden" name="req_type" id="req_type" value="ready">
                
                <div class="mb-3">
                    <label class="form-label fw-bold">ประเภทข่าว <span class="text-danger">*</span></label>
                    <select name="cat_id" class="form-select" required>
                        <option value="">-- กรุณาเลือกประเภทข่าว --</option>
                        <?php
                        $cat_res = mysqli_query($conn, "SELECT * FROM news_categories ORDER BY cat_id ASC");
                        while($c = mysqli_fetch_assoc($cat_res)){
                            echo "<option value='".$c['cat_id']."'>".$c['cat_name']."</option>";
                        }
                        ?>
                    </select>
                </div>

                <div class="mb-3">
                    <label class="form-label fw-bold">หัวข้อประชาสัมพันธ์ <span class="text-danger">*</span></label>
                    <input type="text" name="title" class="form-control" required>
                </div>

                <div class="mb-3" id="div_details" style="display:none;">
                    <label class="form-label fw-bold">รายละเอียดที่ต้องการลง/ข้อความในภาพ <span class="text-danger">*</span></label>
                    <textarea name="details" class="form-control" rows="4"></textarea>
                </div>

                <div class="mb-4">
                    <label class="form-label fw-bold" id="label_img">เลือกรูปประชาสัมพันธ์ (เลือกได้หลายรูป) <span class="text-danger">*</span></label>
                    <input type="file" name="imgs[]" class="form-control" multiple accept="image/*" required>
                </div>

                <div class="row bg-light p-3 rounded mb-4 mx-0">
                    <div class="col-md-6 mb-2">
                        <label class="form-label fw-bold">วันที่เริ่มแสดงผล <span class="text-danger">*</span></label>
                        <input type="date" name="start_date" class="form-control" required>
                    </div>
                    <div class="col-md-6 mb-2">
                        <label class="form-label fw-bold">ถึงวันที่ <span class="text-danger">*</span></label>
                        <input type="date" name="end_date" class="form-control" required>
                    </div>
                </div>

                <button type="submit" name="save_req" class="btn btn-primary btn-lg w-100"><i class="bi bi-save"></i> บันทึกข้อมูล</button>
            </form>
        </div>
    </div>
</div>

<script>
function setType(type) {
    document.getElementById('req_type').value = type;
    if(type == 'ready') {
        document.getElementById('div_details').style.display = 'none';
        document.getElementById('label_img').innerText = 'เลือกรูปประชาสัมพันธ์ (เลือกได้หลายรูป) *';
    } else {
        document.getElementById('div_details').style.display = 'block';
        document.getElementById('label_img').innerText = 'เลือกรูปอ้างอิง/โลโก้/รูปประกอบ (ถ้ามี) *';
    }
}
</script>

<?php echo get_footer(); ?>

Youez - 2016 - github.com/yon3zu
LinuXploit