|
|
@@ -0,0 +1,81 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+session_start();
|
|
|
+
|
|
|
+require_once "../env.inc.php";
|
|
|
+require_once "../access.inc.php";
|
|
|
+require_once "../conf.inc.php";
|
|
|
+
|
|
|
+require_once DIR_PHP_LAYOUTS . "header.php";
|
|
|
+require_once DIR_PHP_LAYOUTS . "cms.session.php";
|
|
|
+
|
|
|
+$logDir = SERVER_LOGS;
|
|
|
+$selectedLog = $_GET['log'] ?? '';
|
|
|
+$search = strtolower($_GET['search'] ?? '');
|
|
|
+$files = array_filter(scandir($logDir), fn($f) => is_file($logDir . $f));
|
|
|
+
|
|
|
+if (!$selectedLog && !empty($files)) {
|
|
|
+ $selectedLog = reset($files);
|
|
|
+}
|
|
|
+
|
|
|
+$logPath = $logDir . $selectedLog;
|
|
|
+$logLines = [];
|
|
|
+
|
|
|
+if (is_file($logPath) && is_readable($logPath)) {
|
|
|
+ $lines = array_slice(file($logPath), -200);
|
|
|
+ if ($search) {
|
|
|
+ $lines = array_filter($lines, fn($line) => stripos($line, $search) !== false);
|
|
|
+ }
|
|
|
+
|
|
|
+ $logLines = array_map('htmlspecialchars', array_map('trim', $lines));
|
|
|
+}
|
|
|
+?>
|
|
|
+
|
|
|
+<!DOCTYPE html>
|
|
|
+<html lang="fr">
|
|
|
+<head>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <title>Visualiseur de logs</title>
|
|
|
+ <style>
|
|
|
+ body { font-family: monospace; background: #f4f4f4; padding: 20px; }
|
|
|
+ .error { color: red; }
|
|
|
+ .warning { color: orange; }
|
|
|
+ .notice { color: blue; }
|
|
|
+ pre { background: #fff; padding: 10px; border: 1px solid #ccc; overflow-x: auto; }
|
|
|
+ </style>
|
|
|
+ <script>
|
|
|
+
|
|
|
+ setInterval(() => {
|
|
|
+ location.reload();
|
|
|
+ }, 5000);
|
|
|
+ </script>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+ <form method="get">
|
|
|
+ <label for="log">Fichier de log :</label>
|
|
|
+ <select name="log" onchange="this.form.submit()">
|
|
|
+ <?php foreach ($files as $file): ?>
|
|
|
+ <option value="<?= $file ?>" <?= $file === $selectedLog ? 'selected' : '' ?>><?= $file ?></option>
|
|
|
+ <?php endforeach; ?>
|
|
|
+ </select>
|
|
|
+ <br><br>
|
|
|
+ <label for="search">Filtrer par mot-clé :</label>
|
|
|
+ <input type="text" name="search" value="<?= htmlspecialchars($search) ?>">
|
|
|
+ <button type="submit">Filtrer</button>
|
|
|
+ </form>
|
|
|
+ <hr>
|
|
|
+ <pre>
|
|
|
+<?php foreach ($logLines as $line) {
|
|
|
+ if (stripos($line, 'error') !== false) {
|
|
|
+ echo '<div class="error">' . $line . '</div>';
|
|
|
+ } elseif (stripos($line, 'warn') !== false) {
|
|
|
+ echo '<div class="warning">' . $line . '</div>';
|
|
|
+ } elseif (stripos($line, 'notice') !== false) {
|
|
|
+ echo '<div class="notice">' . $line . '</div>';
|
|
|
+ } else {
|
|
|
+ echo '<div>' . $line . '</div>';
|
|
|
+ }
|
|
|
+} ?>
|
|
|
+ </pre>
|
|
|
+</body>
|
|
|
+</html>
|