Bug fixes for Language and DB\IO class

language class needs to have l var set as public
db\io convert encoding function needs to work with false method
parameters as the return can be false and needs a clean pass through in
this case
This commit is contained in:
Clemens Schwaighofer
2019-09-12 16:53:09 +09:00
parent b25f280849
commit 9564f03504
3 changed files with 14 additions and 10 deletions

View File

@@ -262,6 +262,7 @@ if (defined('DEBUG') && DEBUG == false) {
$DEBUG_ALL = 1; $DEBUG_ALL = 1;
$PRINT_ALL = 1; $PRINT_ALL = 1;
$DB_DEBUG = 1; $DB_DEBUG = 1;
$ENABLE_ERROR_HANDLING = 0;
} }
// read auto loader // read auto loader

View File

@@ -106,7 +106,7 @@ class Login extends \CoreLibs\DB\IO
public $default_acl_list = array (); public $default_acl_list = array ();
// language // language
private $l; public $l;
// METHOD: login // METHOD: login
// PARAMS: db_config -> array for logging in to DB where edit_users tables are // PARAMS: db_config -> array for logging in to DB where edit_users tables are
@@ -1173,7 +1173,7 @@ EOM;
$q .= "ip, user_agent, referer, script_name, query_string, server_name, http_host, http_accept, http_accept_charset, http_accept_encoding, session_id, "; $q .= "ip, user_agent, referer, script_name, query_string, server_name, http_host, http_accept, http_accept_charset, http_accept_encoding, session_id, ";
$q .= "action, action_id, action_yes, action_flag, action_menu, action_loaded, action_value, action_error) "; $q .= "action, action_id, action_yes, action_flag, action_menu, action_loaded, action_value, action_error) ";
$q .= "VALUES ('".$this->dbEscapeString($username)."', 'PASSWORD', ".(($this->euid) ? $this->euid : 'NULL').", "; $q .= "VALUES ('".$this->dbEscapeString($username)."', 'PASSWORD', ".(($this->euid) ? $this->euid : 'NULL').", ";
$q .= "NOW(), '".$this->dbEscapeString($event)."', '".$this->dbEscapeString($error)."', '".$this->dbEscapeString($data)."', '".$data_binary."', '".$this->page_name."', "; $q .= "NOW(), '".$this->dbEscapeString($event)."', '".$this->dbEscapeString((string)$error)."', '".$this->dbEscapeString($data)."', '".$data_binary."', '".$this->page_name."', ";
foreach (array( foreach (array(
'REMOTE_ADDR', 'HTTP_USER_AGENT', 'HTTP_REFERER', 'SCRIPT_FILENAME', 'QUERY_STRING', 'SERVER_NAME', 'HTTP_HOST', 'HTTP_ACCEPT', 'HTTP_ACCEPT_CHARSET', 'HTTP_ACCEPT_ENCODING' 'REMOTE_ADDR', 'HTTP_USER_AGENT', 'HTTP_REFERER', 'SCRIPT_FILENAME', 'QUERY_STRING', 'SERVER_NAME', 'HTTP_HOST', 'HTTP_ACCEPT', 'HTTP_ACCEPT_CHARSET', 'HTTP_ACCEPT_ENCODING'
) as $server_code) { ) as $server_code) {

View File

@@ -595,15 +595,18 @@ class IO extends \CoreLibs\Basic
// PARAMS: array from fetch_row // PARAMS: array from fetch_row
// RETURN: convert fetch_row array // RETURN: convert fetch_row array
// DESC : if there is the 'to_encoding' var set, and the field is in the wrong encoding converts it to the target // DESC : if there is the 'to_encoding' var set, and the field is in the wrong encoding converts it to the target
private function __dbConvertEncoding(array $row): array private function __dbConvertEncoding($row)
{ {
if ($this->to_encoding && $this->db_encoding) { // only do if array, else pass through row (can be false)
// go through each row and convert the encoding if needed if (is_array($row)) {
foreach ($row as $key => $value) { if ($this->to_encoding && $this->db_encoding) {
$from_encoding = mb_detect_encoding($value); // go through each row and convert the encoding if needed
// convert only if encoding doesn't match and source is not pure ASCII foreach ($row as $key => $value) {
if ($from_encoding != $this->to_encoding && $from_encoding != 'ASCII') { $from_encoding = mb_detect_encoding($value);
$row[$key] = mb_convert_encoding($value, $this->to_encoding, $from_encoding); // convert only if encoding doesn't match and source is not pure ASCII
if ($from_encoding != $this->to_encoding && $from_encoding != 'ASCII') {
$row[$key] = mb_convert_encoding($value, $this->to_encoding, $from_encoding);
}
} }
} }
} }