aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/application.php47
-rw-r--r--core/configuration-example.php5
-rw-r--r--core/db/database.sql86
-rw-r--r--core/db/migrations/1.sql3
-rw-r--r--core/db/migrations/2.sql3
-rw-r--r--core/db/migrations/3.sql6
-rw-r--r--core/db/migrations/4.sql3
-rw-r--r--core/db/migrations/5.sql3
-rw-r--r--core/functions.php81
-rw-r--r--core/include/feed/main.php100
-rw-r--r--core/include/home.php66
-rw-r--r--core/include/page/list.php66
-rw-r--r--core/include/page/main.php53
-rw-r--r--core/include/post/list.php66
-rw-r--r--core/include/post/main.php53
-rw-r--r--core/include/search/main.php78
-rw-r--r--core/include/user/list.php67
-rw-r--r--core/include/user/main.php66
-rw-r--r--core/language/de.php1
-rw-r--r--core/language/en.php1
-rw-r--r--core/namespace/Application.php7
-rw-r--r--core/namespace/Attribute.php3
-rw-r--r--core/namespace/AttributeInterface.php7
-rw-r--r--core/namespace/Database.php1
-rw-r--r--core/namespace/Factory.php1
-rw-r--r--core/namespace/FactoryInterface.php1
-rw-r--r--core/namespace/HTTP.php1
-rw-r--r--core/namespace/Item.php2
-rw-r--r--core/namespace/ItemFactory.php1
-rw-r--r--core/namespace/ItemInterface.php1
-rw-r--r--core/namespace/Language.php1
-rw-r--r--core/namespace/Page/Attribute.php1
-rw-r--r--core/namespace/Page/Exception.php1
-rw-r--r--core/namespace/Page/Factory.php1
-rw-r--r--core/namespace/Page/Item.php1
-rw-r--r--core/namespace/Parsedown.php43
-rw-r--r--core/namespace/Post/Attribute.php1
-rw-r--r--core/namespace/Post/Exception.php1
-rw-r--r--core/namespace/Post/Factory.php1
-rw-r--r--core/namespace/Post/Item.php1
-rw-r--r--core/namespace/Router.php1
-rw-r--r--core/namespace/Template/Exception.php1
-rw-r--r--core/namespace/Template/Factory.php3
-rw-r--r--core/namespace/Template/Template.php1
-rw-r--r--core/namespace/User/Attribute.php1
-rw-r--r--core/namespace/User/Exception.php1
-rw-r--r--core/namespace/User/Factory.php1
-rw-r--r--core/namespace/User/Item.php1
48 files changed, 479 insertions, 462 deletions
diff --git a/core/application.php b/core/application.php
index 7e4f731..a84669f 100644
--- a/core/application.php
+++ b/core/application.php
@@ -34,9 +34,9 @@ set_exception_handler(function(Throwable $Exception) {
HTTP::init($_GET, $_POST, $_FILES, TRUE);
#===============================================================================
-# Default configuration (can be overridden in configuration.php)
+# Set default configuration
#===============================================================================
-$configuration = [
+foreach([
'CORE.LANGUAGE' => 'en',
'CORE.SEND_304' => FALSE,
'BLOGMETA.NAME' => 'Example blog',
@@ -48,7 +48,7 @@ $configuration = [
'DATABASE.BASENAME' => 'blog',
'DATABASE.USERNAME' => 'blog',
'DATABASE.PASSWORD' => '',
- 'TEMPLATE.NAME' => 'standard',
+ 'TEMPLATE.NAME' => 'default',
'TEMPLATE.LANG' => 'en',
'ADMIN.TEMPLATE' => 'admin',
'ADMIN.LANGUAGE' => 'en',
@@ -82,12 +82,21 @@ $configuration = [
'POST.FEED_SORT' => 'time_insert DESC',
'PAGE.FEED_GUID' => ['id', 'time_insert'],
'POST.FEED_GUID' => ['id', 'time_insert']
-];
+] as $name => $value) {
+ Application::set($name, $value);
+}
#===============================================================================
-# Set default configuration
+# Set default configuration (for admin prefixes)
#===============================================================================
-foreach($configuration as $name => $value) {
+foreach([
+ 'ADMIN.PAGE.LIST_SIZE' => 12, # for 1/2/3-column grid layout
+ 'ADMIN.POST.LIST_SIZE' => 12, # for 1/2/3-column grid layout
+ 'ADMIN.USER.LIST_SIZE' => Application::get('USER.LIST_SIZE'),
+ 'ADMIN.PAGE.LIST_SORT' => Application::get('PAGE.LIST_SORT'),
+ 'ADMIN.POST.LIST_SORT' => Application::get('POST.LIST_SORT'),
+ 'ADMIN.USER.LIST_SORT' => Application::get('USER.LIST_SORT')
+] as $name => $value) {
Application::set($name, $value);
}
@@ -127,22 +136,23 @@ if(defined('ADMINISTRATION') AND ADMINISTRATION === TRUE) {
require 'functions.php';
#===============================================================================
-# TRY: PDOException
+# Get Language and Database singletons
#===============================================================================
-try {
- $Language = Application::getLanguage();
- $Database = Application::getDatabase();
-
- $Database->setAttribute($Database::ATTR_DEFAULT_FETCH_MODE, $Database::FETCH_ASSOC);
- $Database->setAttribute($Database::ATTR_ERRMODE, $Database::ERRMODE_EXCEPTION);
-}
+$Language = Application::getLanguage();
+$Database = Application::getDatabase();
#===============================================================================
-# CATCH: PDOException
+# Set Database attributes
#===============================================================================
-catch(PDOException $Exception) {
- Application::exit($Exception->getMessage());
-}
+$Database->setAttribute(
+ $Database::ATTR_DEFAULT_FETCH_MODE,
+ $Database::FETCH_ASSOC
+);
+
+$Database->setAttribute(
+ $Database::ATTR_ERRMODE,
+ $Database::ERRMODE_EXCEPTION
+);
#===============================================================================
# Check if "304 Not Modified" and ETag header should be sent
@@ -186,4 +196,3 @@ if(Application::get('CORE.SEND_304') === TRUE AND !defined('ADMINISTRATION')) {
}
}
}
-?> \ No newline at end of file
diff --git a/core/configuration-example.php b/core/configuration-example.php
index 6c7d40a..f99d130 100644
--- a/core/configuration-example.php
+++ b/core/configuration-example.php
@@ -13,6 +13,8 @@
# #
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#
+# setlocale(LC_TIME, ['en_US.utf8', 'en_US']);
+
Application::set('CORE.LANGUAGE', 'en');
Application::set('BLOGMETA.NAME', 'My Techblog');
Application::set('BLOGMETA.DESC', '[a creative description]');
@@ -22,7 +24,6 @@ Application::set('BLOGMETA.LANG', 'en');
Application::set('DATABASE.BASENAME', 'blog');
Application::set('DATABASE.USERNAME', '');
Application::set('DATABASE.PASSWORD', '');
-Application::set('TEMPLATE.NAME', 'standard');
+Application::set('TEMPLATE.NAME', 'default');
Application::set('TEMPLATE.LANG', Application::get('CORE.LANGUAGE'));
Application::set('ADMIN.LANGUAGE', Application::get('CORE.LANGUAGE'));
-?> \ No newline at end of file
diff --git a/core/db/database.sql b/core/db/database.sql
new file mode 100644
index 0000000..ae61034
--- /dev/null
+++ b/core/db/database.sql
@@ -0,0 +1,86 @@
+-- =============================================================================
+-- Internal information table for migrations
+-- =============================================================================
+CREATE TABLE `migration` (`schema_version` smallint(4) NOT NULL)
+ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+INSERT INTO `migration` (`schema_version`) VALUES (5);
+
+-- =============================================================================
+-- Table structure for page items
+-- =============================================================================
+CREATE TABLE `page` (
+ `id` smallint(6) NOT NULL,
+ `time_insert` datetime NOT NULL,
+ `time_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ `user` tinyint(4) NOT NULL,
+ `slug` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
+ `name` varchar(100) NOT NULL,
+ `body` text NOT NULL,
+ `argv` varchar(250) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+-- =============================================================================
+-- Table structure for post items
+-- =============================================================================
+CREATE TABLE `post` (
+ `id` smallint(6) NOT NULL,
+ `time_insert` datetime NOT NULL,
+ `time_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ `user` tinyint(4) NOT NULL,
+ `slug` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
+ `name` varchar(100) NOT NULL,
+ `body` text NOT NULL,
+ `argv` varchar(250) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+-- =============================================================================
+-- Table structure for user items
+-- =============================================================================
+CREATE TABLE `user` (
+ `id` tinyint(4) NOT NULL,
+ `time_insert` datetime NOT NULL,
+ `time_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ `slug` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
+ `username` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
+ `password` char(64) CHARACTER SET latin1 DEFAULT NULL,
+ `fullname` varchar(40) NOT NULL,
+ `mailaddr` varchar(60) NOT NULL,
+ `body` text NOT NULL,
+ `argv` varchar(250) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+-- =============================================================================
+-- Insert demo page, post and user
+-- =============================================================================
+INSERT INTO `page` (`id`, `time_insert`, `time_update`, `user`, `slug`, `name`, `body`, `argv`) VALUES
+(1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 1, 'example-page', 'Example Page', 'OK. You discovered that there is also a page functionality. But what is the difference between a **page** and a **post**? This is simple: There is not really much difference. But you can style posts and pages within the themes CSS completely independent from each other. For example, use **pages** for things like your imprint, your terms of use, your FAQ or other stuff. And **posts** for your main blog posts. A **page** (and also a **user**) has exactly the same functionality as already described within the [first post]({POST[1]})! 8)', NULL);
+INSERT INTO `post` (`id`, `time_insert`, `time_update`, `user`, `slug`, `name`, `body`, `argv`) VALUES
+(1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 1, 'hello-world', 'Hello World!', 'Hello! This is the automatically generated first post on your new blog installation. You can type [Markdown](https://daringfireball.net/projects/markdown/) plaintext into the editor to format your content like you want.\r\n\r\nIn this post you can see several examples to [format your content with Markdown](https://daringfireball.net/projects/markdown/syntax) and with the *special codes* provided by this blog application. After you are familiar with the text formatting and done with the exploration of your new blog application, you can delete this post and create your own one. 😃\r\n\r\n![Demo image: Computer Guy (Public Domain)]({FILE[\"image/content/computer-guy-public-domain.svg\"]})\r\n\r\n## Dynamic internal URLs for items\r\nIf you want to link an item, please do not put the URL to the item hardcoded into your content! What if you want to change your sites address (or the base directory) in the future? Then you have to change all internal links in your content. This is not cool!\r\n\r\nTherefore, you can use the following code **without spaces between the braces** by knowing the unique ID of an item to link it dynamically:\r\n\r\n1. Example: `{ POST[1] }` \r\n{POST[1]}\r\n\r\n2. Example: `{ PAGE[1] }` \r\n{PAGE[1]}\r\n\r\n3. Example: `{ USER[1] }` \r\n{USER[1]}\r\n\r\n## Dynamic internal URLs for other resources\r\nThis also applies to any other resource that exists in the blog system and that you want to link to! You can link any other resource dynamically either relative to your base directory or relative to your resource directory (`/rsrc/`) for static files:\r\n\r\n* Example: `{ BASE[\"foo/bar/\"] }` \r\n{BASE[\"foo/bar/\"]}\r\n\r\n* Example: `{ FILE[\"foo/bar/\"] }` \r\n{FILE[\"foo/bar/\"]}', NULL);
+INSERT INTO `user` (`id`, `time_insert`, `time_update`, `slug`, `username`, `password`, `fullname`, `mailaddr`, `body`, `argv`) VALUES
+(1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'change-me', 'ChangeMe', '$2y$10$jH48L1K1y9dB303aI2biN.ob0biZDuUbMxPKadi3wDqOIxj6yNT6K', 'John Doe', 'mail@example.org', 'Describe yourself.', NULL);
+
+-- =============================================================================
+-- Add keys for table columns
+-- =============================================================================
+ALTER TABLE `page` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `time_insert` (`time_insert`), ADD UNIQUE KEY `slug` (`slug`), ADD KEY `page_user` (`user`);
+ALTER TABLE `post` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `time_insert` (`time_insert`), ADD UNIQUE KEY `slug` (`slug`), ADD KEY `post_user` (`user`);
+ALTER TABLE `user` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `time_insert` (`time_insert`), ADD UNIQUE KEY `slug` (`slug`), ADD UNIQUE KEY `username` (`username`);
+
+-- =============================================================================
+-- Add FULLTEXT indexes for table columns
+-- =============================================================================
+ALTER TABLE `page` ADD FULLTEXT KEY `search` (`name`, `body`);
+ALTER TABLE `post` ADD FULLTEXT KEY `search` (`name`, `body`);
+
+-- =============================================================================
+-- Add AUTO_INCREMENT for primary keys
+-- =============================================================================
+ALTER TABLE `page` MODIFY `id` smallint(6) NOT NULL AUTO_INCREMENT;
+ALTER TABLE `post` MODIFY `id` smallint(6) NOT NULL AUTO_INCREMENT;
+ALTER TABLE `user` MODIFY `id` tinyint(4) NOT NULL AUTO_INCREMENT;
+
+-- =============================================================================
+-- Add foreign keys for data integrity
+-- =============================================================================
+ALTER TABLE `page` ADD CONSTRAINT `page_user` FOREIGN KEY (`user`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
+ALTER TABLE `post` ADD CONSTRAINT `post_user` FOREIGN KEY (`user`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
diff --git a/core/db/migrations/1.sql b/core/db/migrations/1.sql
new file mode 100644
index 0000000..a875d13
--- /dev/null
+++ b/core/db/migrations/1.sql
@@ -0,0 +1,3 @@
+ALTER TABLE `page` ADD `argv` VARCHAR(100) NULL DEFAULT NULL AFTER `body`;
+ALTER TABLE `post` ADD `argv` VARCHAR(100) NULL DEFAULT NULL AFTER `body`;
+ALTER TABLE `user` ADD `argv` VARCHAR(100) NULL DEFAULT NULL AFTER `body`;
diff --git a/core/db/migrations/2.sql b/core/db/migrations/2.sql
new file mode 100644
index 0000000..525b768
--- /dev/null
+++ b/core/db/migrations/2.sql
@@ -0,0 +1,3 @@
+ALTER TABLE `page` ADD UNIQUE KEY `time_insert` (`time_insert`);
+ALTER TABLE `post` ADD UNIQUE KEY `time_insert` (`time_insert`);
+ALTER TABLE `user` ADD UNIQUE KEY `time_insert` (`time_insert`);
diff --git a/core/db/migrations/3.sql b/core/db/migrations/3.sql
new file mode 100644
index 0000000..ae46ed0
--- /dev/null
+++ b/core/db/migrations/3.sql
@@ -0,0 +1,6 @@
+ALTER TABLE `post` ENGINE=InnoDB;
+ALTER TABLE `post` DROP INDEX `body`;
+ALTER TABLE `page` ADD FULLTEXT KEY `search` (`name`, `body`);
+ALTER TABLE `post` ADD FULLTEXT KEY `search` (`name`, `body`);
+ALTER TABLE `post` ADD CONSTRAINT `post_user` FOREIGN KEY (`user`)
+ REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
diff --git a/core/db/migrations/4.sql b/core/db/migrations/4.sql
new file mode 100644
index 0000000..4a26c48
--- /dev/null
+++ b/core/db/migrations/4.sql
@@ -0,0 +1,3 @@
+ALTER TABLE `page` MODIFY `argv` VARCHAR(250);
+ALTER TABLE `post` MODIFY `argv` VARCHAR(250);
+ALTER TABLE `user` MODIFY `argv` VARCHAR(250);
diff --git a/core/db/migrations/5.sql b/core/db/migrations/5.sql
new file mode 100644
index 0000000..a3c8e5a
--- /dev/null
+++ b/core/db/migrations/5.sql
@@ -0,0 +1,3 @@
+CREATE TABLE `migration` (`schema_version` smallint(4) NOT NULL)
+ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+INSERT INTO `migration` (`schema_version`) VALUES (5);
diff --git a/core/functions.php b/core/functions.php
index ad63334..517be51 100644
--- a/core/functions.php
+++ b/core/functions.php
@@ -107,37 +107,12 @@ function generateItemTemplateData(Item $Item): array {
# Parser for datetime formatted strings [YYYY-MM-DD HH:II:SS]
#===============================================================================
function parseDatetime($datetime, $format): string {
- $Language = Application::getLanguage();
-
list($date, $time) = explode(' ', $datetime);
list($DATE['Y'], $DATE['M'], $DATE['D']) = explode('-', $date);
list($TIME['H'], $TIME['M'], $TIME['S']) = explode(':', $time);
- $M_LIST = [
- '01' => $Language->text('month_01'),
- '02' => $Language->text('month_02'),
- '03' => $Language->text('month_03'),
- '04' => $Language->text('month_04'),
- '05' => $Language->text('month_05'),
- '06' => $Language->text('month_06'),
- '07' => $Language->text('month_07'),
- '08' => $Language->text('month_08'),
- '09' => $Language->text('month_09'),
- '10' => $Language->text('month_10'),
- '11' => $Language->text('month_11'),
- '12' => $Language->text('month_12'),
- ];
-
- $D_LIST = [
- 0 => $Language->text('day_6'),
- 1 => $Language->text('day_0'),
- 2 => $Language->text('day_1'),
- 3 => $Language->text('day_2'),
- 4 => $Language->text('day_3'),
- 5 => $Language->text('day_4'),
- 6 => $Language->text('day_5'),
- ];
+ $unixtime = strtotime($datetime);
return strtr($format, [
'[Y]' => $DATE['Y'],
@@ -146,11 +121,11 @@ function parseDatetime($datetime, $format): string {
'[H]' => $TIME['H'],
'[I]' => $TIME['M'],
'[S]' => $TIME['S'],
- '[W]' => $D_LIST[date('w', strtotime($datetime))],
- '[F]' => $M_LIST[date('m', strtotime($datetime))],
+ '[W]' => strftime('%A', $unixtime),
+ '[F]' => strftime('%B', $unixtime),
'[DATE]' => $date,
'[TIME]' => $time,
- '[RFC2822]' => date('r', strtotime($datetime))
+ '[RFC2822]' => date('r', $unixtime)
]);
}
@@ -184,7 +159,45 @@ function getEmoticons(): array {
function parseEmoticons($string): string {
foreach(getEmoticons() as $emoticon => $data) {
$pattern = '#(^|\s)'.preg_quote($emoticon).'#';
- $replace = " <span title=\"{$data[1]}\">{$data[0]}</span>";
+ $replace = "\\1<span title=\"{$data[1]}\">{$data[0]}</span>";
+
+ $string = preg_replace($pattern, $replace, $string);
+ }
+
+ return $string;
+}
+
+#===============================================================================
+# Get unicode emoticons with their corresponding explanation
+#===============================================================================
+function getUnicodeEmoticons(): array {
+ $Language = Application::getLanguage();
+
+ return [
+ html_entity_decode('&#x1F60A;') => $Language->text('emoticon_1F60A'),
+ html_entity_decode('&#x1F61E;') => $Language->text('emoticon_1F61E'),
+ html_entity_decode('&#x1F603;') => $Language->text('emoticon_1F603'),
+ html_entity_decode('&#x1F61B;') => $Language->text('emoticon_1F61B'),
+ html_entity_decode('&#x1F632;') => $Language->text('emoticon_1F632'),
+ html_entity_decode('&#x1F609;') => $Language->text('emoticon_1F609'),
+ html_entity_decode('&#x1F622;') => $Language->text('emoticon_1F622'),
+ html_entity_decode('&#x1F610;') => $Language->text('emoticon_1F610'),
+ html_entity_decode('&#x1F635;') => $Language->text('emoticon_1F635'),
+ html_entity_decode('&#x1F612;') => $Language->text('emoticon_1F612'),
+ html_entity_decode('&#x1F60E;') => $Language->text('emoticon_1F60E'),
+ html_entity_decode('&#x1F61F;') => $Language->text('emoticon_1F61F'),
+ html_entity_decode('&#x1F602;') => $Language->text('emoticon_1F602'),
+ html_entity_decode('&#x1F604;') => $Language->text('emoticon_1F604'),
+ ];
+}
+
+#===============================================================================
+# Wrap emoticons in <span> element with "title" attribute for explanation
+#===============================================================================
+function parseUnicodeEmoticons($string): string {
+ foreach(getUnicodeEmoticons() as $emoticon => $explanation) {
+ $pattern = '#(^|\s)'.preg_quote($emoticon).'#';
+ $replace = "\\1<span title=\"{$explanation}\">{$emoticon}</span>";
$string = preg_replace($pattern, $replace, $string);
}
@@ -221,13 +234,6 @@ function removeWhitespace($string): string {
}
#===============================================================================
-# Return pseudo-random (hex converted) string
-#===============================================================================
-function getRandomValue($length = 40): string {
- return strtoupper(bin2hex(random_bytes(ceil($length / 2))));
-}
-
-#===============================================================================
# Return truncated string
#===============================================================================
function truncate($string, $length, $replace = '') {
@@ -318,4 +324,3 @@ function USER(int $id): array {
return [];
}
}
-?> \ No newline at end of file
diff --git a/core/include/feed/main.php b/core/include/feed/main.php
index 84f3edb..59be3d1 100644
--- a/core/include/feed/main.php
+++ b/core/include/feed/main.php
@@ -11,73 +11,69 @@ $Language = Application::getLanguage();
HTTP::responseHeader(HTTP::HEADER_CONTENT_TYPE, HTTP::CONTENT_TYPE_XML);
#===============================================================================
-# TRY: Template\Exception
+# Post feed
#===============================================================================
-try {
- if(!isset($param) OR $param !== 'page') {
- $POST['FEED_SORT'] = Application::get('POST.FEED_SORT');
- $POST['FEED_SIZE'] = Application::get('POST.FEED_SIZE');
+if(!isset($param) OR $param !== 'page') {
+ $POST['FEED_SORT'] = Application::get('POST.FEED_SORT');
+ $POST['FEED_SIZE'] = Application::get('POST.FEED_SIZE');
- $execSQL = "SELECT * FROM %s ORDER BY {$POST['FEED_SORT']} LIMIT {$POST['FEED_SIZE']}";
- $Statement = $Database->query(sprintf($execSQL, Post\Attribute::TABLE));
+ $execSQL = "SELECT * FROM %s ORDER BY {$POST['FEED_SORT']} LIMIT {$POST['FEED_SIZE']}";
+ $Statement = $Database->query(sprintf($execSQL, Post\Attribute::TABLE));
- 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 = Template\Factory::build('feed/item_post');
- $ItemTemplate->set('POST', generateItemTemplateData($Post));
- $ItemTemplate->set('USER', generateItemTemplateData($User));
+ $ItemTemplate = Template\Factory::build('feed/item_post');
+ $ItemTemplate->set('POST', generateItemTemplateData($Post));
+ $ItemTemplate->set('USER', generateItemTemplateData($User));
- $posts[] = $ItemTemplate;
- }
-
- catch(Post\Exception $Exception){}
- catch(User\Exception $Exception){}
+ $posts[] = $ItemTemplate;
}
- }
- if(!isset($param) OR $param !== 'post') {
- $PAGE['FEED_SORT'] = Application::get('PAGE.FEED_SORT');
- $PAGE['FEED_SIZE'] = Application::get('PAGE.FEED_SIZE');
+ catch(Post\Exception $Exception){}
+ catch(User\Exception $Exception){}
+ }
+}
- $execSQL = "SELECT * FROM %s ORDER BY {$PAGE['FEED_SORT']} LIMIT {$PAGE['FEED_SIZE']}";
- $Statement = $Database->query(sprintf($execSQL, Page\Attribute::TABLE));
+#===============================================================================
+# Page feed
+#===============================================================================
+if(!isset($param) OR $param !== 'post') {
+ $PAGE['FEED_SORT'] = Application::get('PAGE.FEED_SORT');
+ $PAGE['FEED_SIZE'] = Application::get('PAGE.FEED_SIZE');
- while($Attribute = $Statement->fetchObject('Page\Attribute')) {
- try {
- $Page = Page\Factory::buildByAttribute($Attribute);
- $User = User\Factory::build($Page->attr('user'));
+ $execSQL = "SELECT * FROM %s ORDER BY {$PAGE['FEED_SORT']} LIMIT {$PAGE['FEED_SIZE']}";
+ $Statement = $Database->query(sprintf($execSQL, Page\Attribute::TABLE));
- $ItemTemplate = Template\Factory::build('feed/item_page');
- $ItemTemplate->set('PAGE', generateItemTemplateData($Page));
- $ItemTemplate->set('USER', generateItemTemplateData($User));
+ while($Attribute = $Statement->fetchObject('Page\Attribute')) {
+ try {
+ $Page = Page\Factory::buildByAttribute($Attribute);
+ $User = User\Factory::build($Page->attr('user'));
- $pages[] = $ItemTemplate;
- }
+ $ItemTemplate = Template\Factory::build('feed/item_page');
+ $ItemTemplate->set('PAGE', generateItemTemplateData($Page));
+ $ItemTemplate->set('USER', generateItemTemplateData($User));
- catch(Page\Exception $Exception){}
- catch(User\Exception $Exception){}
+ $pages[] = $ItemTemplate;
}
- }
-
- $FeedTemplate = Template\Factory::build('feed/main');
- $FeedTemplate->set('FEED', [
- 'TYPE' => $param ?? NULL,
- 'LIST' => [
- 'POSTS' => $posts ?? [],
- 'PAGES' => $pages ?? [],
- ]
- ]);
- echo $FeedTemplate;
+ 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
+$FeedTemplate = Template\Factory::build('feed/main');
+$FeedTemplate->set('FEED', [
+ 'TYPE' => $param ?? NULL,
+ 'LIST' => [
+ 'POSTS' => $posts ?? [],
+ 'PAGES' => $pages ?? [],
+ ]
+]);
+
+echo $FeedTemplate;
diff --git a/core/include/home.php b/core/include/home.php
index 2fe81a2..fe732de 100644
--- a/core/include/home.php
+++ b/core/include/home.php
@@ -5,49 +5,39 @@
$Database = Application::getDatabase();
$Language = Application::getLanguage();
-#===============================================================================
-# TRY: Template\Exception
-#===============================================================================
-try {
- $execSQL = 'SELECT * FROM %s ORDER BY '.Application::get('POST.LIST_SORT').' LIMIT '.Application::get('POST.LIST_SIZE');
- $Statement = $Database->query(sprintf($execSQL, Post\Attribute::TABLE));
+$execSQL = 'SELECT * FROM %s ORDER BY '.Application::get('POST.LIST_SORT').' LIMIT '.Application::get('POST.LIST_SIZE');
+$Statement = $Database->query(sprintf($execSQL, Post\Attribute::TABLE));
- 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;
}
-
- $HomeTemplate = Template\Factory::build('home');
- $HomeTemplate->set('PAGINATION', [
- 'HTML' => generatePostNaviTemplate(1)
- ]);
- $HomeTemplate->set('LIST', [
- 'POSTS' => $posts ?? []
- ]);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('HTML', $HomeTemplate);
- $MainTemplate->set('HEAD', [
- 'NAME' => Application::get('BLOGMETA.HOME'),
- 'DESC' => Application::get('BLOGMETA.NAME').' – '.Application::get('BLOGMETA.DESC'),
- 'PERM' => Application::getURL()
- ]);
-
- 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
+$HomeTemplate = Template\Factory::build('home');
+$HomeTemplate->set('PAGINATION', [
+ 'HTML' => generatePostNaviTemplate(1)
+]);
+$HomeTemplate->set('LIST', [
+ 'POSTS' => $posts ?? []
+]);
+
+$MainTemplate = Template\Factory::build('main');
+$MainTemplate->set('HTML', $HomeTemplate);
+$MainTemplate->set('HEAD', [
+ 'NAME' => Application::get('BLOGMETA.HOME'),
+ 'DESC' => Application::get('BLOGMETA.NAME').' – '.Application::get('BLOGMETA.DESC'),
+ 'PERM' => Application::getURL()
+]);
+
+echo $MainTemplate;
diff --git a/core/include/page/list.php b/core/include/page/list.php
index 656d01a..2bb2639 100644
--- a/core/include/page/list.php
+++ b/core/include/page/list.php
@@ -30,49 +30,39 @@ if(Application::get('PAGE.SINGLE_REDIRECT') === TRUE AND $count === '1') {
HTTP::redirect($Page->getURL());
}
-#===============================================================================
-# TRY: Template\Exception
-#===============================================================================
-try {
- $execSQL = "SELECT * FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_size}";
- $Statement = $Database->query(sprintf($execSQL, Page\Attribute::TABLE));
+$execSQL = "SELECT * FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_size}";
+$Statement = $Database->query(sprintf($execSQL, Page\Attribute::TABLE));
- 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;
}
-
- $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(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
+$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;
diff --git a/core/include/page/main.php b/core/include/page/main.php
index 7f1aa02..955bb35 100644
--- a/core/include/page/main.php
+++ b/core/include/page/main.php
@@ -6,7 +6,7 @@ $Database = Application::getDatabase();
$Language = Application::getLanguage();
#===============================================================================
-# TRY: Page\Exception, User\Exception
+# TRY: Page\Exception
#===============================================================================
try {
if(Application::get('PAGE.SLUG_URLS')) {
@@ -36,36 +36,27 @@ try {
} catch(Page\Exception $Exception){}
#===============================================================================
- # TRY: Template\Exception
+ # Build document
#===============================================================================
- 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' => description($page_data['BODY']['HTML'](), Application::get('PAGE.DESCRIPTION_SIZE')),
- 'PERM' => $page_data['URL'],
- 'OG_IMAGES' => $page_data['FILE']['LIST']
- ]);
+ $PageTemplate = Template\Factory::build('page/main');
+ $PageTemplate->set('PAGE', $page_data);
+ $PageTemplate->set('USER', $user_data);
- # Get access to the current item data from main template
- $MainTemplate->set('TYPE', 'PAGE');
- $MainTemplate->set('PAGE', $page_data);
- $MainTemplate->set('USER', $user_data);
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('HTML', $PageTemplate);
+ $MainTemplate->set('HEAD', [
+ 'NAME' => $page_data['ATTR']['NAME'],
+ 'DESC' => description($page_data['BODY']['HTML'](), Application::get('PAGE.DESCRIPTION_SIZE')),
+ 'PERM' => $page_data['URL'],
+ 'OG_IMAGES' => $page_data['FILE']['LIST']
+ ]);
- echo $MainTemplate;
- }
+ # Get access to the current item data from main template
+ $MainTemplate->set('TYPE', 'PAGE');
+ $MainTemplate->set('PAGE', $page_data);
+ $MainTemplate->set('USER', $user_data);
- #===============================================================================
- # CATCH: Template\Exception
- #===============================================================================
- catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
- }
+ echo $MainTemplate;
}
#===============================================================================
@@ -86,11 +77,3 @@ catch(Page\Exception $Exception) {
Application::error404();
}
}
-
-#===============================================================================
-# CATCH: User\Exception
-#===============================================================================
-catch(User\Exception $Exception) {
- Application::exit($Exception->getMessage());
-}
-?> \ No newline at end of file
diff --git a/core/include/post/list.php b/core/include/post/list.php
index 6ade592..68183c7 100644
--- a/core/include/post/list.php
+++ b/core/include/post/list.php
@@ -30,49 +30,39 @@ if(Application::get('POST.SINGLE_REDIRECT') === TRUE AND $count === '1') {
HTTP::redirect($Post->getURL());
}
-#===============================================================================
-# TRY: Template\Exception
-#===============================================================================
-try {
- $execSQL = "SELECT * FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_size}";
- $Statement = $Database->query(sprintf($execSQL, Post\Attribute::TABLE));
+$execSQL = "SELECT * FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_size}";
+$Statement = $Database->query(sprintf($execSQL, Post\Attribute::TABLE));
- 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;
}
-
- $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(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
+$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;
diff --git a/core/include/post/main.php b/core/include/post/main.php
index aa5dc50..8c65740 100644
--- a/core/include/post/main.php
+++ b/core/include/post/main.php
@@ -6,7 +6,7 @@ $Database = Application::getDatabase();
$Language = Application::getLanguage();
#===============================================================================
-# TRY: Post\Exception, User\Exception
+# TRY: Post\Exception
#===============================================================================
try {
if(Application::get('POST.SLUG_URLS')) {
@@ -36,36 +36,27 @@ try {
} catch(Post\Exception $Exception){}
#===============================================================================
- # TRY: Template\Exception
+ # Build document
#===============================================================================
- 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' => description($post_data['BODY']['HTML'](), Application::get('POST.DESCRIPTION_SIZE')),
- 'PERM' => $post_data['URL'],
- 'OG_IMAGES' => $post_data['FILE']['LIST']
- ]);
+ $PostTemplate = Template\Factory::build('post/main');
+ $PostTemplate->set('POST', $post_data);
+ $PostTemplate->set('USER', $user_data);
- # Get access to the current item data from main template
- $MainTemplate->set('TYPE', 'POST');
- $MainTemplate->set('POST', $post_data);
- $MainTemplate->set('USER', $user_data);
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('HTML', $PostTemplate);
+ $MainTemplate->set('HEAD', [
+ 'NAME' => $post_data['ATTR']['NAME'],
+ 'DESC' => description($post_data['BODY']['HTML'](), Application::get('POST.DESCRIPTION_SIZE')),
+ 'PERM' => $post_data['URL'],
+ 'OG_IMAGES' => $post_data['FILE']['LIST']
+ ]);
- echo $MainTemplate;
- }
+ # Get access to the current item data from main template
+ $MainTemplate->set('TYPE', 'POST');
+ $MainTemplate->set('POST', $post_data);
+ $MainTemplate->set('USER', $user_data);
- #===============================================================================
- # CATCH: Template\Exception
- #===============================================================================
- catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
- }
+ echo $MainTemplate;
}
#===============================================================================
@@ -86,11 +77,3 @@ catch(Post\Exception $Exception) {
Application::error404();
}
}
-
-#===============================================================================
-# CATCH: User\Exception
-#===============================================================================
-catch(User\Exception $Exception) {
- Application::exit($Exception->getMessage());
-}
-?> \ No newline at end of file
diff --git a/core/include/search/main.php b/core/include/search/main.php
index 5a9708e..ac7e23a 100644
--- a/core/include/search/main.php
+++ b/core/include/search/main.php
@@ -35,56 +35,46 @@ $search_data = [
];
#===============================================================================
-# TRY: Template\Exception
+# Build document
#===============================================================================
-try {
- if(isset($attributes) AND !empty($attributes)) {
- foreach($attributes as $Attribute) {
- try {
- $Post = Post\Factory::buildByAttribute($Attribute);
- $User = User\Factory::build($Post->attr('user'));
+if(isset($attributes) AND !empty($attributes)) {
+ foreach($attributes as $Attribute) {
+ try {
+ $Post = Post\Factory::buildByAttribute($Attribute);
+ $User = User\Factory::build($Post->attr('user'));
- $posts[] = generatePostItemTemplate($Post, $User);
- }
- catch(Post\Exception $Exception){}
- catch(User\Exception $Exception){}
+ $posts[] = generatePostItemTemplate($Post, $User);
}
-
- $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/')
- ]);
+ catch(Post\Exception $Exception){}
+ catch(User\Exception $Exception){}
}
- 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'),
- 'PERM' => Application::getURL('search/')
- ]);
- }
+ $ResultTemplate = Template\Factory::build('search/result');
+ $ResultTemplate->set('FORM', $form_data);
+ $ResultTemplate->set('SEARCH', $search_data);
+ $ResultTemplate->set('RESULT', [
+ 'LIST' => $posts ?? []
+ ]);
- echo $MainTemplate;
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('HTML', $ResultTemplate);
+ $MainTemplate->set('HEAD', [
+ 'NAME' => $Language->text('title_search_results', escapeHTML($search)),
+ 'PERM' => Application::getURL('search/')
+ ]);
}
-#===============================================================================
-# CATCH: Template\Exception
-#===============================================================================
-catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
+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'),
+ 'PERM' => Application::getURL('search/')
+ ]);
}
-?> \ No newline at end of file
+
+echo $MainTemplate;
diff --git a/core/include/user/list.php b/core/include/user/list.php
index adc28ec..72375a4 100644
--- a/core/include/user/list.php
+++ b/core/include/user/list.php
@@ -30,45 +30,44 @@ if(Application::get('USER.SINGLE_REDIRECT') === TRUE AND $count === '1') {
HTTP::redirect($User->getURL());
}
-#===============================================================================
-# TRY: Template\Exception
-#===============================================================================
-try {
- $execSQL = "SELECT * FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_size}";
- $Statement = $Database->query(sprintf($execSQL, User\Attribute::TABLE));
+$execSQL = "SELECT * FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_size}";
+$Statement = $Database->query(sprintf($execSQL, User\Attribute::TABLE));
- while($Attribute = $Statement->fetchObject('User\Attribute')) {
- try {
- $User = User\Factory::buildByAttribute($Attribute);
- $ItemTemplate = generateUserItemTemplate($User);
+while($Attribute = $Statement->fetchObject('User\Attribute')) {
+ try {
+ $User = User\Factory::buildByAttribute($Attribute);
+ $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 ?? []
- ]);
+ $users[] = $ItemTemplate;
+ } catch(User\Exception $Exception){}
+}
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('HTML', $ListTemplate);
- $MainTemplate->set('HEAD', [
- 'NAME' => $Language->text('title_user_overview', $currentSite)
- ]);
+foreach($userIDs as $userID) {
+ try {
+ $User = User\Factory::build($userID);
+ $ItemTemplate = generateUserItemTemplate($User);
- 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
+$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;
diff --git a/core/include/user/main.php b/core/include/user/main.php
index 4f30020..80969da 100644
--- a/core/include/user/main.php
+++ b/core/include/user/main.php
@@ -32,54 +32,33 @@ try {
$user_data['NEXT'] = generateItemTemplateData($NextUser);
} catch(User\Exception $Exception){}
+ $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()));
+
#===============================================================================
- # TRY: Template\Exception
+ # Build document
#===============================================================================
- 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()
- ]);
+ $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' => description($user_data['BODY']['HTML'](), Application::get('USER.DESCRIPTION_SIZE')),
- 'PERM' => $User->getURL(),
- 'OG_IMAGES' => $User->getFiles()
- ]);
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('HTML', $UserTemplate);
+ $MainTemplate->set('HEAD', [
+ 'NAME' => $user_data['ATTR']['FULLNAME'],
+ 'DESC' => description($user_data['BODY']['HTML'](), Application::get('USER.DESCRIPTION_SIZE')),
+ 'PERM' => $User->getURL(),
+ 'OG_IMAGES' => $User->getFiles()
+ ]);
- # Get access to the current item data from main template
- $MainTemplate->set('TYPE', 'USER');
- $MainTemplate->set('USER', $user_data);
+ # Get access to the current item data from main template
+ $MainTemplate->set('TYPE', 'USER');
+ $MainTemplate->set('USER', $user_data);
- echo $MainTemplate;
- }
-
- #===============================================================================
- # CATCH: Template\Exception
- #===============================================================================
- catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
- }
+ echo $MainTemplate;
}
#===============================================================================
@@ -100,4 +79,3 @@ catch(User\Exception $Exception) {
Application::error404();
}
}
-?> \ No newline at end of file
diff --git a/core/language/de.php b/core/language/de.php
index 5d29d5d..2f008da 100644
--- a/core/language/de.php
+++ b/core/language/de.php
@@ -210,4 +210,3 @@ $LANGUAGE['title_search_results'] = 'Ergebnisse für "%s"';
$LANGUAGE['feed_name_items'] = '%s [alle Inhalte]';
$LANGUAGE['feed_name_pages'] = '%s [nur Seiten]';
$LANGUAGE['feed_name_posts'] = '%s [nur Beiträge]';
-?> \ No newline at end of file
diff --git a/core/language/en.php b/core/language/en.php
index dc70154..eeec0a9 100644
--- a/core/language/en.php
+++ b/core/language/en.php
@@ -210,4 +210,3 @@ $LANGUAGE['title_search_results'] = 'Results for "%s"';
$LANGUAGE['feed_name_items'] = '%s [all content]';
$LANGUAGE['feed_name_pages'] = '%s [only pages]';
$LANGUAGE['feed_name_posts'] = '%s [only posts]';
-?> \ No newline at end of file
diff --git a/core/namespace/Application.php b/core/namespace/Application.php
index 8c3be12..6a77865 100644
--- a/core/namespace/Application.php
+++ b/core/namespace/Application.php
@@ -59,7 +59,7 @@ class Application {
$Language = new Language(self::get('CORE.LANGUAGE'));
$Language->load(sprintf(ROOT.'core/language/%s.php', Application::get('CORE.LANGUAGE')));
- $Language->load(sprintf(ROOT.'template/%s/lang/%s.php', $template_name, $template_lang));
+ $Language->load(sprintf(ROOT.'theme/%s/lang/%s.php', $template_name, $template_lang));
self::$Language = $Language;
}
@@ -72,7 +72,7 @@ class Application {
#===============================================================================
public static function getSecurityToken(): string {
if(!isset($_SESSION['token'])) {
- $_SESSION['token'] = getRandomValue();
+ $_SESSION['token'] = bin2hex(random_bytes(16));
}
return $_SESSION['token'];
@@ -136,7 +136,7 @@ class Application {
#===============================================================================
public static function getTemplateURL($more = ''): string {
$template = self::get('TEMPLATE.NAME');
- return self::getURL("template/{$template}/{$more}");
+ return self::getURL("theme/{$template}/{$more}");
}
#===============================================================================
@@ -163,4 +163,3 @@ class Application {
exit();
}
}
-?> \ No newline at end of file
diff --git a/core/namespace/Attribute.php b/core/namespace/Attribute.php
index 32cfa0a..ba782ac 100644
--- a/core/namespace/Attribute.php
+++ b/core/namespace/Attribute.php
@@ -1,5 +1,5 @@
<?php
-abstract class Attribute implements AttributeInterface {
+abstract class Attribute {
#===============================================================================
# Set attribute
@@ -82,4 +82,3 @@ abstract class Attribute implements AttributeInterface {
return $Statement->execute([$this->get('id')]);
}
}
-?> \ No newline at end of file
diff --git a/core/namespace/AttributeInterface.php b/core/namespace/AttributeInterface.php
deleted file mode 100644
index 74cd1f1..0000000
--- a/core/namespace/AttributeInterface.php
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php
-interface AttributeInterface {
- public function databaseINSERT(\Database $Database);
- public function databaseUPDATE(\Database $Database);
- public function databaseDELETE(\Database $Database);
-}
-?> \ No newline at end of file
diff --git a/core/namespace/Database.php b/core/namespace/Database.php
index ae233f4..54fb36b 100644
--- a/core/namespace/Database.php
+++ b/core/namespace/Database.php
@@ -4,4 +4,3 @@ class Database extends \PDO {
parent::__construct("mysql:host={$hostname};dbname={$basename};charset=utf8mb4;", $username, $password);
}
}
-?> \ No newline at end of file
diff --git a/core/namespace/Factory.php b/core/namespace/Factory.php
index 38be666..779b890 100644
--- a/core/namespace/Factory.php
+++ b/core/namespace/Factory.php
@@ -16,4 +16,3 @@ abstract class Factory implements FactoryInterface {
return self::$storage[get_called_class()][$identifier] ?? FALSE;
}
}
-?> \ No newline at end of file
diff --git a/core/namespace/FactoryInterface.php b/core/namespace/FactoryInterface.php
index 54a115b..e9017d6 100644
--- a/core/namespace/FactoryInterface.php
+++ b/core/namespace/FactoryInterface.php
@@ -2,4 +2,3 @@
interface FactoryInterface {
public static function build($identifier);
}
-?> \ No newline at end of file
diff --git a/core/namespace/HTTP.php b/core/namespace/HTTP.php
index c8aea27..9145539 100644
--- a/core/namespace/HTTP.php
+++ b/core/namespace/HTTP.php
@@ -228,4 +228,3 @@ class HTTP {
}
}
}
-?> \ No newline at end of file
diff --git a/core/namespace/Item.php b/core/namespace/Item.php
index ba54579..0a7d364 100644
--- a/core/namespace/Item.php
+++ b/core/namespace/Item.php
@@ -96,6 +96,7 @@ abstract class Item implements ItemInterface {
$content = $this->getBody();
if(\Application::get($item::CONFIGURATION.'.EMOTICONS') === TRUE) {
+ $content = parseUnicodeEmoticons($content);
$content = parseEmoticons($content);
}
@@ -196,4 +197,3 @@ abstract class Item implements ItemInterface {
}
}
}
-?> \ No newline at end of file
diff --git a/core/namespace/ItemFactory.php b/core/namespace/ItemFactory.php
index d961028..ba32cd5 100644
--- a/core/namespace/ItemFactory.php
+++ b/core/namespace/ItemFactory.php
@@ -33,4 +33,3 @@ abstract class ItemFactory extends Factory {
return $Instance;
}
}
-?> \ No newline at end of file
diff --git a/core/namespace/ItemInterface.php b/core/namespace/ItemInterface.php
index f2ba12d..917db6a 100644
--- a/core/namespace/ItemInterface.php
+++ b/core/namespace/ItemInterface.php
@@ -2,4 +2,3 @@
interface ItemInterface {
public function __construct($param, \Database $Database);
}
-?> \ No newline at end of file
diff --git a/core/namespace/Language.php b/core/namespace/Language.php
index fdaf104..f082b37 100644
--- a/core/namespace/Language.php
+++ b/core/namespace/Language.php
@@ -49,4 +49,3 @@ class Language {
return $this->text($name, $params);
}
}
-?> \ No newline at end of file
diff --git a/core/namespace/Page/Attribute.php b/core/namespace/Page/Attribute.php
index b1c4e01..05eaa33 100644
--- a/core/namespace/Page/Attribute.php
+++ b/core/namespace/Page/Attribute.php
@@ -20,4 +20,3 @@ class Attribute extends \Attribute {
#===============================================================================
const TABLE = 'page';
}
-?> \ No newline at end of file
diff --git a/core/namespace/Page/Exception.php b/core/namespace/Page/Exception.php
index d4794b7..c41bddc 100644
--- a/core/namespace/Page/Exception.php
+++ b/core/namespace/Page/Exception.php
@@ -2,4 +2,3 @@
namespace Page;
class Exception extends \Exception {}
-?> \ No newline at end of file
diff --git a/core/namespace/Page/Factory.php b/core/namespace/Page/Factory.php
index 4b8d390..2fcc361 100644
--- a/core/namespace/Page/Factory.php
+++ b/core/namespace/Page/Factory.php
@@ -2,4 +2,3 @@
namespace Page;
class Factory extends \ItemFactory {}
-?> \ No newline at end of file
diff --git a/core/namespace/Page/Item.php b/core/namespace/Page/Item.php
index 563602a..d875e8a 100644
--- a/core/namespace/Page/Item.php
+++ b/core/namespace/Page/Item.php
@@ -48,4 +48,3 @@ class Item extends \Item {
return $Statement->fetchObject('User\Attribute');
}
}
-?> \ No newline at end of file
diff --git a/core/namespace/Parsedown.php b/core/namespace/Parsedown.php
index e101bc5..51237b3 100644
--- a/core/namespace/Parsedown.php
+++ b/core/namespace/Parsedown.php
@@ -17,7 +17,7 @@ class Parsedown
{
# ~
- const version = '1.7.1';
+ const version = '1.7.4';
# ~
@@ -418,7 +418,21 @@ class Parsedown
if (isset($matches[1]))
{
- $class = 'language-'.$matches[1];
+ /**
+ * https://www.w3.org/TR/2011/WD-html5-20110525/elements.html#classes
+ * Every HTML element may have a class attribute specified.
+ * The attribute, if specified, must have a value that is a set
+ * of space-separated tokens representing the various classes
+ * that the element belongs to.
+ * [...]
+ * The space characters, for the purposes of this specification,
+ * are U+0020 SPACE, U+0009 CHARACTER TABULATION (tab),
+ * U+000A LINE FEED (LF), U+000C FORM FEED (FF), and
+ * U+000D CARRIAGE RETURN (CR).
+ */
+ $language = substr($matches[1], 0, strcspn($matches[1], " \t\n\f\r"));
+
+ $class = 'language-'.$language;
$Element['attributes'] = array(
'class' => $class,
@@ -1464,22 +1478,41 @@ class Parsedown
}
}
+ $permitRawHtml = false;
+
if (isset($Element['text']))
{
+ $text = $Element['text'];
+ }
+ // very strongly consider an alternative if you're writing an
+ // extension
+ elseif (isset($Element['rawHtml']))
+ {
+ $text = $Element['rawHtml'];
+ $allowRawHtmlInSafeMode = isset($Element['allowRawHtmlInSafeMode']) && $Element['allowRawHtmlInSafeMode'];
+ $permitRawHtml = !$this->safeMode || $allowRawHtmlInSafeMode;
+ }
+
+ if (isset($text))
+ {
$markup .= '>';
- if (!isset($Element['nonNestables']))
+ if (!isset($Element['nonNestables']))
{
$Element['nonNestables'] = array();
}
if (isset($Element['handler']))
{
- $markup .= $this->{$Element['handler']}($Element['text'], $Element['nonNestables']);
+ $markup .= $this->{$Element['handler']}($text, $Element['nonNestables']);
+ }
+ elseif (!$permitRawHtml)
+ {
+ $markup .= self::escape($text, true);
}
else
{
- $markup .= self::escape($Element['text'], true);
+ $markup .= $text;
}
$markup .= '</'.$Element['name'].'>';
diff --git a/core/namespace/Post/Attribute.php b/core/namespace/Post/Attribute.php
index 73af3a2..20aafae 100644
--- a/core/namespace/Post/Attribute.php
+++ b/core/namespace/Post/Attribute.php
@@ -20,4 +20,3 @@ class Attribute extends \Attribute {
#===============================================================================
const TABLE = 'post';
}
-?> \ No newline at end of file
diff --git a/core/namespace/Post/Exception.php b/core/namespace/Post/Exception.php
index 516ddbe..29b9345 100644
--- a/core/namespace/Post/Exception.php
+++ b/core/namespace/Post/Exception.php
@@ -2,4 +2,3 @@
namespace Post;
class Exception extends \Exception {}
-?> \ No newline at end of file
diff --git a/core/namespace/Post/Factory.php b/core/namespace/Post/Factory.php
index 4ad8ac8..20b29cc 100644
--- a/core/namespace/Post/Factory.php
+++ b/core/namespace/Post/Factory.php
@@ -2,4 +2,3 @@
namespace Post;
class Factory extends \ItemFactory {}
-?> \ No newline at end of file
diff --git a/core/namespace/Post/Item.php b/core/namespace/Post/Item.php
index 84b5f43..6109e20 100644
--- a/core/namespace/Post/Item.php
+++ b/core/namespace/Post/Item.php
@@ -55,4 +55,3 @@ class Item extends \Item {
return $Statement->fetchObject('User\Attribute');
}
}
-?> \ No newline at end of file
diff --git a/core/namespace/Router.php b/core/namespace/Router.php
index b6221d1..803a8e0 100644
--- a/core/namespace/Router.php
+++ b/core/namespace/Router.php
@@ -61,4 +61,3 @@ class Router {
}
}
}
-?> \ No newline at end of file
diff --git a/core/namespace/Template/Exception.php b/core/namespace/Template/Exception.php
index a38ee1d..3bfbf63 100644
--- a/core/namespace/Template/Exception.php
+++ b/core/namespace/Template/Exception.php
@@ -2,4 +2,3 @@
namespace Template;
class Exception extends \Exception {}
-?> \ No newline at end of file
diff --git a/core/namespace/Template/Factory.php b/core/namespace/Template/Factory.php
index a90c61e..7e56a79 100644
--- a/core/namespace/Template/Factory.php
+++ b/core/namespace/Template/Factory.php
@@ -3,7 +3,7 @@ namespace Template;
class Factory extends \Factory implements \FactoryInterface {
public static function build($template): Template {
- $Template = new Template(ROOT.'template/'.\Application::get('TEMPLATE.NAME')."/html/{$template}.php");
+ $Template = new Template(ROOT.'theme/'.\Application::get('TEMPLATE.NAME')."/html/{$template}.php");
$Template->set('Language', \Application::getLanguage());
$Template->set('BLOGMETA', [
'NAME' => \Application::get('BLOGMETA.NAME'),
@@ -15,4 +15,3 @@ class Factory extends \Factory implements \FactoryInterface {
return $Template;
}
}
-?> \ No newline at end of file
diff --git a/core/namespace/Template/Template.php b/core/namespace/Template/Template.php
index 16459fb..25034a2 100644
--- a/core/namespace/Template/Template.php
+++ b/core/namespace/Template/Template.php
@@ -41,4 +41,3 @@ class Template {
return ob_get_clean();
}
}
-?> \ No newline at end of file
diff --git a/core/namespace/User/Attribute.php b/core/namespace/User/Attribute.php
index c83fdfc..ccd31b5 100644
--- a/core/namespace/User/Attribute.php
+++ b/core/namespace/User/Attribute.php
@@ -22,4 +22,3 @@ class Attribute extends \Attribute {
#===============================================================================
const TABLE = 'user';
}
-?> \ No newline at end of file
diff --git a/core/namespace/User/Exception.php b/core/namespace/User/Exception.php
index b5bcad0..fdbe733 100644
--- a/core/namespace/User/Exception.php
+++ b/core/namespace/User/Exception.php
@@ -2,4 +2,3 @@
namespace User;
class Exception extends \Exception {}
-?> \ No newline at end of file
diff --git a/core/namespace/User/Factory.php b/core/namespace/User/Factory.php
index e352368..81930e6 100644
--- a/core/namespace/User/Factory.php
+++ b/core/namespace/User/Factory.php
@@ -6,4 +6,3 @@ class Factory extends \ItemFactory {
return self::build(Item::getIDByField('username', $username, \Application::getDatabase()));
}
}
-?> \ No newline at end of file
diff --git a/core/namespace/User/Item.php b/core/namespace/User/Item.php
index 129d8f9..a4ab799 100644
--- a/core/namespace/User/Item.php
+++ b/core/namespace/User/Item.php
@@ -33,4 +33,3 @@ class Item extends \Item {
return password_verify($password, $this->Attribute->get('password'));
}
}
-?> \ No newline at end of file