97 lines
2.3 KiB
PHP
97 lines
2.3 KiB
PHP
<?php
|
|
|
|
$conn = db_connect();
|
|
|
|
// Dev-IPs
|
|
$devips = (new getSpecificData())->getWhitelistedIPs();
|
|
$devips_sql = "'" . implode("','", $devips) . "'";
|
|
|
|
// Filter & Custom Query
|
|
$customQuery = $_POST['custom_query'] ?? '';
|
|
$sql = '';
|
|
$useCustom = false;
|
|
|
|
// Custom Query Schutz
|
|
if ($customQuery) {
|
|
$forbidden = ['DELETE', 'UPDATE', 'INSERT', 'DROP', 'ALTER', 'TRUNCATE'];
|
|
$upper = strtoupper($customQuery);
|
|
|
|
foreach ($forbidden as $bad) {
|
|
if (strpos($upper, $bad) !== false) {
|
|
echo "<b style='color:red'>Gefährliche Query blockiert ($bad)</b>";
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (stripos(trim($customQuery), "SELECT") !== 0) {
|
|
echo "<b style='color:red'>Nur SELECT erlaubt</b>";
|
|
return;
|
|
}
|
|
|
|
$sql = $customQuery;
|
|
$useCustom = true;
|
|
}
|
|
|
|
// Standard Query (falls kein Custom Query)
|
|
if (!$useCustom) {
|
|
// Einfache Standard-Query für Logs ohne Dev-IPs
|
|
$sql = "
|
|
SELECT WEBSITE, REQUEST_URL, FIRST_REQUEST, COUNTER
|
|
FROM logs
|
|
WHERE CLIENT_IP = '" . (new getSpecificData())->getClientIP() . "'
|
|
ORDER BY FIRST_REQUEST DESC
|
|
";
|
|
}
|
|
|
|
if (isset($_POST['delete_logs'])) {
|
|
DatabaseDelete(
|
|
"logs",
|
|
"CLIENT_IP = ?",
|
|
(new getSpecificData())->getClientIP()
|
|
);
|
|
header("Location: " . (new getSpecificData())->getReferer());
|
|
exit;
|
|
}
|
|
|
|
?>
|
|
|
|
<h1>📊 Logs</h1>
|
|
|
|
<?php
|
|
$daten = [];
|
|
|
|
if ($erg = $conn->query($sql)) {
|
|
while ($row = $erg->fetch_object()) {
|
|
$daten[] = $row;
|
|
}
|
|
}
|
|
?>
|
|
|
|
<?php if (!$daten): ?>
|
|
<b>Keine Daten gefunden</b>
|
|
<?php else: ?>
|
|
|
|
<div style="overflow-x:auto;">
|
|
<?php if ((new getSpecificData())->getIsAdmin()): ?>
|
|
<form method="post">
|
|
<button name="delete_logs" class="btn-delete" style="margin-bottom: 10px">Lösche Logs</button>
|
|
</form>
|
|
<?php endif; ?>
|
|
<table border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse;width:100%;">
|
|
<tr>
|
|
<?php foreach ($daten[0] as $key => $_): ?>
|
|
<th><?= htmlspecialchars($key) ?></th>
|
|
<?php endforeach; ?>
|
|
</tr>
|
|
|
|
<?php foreach ($daten as $row): ?>
|
|
<tr>
|
|
<?php foreach ($row as $val): ?>
|
|
<td><?= htmlspecialchars($val ?? '') ?></td>
|
|
<?php endforeach; ?>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</table>
|
|
</div>
|
|
|
|
<?php endif; ?>
|