diff options
| author | winter | 2025-05-11 20:25:11 +0100 |
|---|---|---|
| committer | winter | 2025-05-11 20:25:11 +0100 |
| commit | 07d1f1236c11b4261ab2b954a91278711a24901c (patch) | |
| tree | dc52072e468ec6a5980cbe6894459e8623441025 /routes/admin.php | |
| parent | 5d7a4605bd0bd71949a37139eccfbf8a70d0c32e (diff) | |
sql console in admin menu + other misc
Diffstat (limited to 'routes/admin.php')
| -rw-r--r-- | routes/admin.php | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/routes/admin.php b/routes/admin.php index 82981c9..20c6ee5 100644 --- a/routes/admin.php +++ b/routes/admin.php @@ -1,5 +1,6 @@ <?php +use Digitigrade\Db; use Digitigrade\GlobalSettings; use Digitigrade\HttpResponseStatus\NotFound; use Digitigrade\HttpResponseStatus\TemporaryRedirect; @@ -58,4 +59,25 @@ Router::getInstance()->mount('/fragment/admin/plugins/download', function (array $success = true; } render_template('admin/plugin_download_form', ['success' => $success]); +}); + +Router::getInstance()->mount('/admin/sql-console', function (array $args) { + UserAccount::requireByCurrentSession()->requireAdmin(); + render_template('admin/sql_console_page'); +}); + +Router::getInstance()->mount('/fragment/admin/sql-console/query', function (array $args) { + UserAccount::requireByCurrentSession()->requireAdmin(); + $results = null; + $error = null; + if (isset($_POST['query'])) { + try { + $pdo = Db::getInstance()->getPdo(); + $query = $pdo->query($_POST['query'], PDO::FETCH_ASSOC); + $results = $query->fetchAll(); + } catch (\PDOException $e) { + $error = $e; + } + } + render_template('admin/sql_console_form', ['results' => $results, 'error' => $error]); });
\ No newline at end of file |
