console.logs.apache.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. session_start();
  3. require_once "../env.inc.php";
  4. require_once "../access.inc.php";
  5. require_once "../conf.inc.php";
  6. require_once DIR_PHP_LAYOUTS . "header.php";
  7. require_once DIR_PHP_LAYOUTS . "cms.session.php";
  8. if (!is_readable(SERVER_LOGS)) {
  9. echo "Le fichier n'est pas accessible en lecture.";
  10. exit();
  11. }
  12. $lines = file(SERVER_LOGS);
  13. $search = strtolower($_GET['search'] ?? '');
  14. $limit = strtolower($_GET['limit'] ?? 50); // A défaut les 50 derniers logs
  15. if ($search) {
  16. $lines = array_filter($lines, fn($line) => stripos($line, $search) !== false);
  17. }
  18. $lines = array_reverse($lines);
  19. ?>
  20. <!DOCTYPE html>
  21. <html lang="fr">
  22. <head>
  23. <meta charset="UTF-8">
  24. <style>
  25. body { font-family: monospace; background: black !important; padding: 20px; }
  26. div { font-size: 0.8em; }
  27. .error { color: salmon; }
  28. .warning { color: orange; }
  29. .notice { color: white; }
  30. .grey { color: grey; }
  31. pre { background: #fff; padding: 10px; border: 1px solid #ccc; overflow-x: auto; }
  32. </style>
  33. <link rel="stylesheet" href="<?php cache::printFileWithTime("libs/bootstrap/assets/dist/css/bootstrap.min.css") ?>">
  34. <script src="<?php cache::printFileWithTime("libs/bootstrap/js/bootstrap.min.js") ?>"></script>
  35. </head>
  36. <body>
  37. <?php
  38. foreach (array_slice($lines, 0, $limit) as $line) {
  39. serverLog::filtreLog($line);
  40. }
  41. ?>
  42. </body>
  43. </html>