diff --git a/bl-kernel/abstract/plugin.class.php b/bl-kernel/abstract/plugin.class.php index 04e2cc27..8c1113eb 100644 --- a/bl-kernel/abstract/plugin.class.php +++ b/bl-kernel/abstract/plugin.class.php @@ -263,7 +263,6 @@ class Plugin { $this->db[$key] = $value; } } - return $this->save(); } diff --git a/bl-kernel/admin/controllers/install-plugin.php b/bl-kernel/admin/controllers/install-plugin.php index 3d002046..cfabd262 100644 --- a/bl-kernel/admin/controllers/install-plugin.php +++ b/bl-kernel/admin/controllers/install-plugin.php @@ -30,6 +30,12 @@ $pluginClassName = $layout['parameters']; if( isset($plugins['all'][$pluginClassName]) ) { $plugin = $plugins['all'][$pluginClassName]; + // Plugins for Bludit PRO + $blackList = array('pluginTimeMachine', 'pluginRemoteContent'); + if( in_array($pluginClassName, $blackList) && !defined('BLUDIT_PRO') ) { + Redirect::page('plugins'); + } + // Install plugin if( $plugin->install() ) { // Add to syslog diff --git a/bl-kernel/admin/views/edit-user.php b/bl-kernel/admin/views/edit-user.php index be5d259d..fe7e7d5e 100644 --- a/bl-kernel/admin/views/edit-user.php +++ b/bl-kernel/admin/views/edit-user.php @@ -114,6 +114,16 @@ if($Login->role()==='admin') { '; + HTML::legend(array('value'=>$L->g('Authentication Token'))); + + HTML::formInputText(array( + 'name'=>'tokenAuth', + 'label'=>$L->g('Token'), + 'value'=>$User->tokenAuth(), + 'class'=>'uk-width-1-2 uk-form-medium', + 'tip'=>$L->g('This token is similar to your password, do not share this token.') + )); + HTML::legend(array('value'=>$L->g('Status'))); HTML::formInputText(array( diff --git a/bl-kernel/dbusers.class.php b/bl-kernel/dbusers.class.php index 75bbd51a..929f7505 100644 --- a/bl-kernel/dbusers.class.php +++ b/bl-kernel/dbusers.class.php @@ -41,6 +41,60 @@ class dbUsers extends dbJSON return isset($this->db[$username]); } + // Create a new user + public function add($args) + { + $dataForDb = array(); + + // Verify arguments with the database fields. + foreach($this->dbFields as $field=>$options) + { + // If the user send the field. + if( isset($args[$field]) ) + { + // Sanitize if will be saved on database. + if( !$options['inFile'] ) { + $tmpValue = Sanitize::html($args[$field]); + } + else { + $tmpValue = $args[$field]; + } + } + // Uses a default value for the field. + else + { + $tmpValue = $options['value']; + } + + // Set type + settype($tmpValue, gettype($options['value'])); + + // Save on database + $dataForDb[$field] = $tmpValue; + } + + // Check if the user alredy exists. + if( $this->userExists($dataForDb['username']) ) { + return false; + } + + // Current date. + $dataForDb['registered'] = Date::current(DB_DATE_FORMAT); + + // Password + $dataForDb['salt'] = Text::randomText(SALT_LENGTH); + $dataForDb['password'] = sha1($dataForDb['password'].$dataForDb['salt']); + + // Save the database + $this->db[$dataForDb['username']] = $dataForDb; + if( $this->save() === false ) { + Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.'); + return false; + } + + return true; + } + // Set the parameters of a user public function set($args) { @@ -170,57 +224,6 @@ class dbUsers extends dbJSON - public function add($args) - { - $dataForDb = array(); - // Verify arguments with the database fields. - foreach($this->dbFields as $field=>$options) - { - // If the user send the field. - if( isset($args[$field]) ) - { - // Sanitize if will be saved on database. - if( !$options['inFile'] ) { - $tmpValue = Sanitize::html($args[$field]); - } - else { - $tmpValue = $args[$field]; - } - } - // Uses a default value for the field. - else - { - $tmpValue = $options['value']; - } - - // Set type - settype($tmpValue, gettype($options['value'])); - - // Save on database - $dataForDb[$field] = $tmpValue; - } - - // Check if the user alredy exists. - if( $this->userExists($dataForDb['username']) ) { - return false; - } - - // Current date. - $dataForDb['registered'] = Date::current(DB_DATE_FORMAT); - - // Password - $dataForDb['salt'] = Text::randomText(SALT_LENGTH); - $dataForDb['password'] = sha1($dataForDb['password'].$dataForDb['salt']); - - // Save the database - $this->db[$dataForDb['username']] = $dataForDb; - if( $this->save() === false ) { - Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.'); - return false; - } - - return true; - } } diff --git a/bl-kernel/user.class.php b/bl-kernel/user.class.php index 47fe4edd..b6ab25f1 100644 --- a/bl-kernel/user.class.php +++ b/bl-kernel/user.class.php @@ -36,6 +36,11 @@ class User return $this->getField('lastName'); } + public function tokenAuth() + { + return $this->getField('tokenAuth'); + } + public function role() { return $this->getField('role'); diff --git a/bl-plugins/categories/plugin.php b/bl-plugins/categories/plugin.php index ed5dc631..8ffae222 100644 --- a/bl-plugins/categories/plugin.php +++ b/bl-plugins/categories/plugin.php @@ -25,8 +25,8 @@ class pluginCategories extends Plugin { $html .= '
'; $html .= ''; $html .= ''; $html .= ''.$Language->get('Show the categories without content').''; $html .= '
'; diff --git a/bl-plugins/simplemde/plugin.php b/bl-plugins/simplemde/plugin.php index ccfe3218..35c4a442 100644 --- a/bl-plugins/simplemde/plugin.php +++ b/bl-plugins/simplemde/plugin.php @@ -14,8 +14,8 @@ class pluginsimpleMDE extends Plugin { $this->dbFields = array( 'tabSize'=>'2', 'toolbar'=>'"bold", "italic", "heading", "|", "quote", "unordered-list", "|", "link", "image", "code", "horizontal-rule", "|", "preview", "side-by-side", "fullscreen", "guide"', - 'autosave'=>0, - 'spellChecker'=>0 + 'autosave'=>true, + 'spellChecker'=>true ); } @@ -34,15 +34,19 @@ class pluginsimpleMDE extends Plugin { $html .= ''; $html .= '
'; - $html .= ''; - $html .= 'getDbField('autosave')?'checked':'').'>'; - $html .= ''; + $html .= ''; + $html .= ''; $html .= '
'; $html .= '
'; - $html .= ''; - $html .= 'getDbField('spellChecker')?'checked':'').'>'; - $html .= ''; + $html .= ''; + $html .= ''; $html .= '
'; return $html; diff --git a/bl-plugins/version/plugin.php b/bl-plugins/version/plugin.php index d263f683..399c1b51 100644 --- a/bl-plugins/version/plugin.php +++ b/bl-plugins/version/plugin.php @@ -39,7 +39,7 @@ class pluginVersion extends Plugin { if( version_compare(Session::get('latestVersion'), BLUDIT_VERSION, '>') ) { $html = '
New version available
'; } else { - if(BLUDIT_PRO) { + if(defined('BLUDIT_PRO')) { $html = '
Bludit PRO v'.BLUDIT_VERSION.'
'; } else { $html = '
Bludit v'.BLUDIT_VERSION.'Upgrade to Bludit PRO
';