summaryrefslogtreecommitdiffstats
path: root/admin/index.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/index.php
downloadblog-52b077a48c743ba4d08ac00520a0bf1ef6deef5f.tar.gz
blog-52b077a48c743ba4d08ac00520a0bf1ef6deef5f.tar.xz
blog-52b077a48c743ba4d08ac00520a0bf1ef6deef5f.zip
Initial commit.v1.0
Diffstat (limited to 'admin/index.php')
-rw-r--r--admin/index.php88
1 files changed, 88 insertions, 0 deletions
diff --git a/admin/index.php b/admin/index.php
new file mode 100644
index 0000000..c2ef0e0
--- /dev/null
+++ b/admin/index.php
@@ -0,0 +1,88 @@
+<?php
+#===============================================================================
+# DEFINE: Administration
+#===============================================================================
+define('ADMINISTRATION', TRUE);
+define('AUTHENTICATION', TRUE);
+
+#===============================================================================
+# INCLUDE: Main configuration
+#===============================================================================
+require_once '../core/application.php';
+
+#===============================================================================
+# TRY: PDOException
+#===============================================================================
+try {
+ $LastPageStatement = $Database->query(sprintf('SELECT id FROM %s ORDER BY time_insert DESC LIMIT 1', Page\Attribute::TABLE));
+ $LastPostStatement = $Database->query(sprintf('SELECT id FROM %s ORDER BY time_insert DESC LIMIT 1', Post\Attribute::TABLE));
+ $LastUserStatement = $Database->query(sprintf('SELECT id FROM %s ORDER BY time_insert DESC LIMIT 1', User\Attribute::TABLE));
+
+ $PageCountStatement = $Database->query(sprintf('SELECT COUNT(*) FROM %s', Page\Attribute::TABLE));
+ $PostCountStatement = $Database->query(sprintf('SELECT COUNT(*) FROM %s', Post\Attribute::TABLE));
+ $UserCountStatement = $Database->query(sprintf('SELECT COUNT(*) FROM %s', User\Attribute::TABLE));
+}
+
+#===============================================================================
+# CATCH: PDOException
+#===============================================================================
+catch(PDOException $Exception) {
+ exit($Exception->getMessage());
+}
+
+#===============================================================================
+# TRY: Template\Exception
+#===============================================================================
+try {
+ try {
+ $LastPage = Page\Factory::build($LastPageStatement->fetchColumn());
+ $LastPageUser = User\Factory::build($LastPage->attr('user'));
+
+ $PageItemTemplate = generatePageItemTemplate($LastPage, $LastPageUser);
+ }
+
+ catch(Page\Exception $Exception){}
+ catch(User\Exception $Exception){}
+
+ try {
+ $LastPost = Post\Factory::build($LastPostStatement->fetchColumn());
+ $LastPostUser = User\Factory::build($LastPost->attr('user'));
+
+ $PostItemTemplate = generatePostItemTemplate($LastPost, $LastPostUser);
+ }
+
+ catch(Post\Exception $Exception){}
+ catch(User\Exception $Exception){}
+
+ try {
+ $LastUser = User\Factory::build($LastUserStatement->fetchColumn());
+ $UserItemTemplate = generateUserItemTemplate($LastUser);
+ } catch(User\Exception $Exception){}
+
+ $HomeTemplate = Template\Factory::build('home');
+ $HomeTemplate->set('LAST', [
+ 'PAGE' => $PageItemTemplate ?? FALSE,
+ 'POST' => $PostItemTemplate ?? FALSE,
+ 'USER' => $UserItemTemplate ?? FALSE,
+
+ ]);
+
+ $HomeTemplate->set('COUNT', [
+ 'PAGE' => $PageCountStatement->fetchColumn(),
+ 'POST' => $PostCountStatement->fetchColumn(),
+ 'USER' => $UserCountStatement->fetchColumn(),
+ ]);
+
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('NAME', 'Dashboard');
+ $MainTemplate->set('HTML', $HomeTemplate);
+ echo $MainTemplate;
+}
+
+#===============================================================================
+# CATCH: Template\Exception
+#===============================================================================
+catch(Template\Exception $Exception) {
+ $Exception->defaultHandler();
+}
+?> \ No newline at end of file