issue #75: defines length of sql user and database names depending of the local configuration.
This commit is contained in:
parent
170114cdf8
commit
b28b73e913
|
@ -96,8 +96,8 @@ for($i=0;$i<count($rdb);$i++) {
|
|||
<th><label for="dbn"><?php __("MySQL Database"); ?></label></th>
|
||||
<td>
|
||||
<?php
|
||||
// Max 16 caracters for the database name if we want the mysql user to be automatically created.
|
||||
$max_dbsufix_size=(16-strlen($mem->user["login"].'_'));
|
||||
// Set a maximum length for the database name if we want the mysql user to be automatically created.
|
||||
$max_dbsufix_size=(variable_get("sql_max_database_length", 16)-strlen($mem->user["login"].'_'));
|
||||
?>
|
||||
<span class="int" id="dbnpfx"><?php echo $mem->user["login"]; ?>_</span><input type="text" class="int" name="dbn" id="dbn" value="" size="20" maxlength="<?php echo $max_dbsufix_size ;?>" />
|
||||
</td>
|
||||
|
|
|
@ -225,3 +225,14 @@ variable_get('subadmin_restriction', '0', "This variable sets the way the accoun
|
|||
|
||||
variable_get('auth_ip_ftp_default_yes', '1', "This variable sets if you want to allow all IP address to access FTP by default. If the user start to define some IP or subnet in the allow list, only those he defined will be allowed.", array('desc' => 'Allow by default?', 'type' => 'boolean'));
|
||||
|
||||
if ((variable_get('sql_max_username_length', NULL)==NULL)||(variable_get('sql_max_database_length', NULL)==NULL)) {
|
||||
$result = $db->query("SELECT (SELECT CHARACTER_MAXIMUM_LENGTH length FROM information_schema.columns WHERE TABLE_SCHEMA='mysql' and TABLE_NAME='user' and COLUMN_NAME='User') username, (SELECT CHARACTER_MAXIMUM_LENGTH length FROM information_schema.columns WHERE TABLE_SCHEMA='mysql' and TABLE_NAME='db' and COLUMN_NAME='Db') `database`");
|
||||
if ($db->next_record($result)) {
|
||||
$variable = $db->Record;
|
||||
$variable['username']=min(128, $variable['username']);
|
||||
$variable['database']=min($variable['database'], $variable['username']);
|
||||
variable_set('sql_max_username_length', $variable['username'], 'Maximum length allowed for SQL usernames');
|
||||
variable_set('sql_max_database_length', $variable['database'], 'Maximum length allowed for SQL databases names');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -257,8 +257,9 @@ class m_mysql {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (strlen($dbname) > 64) {
|
||||
$err->raise("mysql", _("Database name cannot exceed 64 characters"));
|
||||
$len=variable_get("sql_max_database_length", 64);
|
||||
if (strlen($dbname) > $len) {
|
||||
$err->raise("mysql", _("Database name cannot exceed %d characters"), $len);
|
||||
return false;
|
||||
}
|
||||
$db->query("SELECT * FROM db WHERE db='$dbname';");
|
||||
|
@ -422,8 +423,9 @@ class m_mysql {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (strlen($password) > 16) {
|
||||
$err->raise("mysql", _("MySQL password cannot exceed 16 characters"));
|
||||
$len=variable_get("sql_max_username_length", 16);
|
||||
if (strlen($password) > $len) {
|
||||
$err->raise("mysql", _("MySQL password cannot exceed %d characters"), $len);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -714,8 +716,9 @@ class m_mysql {
|
|||
}
|
||||
|
||||
// We check the length of the COMPLETE username, not only the part after _
|
||||
if (strlen($user) > 16) {
|
||||
$err->raise("mysql", _("MySQL username cannot exceed 16 characters"));
|
||||
$len=variable_get("sql_max_username_length", 16);
|
||||
if (strlen($user) > $len) {
|
||||
$err->raise("mysql", _("MySQL username cannot exceed %d characters"), $len);
|
||||
return false;
|
||||
}
|
||||
$db->query("SELECT * FROM dbusers WHERE name='$user';");
|
||||
|
|
Loading…
Reference in New Issue