File manager - Edit - /home/webapp69.cm.in.th/u69319090041/Shop41/public/vendor_pending.php
Back
<?php /** * vendor_pending.php * หน้าแสดงสถานะสำหรับ vendor ที่ยังรอการอนุมัติจาก Admin */ session_start(); ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); // แก้ไข path ให้ถูกต้อง ถอยกลับ 1 โฟลเดอร์จาก public/ ไปยัง root/ require_once __DIR__ . '/../config/config.php'; require_once __DIR__ . '/../includes/auth.php'; // Safe Fallback Function สำหรับ htmlspecialchars if (!function_exists('safe_sanitize')) { function safe_sanitize($string) { if (function_exists('sanitize')) { return sanitize($string); } return htmlspecialchars((string)$string, ENT_QUOTES, 'UTF-8'); } } requireLogin(); // ถ้าไม่ใช่ vendor redirect กลับ if (!isVendor()) { header('Location: ' . (defined('SITE_URL') ? SITE_URL : '') . '/index.php'); exit; } $info = []; $dbError = ''; try { // ดึงสถานะล่าสุดจาก DB (ปรับเป็นตัวพิมพ์เล็กทั้งหมดเพื่อรองรับ Linux) $pdo = getDBConnection(); $stmt = $pdo->prepare(" select v.status, v.store_name, va.admin_note, va.reviewed_at from vendors v left join vendor_applications va on va.user_id = v.user_id where v.user_id = ? order by va.created_at desc limit 1 "); $stmt->execute([$_SESSION['user']['id'] ?? 0]); $result = $stmt->fetch(); if ($result) { $info = $result; } } catch (PDOException $e) { $dbError = 'Database Error: ' . $e->getMessage(); } catch (Exception $e) { $dbError = 'System Error: ' . $e->getMessage(); } // ตรวจสอบข้อมูลแบบปลอดภัยด้วย ?? ป้องกัน Undefined Index $status = $info['status'] ?? 'pending'; $storeName = $info['store_name'] ?? 'ร้านค้าของคุณ'; $adminNote = $info['admin_note'] ?? null; if ($status === 'approved') { // ถ้าได้รับการอนุมัติแล้ว ส่งไป dashboard header('Location: ' . (defined('SITE_URL') ? dirname(SITE_URL) : '') . '/vendor_panel/index.php'); exit; } $pageTitle = 'สถานะการสมัครร้านค้า'; ?> <!DOCTYPE html> <html lang="th"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title><?php echo safe_sanitize($pageTitle); ?> - <?php echo defined('SITE_NAME') ? safe_sanitize(SITE_NAME) : 'Shop'; ?></title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"> <style> body { background: #f8f9fa; } .pending-card { max-width: 520px; margin: 80px auto; border-radius: 20px; box-shadow: 0 8px 40px rgba(0,0,0,.10); overflow: hidden; } .status-badge-pending { background: #fff3cd; color: #856404; } .status-badge-rejected { background: #f8d7da; color: #842029; } .icon-big { font-size: 4rem; line-height: 1; } </style> </head> <body> <div class="container"> <?php if (!empty($dbError)): ?> <div class="alert alert-danger mt-5 shadow-sm rounded-3"> <strong>⚠️ ระบบขัดข้องชั่วคราว:</strong> ขออภัยในความไม่สะดวก ไม่สามารถตรวจสอบสถานะได้ในขณะนี้<br> <small class="text-muted"><?php echo safe_sanitize($dbError); ?></small> </div> <?php endif; ?> <div class="pending-card bg-white"> <div class="text-center p-5"> <?php if ($status === 'pending'): ?> <div class="icon-big mb-3">⏳</div> <h2 class="fw-bold">รอการอนุมัติ</h2> <p class="text-muted mt-2">ร้านค้า <strong><?php echo safe_sanitize($storeName); ?></strong> ของคุณกำลังอยู่ระหว่างการตรวจสอบจาก Admin</p> <span class="badge status-badge-pending px-3 py-2 rounded-pill fs-6">🕐 Pending Review</span> <hr class="my-4"> <p class="text-muted small">โดยปกติจะใช้เวลาไม่เกิน <strong>1-2 วันทำการ</strong><br>เมื่ออนุมัติแล้ว คุณจะได้รับอีเมลแจ้งเตือน</p> <?php elseif ($status === 'rejected'): ?> <div class="icon-big mb-3">❌</div> <h2 class="fw-bold text-danger">คำขอถูกปฏิเสธ</h2> <p class="text-muted mt-2">ร้านค้า <strong><?php echo safe_sanitize($storeName); ?></strong> ไม่ผ่านการตรวจสอบ</p> <span class="badge status-badge-rejected px-3 py-2 rounded-pill fs-6">❌ Rejected</span> <?php if (!empty($adminNote)): ?> <div class="alert alert-danger mt-4 text-start"> <strong>เหตุผล:</strong> <?php echo safe_sanitize($adminNote); ?> </div> <?php endif; ?> <hr class="my-4"> <a href="<?php echo defined('SITE_URL') ? safe_sanitize(SITE_URL) : ''; ?>/apply_vendor.php" class="btn btn-primary rounded-pill px-4"> 📝 สมัครใหม่อีกครั้ง </a> <?php else: ?> <!-- For fallback if status is something else unexpectedly --> <div class="icon-big mb-3">❓</div> <h2 class="fw-bold text-warning">สถานะไม่ทราบแน่ชัด</h2> <p class="text-muted mt-2">กรุณาติดต่อผู้ดูแลระบบ</p> <?php endif; ?> <div class="mt-3"> <a href="<?php echo defined('SITE_URL') ? safe_sanitize(SITE_URL) : ''; ?>/index.php" class="btn btn-outline-secondary btn-sm rounded-pill px-3"> 🏠 กลับหน้าหลัก </a> <a href="<?php echo defined('SITE_URL') ? safe_sanitize(SITE_URL) : ''; ?>/login.php?action=logout" class="btn btn-outline-danger btn-sm rounded-pill px-3 ms-2"> 🚪 ออกจากระบบ </a> </div> </div> </div> </div> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.3 |
proxy
|
phpinfo
|
Settings