Feature #1150; Add random SQL-Prefixes to customer DBs
This commit is contained in:
@@ -162,7 +162,6 @@ elseif($page == 'mysqls')
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$username = $userinfo['loginname'] . $settings['customer']['mysqlprefix'] . (intval($userinfo['mysql_lastaccountnumber']) + 1);
|
|
||||||
|
|
||||||
if(count($sql_root) > 1)
|
if(count($sql_root) > 1)
|
||||||
{
|
{
|
||||||
@@ -181,6 +180,20 @@ elseif($page == 'mysqls')
|
|||||||
// Begin root-session
|
// Begin root-session
|
||||||
|
|
||||||
$db_root = new db($sql_root[$dbserver]['host'], $sql_root[$dbserver]['user'], $sql_root[$dbserver]['password'], '');
|
$db_root = new db($sql_root[$dbserver]['host'], $sql_root[$dbserver]['user'], $sql_root[$dbserver]['password'], '');
|
||||||
|
|
||||||
|
if ($settings['customer']['mysqlprefix'] == "RANDOM") {
|
||||||
|
$result = $db_root->query('SELECT `User` FROM mysql.user');
|
||||||
|
while ($row = $db_root->fetch_array($result)) {
|
||||||
|
$allsqlusers[] = $row[User];
|
||||||
|
}
|
||||||
|
$username = $userinfo['loginname'] . '-' . substr(md5(uniqid(microtime(), 1)), 20, 3);
|
||||||
|
while (in_Array($username , $allsqlusers)) {
|
||||||
|
$username = $userinfo['loginname'] . '-' . substr(md5(uniqid(microtime(), 1)), 20, 3);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$username = $userinfo['loginname'] . $settings['customer']['mysqlprefix'] . (intval($userinfo['mysql_lastaccountnumber']) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
$db_root->query('CREATE DATABASE `' . $db_root->escape($username) . '`');
|
$db_root->query('CREATE DATABASE `' . $db_root->escape($username) . '`');
|
||||||
$log->logAction(USR_ACTION, LOG_INFO, "created database '" . $username . "'");
|
$log->logAction(USR_ACTION, LOG_INFO, "created database '" . $username . "'");
|
||||||
foreach(array_map('trim', explode(',', $settings['system']['mysql_access_host'])) as $mysql_access_host)
|
foreach(array_map('trim', explode(',', $settings['system']['mysql_access_host'])) as $mysql_access_host)
|
||||||
|
|||||||
@@ -339,7 +339,7 @@ $lng['serversettings']['session_timeout']['description'] = 'How long does a user
|
|||||||
$lng['serversettings']['accountprefix']['title'] = 'Customer prefix';
|
$lng['serversettings']['accountprefix']['title'] = 'Customer prefix';
|
||||||
$lng['serversettings']['accountprefix']['description'] = 'Which prefix should customer accounts have?';
|
$lng['serversettings']['accountprefix']['description'] = 'Which prefix should customer accounts have?';
|
||||||
$lng['serversettings']['mysqlprefix']['title'] = 'SQL Prefix';
|
$lng['serversettings']['mysqlprefix']['title'] = 'SQL Prefix';
|
||||||
$lng['serversettings']['mysqlprefix']['description'] = 'Which prefix should MySQL accounts have?';
|
$lng['serversettings']['mysqlprefix']['description'] = 'Which prefix should MySQL accounts have?</br>Use "RANDOM" as vlaue to get a 3-digit random prefix';
|
||||||
$lng['serversettings']['ftpprefix']['title'] = 'FTP Prefix';
|
$lng['serversettings']['ftpprefix']['title'] = 'FTP Prefix';
|
||||||
$lng['serversettings']['ftpprefix']['description'] = 'Which prefix should ftp accounts have?';
|
$lng['serversettings']['ftpprefix']['description'] = 'Which prefix should ftp accounts have?';
|
||||||
$lng['serversettings']['documentroot_prefix']['title'] = 'Home directory';
|
$lng['serversettings']['documentroot_prefix']['title'] = 'Home directory';
|
||||||
|
|||||||
@@ -339,7 +339,7 @@ $lng['serversettings']['session_timeout']['description'] = 'Wie lange muss ein B
|
|||||||
$lng['serversettings']['accountprefix']['title'] = 'Kundenprefix';
|
$lng['serversettings']['accountprefix']['title'] = 'Kundenprefix';
|
||||||
$lng['serversettings']['accountprefix']['description'] = 'Welchen Prefix sollen die Kundenaccounts haben?';
|
$lng['serversettings']['accountprefix']['description'] = 'Welchen Prefix sollen die Kundenaccounts haben?';
|
||||||
$lng['serversettings']['mysqlprefix']['title'] = 'SQL-Prefix';
|
$lng['serversettings']['mysqlprefix']['title'] = 'SQL-Prefix';
|
||||||
$lng['serversettings']['mysqlprefix']['description'] = 'Welchen Prefix sollen die MySQL-Benutzerkonten haben?';
|
$lng['serversettings']['mysqlprefix']['description'] = 'Welchen Prefix sollen die MySQL-Benutzerkonten haben?</br>Mit "RANDOM" als Wert wird ein 3-Stelliger Zufallswert als Prefix genutzt';
|
||||||
$lng['serversettings']['ftpprefix']['title'] = 'FTP-Prefix';
|
$lng['serversettings']['ftpprefix']['title'] = 'FTP-Prefix';
|
||||||
$lng['serversettings']['ftpprefix']['description'] = 'Welchen Prefix sollen die FTP-Benutzerkonten haben?';
|
$lng['serversettings']['ftpprefix']['description'] = 'Welchen Prefix sollen die FTP-Benutzerkonten haben?';
|
||||||
$lng['serversettings']['documentroot_prefix']['title'] = 'Heimatverzeichnis';
|
$lng['serversettings']['documentroot_prefix']['title'] = 'Heimatverzeichnis';
|
||||||
|
|||||||
Reference in New Issue
Block a user