summaryrefslogtreecommitdiffstats
path: root/system
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 /system
downloadblog-52b077a48c743ba4d08ac00520a0bf1ef6deef5f.tar.gz
blog-52b077a48c743ba4d08ac00520a0bf1ef6deef5f.tar.xz
blog-52b077a48c743ba4d08ac00520a0bf1ef6deef5f.zip
Initial commit.v1.0
Diffstat (limited to 'system')
-rw-r--r--system/403.php29
-rw-r--r--system/404.php29
-rw-r--r--system/feed/main.php76
-rw-r--r--system/page/list.php64
-rw-r--r--system/page/main.php89
-rw-r--r--system/post/list.php64
-rw-r--r--system/post/main.php89
-rw-r--r--system/search/main.php89
-rw-r--r--system/user/list.php60
-rw-r--r--system/user/main.php97
10 files changed, 686 insertions, 0 deletions
diff --git a/system/403.php b/system/403.php
new file mode 100644
index 0000000..08ef44d
--- /dev/null
+++ b/system/403.php
@@ -0,0 +1,29 @@
+<?php
+#===============================================================================
+# INCLUDE: Main configuration
+#===============================================================================
+if(!defined('ROOT')) {
+ require_once '../core/application.php';
+}
+
+#===============================================================================
+# TRY: Template\Exception
+#===============================================================================
+try {
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('HEAD', [
+ 'NAME' => '403 Forbidden',
+ 'DESC' => "You don't have permission to access {$_SERVER['REQUEST_URI']} on this server."
+ ]);
+
+ $MainTemplate->set('HTML', Template\Factory::build('403'));
+ echo $MainTemplate;
+}
+
+#===============================================================================
+# CATCH: Template\Exception
+#===============================================================================
+catch(Template\Exception $Exception) {
+ $Exception->defaultHandler();
+}
+?> \ No newline at end of file
diff --git a/system/404.php b/system/404.php
new file mode 100644
index 0000000..a92e9d6
--- /dev/null
+++ b/system/404.php
@@ -0,0 +1,29 @@
+<?php
+#===============================================================================
+# INCLUDE: Main configuration
+#===============================================================================
+if(!defined('ROOT')) {
+ require_once '../core/application.php';
+}
+
+#===============================================================================
+# TRY: Template\Exception
+#===============================================================================
+try {
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('HEAD', [
+ 'NAME' => '404 Not Found',
+ 'DESC' => "The requested URL {$_SERVER['REQUEST_URI']} was not found on this server."
+ ]);
+
+ $MainTemplate->set('HTML', Template\Factory::build('404'));
+ echo $MainTemplate;
+}
+
+#===============================================================================
+# CATCH: Template\Exception
+#===============================================================================
+catch(Template\Exception $Exception) {
+ $Exception->defaultHandler();
+}
+?> \ No newline at end of file
diff --git a/system/feed/main.php b/system/feed/main.php
new file mode 100644
index 0000000..00ac4b8
--- /dev/null
+++ b/system/feed/main.php
@@ -0,0 +1,76 @@
+<?php
+#===============================================================================
+# INCLUDE: Main configuration
+#===============================================================================
+require_once '../../core/application.php';
+
+#===============================================================================
+# HEADER: Content-Type for XML document
+#===============================================================================
+HTTP::responseHeader(HTTP::HEADER_CONTENT_TYPE, HTTP::CONTENT_TYPE_XML);
+
+#===============================================================================
+# TRY: Template\Exception
+#===============================================================================
+try {
+ if(HTTP::GET('item') !== 'page') {
+ $execSQL = 'SELECT id FROM %s ORDER BY '.Application::get('POST.FEED_SORT').' LIMIT '.Application::get('POST.FEED_SIZE');
+ $postIDs = $Database->query(sprintf($execSQL, Post\Attribute::TABLE))->fetchAll($Database::FETCH_COLUMN);
+
+ foreach($postIDs as $postID) {
+ try {
+ $Post = Post\Factory::build($postID);
+ $User = User\Factory::build($Post->attr('user'));
+
+ $ItemTemplate = Template\Factory::build('feed/item_post');
+ $ItemTemplate->set('POST', generatePostItemData($Post));
+ $ItemTemplate->set('USER', generateUserItemData($User));
+
+ $posts[] = $ItemTemplate;
+ }
+
+ catch(Post\Exception $Exception){}
+ catch(User\Exception $Exception){}
+ }
+ }
+
+ if(HTTP::GET('item') !== 'post') {
+ $execSQL = 'SELECT id FROM %s ORDER BY '.Application::get('PAGE.FEED_SORT').' LIMIT '.Application::get('PAGE.FEED_SIZE');
+ $pageIDs = $Database->query(sprintf($execSQL, Page\Attribute::TABLE))->fetchAll($Database::FETCH_COLUMN);
+
+ foreach($pageIDs as $pageID) {
+ try {
+ $Page = Page\Factory::build($pageID);
+ $User = User\Factory::build($Page->attr('user'));
+
+ $ItemTemplate = Template\Factory::build('feed/item_page');
+ $ItemTemplate->set('PAGE', generatePageItemData($Page));
+ $ItemTemplate->set('USER', generateUserItemData($User));
+
+ $pages[] = $ItemTemplate;
+ }
+
+ catch(Page\Exception $Exception){}
+ catch(User\Exception $Exception){}
+ }
+ }
+
+ $FeedTemplate = Template\Factory::build('feed/main');
+ $FeedTemplate->set('FEED', [
+ 'TYPE' => HTTP::GET('item'),
+ 'LIST' => [
+ 'POSTS' => $posts ?? [],
+ 'PAGES' => $pages ?? [],
+ ]
+ ]);
+
+ echo $FeedTemplate;
+}
+
+#===============================================================================
+# CATCH: Template\Exception
+#===============================================================================
+catch(Template\Exception $Exception) {
+ $Exception->defaultHandler();
+}
+?> \ No newline at end of file
diff --git a/system/page/list.php b/system/page/list.php
new file mode 100644
index 0000000..5d07d30
--- /dev/null
+++ b/system/page/list.php
@@ -0,0 +1,64 @@
+<?php
+#===============================================================================
+# INCLUDE: Main configuration
+#===============================================================================
+require_once '../../core/application.php';
+
+$site_size = Application::get('PAGE.LIST_SIZE');
+$site_sort = Application::get('PAGE.LIST_SORT');
+
+$lastSite = ceil($Database->query(sprintf('SELECT COUNT(id) FROM %s', Page\Attribute::TABLE))->fetchColumn() / $site_size);
+
+$currentSite = HTTP::GET('site') ?? 1;
+$currentSite = abs(intval($currentSite));
+
+if($currentSite < 1 OR ($currentSite > $lastSite AND $lastSite > 0)) {
+ Application::exit(404);
+}
+
+#===============================================================================
+# TRY: Template\Exception
+#===============================================================================
+try {
+ $execSQL = "SELECT id FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_size}";
+ $pageIDs = $Database->query(sprintf($execSQL, Page\Attribute::TABLE))->fetchAll($Database::FETCH_COLUMN);
+
+ foreach($pageIDs as $pageID) {
+ try {
+ $Page = Page\Factory::build($pageID);
+ $User = User\Factory::build($Page->attr('user'));
+
+ $ItemTemplate = generatePageItemTemplate($Page, $User);
+
+ $pages[] = $ItemTemplate;
+ }
+ catch(Page\Exception $Exception){}
+ catch(User\Exception $Exception){}
+ }
+
+ $ListTemplate = Template\Factory::build('page/list');
+ $ListTemplate->set('PAGINATION', [
+ 'THIS' => $currentSite,
+ 'LAST' => $lastSite,
+ 'HTML' => generatePageNaviTemplate($currentSite)
+ ]);
+ $ListTemplate->set('LIST', [
+ 'PAGES' => $pages ?? []
+ ]);
+
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('HTML', $ListTemplate);
+ $MainTemplate->set('HEAD', [
+ 'NAME' => $Language->text('title_page_overview', $currentSite)
+ ]);
+
+ echo $MainTemplate;
+}
+
+#===============================================================================
+# CATCH: Template\Exception
+#===============================================================================
+catch(Template\Exception $Exception) {
+ $Exception->defaultHandler();
+}
+?> \ No newline at end of file
diff --git a/system/page/main.php b/system/page/main.php
new file mode 100644
index 0000000..fdd5399
--- /dev/null
+++ b/system/page/main.php
@@ -0,0 +1,89 @@
+<?php
+#===============================================================================
+# INCLUDE: Main configuration
+#===============================================================================
+require_once '../../core/application.php';
+
+#===============================================================================
+# TRY: Page\Exception
+#===============================================================================
+try {
+ if(Application::get('PAGE.SLUG_URLS')) {
+ $Page = Page\Factory::buildBySlug(HTTP::GET('param'));
+ }
+
+ else {
+ $Page = Page\Factory::build(HTTP::GET('param'));
+ }
+
+ $User = User\Factory::build($Page->attr('user'));
+
+ $page_data = generatePageItemData($Page);
+ $user_data = generateUserItemData($User);
+
+ #===============================================================================
+ # Add post data for previous and next post if exists
+ #===============================================================================
+ try {
+ $PrevPage = Page\Factory::build($Page->getPrevID());
+ $page_data['PREV'] = generatePageItemData($PrevPage);
+ } catch(Page\Exception $Exception){}
+
+ try {
+ $NextPage = Page\Factory::build($Page->getNextID());
+ $page_data['NEXT'] = generatePageItemData($NextPage);
+ } catch(Page\Exception $Exception){}
+
+ #===============================================================================
+ # TRY: Template\Exception
+ #===============================================================================
+ try {
+ $PageTemplate = Template\Factory::build('page/main');
+ $PageTemplate->set('PAGE', $page_data);
+ $PageTemplate->set('USER', $user_data);
+
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('HTML', $PageTemplate);
+ $MainTemplate->set('HEAD', [
+ 'NAME' => $page_data['ATTR']['NAME'],
+ 'DESC' => cut(removeLineBreaksAndTabs(removeHTML($Page->getHTML()), ' '), Application::get('PAGE.DESCRIPTION_SIZE')),
+ 'PERM' => $page_data['URL'],
+ 'OG_IMAGES' => $page_data['FILE']['LIST']
+ ]);
+
+ echo $MainTemplate;
+ }
+
+ #===============================================================================
+ # CATCH: Template\Exception
+ #===============================================================================
+ catch(Template\Exception $Exception) {
+ $Exception->defaultHandler();
+ }
+}
+
+#===============================================================================
+# CATCH: Page\Exception
+#===============================================================================
+catch(Page\Exception $Exception) {
+ try {
+ if(Application::get('PAGE.SLUG_URLS') === FALSE) {
+ $Page = Page\Factory::buildBySlug(HTTP::GET('param'));
+ } else {
+ $Page = Page\Factory::build(HTTP::GET('param'));
+ }
+
+ HTTP::redirect($Page->getURL());
+ }
+
+ catch(Page\Exception $Exception) {
+ Application::exit(404);
+ }
+}
+
+#===============================================================================
+# CATCH: User\Exception
+#===============================================================================
+catch(User\Exception $Exception) {
+ exit($Exception->getMessage());
+} \ No newline at end of file
diff --git a/system/post/list.php b/system/post/list.php
new file mode 100644
index 0000000..a7d6ce7
--- /dev/null
+++ b/system/post/list.php
@@ -0,0 +1,64 @@
+<?php
+#===============================================================================
+# INCLUDE: Main configuration
+#===============================================================================
+require_once '../../core/application.php';
+
+$site_size = Application::get('POST.LIST_SIZE');
+$site_sort = Application::get('POST.LIST_SORT');
+
+$lastSite = ceil($Database->query(sprintf('SELECT COUNT(id) FROM %s', Post\Attribute::TABLE))->fetchColumn() / $site_size);
+
+$currentSite = HTTP::GET('site') ?? 1;
+$currentSite = abs(intval($currentSite));
+
+if($currentSite < 1 OR ($currentSite > $lastSite AND $lastSite > 0)) {
+ Application::exit(404);
+}
+
+#===============================================================================
+# TRY: Template\Exception
+#===============================================================================
+try {
+ $execSQL = "SELECT id FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_size}";
+ $postIDs = $Database->query(sprintf($execSQL, Post\Attribute::TABLE))->fetchAll($Database::FETCH_COLUMN);
+
+ foreach($postIDs as $postID) {
+ try {
+ $Post = Post\Factory::build($postID);
+ $User = User\Factory::build($Post->attr('user'));
+
+ $ItemTemplate = generatePostItemTemplate($Post, $User);
+
+ $posts[] = $ItemTemplate;
+ }
+ catch(Post\Exception $Exception){}
+ catch(User\Exception $Exception){}
+ }
+
+ $ListTemplate = Template\Factory::build('post/list');
+ $ListTemplate->set('PAGINATION', [
+ 'THIS' => $currentSite,
+ 'LAST' => $lastSite,
+ 'HTML' => generatePostNaviTemplate($currentSite)
+ ]);
+ $ListTemplate->set('LIST', [
+ 'POSTS' => $posts ?? []
+ ]);
+
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('HTML', $ListTemplate);
+ $MainTemplate->set('HEAD', [
+ 'NAME' => $Language->text('title_post_overview', $currentSite)
+ ]);
+
+ echo $MainTemplate;
+}
+
+#===============================================================================
+# CATCH: Template\Exception
+#===============================================================================
+catch(Template\Exception $Exception) {
+ $Exception->defaultHandler();
+}
+?> \ No newline at end of file
diff --git a/system/post/main.php b/system/post/main.php
new file mode 100644
index 0000000..4322f53
--- /dev/null
+++ b/system/post/main.php
@@ -0,0 +1,89 @@
+<?php
+#===============================================================================
+# INCLUDE: Main configuration
+#===============================================================================
+require_once '../../core/application.php';
+
+#===============================================================================
+# TRY: Post\Exception, User\Exception
+#===============================================================================
+try {
+ if(Application::get('POST.SLUG_URLS')) {
+ $Post = Post\Factory::buildBySlug(HTTP::GET('param'));
+ }
+
+ else {
+ $Post = Post\Factory::build(HTTP::GET('param'));
+ }
+
+ $User = User\Factory::build($Post->attr('user'));
+
+ $post_data = generatePostItemData($Post);
+ $user_data = generateUserItemData($User);
+
+ #===============================================================================
+ # Add post data for previous and next post if exists
+ #===============================================================================
+ try {
+ $PrevPost = Post\Factory::build($Post->getPrevID());
+ $post_data['PREV'] = generatePostItemData($PrevPost);
+ } catch(Post\Exception $Exception){}
+
+ try {
+ $NextPost = Post\Factory::build($Post->getNextID());
+ $post_data['NEXT'] = generatePostItemData($NextPost);
+ } catch(Post\Exception $Exception){}
+
+ #===============================================================================
+ # TRY: Template\Exception
+ #===============================================================================
+ try {
+ $PostTemplate = Template\Factory::build('post/main');
+ $PostTemplate->set('POST', $post_data);
+ $PostTemplate->set('USER', $user_data);
+
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('HTML', $PostTemplate);
+ $MainTemplate->set('HEAD', [
+ 'NAME' => $post_data['ATTR']['NAME'],
+ 'DESC' => cut(removeLineBreaksAndTabs(removeHTML($post_data['BODY']['HTML']), ' '), Application::get('POST.DESCRIPTION_SIZE')),
+ 'PERM' => $post_data['URL'],
+ 'OG_IMAGES' => $post_data['FILE']['LIST']
+ ]);
+
+ echo $MainTemplate;
+ }
+
+ #===============================================================================
+ # CATCH: Template\Exception
+ #===============================================================================
+ catch(Template\Exception $Exception) {
+ $Exception->defaultHandler();
+ }
+}
+
+#===============================================================================
+# CATCH: Post\Exception
+#===============================================================================
+catch(Post\Exception $Exception) {
+ try {
+ if(Application::get('POST.SLUG_URLS') === FALSE) {
+ $Post = Post\Factory::buildBySlug(HTTP::GET('param'));
+ } else {
+ $Post = Post\Factory::build(HTTP::GET('param'));
+ }
+
+ HTTP::redirect($Post->getURL());
+ }
+
+ catch(Post\Exception $Exception) {
+ Application::exit(404);
+ }
+}
+
+#===============================================================================
+# CATCH: User\Exception
+#===============================================================================
+catch(User\Exception $Exception) {
+ exit($Exception->getMessage());
+} \ No newline at end of file
diff --git a/system/search/main.php b/system/search/main.php
new file mode 100644
index 0000000..1c9921a
--- /dev/null
+++ b/system/search/main.php
@@ -0,0 +1,89 @@
+<?php
+#===============================================================================
+# INCLUDE: Main configuration
+#===============================================================================
+require_once '../../core/application.php';
+$SEARCH_SUCCESS = FALSE;
+$D_LIST = $Database->query(sprintf('SELECT DISTINCT DAY(time_insert) AS temp FROM %s ORDER BY temp', Post\Attribute::TABLE));
+$M_LIST = $Database->query(sprintf('SELECT DISTINCT MONTH(time_insert) AS temp FROM %s ORDER BY temp', Post\Attribute::TABLE));
+$Y_LIST = $Database->query(sprintf('SELECT DISTINCT YEAR(time_insert) AS temp FROM %s ORDER BY temp', Post\Attribute::TABLE));
+
+if($search = HTTP::GET('q')) {
+ if(!$postIDs = Post\Item::getSearchResultIDs($search, [HTTP::GET('d'), HTTP::GET('m'), HTTP::GET('y')], $Database)) {
+ $message = $Language->text('search_no_results', escapeHTML($search));
+ }
+}
+
+$form_data = [
+ 'SELECT' => [
+ 'D' => HTTP::GET('d'),
+ 'M' => HTTP::GET('m'),
+ 'Y' => HTTP::GET('y'),
+ ],
+ 'OPTIONS' => [
+ 'D' => $D_LIST->fetchAll(PDO::FETCH_COLUMN),
+ 'M' => $M_LIST->fetchAll(PDO::FETCH_COLUMN),
+ 'Y' => $Y_LIST->fetchAll(PDO::FETCH_COLUMN),
+ ]
+];
+
+$search_data = [
+ 'TEXT' => $search,
+ 'INFO' => isset($message) ? $message : FALSE,
+];
+
+#===============================================================================
+# TRY: Template\Exception
+#===============================================================================
+try {
+ if(isset($postIDs) AND !empty($postIDs)) {
+ foreach($postIDs as $postID) {
+ try {
+ $Post = Post\Factory::build($postID);
+ $User = User\Factory::build($Post->attr('user'));
+
+ $posts[] = generatePostItemTemplate($Post, $User);
+ }
+ catch(Post\Exception $Exception){}
+ catch(User\Exception $Exception){}
+ }
+
+ $ResultTemplate = Template\Factory::build('search/result');
+ $ResultTemplate->set('FORM', $form_data);
+ $ResultTemplate->set('SEARCH', $search_data);
+ $ResultTemplate->set('RESULT', [
+ 'LIST' => $posts ?? []
+ ]);
+
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('HTML', $ResultTemplate);
+ $MainTemplate->set('HEAD', [
+ 'NAME' => $Language->text('title_search_results', escapeHTML($search)),
+ 'PERM' => Application::getURL('search/')
+ ]);
+ }
+
+ else {
+ $SearchTemplate = Template\Factory::build('search/main');
+ $SearchTemplate->set('FORM', $form_data);
+ $SearchTemplate->set('SEARCH', $search_data);
+
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('HTML', $SearchTemplate);
+ $MainTemplate->set('HEAD', [
+ 'NAME' => $Language->text('title_search_request'),
+ 'DESC' => 'Wenn du einen bestimmten Beitrag suchst, aber ihn nicht finden kannst, dann kann dir die Suchfunktion bestimmt weiterhelfen.',
+ 'PERM' => Application::getURL('search/')
+ ]);
+ }
+
+ echo $MainTemplate;
+}
+
+#===============================================================================
+# CATCH: Template\Exception
+#===============================================================================
+catch(Template\Exception $Exception) {
+ $Exception->defaultHandler();
+}
+?> \ No newline at end of file
diff --git a/system/user/list.php b/system/user/list.php
new file mode 100644
index 0000000..1f29473
--- /dev/null
+++ b/system/user/list.php
@@ -0,0 +1,60 @@
+<?php
+#===============================================================================
+# INCLUDE: Main configuration
+#===============================================================================
+require_once '../../core/application.php';
+
+$site_size = Application::get('USER.LIST_SIZE');
+$site_sort = Application::get('USER.LIST_SORT');
+
+$lastSite = ceil($Database->query(sprintf('SELECT COUNT(id) FROM %s', User\Attribute::TABLE))->fetchColumn() / $site_size);
+
+$currentSite = HTTP::GET('site') ?? 1;
+$currentSite = abs(intval($currentSite));
+
+if($currentSite < 1 OR ($currentSite > $lastSite AND $lastSite > 0)) {
+ Application::exit(404);
+}
+
+#===============================================================================
+# TRY: Template\Exception
+#===============================================================================
+try {
+ $execSQL = "SELECT id FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_size}";
+ $userIDs = $Database->query(sprintf($execSQL, User\Attribute::TABLE))->fetchAll($Database::FETCH_COLUMN);
+
+ foreach($userIDs as $userID) {
+ try {
+ $User = User\Factory::build($userID);
+ $ItemTemplate = generateUserItemTemplate($User);
+
+ $users[] = $ItemTemplate;
+ } catch(User\Exception $Exception){}
+ }
+
+ $ListTemplate = Template\Factory::build('user/list');
+ $ListTemplate->set('PAGINATION', [
+ 'THIS' => $currentSite,
+ 'LAST' => $lastSite,
+ 'HTML' => generateUserNaviTemplate($currentSite)
+ ]);
+ $ListTemplate->set('LIST', [
+ 'USERS' => $users ?? []
+ ]);
+
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('HTML', $ListTemplate);
+ $MainTemplate->set('HEAD', [
+ 'NAME' => $Language->text('title_user_overview', $currentSite)
+ ]);
+
+ echo $MainTemplate;
+}
+
+#===============================================================================
+# CATCH: Template\Exception
+#===============================================================================
+catch(Template\Exception $Exception) {
+ $Exception->defaultHandler();
+}
+?> \ No newline at end of file
diff --git a/system/user/main.php b/system/user/main.php
new file mode 100644
index 0000000..d236b94
--- /dev/null
+++ b/system/user/main.php
@@ -0,0 +1,97 @@
+<?php
+#===============================================================================
+# INCLUDE: Main configuration
+#===============================================================================
+require_once '../../core/application.php';
+
+#===============================================================================
+# TRY: User\Exception
+#===============================================================================
+try {
+ if(Application::get('USER.SLUG_URLS')) {
+ $User = User\Factory::buildBySlug(HTTP::GET('param'));
+ }
+
+ else {
+ $User = User\Factory::build(HTTP::GET('param'));
+ }
+
+ $user_data = generateUserItemData($User);
+
+ #===============================================================================
+ # Add user data for previous and next user if exists
+ #===============================================================================
+ try {
+ $PrevUser = User\Factory::build($User->getPrevID());
+ $user_data['PREV'] = generateUserItemData($PrevUser);
+ } catch(User\Exception $Exception){}
+
+ try {
+ $NextUser = User\Factory::build($User->getNextID());
+ $user_data['NEXT'] = generateUserItemData($NextUser);
+ } catch(User\Exception $Exception){}
+
+ #===============================================================================
+ # TRY: Template\Exception
+ #===============================================================================
+ try {
+ #===============================================================================
+ # TRY: PDOException
+ #===============================================================================
+ try {
+ $PostCountStatement = $Database->query(sprintf('SELECT COUNT(*) FROM %s WHERE user = %d', Post\Attribute::TABLE, $User->getID()));
+ $PageCountStatement = $Database->query(sprintf('SELECT COUNT(*) FROM %s WHERE user = %d', Page\Attribute::TABLE, $User->getID()));
+ }
+
+ #===============================================================================
+ # CATCH: PDOException
+ #===============================================================================
+ catch(PDOException $Exception) {
+ exit($Exception->getMessage());
+ }
+
+ $UserTemplate = Template\Factory::build('user/main');
+ $UserTemplate->set('USER', $user_data);
+ $UserTemplate->set('COUNT', [
+ 'POST' => $PostCountStatement->fetchColumn(),
+ 'PAGE' => $PageCountStatement->fetchColumn()
+ ]);
+
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('HTML', $UserTemplate);
+ $MainTemplate->set('HEAD', [
+ 'NAME' => $user_data['ATTR']['FULLNAME'],
+ 'DESC' => cut(removeLineBreaksAndTabs(removeHTML($User->getHTML()), ' '), Application::get('USER.DESCRIPTION_SIZE')),
+ 'PERM' => $User->getURL(),
+ 'OG_IMAGES' => $User->getFiles()
+ ]);
+
+ echo $MainTemplate;
+ }
+
+ #===============================================================================
+ # CATCH: Template\Exception
+ #===============================================================================
+ catch(Template\Exception $Exception) {
+ $Exception->defaultHandler();
+ }
+}
+
+#===============================================================================
+# CATCH: User\Exception
+#===============================================================================
+catch(User\Exception $Exception) {
+ try {
+ if(Application::get('USER.SLUG_URLS') === FALSE) {
+ $User = User\Factory::buildBySlug(HTTP::GET('param'));
+ } else {
+ $User = User\Factory::build(HTTP::GET('param'));
+ }
+
+ HTTP::redirect($User->getURL());
+ }
+
+ catch(User\Exception $Exception) {
+ Application::exit(404);
+ }
+} \ No newline at end of file