diff options
author | Thomas Lange <code@nerdmind.de> | 2021-06-17 22:00:39 +0200 |
---|---|---|
committer | Thomas Lange <code@nerdmind.de> | 2021-06-17 22:00:39 +0200 |
commit | 5555624546ea48d6327700f32b80848e0662dc90 (patch) | |
tree | 47d61fb756a6cb008aaf33586d292fcfe43da2a1 /core/namespace | |
parent | 91d8a28c664afa5378735bcd0efe068dd74d589f (diff) | |
parent | 0a2614cb69fc732c2115ef2f0c356f39f602d311 (diff) | |
download | blog-5555624546ea48d6327700f32b80848e0662dc90.tar.gz blog-5555624546ea48d6327700f32b80848e0662dc90.tar.xz blog-5555624546ea48d6327700f32b80848e0662dc90.zip |
Merge branch 'master' into 'optimization'optimization
Diffstat (limited to 'core/namespace')
28 files changed, 44 insertions, 43 deletions
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 |