fix re-enabling of database users after being deactivated, fixes #660
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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 . '`');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user