| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?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";
- if (!is_readable(SERVER_LOGS)) {
- echo "Le fichier n'est pas accessible en lecture.";
- exit();
- }
- $lines = file(SERVER_LOGS);
- $search = strtolower($_GET['search'] ?? '');
- if ($search) {
- $lines = array_filter($lines, fn($line) => stripos($line, $search) !== false);
- }
- function printLog(string $_log){
- if (stripos($_log, 'error') !== false) {
- echo '<div class="error">' . $_log . '</div>';
- } elseif (stripos($_log, 'warn') !== false) {
- echo '<div class="warning">' . $_log . '</div>';
- } elseif (stripos($_log, 'notice') !== false) {
- echo '<div class="notice">' . $_log . '</div>';
- }
- }
- ?>
- <!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="search">Filtrer par mot-clé :</label>
- <input type="text" name="search" value="<?= htmlspecialchars($search) ?>">
- <button type="submit">Filtrer</button>
- </form>
- <hr>
- <pre>
- <?php foreach (array_slice($lines, -50) as $line) {
- if(stripos($line, DOCUMENT_ROOT) !== false){
- printLog($line);
- } elseif(stripos($line, DOMAIN_CMS) !== false){
- printLog($line);
- } elseif(stripos($line, "/var/www/") === false AND stripos($line, "https://") === false){
- printLog($line);
- }
- } ?>
- </pre>
- </body>
- </html>
|