diff --git a/lib/Froxlor/Api/Commands/Customers.php b/lib/Froxlor/Api/Commands/Customers.php index 1f5bba68..348aa640 100644 --- a/lib/Froxlor/Api/Commands/Customers.php +++ b/lib/Froxlor/Api/Commands/Customers.php @@ -897,7 +897,9 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource $email = $idna_convert->encode(\Froxlor\Validate\Validate::validate($email, 'email', '', '', array(), true)); $customernumber = \Froxlor\Validate\Validate::validate($customernumber, 'customer number', '/^[A-Za-z0-9 \-]*$/Di', '', array(), true); $custom_notes = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $custom_notes), 'custom_notes', '/^[^\0]*$/', '', array(), true); - $allowed_phpconfigs = array_map('intval', $allowed_phpconfigs); + if (!empty($allowed_phpconfigs)) { + $allowed_phpconfigs = array_map('intval', $allowed_phpconfigs); + } } $def_language = \Froxlor\Validate\Validate::validate($def_language, 'default language', '', '', array(), true); $theme = \Froxlor\Validate\Validate::validate($theme, 'theme', '', '', array(), true); diff --git a/lib/Froxlor/Database/Manager/DbManagerMySQL.php b/lib/Froxlor/Database/Manager/DbManagerMySQL.php index 2014ae60..5919bd72 100644 --- a/lib/Froxlor/Database/Manager/DbManagerMySQL.php +++ b/lib/Froxlor/Database/Manager/DbManagerMySQL.php @@ -192,8 +192,13 @@ class DbManagerMySQL */ public function enableUser($username = null, $host = null) { - Database::query('GRANT ALL PRIVILEGES ON `' . $username . '`.* TO `' . $username . '`@`' . $host . '`'); - Database::query('GRANT ALL PRIVILEGES ON `' . str_replace('_', '\_', $username) . '` . * TO `' . $username . '`@`' . $host . '`'); + // check whether user exists to avoid errors + $exist_check_stmt = Database::prepare("SELECT EXISTS(SELECT 1 FROM mysql.user WHERE user = '" . $username . "' AND host = '" . $host . "')"); + $exist_check = Database::pexecute_first($exist_check_stmt); + if ($exist_check && array_pop($exist_check) == '1') { + Database::query('GRANT ALL PRIVILEGES ON `' . $username . '`.* TO `' . $username . '`@`' . $host . '`'); + Database::query('GRANT ALL PRIVILEGES ON `' . str_replace('_', '\_', $username) . '` . * TO `' . $username . '`@`' . $host . '`'); + } } /** diff --git a/lib/Froxlor/Settings/Store.php b/lib/Froxlor/Settings/Store.php index 86fba687..5c567d31 100644 --- a/lib/Froxlor/Settings/Store.php +++ b/lib/Froxlor/Settings/Store.php @@ -305,11 +305,11 @@ class Store // be aware that ipv6 addresses are enclosed in [ ] when passed here $mysql_access_host_array = array_map(array( - self, + '\\Froxlor\\Settings\\Store', 'cleanMySQLAccessHost' ), $mysql_access_host_array); - $mysql_access_host_array = array_unique(\Froxlor\PhpHelper::arrayTrim($mysql_access_host_array)); + $mysql_access_host_array = array_unique($mysql_access_host_array); $newfieldvalue = implode(',', $mysql_access_host_array); \Froxlor\Database\DbManager::correctMysqlUsers($mysql_access_host_array); }