diff --git a/bl-kernel/admin/controllers/edit-content.php b/bl-kernel/admin/controllers/edit-content.php
index d442ba8a..34326cfa 100644
--- a/bl-kernel/admin/controllers/edit-content.php
+++ b/bl-kernel/admin/controllers/edit-content.php
@@ -5,13 +5,21 @@
// ============================================================================
if (!checkRole(array('admin','moderator'), false)) {
- $pageKey = isset($_POST['key']) ? $_POST['key'] : $layout['parameters'];
- $page = buildPage($pageKey);
- if (!$page || $page->username()!==$login->username()) {
+ try {
+ $pageKey = isset($_POST['key']) ? $_POST['key'] : $layout['parameters'];
+ $page = new PageX($pageKey);
+ } catch (Exception $e) {
+ Alert::set($Language->g('You do not have sufficient permissions'));
+ Redirect::page('dashboard');
+ }
+
+ if ($page->username()!==$login->username()) {
+ // Add to syslog
$syslog->add(array(
'dictionaryKey'=>'access-deny',
'notes'=>$login->username()
));
+
Alert::set($Language->g('You do not have sufficient permissions'));
Redirect::page('dashboard');
}
@@ -30,7 +38,7 @@ if (!checkRole(array('admin','moderator'), false)) {
// ============================================================================
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
- if ($_POST['status']==='delete') {
+ if ($_POST['type']==='delete') {
if (deletePage($_POST['key'])) {
Alert::set( $Language->g('The changes have been saved') );
}
diff --git a/bl-kernel/admin/controllers/install-plugin.php b/bl-kernel/admin/controllers/install-plugin.php
index afcbe2f8..6c524e40 100644
--- a/bl-kernel/admin/controllers/install-plugin.php
+++ b/bl-kernel/admin/controllers/install-plugin.php
@@ -23,4 +23,15 @@ checkRole(array('admin'));
// ============================================================================
$pluginClassName = $layout['parameters'];
activatePlugin($pluginClassName);
+
+if (isset($plugins['all'][$pluginClassName])) {
+ $plugin = $plugins['all'][$pluginClassName];
+} else {
+ Redirect::page('plugins');
+}
+
+if (method_exists($plugin, 'form')) {
+ Redirect::page('configure-plugin/'.$pluginClassName);
+}
+
Redirect::page('plugins#'.$pluginClassName);
diff --git a/bl-kernel/admin/views/about.php b/bl-kernel/admin/views/about.php
index b728f7d1..db9e91a8 100644
--- a/bl-kernel/admin/views/about.php
+++ b/bl-kernel/admin/views/about.php
@@ -31,6 +31,11 @@ echo '
Bludit Build Number | ';
echo ''.BLUDIT_BUILD.' | ';
echo '';
+echo '';
+echo 'Bludit Developers | ';
+echo ' | ';
+echo '
';
+
echo '
diff --git a/bl-kernel/admin/views/content.php b/bl-kernel/admin/views/content.php
index 7dcf0955..66d3408d 100644
--- a/bl-kernel/admin/views/content.php
+++ b/bl-kernel/admin/views/content.php
@@ -2,7 +2,7 @@
echo Bootstrap::pageTitle(array('title'=>$L->g('Content'), 'icon'=>'cog'));
-function table($status) {
+function table($type) {
global $url;
global $Language;
global $published;
@@ -11,7 +11,7 @@ function table($status) {
global $static;
global $sticky;
- if ($status=='published') {
+ if ($type=='published') {
$list = $published;
if (empty($list)) {
echo '';
@@ -19,7 +19,7 @@ function table($status) {
echo '
';
return false;
}
- } elseif ($status=='draft') {
+ } elseif ($type=='draft') {
$list = $drafts;
if (empty($list)) {
echo '';
@@ -27,7 +27,7 @@ function table($status) {
echo '
';
return false;
}
- } elseif ($status=='scheduled') {
+ } elseif ($type=='scheduled') {
$list = $scheduled;
if (empty($list)) {
echo '';
@@ -35,7 +35,7 @@ function table($status) {
echo '
';
return false;
}
- } elseif ($status=='static') {
+ } elseif ($type=='static') {
$list = $static;
if (empty($list)) {
echo '';
@@ -43,7 +43,7 @@ function table($status) {
echo '
';
return false;
}
- } elseif ($status=='sticky') {
+ } elseif ($type=='sticky') {
$list = $sticky;
if (empty($list)) {
echo '';
@@ -59,7 +59,7 @@ function table($status) {
'.$Language->g('Title').' |
'.$Language->g('URL').' |
- '.( ((ORDER_BY=='position') || ($status!='published'))?$Language->g('Position'):$Language->g('Creation date')).' |
+ '.( ((ORDER_BY=='position') || ($type!='published'))?$Language->g('Position'):$Language->g('Creation date')).' |
@@ -67,9 +67,9 @@ function table($status) {
if (ORDER_BY=='position') {
foreach ($list as $pageKey) {
- $page = buildPage($pageKey);
- if ($page) {
- if (!$page->isChild() || $status!='published') {
+ try {
+ $page = new PageX($pageKey);
+ if (!$page->isChild() || $type!='published') {
echo '
'
@@ -102,12 +102,14 @@ function table($status) {
}
}
}
+ } catch (Exception $e) {
+ // Continue
}
}
} else {
foreach ($list as $pageKey) {
- $page = buildPage($pageKey);
- if ($page) {
+ try {
+ $page = new PageX($pageKey);
echo '';
echo '
'
@@ -118,9 +120,11 @@ function table($status) {
$friendlyURL = Text::isEmpty($url->filters('page')) ? '/'.$page->key() : '/'.$url->filters('page').'/'.$page->key();
echo ' | '.$friendlyURL.' | ';
- echo ''.( ((ORDER_BY=='position') || ($status!='published'))?$page->position():$page->dateRaw(ADMIN_PANEL_DATE_FORMAT) ).' | ';
+ echo ''.( ((ORDER_BY=='position') || ($type!='published'))?$page->position():$page->dateRaw(ADMIN_PANEL_DATE_FORMAT) ).' | ';
echo ' ';
+ } catch (Exception $e) {
+ // Continue
}
}
}
diff --git a/bl-kernel/ajax/save-as-draft.php b/bl-kernel/ajax/save-as-draft.php
index f242e308..841748be 100644
--- a/bl-kernel/ajax/save-as-draft.php
+++ b/bl-kernel/ajax/save-as-draft.php
@@ -34,7 +34,7 @@ $page = array(
'slug'=>$autosaveUUID,
'title'=>$title.' [ Autosave ] ',
'content'=>$content,
- 'status'=>'draft'
+ 'type'=>'draft'
);
// Get the page key by the UUID
diff --git a/bl-kernel/dbpages.class.php b/bl-kernel/dbpages.class.php
index 84101cb7..3ee2975e 100644
--- a/bl-kernel/dbpages.class.php
+++ b/bl-kernel/dbpages.class.php
@@ -39,7 +39,7 @@ class dbPages extends dbJSON {
{
$row = array();
- // Check values on args or set default values
+ // Check values on args and set default values if not exists
foreach ($this->dbFields as $field=>$value) {
if (isset($args[$field])) {
// Sanitize if will be stored on database
@@ -52,42 +52,50 @@ class dbPages extends dbJSON {
$row[$field] = $finalValue;
}
- // Tags
- if (!empty($args['tags'])) {
- $row['tags'] = $this->generateTags($args['tags']);
- } else {
- $row['tags'] = array();
+ // Content
+ // This variable is not belong to the database so is not defined in $row
+ $contentRaw = $args['content'];
+
+ // Parent
+ // This variable is not belong to the database so is not defined in $row
+ $parent = '';
+ if (!empty($args['parent'])) {
+ $parent = $args['parent'];
}
// Slug from the title or the content
+ // This variable is not belong to the database so is not defined in $row
if (empty($args['slug'])) {
- if (!empty($args['title'])) {
- $args['slug'] = $this->generateSlug($args['title']);
+ if (!empty($row['title'])) {
+ $slug = $this->generateSlug($row['title']);
} else {
- $args['slug'] = $this->generateSlug($args['content']);
+ $slug = $this->generateSlug($contentRaw);
}
- }
-
- // Parent
- if (!isset($args['parent'])) {
- $row['parent'] = '';
+ } else {
+ $slug = $args['slug'];
}
// Generate key
- $key = $this->generateKey($args['slug'], $args['parent']);
+ // This variable is not belong to the database so is not defined in $row
+ $key = $this->generateKey($slug, $parent);
// Generate UUID
- if (empty($args['uuid'])) {
+ if (empty($row['uuid'])) {
$row['uuid'] = $this->generateUUID();
}
+ // Tags
+ if (!empty($row['tags'])) {
+ $row['tags'] = $this->generateTags($args['tags']);
+ }
+
// Validate date
- if (!Valid::date($args['date'], DB_DATE_FORMAT)) {
+ if (!Valid::date($row['date'], DB_DATE_FORMAT)) {
$row['date'] = Date::current(DB_DATE_FORMAT);
}
// Schedule page
- if (($args['date']>Date::current(DB_DATE_FORMAT)) && ($args['type']=='published')) {
+ if (($row['date']>Date::current(DB_DATE_FORMAT)) && ($row['type']=='published')) {
$row['type'] = 'scheduled';
}
@@ -99,7 +107,7 @@ class dbPages extends dbJSON {
}
// Create the index.txt and save the file
- if( file_put_contents(PATH_PAGES.$key.DS.FILENAME, $args['content']) === false ) {
+ if( file_put_contents(PATH_PAGES.$key.DS.FILENAME, $contentRaw) === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the content in the file ['.FILENAME.']',LOG_TYPE_ERROR);
return false;
}
@@ -137,56 +145,73 @@ class dbPages extends dbJSON {
$row[$field] = $finalValue;
}
- // Tags
- if (!empty($args['tags'])) {
- $row['tags'] = $this->generateTags($args['tags']);
- } else {
- $row['tags'] = array();
- }
+ // Content
+ // This variable is not belong to the database so is not defined in $row
+ $contentRaw = $args['content'];
// Parent
- if (!isset($args['parent'])) {
- $row['parent'] = '';
+ // This variable is not belong to the database so is not defined in $row
+ $parent = '';
+ if (!empty($args['parent'])) {
+ $parent = $args['parent'];
}
- $newKey = $this->generateKey($args['slug'], $row['parent'], false, $args['key']);
+ // Old key
+ // This variable is not belong to the database so is not defined in $row
+ $key = $args['key'];
+
+ // Slug from the title or the content
+ // This variable is not belong to the database so is not defined in $row
+ if (empty($args['slug'])) {
+ if (!empty($row['title'])) {
+ $slug = $this->generateSlug($row['title']);
+ } else {
+ $slug = $this->generateSlug($contentRaw);
+ }
+ } else {
+ $slug = $args['slug'];
+ }
+
+ // New key
+ // This variable is not belong to the database so is not defined in $row
+ $newKey = $this->generateKey($slug, $parent, false, $key);
// If the page is draft then the created time is the current
- if ($this->db[$args['key']]['type']=='draft') {
+ if ($this->db[$key]['type']=='draft') {
$row['date'] = Date::current(DB_DATE_FORMAT);
- } elseif (!Valid::date($args['date'], DB_DATE_FORMAT)) {
- $row['date'] = $this->db[$args['key']]['date'];
+ } elseif (!Valid::date($row['date'], DB_DATE_FORMAT)) {
+ $row['date'] = $this->db[$key]['date'];
}
// Modified date
$row['dateModified'] = Date::current(DB_DATE_FORMAT);
// Schedule page
- if (($args['date']>Date::current(DB_DATE_FORMAT)) && ($args['type']=='published')) {
+ if (($row['date']>Date::current(DB_DATE_FORMAT)) && ($row['type']=='published')) {
$row['type'] = 'scheduled';
}
if ($climode===false) {
// Move the directory from old key to new key.
- if ($newKey!==$args['key']) {
- if( Filesystem::mv(PATH_PAGES.$args['key'], PATH_PAGES.$newKey) === false ) {
+ if ($newKey!==$key) {
+ if( Filesystem::mv(PATH_PAGES.$key, PATH_PAGES.$newKey) === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to move the directory to '.PATH_PAGES.$newKey);
return false;
}
}
// Make the index.txt and save the file.
- if (file_put_contents(PATH_PAGES.$newKey.DS.FILENAME, $args['content'])===false) {
+ if (file_put_contents(PATH_PAGES.$newKey.DS.FILENAME, $contentRaw)===false) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to put the content in the file '.FILENAME);
return false;
}
}
// Remove the old key
- unset( $this->db[$args['key']] );
+ unset( $this->db[$key] );
// Reindex Orphan Children
- $this->reindexChildren($args['key'], $newKey);
+ $this->reindexChildren($key, $newKey);
// Checksum MD5
$row['md5file'] = md5_file(PATH_PAGES.$newKey.DS.FILENAME);
diff --git a/bl-kernel/functions.php b/bl-kernel/functions.php
index fe9c043f..bbfc311c 100644
--- a/bl-kernel/functions.php
+++ b/bl-kernel/functions.php
@@ -506,14 +506,11 @@ function deletePage($key) {
global $dbPages;
global $syslog;
- if( $dbPages->delete($key) ) {
+ if ($dbPages->delete($key)) {
// Call the plugins after page deleted
Theme::plugins('afterPageDelete');
- // Re-index categories
reindexCategories();
-
- // Re-index tags
reindextags();
// Add to syslog
@@ -533,10 +530,12 @@ function editUser($args) {
global $syslog;
if ($dbUsers->set($args)) {
+ // Add to syslog
$syslog->add(array(
'dictionaryKey'=>'user-edited',
'notes'=>$args['username']
));
+
return true;
}
@@ -563,10 +562,12 @@ function disableUser($args) {
// Disable the user
if ($dbUsers->disableUser($username)) {
+ // Add to syslog
$syslog->add(array(
'dictionaryKey'=>'user-disabled',
'notes'=>$username
));
+
return true;
}
@@ -604,10 +605,12 @@ function deleteUser($args) {
}
if ($dbUsers->delete($username)) {
+ // Add to syslog
$syslog->add(array(
'dictionaryKey'=>'user-deleted',
'notes'=>$username
));
+
return true;
}
@@ -746,10 +749,12 @@ function changeUserPassword($args) {
}
if ($dbUsers->setPassword(array('username'=>$username, 'password'=>$newPassword))) {
+ // Add to syslog
$syslog->add(array(
'dictionaryKey'=>'user-password-changed',
'notes'=>$username
));
+
Alert::set($Language->g('The changes have been saved'), ALERT_STATUS_OK);
return true;
}
@@ -769,10 +774,12 @@ function checkRole($allowRoles, $redirect=true) {
}
if ($redirect) {
+ // Add to syslog
$syslog->add(array(
'dictionaryKey'=>'access-deny',
'notes'=>$login->username()
));
+
Alert::set($Language->g('You do not have sufficient permissions'));
Redirect::page('dashboard');
}
@@ -792,6 +799,7 @@ function createCategory($category) {
}
if ($dbCategories->add(array('name'=>$category))) {
+ // Add to syslog
$syslog->add(array(
'dictionaryKey'=>'new-category-created',
'notes'=>$category
@@ -826,6 +834,7 @@ function editCategory($args) {
// Change the category key in the pages database
$dbPages->changeCategory($args['oldKey'], $newCategoryKey);
+ // Add to syslog
$syslog->add(array(
'dictionaryKey'=>'category-edited',
'notes'=>$newCategoryKey
@@ -845,6 +854,7 @@ function deleteCategory($args) {
// Remove the category from the pages ? or keep it if the user want to recovery the category ?
+ // Add to syslog
$syslog->add(array(
'dictionaryKey'=>'category-deleted',
'notes'=>$args['oldCategoryKey']
diff --git a/bl-plugins/disqus/plugin.php b/bl-plugins/disqus/plugin.php
index ff660a26..fbe20198 100644
--- a/bl-plugins/disqus/plugin.php
+++ b/bl-plugins/disqus/plugin.php
@@ -54,8 +54,8 @@ class pluginDisqus extends Plugin {
if ( !$url->notFound() &&
( $url->whereAmI()=='page' &&
- (($this->getDbField('enablePosts') && $page->status()=='published') ||
- ($this->getDbField('enablePages') && $page->status()=='static'))
+ (($this->getDbField('enablePosts') && $page->published()) ||
+ ($this->getDbField('enablePages') && $page->static()))
) &&
$page->allowComments() ) {
$html = '';
diff --git a/install.php b/install.php
index cedec3ce..c3b464ea 100644
--- a/install.php
+++ b/install.php
@@ -275,7 +275,7 @@ function install($adminPassword, $timezone)
}
// Directories for initial plugins
- $pluginsToInstall = array('simplemde', 'tags', 'about', 'simple-stats');
+ $pluginsToInstall = array('simplemde', 'tags', 'about', 'simple-stats', 'robots');
foreach ($pluginsToInstall as $plugin) {
if (!mkdir(PATH_PLUGINS_DATABASES.$plugin, DIR_PERMISSIONS, true)) {
$errorText = 'Error when trying to created the directory=>'.PATH_PLUGINS_DATABASES.$plugin;
@@ -497,6 +497,17 @@ function install($adminPassword, $timezone)
LOCK_EX
);
+ // File plugins/robots/db.php
+ file_put_contents(
+ PATH_PLUGINS_DATABASES.'robots'.DS.'db.php',
+ $dataHead.json_encode(
+ array(
+ 'position'=>1
+ ),
+ JSON_PRETTY_PRINT),
+ LOCK_EX
+ );
+
return true;
}
|