summaryrefslogtreecommitdiffstats
path: root/admin/database.php
diff options
context:
space:
mode:
Diffstat (limited to 'admin/database.php')
-rw-r--r--admin/database.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/admin/database.php b/admin/database.php
new file mode 100644
index 0000000..47ffd29
--- /dev/null
+++ b/admin/database.php
@@ -0,0 +1,49 @@
+<?php
+#===============================================================================
+# DEFINE: Administration
+#===============================================================================
+define('ADMINISTRATION', TRUE);
+define('AUTHENTICATION', TRUE);
+
+#===============================================================================
+# INCLUDE: Main configuration
+#===============================================================================
+require_once '../core/application.php';
+
+#===============================================================================
+# Execute database command(s)
+#===============================================================================
+if(HTTP::issetPOST(['token' => Application::getSecurityToken()], 'command')) {
+ try {
+ $Statement = $Database->query(HTTP::POST('command'));
+ $result = print_r($Statement->fetchAll(), TRUE);
+ } catch(PDOException $Exception) {
+ $messages[] = $Exception->getMessage();
+ }
+}
+
+#===============================================================================
+# TRY: Template\Exception
+#===============================================================================
+try {
+ $DatabaseTemplate = Template\Factory::build('database');
+ $DatabaseTemplate->set('FORM', [
+ 'INFO' => $messages ?? [],
+ 'TOKEN' => Application::getSecurityToken(),
+ 'RESULT' => $result ?? NULL,
+ 'COMMAND' => HTTP::POST('command'),
+ ]);
+
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('NAME', 'SQL');
+ $MainTemplate->set('HTML', $DatabaseTemplate);
+ echo $MainTemplate;
+}
+
+#===============================================================================
+# CATCH: Template\Exception
+#===============================================================================
+catch(Template\Exception $Exception) {
+ $Exception->defaultHandler();
+}
+?> \ No newline at end of file