diff --git a/admin/controllers/edit-page.php b/admin/controllers/edit-page.php index 73684983..ec77d9de 100644 --- a/admin/controllers/edit-page.php +++ b/admin/controllers/edit-page.php @@ -69,7 +69,9 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' ) // Main // ============================================================================ -if(!$dbPages->pageExists($layout['parameters'])) { +if(!$dbPages->pageExists($layout['parameters'])) +{ + Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the page: '.$layout['parameters']); Redirect::page('admin', 'manage-pages'); } diff --git a/admin/controllers/edit-post.php b/admin/controllers/edit-post.php index a2473f24..6d01c2b2 100644 --- a/admin/controllers/edit-post.php +++ b/admin/controllers/edit-post.php @@ -63,7 +63,9 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' ) // Main // ============================================================================ -if(!$dbPosts->postExists($layout['parameters'])) { +if(!$dbPosts->postExists($layout['parameters'])) +{ + Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the post: '.$layout['parameters']); Redirect::page('admin', 'manage-posts'); } diff --git a/kernel/boot/init.php b/kernel/boot/init.php index 15fc558c..c8720f18 100644 --- a/kernel/boot/init.php +++ b/kernel/boot/init.php @@ -38,7 +38,7 @@ if(!defined('JSON_PRETTY_PRINT')) { define('SALT_LENGTH', 8); // Page brake string -define('PAGE_BRAKE', ''); +define('PAGE_BREAK', ''); // Bludit version define('BLUDIT_VERSION', 'githubVersion'); diff --git a/kernel/boot/rules/70.build_pages.php b/kernel/boot/rules/70.build_pages.php index e2e7abca..d3ea1db0 100644 --- a/kernel/boot/rules/70.build_pages.php +++ b/kernel/boot/rules/70.build_pages.php @@ -64,8 +64,8 @@ function build_page($key) $Page->setField('contentRaw', $Page->content(), true); // Parse markdown content. - $content = Text::imgRel2Abs($contentRaw, HTML_PATH_UPLOADS); // Parse img src relative to absolute. - $content = $Parsedown->text($content); // Parse Markdown. + $content = $Parsedown->text($contentRaw); // Parse Markdown. + $content = Text::imgRel2Abs($content, HTML_PATH_UPLOADS); // Parse img src relative to absolute. $Page->setField('content', $content, true); // Parse username for the page. diff --git a/kernel/boot/rules/70.build_posts.php b/kernel/boot/rules/70.build_posts.php index 3c8964a0..91c7e1ff 100644 --- a/kernel/boot/rules/70.build_posts.php +++ b/kernel/boot/rules/70.build_posts.php @@ -53,10 +53,15 @@ function buildPost($key) $Post->setField('contentRaw', $contentRaw, true); // Parse the content - $content = Text::imgRel2Abs($contentRaw, HTML_PATH_UPLOADS); // Parse img src relative to absolute. - $content = $Parsedown->text($content); // Parse Markdown. + $content = $Parsedown->text($contentRaw); // Parse Markdown. + $content = Text::imgRel2Abs($content, HTML_PATH_UPLOADS); // Parse img src relative to absolute. $Post->setField('content', $content, true); + // Pagebrake + $explode = explode(PAGE_BREAK, $content); + $Post->setField('breakContent', $explode[0], true); + $Post->setField('readMore', !empty($explode[1]), true); + // Parse username for the post. if( $dbUsers->userExists( $Post->username() ) ) { diff --git a/kernel/helpers/text.class.php b/kernel/helpers/text.class.php index 2afe3ed6..33a441ea 100644 --- a/kernel/helpers/text.class.php +++ b/kernel/helpers/text.class.php @@ -155,7 +155,7 @@ class Text { public static function imgRel2Abs($string, $base) { - return preg_replace("/(src)\=\"([^(http)])(\/)?/", "$1=\"$base$2", $string); + return preg_replace('/(src)="([^:"]*)(?:")/', "$1=\"$base$2\"", $string); } } diff --git a/kernel/page.class.php b/kernel/page.class.php index 76d74ea8..20240db1 100644 --- a/kernel/page.class.php +++ b/kernel/page.class.php @@ -20,17 +20,11 @@ class Page extends fileContent // This content is markdown parser. // $fullContent, TRUE returns all content, if FALSE returns the first part of the content. // $html, TRUE returns the content without satinize, FALSE otherwise. - public function content($fullContent=true, $html=true) + public function content($html=true) { // This content is not sanitized. $content = $this->getField('content'); - if(!$fullContent) - { - $explode = explode(PAGE_BRAKE, $content); - $content = $explode[0]; - } - if($html) { return $content; } @@ -42,17 +36,11 @@ class Page extends fileContent // This content is not markdown parser. // $fullContent, TRUE returns all content, if FALSE returns the first part of the content. // $html, TRUE returns the content without satinize, FALSE otherwise. - public function contentRaw($fullContent=true, $html=true) + public function contentRaw($html=true) { // This content is not sanitized. $content = $this->getField('contentRaw'); - if(!$fullContent) - { - $explode = explode(PAGE_BRAKE, $content); - $content = $explode[0]; - } - if($html) { return $content; } diff --git a/kernel/post.class.php b/kernel/post.class.php index 9f0b5624..50217e4c 100644 --- a/kernel/post.class.php +++ b/kernel/post.class.php @@ -27,8 +27,7 @@ class Post extends fileContent if(!$fullContent) { - $explode = explode(PAGE_BRAKE, $content); - $content = $explode[0]; + $content = $this->getField('breakContent'); } if($html) { @@ -38,21 +37,19 @@ class Post extends fileContent return Sanitize::html($content); } + public function readMore() + { + return $this->getField('readMore'); + } + // Returns the content. // This content is not markdown parser. - // $fullContent, TRUE returns all content, if FALSE returns the first part of the content. // $html, TRUE returns the content without satinize, FALSE otherwise. - public function contentRaw($fullContent=true, $html=true) + public function contentRaw($html=true) { // This content is not sanitized. $content = $this->getField('contentRaw'); - if(!$fullContent) - { - $explode = explode(PAGE_BRAKE, $content); - $content = $explode[0]; - } - if($html) { return $content; } diff --git a/kernel/url.class.php b/kernel/url.class.php index c9ee1686..21aed6ad 100644 --- a/kernel/url.class.php +++ b/kernel/url.class.php @@ -15,10 +15,9 @@ class Url // Decodes any %## encoding in the given string. Plus symbols ('+') are decoded to a space character. $decode = urldecode($_SERVER['REQUEST_URI']); - // Parse, http://php.net/parse_url - $parse = parse_url($decode); - - $this->uri = $parse['path']; + // remove parameters GET, do not use parse_url because has problem with utf-8. + $explode = explode('?', $decode); + $this->uri = $explode[0]; $this->parameters = $_GET; diff --git a/themes/pure/php/home.php b/themes/pure/php/home.php index c21244d1..c2f80447 100644 --- a/themes/pure/php/home.php +++ b/themes/pure/php/home.php @@ -33,10 +33,15 @@