Print database tables in tables-not-found error page

This commit is contained in:
ruan 2023-03-13 19:30:28 +02:00
parent 785c58121f
commit ca8a5b2b59

View File

@ -12,7 +12,7 @@
<div class="jumbotron"> <div class="jumbotron">
<h2>Tables Not Found</h2><br> <h2>Tables Not Found</h2><br>
<div class="text-warning"> <div class="text-warning">
The web interface has connected to the database, but could not find any tables generated by LiteBans. The web interface has connected to the database, but could not find the tables generated by LiteBans.
<br> <br>
This means that the plugin has not successfully connected to this database before with the same This means that the plugin has not successfully connected to this database before with the same
configuration. configuration.
@ -29,6 +29,7 @@
<a class="text-danger">"driver: H2"</a> with <a class="text-info">"driver: MySQL"</a>) <a class="text-danger">"driver: H2"</a> with <a class="text-info">"driver: MySQL"</a>)
<?php <?php
require_once '../inc/settings.php'; require_once '../inc/settings.php';
require_once '../inc/database.php';
$settings = new Settings(false); $settings = new Settings(false);
$host = $settings->host; $host = $settings->host;
if ($host === "localhost" || $host === "127.0.0.1" || $host === "0.0.0.0") { if ($host === "localhost" || $host === "127.0.0.1" || $host === "0.0.0.0") {
@ -40,6 +41,26 @@
<br> <br>
- Ensure that you are using the latest version of LiteBans. - Ensure that you are using the latest version of LiteBans.
<br> <br>
<?php
echo("<br>Database tables:");
$db = new Database($settings, true, true);
try {
$st = $db->conn->query("SELECT * FROM " . $settings->table['bans'] . " LIMIT 1;");
$st->fetch();
$st->closeCursor();
} catch (PDOException $e) {
$st = $db->conn->query("SHOW TABLES;");
$st->execute();
$rows = $st->fetchAll(PDO::FETCH_ASSOC);
foreach ($rows as $row) {
foreach ($row as $k => $v) {
echo("<br> - $v");
}
}
$st->closeCursor();
}
?>
</div> </div>
<br> <br>
<a href="../" class="btn btn-default">Try Again</a> <a href="../" class="btn btn-default">Try Again</a>