diff --git a/interface/web/sites/database_edit.php b/interface/web/sites/database_edit.php index 088e37a3b6c9f3cdeff442e3ed8b8a5be6b1ef0e..2fb8a05189c2ddc1fca97e5ccb7b146b7feb6b8e 100644 --- a/interface/web/sites/database_edit.php +++ b/interface/web/sites/database_edit.php @@ -255,6 +255,9 @@ class page_action extends tform_actions { } } unset($old_record); + + if(strlen($dbname_prefix . $this->dataRecord['database_name']) > 64) $app->tform->errorMessage .= str_replace('{db}',$dbname_prefix . $this->dataRecord['database_name'],$app->tform->wordbook["database_name_error_len"]).'<br />'; + if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16) $app->tform->errorMessage .= str_replace('{user}',$dbuser_prefix . $this->dataRecord['database_user'],$app->tform->wordbook["database_user_error_len"]).'<br />'; if ($app->tform->errorMessage == ''){ /* restrict the names if there is no error */ @@ -278,11 +281,17 @@ class page_action extends tform_actions { $global_config = $app->getconf->get_global_config('sites'); $dbname_prefix = replacePrefix($global_config['dbname_prefix'], $this->dataRecord); $dbuser_prefix = replacePrefix($global_config['dbuser_prefix'], $this->dataRecord); + + if(strlen($dbname_prefix . $this->dataRecord['database_name']) > 64) $app->tform->errorMessage .= str_replace('{db}',$dbname_prefix . $this->dataRecord['database_name'],$app->tform->wordbook["database_name_error_len"]).'<br />'; + if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16) $app->tform->errorMessage .= str_replace('{user}',$dbuser_prefix . $this->dataRecord['database_user'],$app->tform->wordbook["database_user_error_len"]).'<br />'; + /* restrict the names */ /* crop user and db names if they are too long -> mysql: user: 16 chars / db: 64 chars */ - $this->dataRecord['database_name'] = substr($dbname_prefix . $this->dataRecord['database_name'], 0, 64); - $this->dataRecord['database_user'] = substr($dbuser_prefix . $this->dataRecord['database_user'], 0, 16); + if ($app->tform->errorMessage == ''){ + $this->dataRecord['database_name'] = substr($dbname_prefix . $this->dataRecord['database_name'], 0, 64); + $this->dataRecord['database_user'] = substr($dbuser_prefix . $this->dataRecord['database_user'], 0, 16); + } parent::onBeforeInsert(); } diff --git a/interface/web/sites/lib/lang/en_database.lng b/interface/web/sites/lib/lang/en_database.lng index 555511af3a3fcf5914e7c688c7ae7a7fa1fc104a..48d7ea3b148dbc621e4909af85368373d12ea434 100644 --- a/interface/web/sites/lib/lang/en_database.lng +++ b/interface/web/sites/lib/lang/en_database.lng @@ -20,4 +20,6 @@ $wb["database_user_error_regex"] = 'Invalid database user name. The username may $wb["limit_database_txt"] = 'The max. number of databases is reached.'; $wb["database_name_change_txt"] = 'The database name can not be changed'; $wb["database_charset_change_txt"] = 'The database charset can not be changed'; +$wb["database_name_error_len"] = 'Database name - {db} - too long. The max. database name length incl. prefix is 64 chars.'; +$wb["database_user_error_len"] = 'Database username - {user}- too long. The max. database username length incl. prefix is 16 chars.'; ?>