postgres.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?
  2. ini_set('display_errors', 1);
  3. error_reporting(E_ALL);
  4. ?>
  5. <!DOCTYPE html>
  6. <html lang="en">
  7. <head>
  8. <meta charset="UTF-8">
  9. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  10. <title>Archivos de log Postgres</title>
  11. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"
  12. integrity="sha512-iecdLmaskl7CVkqkXNQ/ZH/XLlvWZOJyj7Yy7tcenmpD1ypASozpmT/E0iPtmFIB46ZmdtAc9eNBvH0H/ZpiBw=="
  13. crossorigin="anonymous" referrerpolicy="no-referrer" />
  14. <?php
  15. $ruta = "../";
  16. include '../import/html_css_files.php';
  17. include '../import/html_header.php';
  18. html_header(
  19. "Archivos de log Postgres",
  20. "Archivos de log Postgres",
  21. );
  22. ?>
  23. </head>
  24. <body>
  25. <main class="content marco">
  26. <form method="POST" class="mb-3">
  27. <label for="logDay">Select a day:</label>
  28. <select name="logDay" id="logDay" class="form-control">
  29. <option value="Mon">Monday</option>
  30. <option value="Tue">Tuesday</option>
  31. <option value="Wed">Wednesday</option>
  32. <option value="Thu">Thursday</option>
  33. <option value="Fri">Friday</option>
  34. <option value="Sat">Saturday</option>
  35. <option value="Sun">Sunday</option>
  36. </select>
  37. <button type="submit" class="btn btn-primary mt-2">View Log</button>
  38. </form>
  39. <?php
  40. $password = 'admin';
  41. echo "Output: <pre>" . shell_exec("sh ../pgsql-log/get-logs.sh 2>&1") . "</pre>";
  42. if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['logDay'])) {
  43. $fileName = "../pgsql-log/postgresql-{$_POST['logDay']}.log";
  44. echo "<h3>Log file for {$_POST['logDay']}:</h3>";
  45. echo "<p>File path: $fileName</p>";
  46. // execute a command in the shell: sudo sh get-logs.sh
  47. if (file_exists($fileName)) {
  48. $fileContents = file_get_contents($fileName);
  49. echo "<pre>" . htmlspecialchars($fileContents) . "</pre>";
  50. } else {
  51. echo "Log file for " . $_POST['logDay'] . " does not exist.";
  52. }
  53. }
  54. ?>
  55. </main>
  56. <?php
  57. include "../import/html_footer.php";
  58. ?>
  59. <script src="<?= $ruta ?? '' ?>js/jquery.min.js"></script>
  60. <script src="<?= $ruta ?? '' ?>js/bootstrap/bootstrap.min.js"></script>
  61. </body>
  62. </html>