201 lines
7.0 KiB
PHP
201 lines
7.0 KiB
PHP
<?php include_once('header02.php');
|
|
checkAdmin();
|
|
// SQL query to fetch data
|
|
$sql = "SELECT ip_address, user_id, page_url, referrer_url, visit_time, country FROM visitor_logs WHERE NOT (ip_address = '185.203.122.69' OR ip_address = '156.155.29.213') ORDER BY visit_time DESC";
|
|
|
|
$result = $conn->query($sql);
|
|
?>
|
|
<style>
|
|
table {
|
|
width: 100%;
|
|
border-collapse: separate;
|
|
border-spacing: 0;
|
|
margin: 10px 0;
|
|
}
|
|
|
|
thead th {
|
|
cursor: pointer;
|
|
text-align: left;
|
|
padding: 10px;
|
|
font-weight: bold;
|
|
position: relative;
|
|
}
|
|
|
|
thead th::after {
|
|
content: '\25B2';
|
|
/* Up arrow */
|
|
font-size: 0.8em;
|
|
position: absolute;
|
|
right: 10px;
|
|
opacity: 0;
|
|
transition: opacity 0.2s;
|
|
}
|
|
|
|
thead th.asc::after {
|
|
content: '\25B2';
|
|
/* Up arrow */
|
|
opacity: 1;
|
|
}
|
|
|
|
thead th.desc::after {
|
|
content: '\25BC';
|
|
/* Down arrow */
|
|
opacity: 1;
|
|
}
|
|
|
|
tbody tr:nth-child(odd) {
|
|
background-color: transparent;
|
|
}
|
|
|
|
tbody tr:nth-child(even) {
|
|
background-color: rgb(255, 255, 255);
|
|
border-radius: 10px;
|
|
}
|
|
|
|
tbody td {
|
|
padding: 5px;
|
|
}
|
|
|
|
tbody tr:nth-child(even) td:first-child {
|
|
border-top-left-radius: 10px;
|
|
border-bottom-left-radius: 10px;
|
|
}
|
|
|
|
tbody tr:nth-child(even) td:last-child {
|
|
border-top-right-radius: 10px;
|
|
border-bottom-right-radius: 10px;
|
|
}
|
|
|
|
.filter-input {
|
|
width: 100%;
|
|
padding: 5px;
|
|
/* margin-bottom: 20px; */
|
|
font-size: 16px;
|
|
background-color: rgb(255, 255, 255);
|
|
border-radius: 25px;
|
|
}
|
|
|
|
.infobox {
|
|
color: #484848;
|
|
background: #f9f9f7;
|
|
border: 1px solid #d8d8d8;
|
|
border-radius: 10px;
|
|
margin-top: 15px;
|
|
margin-bottom: 15px;
|
|
}
|
|
</style>
|
|
<script>
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
const table = document.querySelector("table");
|
|
const headers = table.querySelectorAll("thead th");
|
|
const rows = Array.from(table.querySelectorAll("tbody tr"));
|
|
const filterInput = document.getElementById("filterInput");
|
|
|
|
headers.forEach((header, index) => {
|
|
header.addEventListener("click", () => {
|
|
const sortedRows = rows.sort((a, b) => {
|
|
const aText = a.cells[index].textContent.trim().toLowerCase();
|
|
const bText = b.cells[index].textContent.trim().toLowerCase();
|
|
|
|
if (aText < bText) return -1;
|
|
if (aText > bText) return 1;
|
|
return 0;
|
|
});
|
|
|
|
if (header.classList.contains("asc")) {
|
|
header.classList.remove("asc");
|
|
header.classList.add("desc");
|
|
sortedRows.reverse();
|
|
} else {
|
|
headers.forEach(h => h.classList.remove("asc", "desc"));
|
|
header.classList.add("asc");
|
|
}
|
|
|
|
const tbody = table.querySelector("tbody");
|
|
tbody.innerHTML = "";
|
|
sortedRows.forEach(row => tbody.appendChild(row));
|
|
});
|
|
});
|
|
|
|
filterInput.addEventListener("input", function() {
|
|
const filterValue = filterInput.value.trim().toLowerCase();
|
|
rows.forEach(row => {
|
|
const rowText = row.textContent.trim().toLowerCase();
|
|
row.style.display = rowText.includes(filterValue) ? "" : "none";
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
<!-- Page Banner Start -->
|
|
<?php
|
|
$bannerFolder = 'assets/images/banners/';
|
|
$bannerImages = glob($bannerFolder . '*.{jpg,jpeg,png,webp}', GLOB_BRACE);
|
|
|
|
$randomBanner = 'assets/images/base4/camping.jpg'; // default fallback
|
|
if (!empty($bannerImages)) {
|
|
$randomBanner = $bannerImages[array_rand($bannerImages)];
|
|
}
|
|
?>
|
|
<section class="page-banner-area pt-50 pb-35 rel z-1 bgs-cover" style="background-image: url('<?php echo $randomBanner; ?>');">
|
|
<div class="banner-overlay"></div>
|
|
<div class="container">
|
|
<div class="banner-inner text-white mb-50">
|
|
<h2 class="page-title mb-10" data-aos="fade-left" data-aos-duration="1500" data-aos-offset="50">4WDCSA Visitor Logs</h2>
|
|
<nav aria-label="breadcrumb">
|
|
<ol class="breadcrumb justify-content-center mb-20" data-aos="fade-right" data-aos-delay="200" data-aos-duration="1500" data-aos-offset="50">
|
|
<li class="breadcrumb-item"><a href="index.php">Home</a></li>
|
|
<li class="breadcrumb-item active">4WDCSA Visitor Logs</li>
|
|
</ol>
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<!-- Tour List Area start -->
|
|
<section class="tour-list-page py-10 rel z-1">
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="col-lg-12">
|
|
<div class='infobox' data-aos='fade-up' data-aos-duration='1500' data-aos-offset='50'>
|
|
<div style='padding:10px;'>
|
|
<input type="text" id="filterInput" class="filter-input" placeholder="Filter results...">
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Country</th>
|
|
<th>IP Address</th>
|
|
<th>User ID</th>
|
|
<th>Page URL</th>
|
|
<th>Referrer</th>
|
|
<th>Timestamp</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
if ($result->num_rows > 0) {
|
|
while ($row = $result->fetch_assoc()) {
|
|
echo "<tr>
|
|
<td>" . ($row['country']) . "</td>
|
|
<td>" . htmlspecialchars($row['ip_address']) . "</td>
|
|
<td>" . ($row['user_id'] !== null ? htmlspecialchars(getFullName($row['user_id'])) : '-') . "</td>
|
|
<td>" . htmlspecialchars($row['page_url']) . "</td>
|
|
<td>" . ($row['referrer_url'] ? htmlspecialchars($row['referrer_url']) : '-') . "</td>
|
|
<td>" . htmlspecialchars($row['visit_time']) . "</td>
|
|
</tr>";
|
|
}
|
|
} else {
|
|
echo '<tr><td colspan="5">No logs found</td></tr>';
|
|
}
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
<!-- Tour List Area end -->
|
|
|
|
|
|
<?php include_once("insta_footer.php"); ?>
|