diff options
author | Thomas Lange <code@nerdmind.de> | 2017-02-24 21:27:59 +0100 |
---|---|---|
committer | Thomas Lange <code@nerdmind.de> | 2017-02-24 21:27:59 +0100 |
commit | 52b077a48c743ba4d08ac00520a0bf1ef6deef5f (patch) | |
tree | b4205c194167e0e03e273957cdd0aab3be9fdf01 /admin/index.php | |
download | blog-6442789bf36c04639bf5f104ea963937717a39b5.tar.gz blog-6442789bf36c04639bf5f104ea963937717a39b5.tar.xz blog-6442789bf36c04639bf5f104ea963937717a39b5.zip |
Initial commit.v1.0
Diffstat (limited to 'admin/index.php')
-rw-r--r-- | admin/index.php | 88 |
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 |