diff --git a/www/lib/CoreLibs/ACL/Login.inc b/www/lib/CoreLibs/ACL/Login.inc index e71c7ee6..1804d9d8 100644 --- a/www/lib/CoreLibs/ACL/Login.inc +++ b/www/lib/CoreLibs/ACL/Login.inc @@ -845,63 +845,77 @@ class Login extends \CoreLibs\DB\IO private function loginPrintLogin() { if (!$this->permission_okay) { - // set the templates now - $this->loginSetTemplates(); - // if there is a global logout target ... - if (file_exists($this->logout_target) && $this->logout_target) { - $LOGOUT_TARGET = $this->logout_target; + // get global AJAX page trigger + // if true, return error ajax + global $AJAX_PAGE; + if ($AJAX_PAGE === true) { + $data = array ( + 'status' => 'error', + 'error_code' => $this->loging_error, + 'msg' => array ( + 'level' => 'error', + 'str' => $this->l->__('Login necessary') + ) + ); + $html_string = json_encode($data); } else { - $LOGOUT_TARGET = ""; - } - - $html_string = $this->login_template['template']; - - // if password change is okay - if ($this->password_change) { - $html_string_password_change = $this->login_template['password_change']; - - // pre change the data in the PASSWORD_CHANGE_DIV first - foreach ($this->login_template['strings'] as $string => $data) { - if ($data) { - $html_string_password_change = str_replace('{'.$string.'}', $data, $html_string_password_change); - } + // set the templates now + $this->loginSetTemplates(); + // if there is a global logout target ... + if (file_exists($this->logout_target) && $this->logout_target) { + $LOGOUT_TARGET = $this->logout_target; + } else { + $LOGOUT_TARGET = ""; } + + $html_string = $this->login_template['template']; + + // if password change is okay + if ($this->password_change) { + $html_string_password_change = $this->login_template['password_change']; + + // pre change the data in the PASSWORD_CHANGE_DIV first + foreach ($this->login_template['strings'] as $string => $data) { + if ($data) { + $html_string_password_change = str_replace('{'.$string.'}', $data, $html_string_password_change); + } + } + // print error messagae + if ($this->login_error) { + $html_string_password_change = str_replace('{ERROR_MSG}', $this->login_error_msg[$this->login_error].'
', $html_string_password_change); + } else { + $html_string_password_change = str_replace('{ERROR_MSG}', '
', $html_string_password_change); + } + // if pw change action, show the float again + if ($this->change_password && !$this->password_change_ok) { + $html_string_password_change = str_replace('{PASSWORD_CHANGE_SHOW}', '', $html_string_password_change); + } else { + $html_string_password_change = str_replace('{PASSWORD_CHANGE_SHOW}', '', $html_string_password_change); + } + $this->login_template['strings']['PASSWORD_CHANGE_DIV'] = $html_string_password_change; + } + + // put in the logout redirect string + if ($this->logout && $LOGOUT_TARGET) { + $html_string = str_replace('{LOGOUT_TARGET}', '', $html_string); + } else { + $html_string = str_replace('{LOGOUT_TARGET}', '', $html_string); + } + // print error messagae if ($this->login_error) { - $html_string_password_change = str_replace('{ERROR_MSG}', $this->login_error_msg[$this->login_error].'
', $html_string_password_change); + $html_string = str_replace('{ERROR_MSG}', $this->login_error_msg[$this->login_error].'
', $html_string); + } elseif ($this->password_change_ok && $this->password_change) { + $html_string = str_replace('{ERROR_MSG}', $this->login_error_msg[300].'
', $html_string); } else { - $html_string_password_change = str_replace('{ERROR_MSG}', '
', $html_string_password_change); + $html_string = str_replace('{ERROR_MSG}', '
', $html_string); } - // if pw change action, show the float again - if ($this->change_password && !$this->password_change_ok) { - $html_string_password_change = str_replace('{PASSWORD_CHANGE_SHOW}', '', $html_string_password_change); - } else { - $html_string_password_change = str_replace('{PASSWORD_CHANGE_SHOW}', '', $html_string_password_change); + + // create the replace array context + foreach ($this->login_template['strings'] as $string => $data) { + $html_string = str_replace('{'.$string.'}', $data, $html_string); } - $this->login_template['strings']['PASSWORD_CHANGE_DIV'] = $html_string_password_change; } - - // put in the logout redirect string - if ($this->logout && $LOGOUT_TARGET) { - $html_string = str_replace('{LOGOUT_TARGET}', '', $html_string); - } else { - $html_string = str_replace('{LOGOUT_TARGET}', '', $html_string); - } - - // print error messagae - if ($this->login_error) { - $html_string = str_replace('{ERROR_MSG}', $this->login_error_msg[$this->login_error].'
', $html_string); - } elseif ($this->password_change_ok && $this->password_change) { - $html_string = str_replace('{ERROR_MSG}', $this->login_error_msg[300].'
', $html_string); - } else { - $html_string = str_replace('{ERROR_MSG}', '
', $html_string); - } - - // create the replace array context - foreach ($this->login_template['strings'] as $string => $data) { - $html_string = str_replace('{'.$string.'}', $data, $html_string); - } - // return the created HTML here return $html_string; } // if permission is 0 then print out login diff --git a/www/lib/CoreLibs/Basic.inc b/www/lib/CoreLibs/Basic.inc index cf281eef..29b93a53 100644 --- a/www/lib/CoreLibs/Basic.inc +++ b/www/lib/CoreLibs/Basic.inc @@ -1238,7 +1238,7 @@ class Basic // DESC : calculates the bytes based on a string with nnG, nnM, etc public static function stringByteFormat($number) { - $number = trim($number); + $number = (int)trim($number); $last = strtolower($number[strlen($number) - 1]); switch ($last) { case 't': @@ -2266,6 +2266,15 @@ class Basic } } + // METHOD: removeLB + // PARAMS: string, optional replace character + // RETURN: string with line breaks removed + // DESC : strips out all line breaks or replaced with given string + public function removeLB($string, $replace = ' ') + { + return str_replace(array("\r", "\n"), $replace, $string); + } + // METHOD: setFormToken // PARAMS: session name, if not set then default is form_token // RETURN: form token diff --git a/www/lib/CoreLibs/DB/Extended/ArrayIO.inc b/www/lib/CoreLibs/DB/Extended/ArrayIO.inc index 1d2e2fcf..4e87f729 100644 --- a/www/lib/CoreLibs/DB/Extended/ArrayIO.inc +++ b/www/lib/CoreLibs/DB/Extended/ArrayIO.inc @@ -410,6 +410,7 @@ class ArrayIO extends \CoreLibs\DB\IO } $q_data .= $_value; } elseif ($this->table_array[$column]['bool']) { + // boolean storeage (reverse check on ifset) $q_data .= "'".$this->dbBoolean($this->table_array[$column]["value"], true)."'"; } elseif ($this->table_array[$column]["interval"]) { // for interval we check if no value, then we set null diff --git a/www/lib/CoreLibs/DB/IO.inc b/www/lib/CoreLibs/DB/IO.inc index 21d08f1c..81ccd06d 100644 --- a/www/lib/CoreLibs/DB/IO.inc +++ b/www/lib/CoreLibs/DB/IO.inc @@ -124,7 +124,7 @@ * - closes db connection and writes error_msg to global error_msg * db_cursor_pos($query) * - returns the current position the db_return -* $array_of_hashes db_show_table_meta_Data($table_name) +* $array_of_hashes db_show_table_meta_data($table_name) * - returns an hashed array of table column data * function db_prepare($stm_name, $query) * - prepares a query with the given stm name, returns false on error @@ -317,11 +317,11 @@ class IO extends \CoreLibs\Basic $this->db_user = $db_config['db_user'] ?? ''; $this->db_pwd = $db_config['db_pass'] ?? ''; $this->db_host = $db_config['db_host'] ?? ''; - $this->db_port = array_key_exists('db_port', $db_config) ? $db_config['db_port'] : '5432'; - $this->db_schema = array_key_exists('db_schema', $db_config) ? $db_config['db_schema'] : ''; // do not set to 'public' if not set, because the default is already public - $this->db_encoding = array_key_exists('db_encoding', $db_config) ? $db_config['db_encoding'] : ''; + $this->db_port = !empty($db_config['db_port']) ? $db_config['db_port'] : '5432'; + $this->db_schema = !empty($db_config['db_schema']) ? $db_config['db_schema'] : ''; // do not set to 'public' if not set, because the default is already public + $this->db_encoding = !empty($db_config['db_encoding']) ? $db_config['db_encoding'] : ''; $this->db_type = $db_config['db_type'] ?? ''; - $this->db_ssl = array_key_exists('db_ssl', $db_config) ? $db_config['db_ssl'] : 'allow'; + $this->db_ssl = !empty($db_config['db_ssl']) ? $db_config['db_ssl'] : 'allow'; // set the target encoding to the DEFAULT_ENCODING if it is one of them: EUC, Shift_JIS, UTF-8 // @ the moment set only from outside @@ -938,7 +938,7 @@ class IO extends \CoreLibs\Basic // DESC : returns the current set client encoding from the connected DB public function dbGetEncoding() { - return $this->db_return_row('SHOW client_encoding')['client_encoding']; + return $this->dbReturnRow('SHOW client_encoding')['client_encoding']; } // METHOD: dbInfo