aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2021-06-17 22:00:39 +0200
committerThomas Lange <code@nerdmind.de>2021-06-17 22:00:39 +0200
commit5555624546ea48d6327700f32b80848e0662dc90 (patch)
tree47d61fb756a6cb008aaf33586d292fcfe43da2a1 /admin
parent91d8a28c664afa5378735bcd0efe068dd74d589f (diff)
parent0a2614cb69fc732c2115ef2f0c356f39f602d311 (diff)
downloadblog-optimization.tar.gz
blog-optimization.tar.xz
blog-optimization.zip
Merge branch 'master' into 'optimization'optimization
Diffstat (limited to 'admin')
-rw-r--r--admin/auth.php38
-rw-r--r--admin/database.php36
-rw-r--r--admin/index.php109
-rw-r--r--admin/page/delete.php44
-rw-r--r--admin/page/index.php72
-rw-r--r--admin/page/insert.php60
-rw-r--r--admin/page/search.php26
-rw-r--r--admin/page/update.php60
-rw-r--r--admin/post/delete.php44
-rw-r--r--admin/post/index.php72
-rw-r--r--admin/post/insert.php60
-rw-r--r--admin/post/search.php26
-rw-r--r--admin/post/update.php60
-rw-r--r--admin/user/delete.php44
-rw-r--r--admin/user/index.php68
-rw-r--r--admin/user/insert.php44
-rw-r--r--admin/user/update.php45
17 files changed, 363 insertions, 545 deletions
diff --git a/admin/auth.php b/admin/auth.php
index e2e1b57..8c6d5a6 100644
--- a/admin/auth.php
+++ b/admin/auth.php
@@ -50,29 +50,19 @@ if(HTTP::issetPOST(['token' => Application::getSecurityToken()], 'username', 'pa
}
#===============================================================================
-# TRY: Template\Exception
+# Build document
#===============================================================================
-try {
- $AuthTemplate = Template\Factory::build('auth');
- $AuthTemplate->set('FORM', [
- 'INFO' => $messages ?? [],
- 'DATA' => [
- 'USERNAME' => HTTP::POST('username'),
- 'PASSWORD' => HTTP::POST('password'),
- ],
- 'TOKEN' => Application::getSecurityToken()
- ]);
+$AuthTemplate = Template\Factory::build('auth');
+$AuthTemplate->set('FORM', [
+ 'INFO' => $messages ?? [],
+ 'DATA' => [
+ 'USERNAME' => HTTP::POST('username'),
+ 'PASSWORD' => HTTP::POST('password'),
+ ],
+ 'TOKEN' => Application::getSecurityToken()
+]);
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', 'Authentication');
- $MainTemplate->set('HTML', $AuthTemplate);
- echo $MainTemplate;
-}
-
-#===============================================================================
-# CATCH: Template\Exception
-#===============================================================================
-catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
-}
-?> \ No newline at end of file
+$MainTemplate = Template\Factory::build('main');
+$MainTemplate->set('NAME', 'Authentication');
+$MainTemplate->set('HTML', $AuthTemplate);
+echo $MainTemplate;
diff --git a/admin/database.php b/admin/database.php
index d37e158..78d47c1 100644
--- a/admin/database.php
+++ b/admin/database.php
@@ -26,27 +26,17 @@ if(HTTP::issetPOST(['token' => Application::getSecurityToken()], 'command')) {
}
#===============================================================================
-# TRY: Template\Exception
-#===============================================================================
-try {
- $DatabaseTemplate = Template\Factory::build('database');
- $DatabaseTemplate->set('FORM', [
- 'INFO' => $messages ?? [],
- 'TOKEN' => Application::getSecurityToken(),
- 'RESULT' => implode(NULL, $result ?? []),
- 'COMMAND' => HTTP::POST('command'),
- ]);
+# Build document
+#===============================================================================
+$DatabaseTemplate = Template\Factory::build('database');
+$DatabaseTemplate->set('FORM', [
+ 'INFO' => $messages ?? [],
+ 'TOKEN' => Application::getSecurityToken(),
+ 'RESULT' => implode(NULL, $result ?? []),
+ '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) {
- Application::exit($Exception->getMessage());
-}
-?> \ No newline at end of file
+$MainTemplate = Template\Factory::build('main');
+$MainTemplate->set('NAME', 'SQL');
+$MainTemplate->set('HTML', $DatabaseTemplate);
+echo $MainTemplate;
diff --git a/admin/index.php b/admin/index.php
index 1f8d9f6..788cee4 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -11,82 +11,61 @@ define('AUTHENTICATION', TRUE);
require '../core/application.php';
#===============================================================================
-# TRY: PDOException
+# Fetch last items and item count
#===============================================================================
-try {
- $execute = 'SELECT id FROM %s ORDER BY time_insert DESC LIMIT 1';
+$execute = 'SELECT id FROM %s ORDER BY time_insert DESC LIMIT 1';
+$LastPageStatement = $Database->query(sprintf($execute, Page\Attribute::TABLE));
+$LastPostStatement = $Database->query(sprintf($execute, Post\Attribute::TABLE));
+$LastUserStatement = $Database->query(sprintf($execute, User\Attribute::TABLE));
- $LastPageStatement = $Database->query(sprintf($execute, Page\Attribute::TABLE));
- $LastPostStatement = $Database->query(sprintf($execute, Post\Attribute::TABLE));
- $LastUserStatement = $Database->query(sprintf($execute, User\Attribute::TABLE));
+$execute = 'SELECT COUNT(*) FROM %s';
+$PageCountStatement = $Database->query(sprintf($execute, Page\Attribute::TABLE));
+$PostCountStatement = $Database->query(sprintf($execute, Post\Attribute::TABLE));
+$UserCountStatement = $Database->query(sprintf($execute, User\Attribute::TABLE));
- $execute = 'SELECT COUNT(*) FROM %s';
+try {
+ $LastPage = Page\Factory::build($LastPageStatement->fetchColumn());
+ $LastPageUser = User\Factory::build($LastPage->attr('user'));
- $PageCountStatement = $Database->query(sprintf($execute, Page\Attribute::TABLE));
- $PostCountStatement = $Database->query(sprintf($execute, Post\Attribute::TABLE));
- $UserCountStatement = $Database->query(sprintf($execute, User\Attribute::TABLE));
+ $PageItemTemplate = generatePageItemTemplate($LastPage, $LastPageUser);
}
-#===============================================================================
-# CATCH: PDOException
-#===============================================================================
-catch(PDOException $Exception) {
- exit($Exception->getMessage());
-}
+catch(Page\Exception $Exception){}
+catch(User\Exception $Exception){}
-#===============================================================================
-# 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){}
+ $LastPost = Post\Factory::build($LastPostStatement->fetchColumn());
+ $LastPostUser = User\Factory::build($LastPost->attr('user'));
- 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,
-
- ]);
+ $PostItemTemplate = generatePostItemTemplate($LastPost, $LastPostUser);
+}
- $HomeTemplate->set('COUNT', [
- 'PAGE' => $PageCountStatement->fetchColumn(),
- 'POST' => $PostCountStatement->fetchColumn(),
- 'USER' => $UserCountStatement->fetchColumn(),
- ]);
+catch(Post\Exception $Exception){}
+catch(User\Exception $Exception){}
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', 'Dashboard');
- $MainTemplate->set('HTML', $HomeTemplate);
- echo $MainTemplate;
-}
+try {
+ $LastUser = User\Factory::build($LastUserStatement->fetchColumn());
+ $UserItemTemplate = generateUserItemTemplate($LastUser);
+} catch(User\Exception $Exception){}
#===============================================================================
-# CATCH: Template\Exception
+# Build document
#===============================================================================
-catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
-}
-?> \ No newline at end of file
+$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;
diff --git a/admin/page/delete.php b/admin/page/delete.php
index d23089c..1406ece 100644
--- a/admin/page/delete.php
+++ b/admin/page/delete.php
@@ -28,33 +28,24 @@ try {
}
#===============================================================================
- # TRY: Template\Exception
+ # Build document
#===============================================================================
- try {
- $FormTemplate = Template\Factory::build('page/form');
- $FormTemplate->set('HTML', $Page->getHTML());
- $FormTemplate->set('FORM', [
- 'TYPE' => 'DELETE',
- 'INFO' => $messages ?? [],
- 'DATA' => array_change_key_case($Attribute->getAll(), CASE_UPPER),
- 'TOKEN' => Application::getSecurityToken()
- ]);
-
- $DeleteTemplate = Template\Factory::build('page/delete');
- $DeleteTemplate->set('HTML', $FormTemplate);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_page_delete'));
- $MainTemplate->set('HTML', $DeleteTemplate);
- echo $MainTemplate;
- }
-
- #===============================================================================
- # CATCH: Template\Exception
- #===============================================================================
- catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
- }
+ $FormTemplate = Template\Factory::build('page/form');
+ $FormTemplate->set('HTML', $Page->getHTML());
+ $FormTemplate->set('FORM', [
+ 'TYPE' => 'DELETE',
+ 'INFO' => $messages ?? [],
+ 'DATA' => array_change_key_case($Attribute->getAll(), CASE_UPPER),
+ 'TOKEN' => Application::getSecurityToken()
+ ]);
+
+ $DeleteTemplate = Template\Factory::build('page/delete');
+ $DeleteTemplate->set('HTML', $FormTemplate);
+
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('NAME', $Language->text('title_page_delete'));
+ $MainTemplate->set('HTML', $DeleteTemplate);
+ echo $MainTemplate;
}
#===============================================================================
@@ -63,4 +54,3 @@ try {
catch(Page\Exception $Exception) {
Application::error404();
}
-?> \ No newline at end of file
diff --git a/admin/page/index.php b/admin/page/index.php
index caff257..82ac05f 100644
--- a/admin/page/index.php
+++ b/admin/page/index.php
@@ -13,8 +13,8 @@ require '../../core/application.php';
#===============================================================================
# Pagination
#===============================================================================
-$site_size = Application::get('PAGE.LIST_SIZE');
-$site_sort = Application::get('PAGE.LIST_SORT');
+$site_size = Application::get('ADMIN.PAGE.LIST_SIZE');
+$site_sort = Application::get('ADMIN.PAGE.LIST_SORT');
$lastSite = ceil($Database->query(sprintf('SELECT COUNT(id) FROM %s', Page\Attribute::TABLE))->fetchColumn() / $site_size);
@@ -31,49 +31,39 @@ if($currentSite < 1 OR ($currentSite > $lastSite AND $lastSite > 0)) {
$execSQL = "SELECT * FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_size}";
$Statement = $Database->query(sprintf($execSQL, Page\Attribute::TABLE));
-#===============================================================================
-# TRY: Template\Exception
-#===============================================================================
-try {
- while($Attribute = $Statement->fetchObject('Page\Attribute')) {
- try {
- $Page = Page\Factory::buildByAttribute($Attribute);
- $User = User\Factory::build($Page->attr('user'));
+while($Attribute = $Statement->fetchObject('Page\Attribute')) {
+ try {
+ $Page = Page\Factory::buildByAttribute($Attribute);
+ $User = User\Factory::build($Page->attr('user'));
- $ItemTemplate = generatePageItemTemplate($Page, $User);
+ $ItemTemplate = generatePageItemTemplate($Page, $User);
- $pages[] = $ItemTemplate;
- }
- catch(Page\Exception $Exception){}
- catch(User\Exception $Exception){}
+ $pages[] = $ItemTemplate;
}
-
- $PaginationTemplate = Template\Factory::build('pagination');
- $PaginationTemplate->set('THIS', $currentSite);
- $PaginationTemplate->set('LAST', $lastSite);
- $PaginationTemplate->set('HREF', Application::getAdminURL('page/?site=%d'));
-
- $ListTemplate = Template\Factory::build('page/index');
- $ListTemplate->set('LIST', [
- 'PAGES' => $pages ?? []
- ]);
-
- $ListTemplate->set('PAGINATION', [
- 'THIS' => $currentSite,
- 'LAST' => $lastSite,
- 'HTML' => $PaginationTemplate
- ]);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_page_overview', $currentSite));
- $MainTemplate->set('HTML', $ListTemplate);
- echo $MainTemplate;
+ catch(Page\Exception $Exception){}
+ catch(User\Exception $Exception){}
}
#===============================================================================
-# CATCH: Template\Exception
+# Build document
#===============================================================================
-catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
-}
-?> \ No newline at end of file
+$PaginationTemplate = Template\Factory::build('pagination');
+$PaginationTemplate->set('THIS', $currentSite);
+$PaginationTemplate->set('LAST', $lastSite);
+$PaginationTemplate->set('HREF', Application::getAdminURL('page/?site=%d'));
+
+$ListTemplate = Template\Factory::build('page/index');
+$ListTemplate->set('LIST', [
+ 'PAGES' => $pages ?? []
+]);
+
+$ListTemplate->set('PAGINATION', [
+ 'THIS' => $currentSite,
+ 'LAST' => $lastSite,
+ 'HTML' => $PaginationTemplate
+]);
+
+$MainTemplate = Template\Factory::build('main');
+$MainTemplate->set('NAME', $Language->text('title_page_overview', $currentSite));
+$MainTemplate->set('HTML', $ListTemplate);
+echo $MainTemplate;
diff --git a/admin/page/insert.php b/admin/page/insert.php
index d95a33d..ec903e7 100644
--- a/admin/page/insert.php
+++ b/admin/page/insert.php
@@ -37,43 +37,33 @@ if(HTTP::issetPOST('id', 'user', 'slug', 'name', 'body', 'argv', 'time_insert',
}
}
-#===============================================================================
-# TRY: Template\Exception
-#===============================================================================
-try {
- $userIDs = $Database->query(sprintf('SELECT id FROM %s ORDER BY fullname ASC', User\Attribute::TABLE));
-
- foreach($userIDs->fetchAll($Database::FETCH_COLUMN) as $userID) {
- $User = User\Factory::build($userID);
- $userAttributes[] = [
- 'ID' => $User->attr('id'),
- 'FULLNAME' => $User->attr('fullname'),
- 'USERNAME' => $User->attr('username'),
- ];
- }
-
- $FormTemplate = Template\Factory::build('page/form');
- $FormTemplate->set('FORM', [
- 'TYPE' => 'INSERT',
- 'INFO' => $messages ?? [],
- 'DATA' => array_change_key_case($Attribute->getAll(), CASE_UPPER),
- 'USER_LIST' => $userAttributes ?? [],
- 'TOKEN' => Application::getSecurityToken()
- ]);
+$userIDs = $Database->query(sprintf('SELECT id FROM %s ORDER BY fullname ASC', User\Attribute::TABLE));
- $InsertTemplate = Template\Factory::build('page/insert');
- $InsertTemplate->set('HTML', $FormTemplate);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_page_insert'));
- $MainTemplate->set('HTML', $InsertTemplate);
- echo $MainTemplate;
+foreach($userIDs->fetchAll($Database::FETCH_COLUMN) as $userID) {
+ $User = User\Factory::build($userID);
+ $userAttributes[] = [
+ 'ID' => $User->attr('id'),
+ 'FULLNAME' => $User->attr('fullname'),
+ 'USERNAME' => $User->attr('username'),
+ ];
}
#===============================================================================
-# CATCH: Template\Exception
+# Build document
#===============================================================================
-catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
-}
-?> \ No newline at end of file
+$FormTemplate = Template\Factory::build('page/form');
+$FormTemplate->set('FORM', [
+ 'TYPE' => 'INSERT',
+ 'INFO' => $messages ?? [],
+ 'DATA' => array_change_key_case($Attribute->getAll(), CASE_UPPER),
+ 'USER_LIST' => $userAttributes ?? [],
+ 'TOKEN' => Application::getSecurityToken()
+]);
+
+$InsertTemplate = Template\Factory::build('page/insert');
+$InsertTemplate->set('HTML', $FormTemplate);
+
+$MainTemplate = Template\Factory::build('main');
+$MainTemplate->set('NAME', $Language->text('title_page_insert'));
+$MainTemplate->set('HTML', $InsertTemplate);
+echo $MainTemplate;
diff --git a/admin/page/search.php b/admin/page/search.php
index 0506a0d..9f68b69 100644
--- a/admin/page/search.php
+++ b/admin/page/search.php
@@ -27,24 +27,14 @@ if($search = HTTP::GET('q')) {
}
#===============================================================================
-# TRY: Template\Exception
+# Build document
#===============================================================================
-try {
- $SearchTemplate = Template\Factory::build('page/search');
- $SearchTemplate->set('QUERY', $search);
- $SearchTemplate->set('PAGES', $pages ?? []);
+$SearchTemplate = Template\Factory::build('page/search');
+$SearchTemplate->set('QUERY', $search);
+$SearchTemplate->set('PAGES', $pages ?? []);
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_page_search'));
- $MainTemplate->set('HTML', $SearchTemplate);
+$MainTemplate = Template\Factory::build('main');
+$MainTemplate->set('NAME', $Language->text('title_page_search'));
+$MainTemplate->set('HTML', $SearchTemplate);
- echo $MainTemplate;
-}
-
-#===============================================================================
-# CATCH: Template\Exception
-#===============================================================================
-catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
-}
-?> \ No newline at end of file
+echo $MainTemplate;
diff --git a/admin/page/update.php b/admin/page/update.php
index f0bef1e..ba34a86 100644
--- a/admin/page/update.php
+++ b/admin/page/update.php
@@ -39,45 +39,36 @@ try {
}
}
- #===============================================================================
- # TRY: Template\Exception
- #===============================================================================
- try {
- $userIDs = $Database->query(sprintf('SELECT id FROM %s ORDER BY fullname ASC', User\Attribute::TABLE));
-
- foreach($userIDs->fetchAll($Database::FETCH_COLUMN) as $userID) {
- $User = User\Factory::build($userID);
- $userAttributes[] = [
- 'ID' => $User->attr('id'),
- 'FULLNAME' => $User->attr('fullname'),
- 'USERNAME' => $User->attr('username'),
- ];
- }
-
- $FormTemplate = Template\Factory::build('page/form');
- $FormTemplate->set('FORM', [
- 'TYPE' => 'UPDATE',
- 'INFO' => $messages ?? [],
- 'DATA' => array_change_key_case($Attribute->getAll(), CASE_UPPER),
- 'USER_LIST' => $userAttributes ?? [],
- 'TOKEN' => Application::getSecurityToken()
- ]);
+ $userIDs = $Database->query(sprintf('SELECT id FROM %s ORDER BY fullname ASC', User\Attribute::TABLE));
- $PageUpdateTemplate = Template\Factory::build('page/update');
- $PageUpdateTemplate->set('HTML', $FormTemplate);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_page_update'));
- $MainTemplate->set('HTML', $PageUpdateTemplate);
- echo $MainTemplate;
+ foreach($userIDs->fetchAll($Database::FETCH_COLUMN) as $userID) {
+ $User = User\Factory::build($userID);
+ $userAttributes[] = [
+ 'ID' => $User->attr('id'),
+ 'FULLNAME' => $User->attr('fullname'),
+ 'USERNAME' => $User->attr('username'),
+ ];
}
#===============================================================================
- # CATCH: Template\Exception
+ # Build document
#===============================================================================
- catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
- }
+ $FormTemplate = Template\Factory::build('page/form');
+ $FormTemplate->set('FORM', [
+ 'TYPE' => 'UPDATE',
+ 'INFO' => $messages ?? [],
+ 'DATA' => array_change_key_case($Attribute->getAll(), CASE_UPPER),
+ 'USER_LIST' => $userAttributes ?? [],
+ 'TOKEN' => Application::getSecurityToken()
+ ]);
+
+ $PageUpdateTemplate = Template\Factory::build('page/update');
+ $PageUpdateTemplate->set('HTML', $FormTemplate);
+
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('NAME', $Language->text('title_page_update'));
+ $MainTemplate->set('HTML', $PageUpdateTemplate);
+ echo $MainTemplate;
}
#===============================================================================
@@ -86,4 +77,3 @@ try {
catch(Page\Exception $Exception) {
Application::error404();
}
-?> \ No newline at end of file
diff --git a/admin/post/delete.php b/admin/post/delete.php
index 78fdf6e..6da8a68 100644
--- a/admin/post/delete.php
+++ b/admin/post/delete.php
@@ -28,33 +28,24 @@ try {
}
#===============================================================================
- # TRY: Template\Exception
+ # Build document
#===============================================================================
- try {
- $FormTemplate = Template\Factory::build('post/form');
- $FormTemplate->set('HTML', $Post->getHTML());
- $FormTemplate->set('FORM', [
- 'TYPE' => 'DELETE',
- 'INFO' => $messages ?? [],
- 'DATA' => array_change_key_case($Attribute->getAll(), CASE_UPPER),
- 'TOKEN' => Application::getSecurityToken()
- ]);
-
- $DeleteTemplate = Template\Factory::build('post/delete');
- $DeleteTemplate->set('HTML', $FormTemplate);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_post_delete'));
- $MainTemplate->set('HTML', $DeleteTemplate);
- echo $MainTemplate;
- }
-
- #===============================================================================
- # CATCH: Template\Exception
- #===============================================================================
- catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
- }
+ $FormTemplate = Template\Factory::build('post/form');
+ $FormTemplate->set('HTML', $Post->getHTML());
+ $FormTemplate->set('FORM', [
+ 'TYPE' => 'DELETE',
+ 'INFO' => $messages ?? [],
+ 'DATA' => array_change_key_case($Attribute->getAll(), CASE_UPPER),
+ 'TOKEN' => Application::getSecurityToken()
+ ]);
+
+ $DeleteTemplate = Template\Factory::build('post/delete');
+ $DeleteTemplate->set('HTML', $FormTemplate);
+
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('NAME', $Language->text('title_post_delete'));
+ $MainTemplate->set('HTML', $DeleteTemplate);
+ echo $MainTemplate;
}
#===============================================================================
@@ -63,4 +54,3 @@ try {
catch(Post\Exception $Exception) {
Application::error404();
}
-?> \ No newline at end of file
diff --git a/admin/post/index.php b/admin/post/index.php
index 7e492ba..1269236 100644
--- a/admin/post/index.php
+++ b/admin/post/index.php
@@ -13,8 +13,8 @@ require '../../core/application.php';
#===============================================================================
# Pagination
#===============================================================================
-$site_size = Application::get('POST.LIST_SIZE');
-$site_sort = Application::get('POST.LIST_SORT');
+$site_size = Application::get('ADMIN.POST.LIST_SIZE');
+$site_sort = Application::get('ADMIN.POST.LIST_SORT');
$lastSite = ceil($Database->query(sprintf('SELECT COUNT(id) FROM %s', Post\Attribute::TABLE))->fetchColumn() / $site_size);
@@ -31,49 +31,39 @@ if($currentSite < 1 OR ($currentSite > $lastSite AND $lastSite > 0)) {
$execSQL = "SELECT * FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_size}";
$Statement = $Database->query(sprintf($execSQL, Post\Attribute::TABLE));
-#===============================================================================
-# TRY: Template\Exception
-#===============================================================================
-try {
- while($Attribute = $Statement->fetchObject('Post\Attribute')) {
- try {
- $Post = Post\Factory::buildByAttribute($Attribute);
- $User = User\Factory::build($Post->attr('user'));
+while($Attribute = $Statement->fetchObject('Post\Attribute')) {
+ try {
+ $Post = Post\Factory::buildByAttribute($Attribute);
+ $User = User\Factory::build($Post->attr('user'));
- $ItemTemplate = generatePostItemTemplate($Post, $User);
+ $ItemTemplate = generatePostItemTemplate($Post, $User);
- $posts[] = $ItemTemplate;
- }
- catch(Post\Exception $Exception){}
- catch(User\Exception $Exception){}
+ $posts[] = $ItemTemplate;
}
-
- $PaginationTemplate = Template\Factory::build('pagination');
- $PaginationTemplate->set('THIS', $currentSite);
- $PaginationTemplate->set('LAST', $lastSite);
- $PaginationTemplate->set('HREF', Application::getAdminURL('post/?site=%d'));
-
- $ListTemplate = Template\Factory::build('post/index');
- $ListTemplate->set('LIST', [
- 'POSTS' => $posts ?? []
- ]);
-
- $ListTemplate->set('PAGINATION', [
- 'THIS' => $currentSite,
- 'LAST' => $lastSite,
- 'HTML' => $PaginationTemplate
- ]);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_post_overview', $currentSite));
- $MainTemplate->set('HTML', $ListTemplate);
- echo $MainTemplate;
+ catch(Post\Exception $Exception){}
+ catch(User\Exception $Exception){}
}
#===============================================================================
-# CATCH: Template\Exception
+# Build document
#===============================================================================
-catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
-}
-?> \ No newline at end of file
+$PaginationTemplate = Template\Factory::build('pagination');
+$PaginationTemplate->set('THIS', $currentSite);
+$PaginationTemplate->set('LAST', $lastSite);
+$PaginationTemplate->set('HREF', Application::getAdminURL('post/?site=%d'));
+
+$ListTemplate = Template\Factory::build('post/index');
+$ListTemplate->set('LIST', [
+ 'POSTS' => $posts ?? []
+]);
+
+$ListTemplate->set('PAGINATION', [
+ 'THIS' => $currentSite,
+ 'LAST' => $lastSite,
+ 'HTML' => $PaginationTemplate
+]);
+
+$MainTemplate = Template\Factory::build('main');
+$MainTemplate->set('NAME', $Language->text('title_post_overview', $currentSite));
+$MainTemplate->set('HTML', $ListTemplate);
+echo $MainTemplate;
diff --git a/admin/post/insert.php b/admin/post/insert.php
index d35d527..6065c95 100644
--- a/admin/post/insert.php
+++ b/admin/post/insert.php
@@ -37,43 +37,33 @@ if(HTTP::issetPOST('id', 'user', 'slug', 'name', 'body', 'argv', 'time_insert',
}
}
-#===============================================================================
-# TRY: Template\Exception
-#===============================================================================
-try {
- $userIDs = $Database->query(sprintf('SELECT id FROM %s ORDER BY fullname ASC', User\Attribute::TABLE));
-
- foreach($userIDs->fetchAll($Database::FETCH_COLUMN) as $userID) {
- $User = User\Factory::build($userID);
- $userAttributes[] = [
- 'ID' => $User->attr('id'),
- 'FULLNAME' => $User->attr('fullname'),
- 'USERNAME' => $User->attr('username'),
- ];
- }
-
- $FormTemplate = Template\Factory::build('post/form');
- $FormTemplate->set('FORM', [
- 'TYPE' => 'INSERT',
- 'INFO' => $messages ?? [],
- 'DATA' => array_change_key_case($Attribute->getAll(), CASE_UPPER),
- 'USER_LIST' => $userAttributes ?? [],
- 'TOKEN' => Application::getSecurityToken()
- ]);
+$userIDs = $Database->query(sprintf('SELECT id FROM %s ORDER BY fullname ASC', User\Attribute::TABLE));
- $InsertTemplate = Template\Factory::build('post/insert');
- $InsertTemplate->set('HTML', $FormTemplate);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_post_insert'));
- $MainTemplate->set('HTML', $InsertTemplate);
- echo $MainTemplate;
+foreach($userIDs->fetchAll($Database::FETCH_COLUMN) as $userID) {
+ $User = User\Factory::build($userID);
+ $userAttributes[] = [
+ 'ID' => $User->attr('id'),
+ 'FULLNAME' => $User->attr('fullname'),
+ 'USERNAME' => $User->attr('username'),
+ ];
}
#===============================================================================
-# CATCH: Template\Exception
+# Build document
#===============================================================================
-catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
-}
-?> \ No newline at end of file
+$FormTemplate = Template\Factory::build('post/form');
+$FormTemplate->set('FORM', [
+ 'TYPE' => 'INSERT',
+ 'INFO' => $messages ?? [],
+ 'DATA' => array_change_key_case($Attribute->getAll(), CASE_UPPER),
+ 'USER_LIST' => $userAttributes ?? [],
+ 'TOKEN' => Application::getSecurityToken()
+]);
+
+$InsertTemplate = Template\Factory::build('post/insert');
+$InsertTemplate->set('HTML', $FormTemplate);
+
+$MainTemplate = Template\Factory::build('main');
+$MainTemplate->set('NAME', $Language->text('title_post_insert'));
+$MainTemplate->set('HTML', $InsertTemplate);
+echo $MainTemplate;
diff --git a/admin/post/search.php b/admin/post/search.php
index ac472f8..261cc06 100644
--- a/admin/post/search.php
+++ b/admin/post/search.php
@@ -27,24 +27,14 @@ if($search = HTTP::GET('q')) {
}
#===============================================================================
-# TRY: Template\Exception
+# Build document
#===============================================================================
-try {
- $SearchTemplate = Template\Factory::build('post/search');
- $SearchTemplate->set('QUERY', $search);
- $SearchTemplate->set('POSTS', $posts ?? []);
+$SearchTemplate = Template\Factory::build('post/search');
+$SearchTemplate->set('QUERY', $search);
+$SearchTemplate->set('POSTS', $posts ?? []);
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_post_search'));
- $MainTemplate->set('HTML', $SearchTemplate);
+$MainTemplate = Template\Factory::build('main');
+$MainTemplate->set('NAME', $Language->text('title_post_search'));
+$MainTemplate->set('HTML', $SearchTemplate);
- echo $MainTemplate;
-}
-
-#===============================================================================
-# CATCH: Template\Exception
-#===============================================================================
-catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
-}
-?> \ No newline at end of file
+echo $MainTemplate;
diff --git a/admin/post/update.php b/admin/post/update.php
index d2cf979..d7778f8 100644
--- a/admin/post/update.php
+++ b/admin/post/update.php
@@ -39,45 +39,36 @@ try {
}
}
- #===============================================================================
- # TRY: Template\Exception
- #===============================================================================
- try {
- $userIDs = $Database->query(sprintf('SELECT id FROM %s ORDER BY fullname ASC', User\Attribute::TABLE));
-
- foreach($userIDs->fetchAll($Database::FETCH_COLUMN) as $userID) {
- $User = User\Factory::build($userID);
- $userAttributes[] = [
- 'ID' => $User->attr('id'),
- 'FULLNAME' => $User->attr('fullname'),
- 'USERNAME' => $User->attr('username'),
- ];
- }
-
- $FormTemplate = Template\Factory::build('post/form');
- $FormTemplate->set('FORM', [
- 'TYPE' => 'UPDATE',
- 'INFO' => $messages ?? [],
- 'DATA' => array_change_key_case($Attribute->getAll(), CASE_UPPER),
- 'USER_LIST' => $userAttributes ?? [],
- 'TOKEN' => Application::getSecurityToken()
- ]);
+ $userIDs = $Database->query(sprintf('SELECT id FROM %s ORDER BY fullname ASC', User\Attribute::TABLE));
- $PostUpdateTemplate = Template\Factory::build('post/update');
- $PostUpdateTemplate->set('HTML', $FormTemplate);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_post_update'));
- $MainTemplate->set('HTML', $PostUpdateTemplate);
- echo $MainTemplate;
+ foreach($userIDs->fetchAll($Database::FETCH_COLUMN) as $userID) {
+ $User = User\Factory::build($userID);
+ $userAttributes[] = [
+ 'ID' => $User->attr('id'),
+ 'FULLNAME' => $User->attr('fullname'),
+ 'USERNAME' => $User->attr('username'),
+ ];
}
#===============================================================================
- # CATCH: Template\Exception
+ # Build document
#===============================================================================
- catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
- }
+ $FormTemplate = Template\Factory::build('post/form');
+ $FormTemplate->set('FORM', [
+ 'TYPE' => 'UPDATE',
+ 'INFO' => $messages ?? [],
+ 'DATA' => array_change_key_case($Attribute->getAll(), CASE_UPPER),
+ 'USER_LIST' => $userAttributes ?? [],
+ 'TOKEN' => Application::getSecurityToken()
+ ]);
+
+ $PostUpdateTemplate = Template\Factory::build('post/update');
+ $PostUpdateTemplate->set('HTML', $FormTemplate);
+
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('NAME', $Language->text('title_post_update'));
+ $MainTemplate->set('HTML', $PostUpdateTemplate);
+ echo $MainTemplate;
}
#===============================================================================
@@ -86,4 +77,3 @@ try {
catch(Post\Exception $Exception) {
Application::error404();
}
-?> \ No newline at end of file
diff --git a/admin/user/delete.php b/admin/user/delete.php
index 16f0d76..18a57cf 100644
--- a/admin/user/delete.php
+++ b/admin/user/delete.php
@@ -28,33 +28,24 @@ try {
}
#===============================================================================
- # TRY: Template\Exception
+ # Build document
#===============================================================================
- try {
- $FormTemplate = Template\Factory::build('user/form');
- $FormTemplate->set('HTML', $User->getHTML());
- $FormTemplate->set('FORM', [
- 'TYPE' => 'DELETE',
- 'INFO' => $messages ?? [],
- 'DATA' => array_change_key_case($Attribute->getAll(['password']), CASE_UPPER),
- 'TOKEN' => Application::getSecurityToken()
- ]);
-
- $DeleteTemplate = Template\Factory::build('user/delete');
- $DeleteTemplate->set('HTML', $FormTemplate);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_user_delete'));
- $MainTemplate->set('HTML', $DeleteTemplate);
- echo $MainTemplate;
- }
-
- #===============================================================================
- # CATCH: Template\Exception
- #===============================================================================
- catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
- }
+ $FormTemplate = Template\Factory::build('user/form');
+ $FormTemplate->set('HTML', $User->getHTML());
+ $FormTemplate->set('FORM', [
+ 'TYPE' => 'DELETE',
+ 'INFO' => $messages ?? [],
+ 'DATA' => array_change_key_case($Attribute->getAll(['password']), CASE_UPPER),
+ 'TOKEN' => Application::getSecurityToken()
+ ]);
+
+ $DeleteTemplate = Template\Factory::build('user/delete');
+ $DeleteTemplate->set('HTML', $FormTemplate);
+
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('NAME', $Language->text('title_user_delete'));
+ $MainTemplate->set('HTML', $DeleteTemplate);
+ echo $MainTemplate;
}
#===============================================================================
@@ -63,4 +54,3 @@ try {
catch(User\Exception $Exception) {
Application::error404();
}
-?> \ No newline at end of file
diff --git a/admin/user/index.php b/admin/user/index.php
index dc5a4e7..8276d91 100644
--- a/admin/user/index.php
+++ b/admin/user/index.php
@@ -13,8 +13,8 @@ require '../../core/application.php';
#===============================================================================
# Pagination
#===============================================================================
-$site_size = Application::get('POST.LIST_SIZE');
-$site_sort = Application::get('POST.LIST_SORT');
+$site_size = Application::get('ADMIN.POST.LIST_SIZE');
+$site_sort = Application::get('ADMIN.POST.LIST_SORT');
$lastSite = ceil($Database->query(sprintf('SELECT COUNT(id) FROM %s', User\Attribute::TABLE))->fetchColumn() / $site_size);
@@ -31,45 +31,35 @@ if($currentSite < 1 OR ($currentSite > $lastSite AND $lastSite > 0)) {
$execSQL = "SELECT * FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_size}";
$Statement = $Database->query(sprintf($execSQL, User\Attribute::TABLE));
-#===============================================================================
-# TRY: Template\Exception
-#===============================================================================
-try {
- while($Attribute = $Statement->fetchObject('User\Attribute')) {
- try {
- $User = User\Factory::buildByAttribute($Attribute);
- $ItemTemplate = generateUserItemTemplate($User);
-
- $users[] = $ItemTemplate;
- } catch(User\Exception $Exception){}
- }
-
- $PaginationTemplate = Template\Factory::build('pagination');
- $PaginationTemplate->set('THIS', $currentSite);
- $PaginationTemplate->set('LAST', $lastSite);
- $PaginationTemplate->set('HREF', Application::getAdminURL('user/?site=%d'));
-
- $ListTemplate = Template\Factory::build('user/index');
- $ListTemplate->set('LIST', [
- 'USERS' => $users ?? []
- ]);
+while($Attribute = $Statement->fetchObject('User\Attribute')) {
+ try {
+ $User = User\Factory::buildByAttribute($Attribute);
+ $ItemTemplate = generateUserItemTemplate($User);
- $ListTemplate->set('PAGINATION', [
- 'THIS' => $currentSite,
- 'LAST' => $lastSite,
- 'HTML' => $PaginationTemplate
- ]);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_user_overview', $currentSite));
- $MainTemplate->set('HTML', $ListTemplate);
- echo $MainTemplate;
+ $users[] = $ItemTemplate;
+ } catch(User\Exception $Exception){}
}
#===============================================================================
-# CATCH: Template\Exception
+# Build document
#===============================================================================
-catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
-}
-?> \ No newline at end of file
+$PaginationTemplate = Template\Factory::build('pagination');
+$PaginationTemplate->set('THIS', $currentSite);
+$PaginationTemplate->set('LAST', $lastSite);
+$PaginationTemplate->set('HREF', Application::getAdminURL('user/?site=%d'));
+
+$ListTemplate = Template\Factory::build('user/index');
+$ListTemplate->set('LIST', [
+ 'USERS' => $users ?? []
+]);
+
+$ListTemplate->set('PAGINATION', [
+ 'THIS' => $currentSite,
+ 'LAST' => $lastSite,
+ 'HTML' => $PaginationTemplate
+]);
+
+$MainTemplate = Template\Factory::build('main');
+$MainTemplate->set('NAME', $Language->text('title_user_overview', $currentSite));
+$MainTemplate->set('HTML', $ListTemplate);
+echo $MainTemplate;
diff --git a/admin/user/insert.php b/admin/user/insert.php
index 53d35df..59b9444 100644
--- a/admin/user/insert.php
+++ b/admin/user/insert.php
@@ -40,30 +40,20 @@ if(HTTP::issetPOST('id', 'slug', 'username', 'password', 'fullname', 'mailaddr',
}
#===============================================================================
-# TRY: Template\Exception
-#===============================================================================
-try {
- $FormTemplate = Template\Factory::build('user/form');
- $FormTemplate->set('FORM', [
- 'TYPE' => 'INSERT',
- 'INFO' => $messages ?? [],
- 'DATA' => array_change_key_case($Attribute->getAll(['password']), CASE_UPPER),
- 'TOKEN' => Application::getSecurityToken()
- ]);
-
- $InsertTemplate = Template\Factory::build('user/insert');
- $InsertTemplate->set('HTML', $FormTemplate);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_user_insert'));
- $MainTemplate->set('HTML', $InsertTemplate);
- echo $MainTemplate;
-}
-
-#===============================================================================
-# CATCH: Template\Exception
-#===============================================================================
-catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
-}
-?> \ No newline at end of file
+# Build document
+#===============================================================================
+$FormTemplate = Template\Factory::build('user/form');
+$FormTemplate->set('FORM', [
+ 'TYPE' => 'INSERT',
+ 'INFO' => $messages ?? [],
+ 'DATA' => array_change_key_case($Attribute->getAll(['password']), CASE_UPPER),
+ 'TOKEN' => Application::getSecurityToken()
+]);
+
+$InsertTemplate = Template\Factory::build('user/insert');
+$InsertTemplate->set('HTML', $FormTemplate);
+
+$MainTemplate = Template\Factory::build('main');
+$MainTemplate->set('NAME', $Language->text('title_user_insert'));
+$MainTemplate->set('HTML', $InsertTemplate);
+echo $MainTemplate;
diff --git a/admin/user/update.php b/admin/user/update.php
index becfdc5..b9b5f08 100644
--- a/admin/user/update.php
+++ b/admin/user/update.php
@@ -30,8 +30,7 @@ try {
if(HTTP::issetPOST(['token' => Application::getSecurityToken()])) {
try {
- if($Attribute->databaseUPDATE($Database)) {
- }
+ $Attribute->databaseUPDATE($Database);
} catch(PDOException $Exception) {
$messages[] = $Exception->getMessage();
}
@@ -42,33 +41,24 @@ try {
}
}
-#===============================================================================
-# TRY: Template\Exception
-#===============================================================================
- try {
- $FormTemplate = Template\Factory::build('user/form');
- $FormTemplate->set('FORM', [
- 'TYPE' => 'UPDATE',
- 'INFO' => $messages ?? [],
- 'DATA' => array_change_key_case($Attribute->getAll(['password']), CASE_UPPER),
- 'TOKEN' => Application::getSecurityToken()
- ]);
+ #===============================================================================
+ # Build document
+ #===============================================================================
+ $FormTemplate = Template\Factory::build('user/form');
+ $FormTemplate->set('FORM', [
+ 'TYPE' => 'UPDATE',
+ 'INFO' => $messages ?? [],
+ 'DATA' => array_change_key_case($Attribute->getAll(['password']), CASE_UPPER),
+ 'TOKEN' => Application::getSecurityToken()
+ ]);
- $InsertTemplate = Template\Factory::build('user/update');
- $InsertTemplate->set('HTML', $FormTemplate);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_user_update'));
- $MainTemplate->set('HTML', $InsertTemplate);
- echo $MainTemplate;
- }
+ $InsertTemplate = Template\Factory::build('user/update');
+ $InsertTemplate->set('HTML', $FormTemplate);
-#===============================================================================
-# CATCH: Template\Exception
-#===============================================================================
- catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
- }
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('NAME', $Language->text('title_user_update'));
+ $MainTemplate->set('HTML', $InsertTemplate);
+ echo $MainTemplate;
}
#===============================================================================
@@ -77,4 +67,3 @@ try {
catch(User\Exception $Exception) {
Application::error404();
}
-?> \ No newline at end of file