show correct error-message when loginname has too many characters, fixes #811
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -628,7 +628,7 @@ if ($page == 'customers'
|
|||||||
&& $_POST['new_loginname'] != ''
|
&& $_POST['new_loginname'] != ''
|
||||||
) {
|
) {
|
||||||
$accountnumber = intval($settings['system']['lastaccountnumber']);
|
$accountnumber = intval($settings['system']['lastaccountnumber']);
|
||||||
$loginname = validate($_POST['new_loginname'], 'loginname', '/^[a-z0-9\-_]+$/i');
|
$loginname = validate($_POST['new_loginname'], 'loginname', '/^[a-z][a-z0-9\-_]+$/i');
|
||||||
|
|
||||||
// Accounts which match systemaccounts are not allowed, filtering them
|
// Accounts which match systemaccounts are not allowed, filtering them
|
||||||
if (preg_match('/^' . preg_quote($settings['customer']['accountprefix'], '/') . '([0-9]+)/', $loginname)) {
|
if (preg_match('/^' . preg_quote($settings['customer']['accountprefix'], '/') . '([0-9]+)/', $loginname)) {
|
||||||
@@ -665,7 +665,7 @@ if ($page == 'customers'
|
|||||||
standard_error('loginnameexists', $loginname);
|
standard_error('loginnameexists', $loginname);
|
||||||
|
|
||||||
} elseif (!validateUsername($loginname, $settings['panel']['unix_names'], 14 - strlen($settings['customer']['mysqlprefix']))) {
|
} elseif (!validateUsername($loginname, $settings['panel']['unix_names'], 14 - strlen($settings['customer']['mysqlprefix']))) {
|
||||||
standard_error('loginnameiswrong', $loginname);
|
standard_error('loginnameiswrong', 14 - strlen($settings['customer']['mysqlprefix']));
|
||||||
}
|
}
|
||||||
|
|
||||||
$guid = intval($settings['system']['lastguid']) + 1;
|
$guid = intval($settings['system']['lastguid']) + 1;
|
||||||
|
|||||||
@@ -24,24 +24,17 @@
|
|||||||
* @return bool Correct or not
|
* @return bool Correct or not
|
||||||
* @author Michael Duergner <michael@duergner.com>
|
* @author Michael Duergner <michael@duergner.com>
|
||||||
*
|
*
|
||||||
* @changes Backported regex from SysCP 1.3 (lib/classes/Syscp/Handler/Validation.class.php)
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function validateUsername($username, $unix_names = 1, $mysql_max = '')
|
function validateUsername($username, $unix_names = 1, $mysql_max = '') {
|
||||||
{
|
|
||||||
if($unix_names == 0)
|
if ($unix_names == 0) {
|
||||||
{
|
if (strpos($username, '--') === false) {
|
||||||
if(strpos($username, '--') === false)
|
|
||||||
{
|
|
||||||
return (preg_match('/^[a-z][a-z0-9\-_]{1,' . (int)($mysql_max - 1) . '}[a-z0-9]{1}$/Di', $username) != false);
|
return (preg_match('/^[a-z][a-z0-9\-_]{1,' . (int)($mysql_max - 1) . '}[a-z0-9]{1}$/Di', $username) != false);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
return (preg_match('/^[a-z][a-z0-9]{1,' . (int)$mysql_max . '}$/Di', $username) != false);
|
||||||
{
|
|
||||||
return (preg_match('/^[a-z][a-z0-9]{1,' . $mysql_max . '}$/Di', $username) != false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ $lng['error']['mydomain'] = '\'Domain\'';
|
|||||||
$lng['error']['mydocumentroot'] = '\'Documentroot\'';
|
$lng['error']['mydocumentroot'] = '\'Documentroot\'';
|
||||||
$lng['error']['loginnameexists'] = 'Loginname %s already exists';
|
$lng['error']['loginnameexists'] = 'Loginname %s already exists';
|
||||||
$lng['error']['emailiswrong'] = 'Email-address %s contains invalid characters or is incomplete';
|
$lng['error']['emailiswrong'] = 'Email-address %s contains invalid characters or is incomplete';
|
||||||
$lng['error']['loginnameiswrong'] = 'Loginname %s contains invalid characters';
|
$lng['error']['loginnameiswrong'] = 'Loginname contains too many characters. Only %s characters are allowed.';
|
||||||
$lng['error']['userpathcombinationdupe'] = 'Combination of username and path already exists';
|
$lng['error']['userpathcombinationdupe'] = 'Combination of username and path already exists';
|
||||||
$lng['error']['patherror'] = 'General Error! Path cannot be empty';
|
$lng['error']['patherror'] = 'General Error! Path cannot be empty';
|
||||||
$lng['error']['errordocpathdupe'] = 'Option for path %s already exists';
|
$lng['error']['errordocpathdupe'] = 'Option for path %s already exists';
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ $lng['error']['mydomain'] = '\'Domain\'';
|
|||||||
$lng['error']['mydocumentroot'] = '\'Documentroot\'';
|
$lng['error']['mydocumentroot'] = '\'Documentroot\'';
|
||||||
$lng['error']['loginnameexists'] = 'Der Login-Name "%s" existiert bereits.';
|
$lng['error']['loginnameexists'] = 'Der Login-Name "%s" existiert bereits.';
|
||||||
$lng['error']['emailiswrong'] = 'Die E-Mail-Adresse "%s" enthält ungültige Zeichen oder ist nicht vollständig.';
|
$lng['error']['emailiswrong'] = 'Die E-Mail-Adresse "%s" enthält ungültige Zeichen oder ist nicht vollständig.';
|
||||||
$lng['error']['loginnameiswrong'] = 'Der Login-Name "%s" enthält ungültige Zeichen.';
|
$lng['error']['loginnameiswrong'] = 'Der Login-Name enthält zuviele Zeichen, maximal %s Zeichen sind erlaubt.';
|
||||||
$lng['error']['userpathcombinationdupe'] = 'Kombination aus Benutzername und Pfad existiert bereits.';
|
$lng['error']['userpathcombinationdupe'] = 'Kombination aus Benutzername und Pfad existiert bereits.';
|
||||||
$lng['error']['patherror'] = 'Allgemeiner Fehler! Pfad darf nicht leer sein.';
|
$lng['error']['patherror'] = 'Allgemeiner Fehler! Pfad darf nicht leer sein.';
|
||||||
$lng['error']['errordocpathdupe'] = 'Option für Pfad "%s" existiert bereits.';
|
$lng['error']['errordocpathdupe'] = 'Option für Pfad "%s" existiert bereits.';
|
||||||
|
|||||||
Reference in New Issue
Block a user