File manager - Edit - /var/www/order.cmtc.ac.th/template_user_header.php
Back
<?php // -------------------------- // ระบบนับจำนวนผู้ใช้ออนไลน์ (Lightweight) // -------------------------- $session_id = session_id(); $user_ip = $_SERVER['REMOTE_ADDR']; $time = time(); $timeout = $time - 300; // 5 นาที // เพิ่มหรืออัปเดตเวลาเข้าใช้งาน $conn->query("REPLACE INTO user_online (session_id, ip_address, last_activity) VALUES ('$session_id', '$user_ip', $time)"); // ลบ session ที่หมดเวลาแล้ว $conn->query("DELETE FROM user_online WHERE last_activity < $timeout"); // ดึงจำนวนผู้ใช้ออนไลน์ทั้งหมด $res = $conn->query("SELECT COUNT(*) AS total FROM user_online"); $row = $res->fetch_assoc(); $online_users = $row['total']; // -------------------------- ?> <!DOCTYPE html> <html lang="th"> <head> <meta charset="UTF-8"> <title><?=$system_name?> <?=$school_name?></title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700&display=swap" rel="stylesheet"> <link href="https://cdn.jsdelivr.net/npm/lightbox2@2.11.4/dist/css/lightbox.min.css" rel="stylesheet"> <style> body { font-family: 'Kanit', sans-serif; background-color: #faf7f2; } .navbar { background: linear-gradient(45deg, #44000E, #44000E); } .navbar-brand { font-weight: 600; color: #fff !important; font-size: 1.2rem; } footer { background-color: #44000E; color: #f5f5f5; text-align: center; padding: 20px 10px; margin-top: 50px; } .btn-gold { background: linear-gradient(45deg, #c9a23f, #ffca28); color: #000; font-weight: 600; border: none; } .btn-gold:hover { background: linear-gradient(45deg, #ffca28, #d4af37); } /* ✅ ผู้ใช้งานออนไลน์ */ .online-counter { color: #ffeb3b; font-size: 0.9rem; font-weight: 500; margin-right: 10px; } </style> </head> <body> <!-- 🔶 Navbar --> <nav class="navbar navbar-expand-lg navbar-dark shadow-sm"> <div class="container"> <a class="navbar-brand" href="#"> <?=$system_name?></a> <div class="ms-auto d-flex align-items-center gap-3"> <span class="online-counter">👥 ออนไลน์: <?=$online_users?> คน</span> <a href="user/index.php" class="btn btn-warning btn-sm"> 🛒 ตะกร้า <?php if($cart_count > 0): ?><span class="badge-cart"><?=$cart_count?></span><?php endif; ?> </a> <a href="?" class="btn btn-outline-primary btn-sm">หน้าหลัก</a> <a href="user/check_status.php" class="btn btn-outline-light btn-sm">ตรวจสอบสถานะ</a> <a href="admin/index.php" class="btn btn-outline-warning btn-sm">เข้าสู่ระบบผู้ดูแล</a> </div> </div> </nav> <div class="container py-4">
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.39 |
proxy
|
phpinfo
|
Settings