From 39d409ccc77c42c3004b33d130c439473164f732 Mon Sep 17 00:00:00 2001 From: Diego Najar Date: Thu, 9 Aug 2018 23:15:52 +0200 Subject: [PATCH] bug fix: install plugins --- bl-kernel/abstract/plugin.class.php | 19 ++++++++++++------- .../admin/controllers/install-plugin.php | 4 +++- bl-plugins/api/plugin.php | 5 +++++ things-to-do | 10 +++++++++- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/bl-kernel/abstract/plugin.class.php b/bl-kernel/abstract/plugin.class.php index 09186108..6409a701 100644 --- a/bl-kernel/abstract/plugin.class.php +++ b/bl-kernel/abstract/plugin.class.php @@ -59,7 +59,7 @@ class Plugin { $this->metadata = json_decode($metadataString, true); // If the plugin is installed then get the database - if($this->installed()) { + if ($this->installed()) { $Tmp = new dbJSON($this->filenameDb); $this->db = $Tmp->db; } @@ -124,11 +124,10 @@ class Plugin { // (boolean) $html, TRUE returns the value sanitized, FALSE unsanitized public function getValue($field, $html=true) { - if( isset($this->db[$field]) ) { - if($html) { + if (isset($this->db[$field])) { + if ($html) { return $this->db[$field]; - } - else { + } else { return Sanitize::htmlDecode($this->db[$field]); } } @@ -220,9 +219,15 @@ class Plugin { // Create database $this->dbFields['position'] = $position; - $this->db = $this->dbFields; - return true; + // Sanitize default values to store in the file + foreach ($this->dbFields as $key=>$value) { + $value = Sanitize::html($value); + settype($value, gettype($this->dbFields[$key])); + $this->db[$key] = $value; + } + + return $this->save(); } public function uninstall() diff --git a/bl-kernel/admin/controllers/install-plugin.php b/bl-kernel/admin/controllers/install-plugin.php index 6c524e40..560c3a14 100644 --- a/bl-kernel/admin/controllers/install-plugin.php +++ b/bl-kernel/admin/controllers/install-plugin.php @@ -22,7 +22,9 @@ checkRole(array('admin')); // Main after POST // ============================================================================ $pluginClassName = $layout['parameters']; -activatePlugin($pluginClassName); +if (activatePlugin($pluginClassName)===false) { + Log::set('Fail when try to activate the plugin.', LOG_TYPE_ERROR); +} if (isset($plugins['all'][$pluginClassName])) { $plugin = $plugins['all'][$pluginClassName]; diff --git a/bl-plugins/api/plugin.php b/bl-plugins/api/plugin.php index 65c03104..eea151a4 100644 --- a/bl-plugins/api/plugin.php +++ b/bl-plugins/api/plugin.php @@ -23,6 +23,11 @@ class pluginAPI extends Plugin { $html .= $this->description(); $html .= ''; + $html .= '
'; + $html .= ''; + $html .= '

'.DOMAIN.'/api/{endpoint}

'; + $html .= '
'; + $html .= '
'; $html .= ''; $html .= ''; diff --git a/things-to-do b/things-to-do index dbcf9e05..98e85ad5 100644 --- a/things-to-do +++ b/things-to-do @@ -32,4 +32,12 @@ Things to do: -- Resize image - pagex.class.php --- improve tags methods, compare with category \ No newline at end of file +-- improve tags methods, compare with category + + +---- + +curl -vvv \ + -X GET \ + -G "http://localhost:8000/api/pages" \ + -d "token=80a09ba055b73f68e3c9e7c9ea12b432" \ No newline at end of file