summaryrefslogtreecommitdiffstats
path: root/admin/database.php
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2017-02-24 21:27:59 +0100
committerThomas Lange <code@nerdmind.de>2017-02-24 21:27:59 +0100
commit52b077a48c743ba4d08ac00520a0bf1ef6deef5f (patch)
treeb4205c194167e0e03e273957cdd0aab3be9fdf01 /admin/database.php
downloadblog-1.0.tar.gz
blog-1.0.tar.xz
blog-1.0.zip
Initial commit.v1.0
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