From e26b86fddd789b18b668f82419ebb9c878186d1f Mon Sep 17 00:00:00 2001 From: dignajar Date: Sat, 6 Feb 2016 17:35:12 -0300 Subject: [PATCH 01/13] Bug fixes, plugins databases - Improves, Disqus plugin --- bl-kernel/abstract/plugin.class.php | 22 ++++++++-- bl-kernel/boot/init.php | 3 ++ bl-kernel/helpers/sanitize.class.php | 7 +++- bl-plugins/disqus/plugin.php | 60 ++++++++++++---------------- 4 files changed, 52 insertions(+), 40 deletions(-) diff --git a/bl-kernel/abstract/plugin.class.php b/bl-kernel/abstract/plugin.class.php index 42a76d4e..c459d252 100644 --- a/bl-kernel/abstract/plugin.class.php +++ b/bl-kernel/abstract/plugin.class.php @@ -103,13 +103,27 @@ class Plugin { return ''; } - public function setDb($array) + public function setDb($args) { $tmp = array(); - // All fields will be sanitize before save. - foreach($array as $key=>$value) { - $tmp[$key] = Sanitize::html($value); + foreach($this->dbFields as $key=>$value) + { + if(isset($args[$key])) + { + // Sanitize value + $tmpValue = Sanitize::html( $args[$key] ); + + // Set type + settype($tmpValue, gettype($value)); + + // Set value + $tmp[$key] = $tmpValue; + } + else + { + $tmp[$key] = false; + } } $this->db = $tmp; diff --git a/bl-kernel/boot/init.php b/bl-kernel/boot/init.php index 9ff1519a..605b238f 100644 --- a/bl-kernel/boot/init.php +++ b/bl-kernel/boot/init.php @@ -56,6 +56,9 @@ if(!defined('JSON_PRETTY_PRINT')) { define('JSON_PRETTY_PRINT', 128); } +// Alert status ok +define('CHECK_SYMBOLIC_LINKS', FALSE); + // Alert status ok define('ALERT_STATUS_OK', 0); diff --git a/bl-kernel/helpers/sanitize.class.php b/bl-kernel/helpers/sanitize.class.php index 0fab0886..b5482f38 100644 --- a/bl-kernel/helpers/sanitize.class.php +++ b/bl-kernel/helpers/sanitize.class.php @@ -40,7 +40,12 @@ class Sanitize { // Fix for Windows on paths. eg: $path = c:\diego/page/subpage convert to c:\diego\page\subpages $fullPath = str_replace('/', DS, $fullPath); - $real = realpath($fullPath); + if(CHECK_SYMBOLIC_LINKS) { + $real = realpath($fullPath); + } + else { + $real = file_exists($fullPath)?$fullPath:false; + } // If $real is FALSE the file does not exist. if($real===false) { diff --git a/bl-plugins/disqus/plugin.php b/bl-plugins/disqus/plugin.php index c81de08e..25c5822d 100644 --- a/bl-plugins/disqus/plugin.php +++ b/bl-plugins/disqus/plugin.php @@ -2,14 +2,14 @@ class pluginDisqus extends Plugin { - private $disable; + private $enable; public function init() { $this->dbFields = array( 'shortname'=>'', 'enablePages'=>false, - 'enablePosts'=>true, + 'enablePosts'=>false, 'enableDefaultHomePage'=>false ); } @@ -20,25 +20,17 @@ class pluginDisqus extends Plugin { global $Url; - // Disable the plugin IF ... - $this->disable = false; + $this->enable = false; - if( (!$this->getDbField('enablePosts')) && ($Url->whereAmI()=='post') ) { - $this->disable = true; + if( $this->getDbField('enablePosts') && ($Url->whereAmI()=='post') ) { + $this->enable = true; } - elseif( (!$this->getDbField('enablePages')) && ($Url->whereAmI()=='page') ) { - $this->disable = true; + elseif( $this->getDbField('enablePages') && ($Url->whereAmI()=='page') ) { + $this->enable = true; } - elseif( !$this->getDbField('enableDefaultHomePage') && ($Url->whereAmI()=='page') ) + elseif( $this->getDbField('enableDefaultHomePage') && ($Url->whereAmI()=='home') ) { - global $Site; - - if( Text::isNotEmpty($Site->homePage()) ) { - $this->disable = true; - } - } - elseif( ($Url->whereAmI()!='post') && ($Url->whereAmI()!='page') ) { - $this->disable = true; + $this->enable = true; } } @@ -71,41 +63,36 @@ class pluginDisqus extends Plugin { public function postEnd() { - if( $this->disable ) { - return false; + if( $this->enable ) { + return '
'; } - $html = '
'; - return $html; + return false; } public function pageEnd() { - if( $this->disable ) { - return false; + if( $this->enable ) { + return '
'; } - $html = '
'; - return $html; + return false; } public function siteHead() { - if( $this->disable ) { - return false; + if( $this->enable ) { + return ''; } - $html = ''; - return $html; + return false; } public function siteBodyEnd() { - if( $this->disable ) { - return false; - } + if( $this->enable ) { - $html = ' + $html = ' '; - return $html; + return $html; + } + + return false; } -} +} \ No newline at end of file From 7cdb2dd7f4688699cb92ce405f218323e782fb11 Mon Sep 17 00:00:00 2001 From: dignajar Date: Sat, 6 Feb 2016 17:48:11 -0300 Subject: [PATCH 02/13] Improves, Disqus plugin --- bl-plugins/disqus/plugin.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bl-plugins/disqus/plugin.php b/bl-plugins/disqus/plugin.php index 25c5822d..427da613 100644 --- a/bl-plugins/disqus/plugin.php +++ b/bl-plugins/disqus/plugin.php @@ -32,6 +32,10 @@ class pluginDisqus extends Plugin { { $this->enable = true; } + + if(!$Url->notFound()) { + $this->enable = false; + } } public function form() From f410f12d1691eff0406f258dccdc2b9fc5e5283b Mon Sep 17 00:00:00 2001 From: dignajar Date: Sat, 6 Feb 2016 18:05:58 -0300 Subject: [PATCH 03/13] Improves, Disqus plugin --- bl-plugins/disqus/plugin.php | 11 ++++++----- index.php | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bl-plugins/disqus/plugin.php b/bl-plugins/disqus/plugin.php index 427da613..3eb8bb67 100644 --- a/bl-plugins/disqus/plugin.php +++ b/bl-plugins/disqus/plugin.php @@ -32,10 +32,6 @@ class pluginDisqus extends Plugin { { $this->enable = true; } - - if(!$Url->notFound()) { - $this->enable = false; - } } public function form() @@ -76,7 +72,12 @@ class pluginDisqus extends Plugin { public function pageEnd() { - if( $this->enable ) { + global $Url; + + // Bludit check not-found page after the plugin method construct. + // It's necesary check here the page not-found. + + if( $this->enable && !$Url->notFound()) { return '
'; } diff --git a/index.php b/index.php index 1be0dbf9..dec231f3 100644 --- a/index.php +++ b/index.php @@ -37,4 +37,4 @@ if($Url->whereAmI()==='admin') { // Site else { require(PATH_BOOT.'site.php'); -} +} \ No newline at end of file From 791f2dfb00c4288ed06f43a8fc80d44839dacde7 Mon Sep 17 00:00:00 2001 From: dignajar Date: Sat, 6 Feb 2016 18:41:27 -0300 Subject: [PATCH 04/13] SSL support --- bl-themes/blogme/assets/css/main.css | 4 ++-- bl-themes/future-imperfect/assets/css/main.css | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bl-themes/blogme/assets/css/main.css b/bl-themes/blogme/assets/css/main.css index c0d89b2b..f829adbd 100644 --- a/bl-themes/blogme/assets/css/main.css +++ b/bl-themes/blogme/assets/css/main.css @@ -1,4 +1,4 @@ -@import url("http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700|Raleway:400,800,900"); +@import url("//fonts.googleapis.com/css?family=Source+Sans+Pro:400,700|Raleway:400,800,900"); /* Future Imperfect by HTML5 UP @@ -3432,4 +3432,4 @@ padding: 1.5em; } - } \ No newline at end of file + } diff --git a/bl-themes/future-imperfect/assets/css/main.css b/bl-themes/future-imperfect/assets/css/main.css index 3b189eb3..6b29d9a6 100644 --- a/bl-themes/future-imperfect/assets/css/main.css +++ b/bl-themes/future-imperfect/assets/css/main.css @@ -1,4 +1,4 @@ -@import url("http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700|Raleway:400,800,900"); +@import url("//fonts.googleapis.com/css?family=Source+Sans+Pro:400,700|Raleway:400,800,900"); /* Future Imperfect by HTML5 UP @@ -3432,4 +3432,4 @@ padding: 1.5em; } - } \ No newline at end of file + } From cfc9d4995046cb40516ae53b1fc5c990862a04ec Mon Sep 17 00:00:00 2001 From: dignajar Date: Sat, 6 Feb 2016 20:44:43 -0300 Subject: [PATCH 05/13] Minor bug fixes --- bl-kernel/abstract/content.class.php | 3 ++- bl-kernel/abstract/dbjson.class.php | 1 + bl-kernel/boot/init.php | 5 ++++- bl-kernel/boot/rules/70.posts.php | 4 ++-- bl-kernel/dbposts.class.php | 21 +++++++++++++-------- bl-kernel/dbtags.class.php | 1 - 6 files changed, 22 insertions(+), 13 deletions(-) diff --git a/bl-kernel/abstract/content.class.php b/bl-kernel/abstract/content.class.php index 710605f5..dcb72fa0 100644 --- a/bl-kernel/abstract/content.class.php +++ b/bl-kernel/abstract/content.class.php @@ -17,6 +17,7 @@ class Content { return($this->vars!==false); } + // Returns the value from the $field, FALSE if the field doesn't exist. public function getField($field) { if(isset($this->vars[$field])) { @@ -38,7 +39,7 @@ class Content { private function build($path) { - if( !Sanitize::pathFile($path, 'index.txt') ) { + if( !Sanitize::pathFile($path.'index.txt') ) { return false; } diff --git a/bl-kernel/abstract/dbjson.class.php b/bl-kernel/abstract/dbjson.class.php index ef881474..04dffaa9 100644 --- a/bl-kernel/abstract/dbjson.class.php +++ b/bl-kernel/abstract/dbjson.class.php @@ -45,6 +45,7 @@ class dbJSON public function restoreDB() { $this->db = $this->dbBackup; + return true; } diff --git a/bl-kernel/boot/init.php b/bl-kernel/boot/init.php index 605b238f..d754fb61 100644 --- a/bl-kernel/boot/init.php +++ b/bl-kernel/boot/init.php @@ -85,9 +85,12 @@ define('POSTS_PER_PAGE_ADMIN', 10); // Check if JSON encode and decode are enabled. // define('JSON', function_exists('json_encode')); -// TRUE if new posts hand-made set published, or FALSE for draft. +// Cli mode status for new posts/pages define('CLI_STATUS', 'published'); +// Cli mode username for new posts/pages +define('CLI_USERNAME', 'admin'); + // Database date format define('DB_DATE_FORMAT', 'Y-m-d H:i:s'); diff --git a/bl-kernel/boot/rules/70.posts.php b/bl-kernel/boot/rules/70.posts.php index e118f999..c9cf812c 100644 --- a/bl-kernel/boot/rules/70.posts.php +++ b/bl-kernel/boot/rules/70.posts.php @@ -20,10 +20,10 @@ function reIndexTagsPosts() // Remove unpublished. $dbPosts->removeUnpublished(); - // Regenerate the tags index for posts + // Regenerate the tags index for posts. $dbTags->reindexPosts( $dbPosts->db ); - // Restore de db on dbPost + // Restore the database, before remove the unpublished. $dbPosts->restoreDB(); return true; diff --git a/bl-kernel/dbposts.class.php b/bl-kernel/dbposts.class.php index f847a80c..7609466e 100644 --- a/bl-kernel/dbposts.class.php +++ b/bl-kernel/dbposts.class.php @@ -244,7 +244,12 @@ class dbPosts extends dbJSON $outrange = $init<0 ? true : $init>$end; if(!$outrange) { - return array_slice($this->db, $init, $postPerPage, true); + $tmp = array_slice($this->db, $init, $postPerPage, true); + + // Restore the database because we delete the unpublished posts. + $this->restoreDB(); + + return $tmp; } return array(); @@ -390,7 +395,7 @@ class dbPosts extends dbJSON return $a['date']<$b['date']; } - // Return TRUE if there are new posts, FALSE otherwise. + // Return TRUE if there are new posts or orphan post deleted, FALSE otherwise. public function regenerateCli() { $db = $this->db; @@ -407,23 +412,23 @@ class dbPosts extends dbJSON $fields['status'] = CLI_STATUS; $fields['date'] = $currentDate; - $fields['username'] = 'admin'; + $fields['username'] = CLI_USERNAME; - // Recovery posts from the first level of directories + // Get all posts from the first level of directories. $tmpPaths = Filesystem::listDirectories(PATH_POSTS); foreach($tmpPaths as $directory) { - if(file_exists($directory.DS.'index.txt')) + // Check if the post have the index.txt file. + if(Sanitize::pathFile($directory.DS.'index.txt')) { // The key is the directory name. $key = basename($directory); - // All keys posts $allPosts[$key] = true; - // Create the new entry if not exist on DATABASE. + // Create the new entry if not exist inside the DATABASE. if(!isset($this->db[$key])) { - // New entry on database + // New entry on database with the default fields and values. $this->db[$key] = $fields; } diff --git a/bl-kernel/dbtags.class.php b/bl-kernel/dbtags.class.php index 157734e6..e338901d 100644 --- a/bl-kernel/dbtags.class.php +++ b/bl-kernel/dbtags.class.php @@ -64,7 +64,6 @@ class dbTags extends dbJSON public function reindexPosts($db) { $tagsIndex = array(); - $currentDate = Date::current(DB_DATE_FORMAT); // Foreach post foreach($db as $postKey=>$values) From bfa4756bf4418543e7f609d2a6c21290e3e640df Mon Sep 17 00:00:00 2001 From: dignajar Date: Tue, 9 Feb 2016 20:02:51 -0300 Subject: [PATCH 06/13] New Menu V8 for Images and improves on cover images --- .../admin/themes/default/css/default.css | 30 ++ bl-kernel/admin/themes/default/init.php | 325 +++++------------- bl-kernel/admin/views/edit-page.php | 3 + bl-kernel/admin/views/edit-post.php | 3 + bl-kernel/admin/views/new-page.php | 3 + bl-kernel/admin/views/new-post.php | 3 + bl-kernel/ajax/delete-file.php | 31 ++ bl-kernel/ajax/slug.php | 4 +- bl-kernel/helpers/theme.class.php | 1 + bl-kernel/js/bludit-cover-image.js | 96 ++++++ bl-kernel/js/bludit-images-v8.js | 68 ++++ bl-kernel/js/bludit-menu-v8.js | 144 ++++++++ bl-kernel/js/bludit-quick-images.js | 33 ++ bl-languages/en_US.json | 8 +- bl-plugins/simplemde/plugin.php | 10 +- install.php | 2 +- 16 files changed, 523 insertions(+), 241 deletions(-) create mode 100644 bl-kernel/ajax/delete-file.php create mode 100644 bl-kernel/js/bludit-cover-image.js create mode 100644 bl-kernel/js/bludit-images-v8.js create mode 100644 bl-kernel/js/bludit-menu-v8.js create mode 100644 bl-kernel/js/bludit-quick-images.js diff --git a/bl-kernel/admin/themes/default/css/default.css b/bl-kernel/admin/themes/default/css/default.css index af0da748..958f0b5c 100644 --- a/bl-kernel/admin/themes/default/css/default.css +++ b/bl-kernel/admin/themes/default/css/default.css @@ -229,6 +229,36 @@ button.delete-button:hover { font-size: 0; } +/* Bludit Menu v8 */ + +#bludit-menuV8 { + display: none; + z-index: 1020; + position: absolute; + overflow: hidden; + border: 1px solid #CCC; + background: #FFF; + color: #333; + border-radius: 2px; + list-style-type: none; + padding: 5px; + margin: 0; +} + +#bludit-menuV8 li { + padding: 8px 12px; + cursor: pointer; +} + +#bludit-menuV8 li:hover { + background-color: #2672ec; + color: #fff; +} + +#bludit-menuV8 li i { + margin-right: 10px; +} + /* ----------- BLUDIT QUICK IMAGES ----------- */ #bludit-quick-images { diff --git a/bl-kernel/admin/themes/default/init.php b/bl-kernel/admin/themes/default/init.php index 5b271e07..a42dbdb2 100644 --- a/bl-kernel/admin/themes/default/init.php +++ b/bl-kernel/admin/themes/default/init.php @@ -249,60 +249,44 @@ $(document).ready(function() { public static function bluditQuickImages() { + // Javascript code + include(PATH_JS.'bludit-quick-images.js'); + global $L; -$html = ''; -$html .= ' -
-
-'; + $html = ''; + $html .= ' +
+
+ '; -$thumbnailList = Filesystem::listFiles(PATH_UPLOADS_THUMBNAILS,'*','*',true); -array_splice($thumbnailList, THUMBNAILS_AMOUNT); -foreach($thumbnailList as $file) { - $filename = basename($file); - $html .= 'Thumbnail'; -} + $thumbnailList = Filesystem::listFiles(PATH_UPLOADS_THUMBNAILS,'*','*',true); + array_splice($thumbnailList, THUMBNAILS_AMOUNT); + foreach($thumbnailList as $file) { + $filename = basename($file); + $html .= 'Thumbnail'; + } -$html .= ' -
-'; + $html .= ' +
+ '; -if(empty($thumbnailList)) { - $html .= '
'.$L->g('There are no images').'
'; -} + $html .= '
'.$L->g('There are no images').'
'; -$html .= ' -'.$L->g('More images').' + $html .= ' + '.$L->g('More images').' -
-'; +
+ '; -$script = ' - -'; - - echo $html.$script; + echo $html; } public static function bluditCoverImage($coverImage="") { + // Javascript code + include(PATH_JS.'bludit-cover-image.js'); + global $L; $style = ''; @@ -310,225 +294,106 @@ function addQuickImages(filename) $style = 'background-image: url('.HTML_PATH_UPLOADS_THUMBNAILS.$coverImage.')'; } -$html = ''; -$html .= ' -
-
+ $html = ''; + $html .= ' +
+
- + -
-
'.$L->g('Cover image').'
-
'.$L->g('Drag and drop or click here').'
-
+
+
'.$L->g('Cover image').'
+
'.$L->g('Drag and drop or click here').'
+
-
-
-
+
+
+
-
-
0%
-
+
+
0%
+
-
-
-'; +
+
+ '; -$script = ' - -'; - echo $html.$script; + echo $html; } public static function bluditImagesV8() { + // Javascript code + include(PATH_JS.'bludit-images-v8.js'); + global $L; -$html = ''; -$html .= ' -
-
+ $html = ''; + $html .= ' +
+
-
+
-
-
'.$L->g('Upload image').'
-
'.$L->g('Drag and drop or click here').'
-
+
+
'.$L->g('Upload image').'
+
'.$L->g('Drag and drop or click here').'
+
-
-
0%
-
+
+
0%
+
-
+
-
-'; +
+ '; -$thumbnailList = Filesystem::listFiles(PATH_UPLOADS_THUMBNAILS,'*','*',true); -foreach($thumbnailList as $file) { - $filename = basename($file); - $html .= 'Thumbnail'; -} - -$html .= ' -
-'; - -if(empty($thumbnailList)) { - $html .= '
'.$L->g('There are no images').'
'; -} - -$html .= ' - - -
-
-'; - -$script = ' - -'; - echo $html.$script; + echo $html; } + + public static function profileUploader($username) { global $L; diff --git a/bl-kernel/admin/views/edit-page.php b/bl-kernel/admin/views/edit-page.php index a58d8413..95012756 100644 --- a/bl-kernel/admin/views/edit-page.php +++ b/bl-kernel/admin/views/edit-page.php @@ -102,6 +102,9 @@ echo '