From 767c421858db1e7bbfd022adcfc6905c0e07ea02 Mon Sep 17 00:00:00 2001 From: Diego Najar Date: Tue, 10 Jul 2018 19:53:53 +0200 Subject: [PATCH] fix when edit a category, log function improves, fix in login css --- bl-kernel/abstract/dbjson.class.php | 2 +- bl-kernel/abstract/dblist.class.php | 4 ++-- bl-kernel/admin/themes/booty/login.php | 5 ++--- bl-kernel/boot/variables.php | 5 ++++- bl-kernel/helpers/log.class.php | 16 +++++++++------- bl-kernel/helpers/text.class.php | 2 +- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/bl-kernel/abstract/dbjson.class.php b/bl-kernel/abstract/dbjson.class.php index 55a269a5..2d713927 100644 --- a/bl-kernel/abstract/dbjson.class.php +++ b/bl-kernel/abstract/dbjson.class.php @@ -58,7 +58,7 @@ class dbJSON // Returns the value from the field. public function getField($field) { - if(isset($this->db[$field])) { + if (isset($this->db[$field])) { return $this->db[$field]; } diff --git a/bl-kernel/abstract/dblist.class.php b/bl-kernel/abstract/dblist.class.php index 0cc953ea..f0cfb3b2 100644 --- a/bl-kernel/abstract/dblist.class.php +++ b/bl-kernel/abstract/dblist.class.php @@ -94,8 +94,8 @@ class dbList extends dbJSON // $args => 'name', 'oldkey', 'newKey', 'template' public function edit($args) { - if (isset($this->db[$args['newKey']])) { - Log::set(__METHOD__.LOG_SEP.'The new key already exists. Key: '.$args['newKey']); + if ( isset($this->db[$args['newKey']]) && ($args['newKey']!==$args['oldKey']) ) { + Log::set(__METHOD__.LOG_SEP.'The new key already exists. Key: '.$args['newKey'], LOG_TYPE_WARN); return false; } diff --git a/bl-kernel/admin/themes/booty/login.php b/bl-kernel/admin/themes/booty/login.php index 1b214766..16525e28 100644 --- a/bl-kernel/admin/themes/booty/login.php +++ b/bl-kernel/admin/themes/booty/login.php @@ -12,10 +12,9 @@ diff --git a/bl-kernel/boot/variables.php b/bl-kernel/boot/variables.php index f92696d0..4efc9d2b 100644 --- a/bl-kernel/boot/variables.php +++ b/bl-kernel/boot/variables.php @@ -5,8 +5,11 @@ If you are going to change some variable from here is recommended do it before the installation */ -// Log separator +// Log define('LOG_SEP', ' | '); +define('LOG_TYPE_INFO', '[INFO]'); +define('LOG_TYPE_WARN', '[WARN]'); +define('LOG_TYPE_ERROR', '[ERROR]'); // Protecting against Symlink attacks define('CHECK_SYMBOLIC_LINKS', TRUE); diff --git a/bl-kernel/helpers/log.class.php b/bl-kernel/helpers/log.class.php index db4fe992..c589ba17 100644 --- a/bl-kernel/helpers/log.class.php +++ b/bl-kernel/helpers/log.class.php @@ -2,18 +2,20 @@ class Log { - public static function set($text, $type=0) + public static function set($text, $type=LOG_TYPE_INFO) { + $messageType = 0; + if (is_array($text) ) { - error_log('------------------------', $type); - error_log('Array', $type); - error_log('------------------------', $type); + error_log('------------------------', $messageType); + error_log('Array', $messageType); + error_log('------------------------', $messageType); foreach ($text as $key=>$value) { - error_log($key.'=>'.$value, $type); + error_log($key.'=>'.$value, $messageType); } - error_log('------------------------', $type); + error_log('------------------------', $messageType); } - error_log('('.BLUDIT_VERSION.') ('.$_SERVER['REQUEST_URI'].') '.$text, $type); + error_log($type.' ['.BLUDIT_VERSION.'] ['.$_SERVER['REQUEST_URI'].'] '.$text, $messageType); } } diff --git a/bl-kernel/helpers/text.class.php b/bl-kernel/helpers/text.class.php index a300059b..3b491130 100644 --- a/bl-kernel/helpers/text.class.php +++ b/bl-kernel/helpers/text.class.php @@ -147,9 +147,9 @@ class Text { } $string = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $string); - $string = trim($string, '-'); $string = self::lowercase($string); $string = preg_replace("/[\/_|+ -]+/", $separator, $string); + $string = trim($string, '-'); return $string; }