added new regexpr function in account.inc
This commit is contained in:
parent
e7aec802ee
commit
21c929f642
|
@ -57,10 +57,10 @@ function getshells() {
|
||||||
* In order to map all non-ascii characters this function should be changed
|
* In order to map all non-ascii characters this function should be changed
|
||||||
*/
|
*/
|
||||||
function replace_umlaut($text) {
|
function replace_umlaut($text) {
|
||||||
$aTranslate = array("ä"=>"ae", "Ä"=>"Ae",
|
$aTranslate = array("<EFBFBD>"=>"ae", "<EFBFBD>"=>"Ae",
|
||||||
"ö"=>"oe", "Ö"=>"Oe",
|
"<EFBFBD>"=>"oe", "<EFBFBD>"=>"Oe",
|
||||||
"ü"=>"ue", "Ü"=>"Ue",
|
"<EFBFBD>"=>"ue", "<EFBFBD>"=>"Ue",
|
||||||
"ß"=>"ss"
|
"<EFBFBD>"=>"ss"
|
||||||
);
|
);
|
||||||
return strtr($text, $aTranslate);
|
return strtr($text, $aTranslate);
|
||||||
}
|
}
|
||||||
|
@ -416,4 +416,44 @@ class samba3domain {
|
||||||
var $RIDbase = 1000;
|
var $RIDbase = 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** This functions contains a collection of regular expressions
|
||||||
|
* It's much easier to handle them here than in every module
|
||||||
|
* because many of them are used several times.
|
||||||
|
**/
|
||||||
|
function get_ereg($argument, $regexp) {
|
||||||
|
// First we check "positive" cases
|
||||||
|
$eregexpr = '';
|
||||||
|
switch ($regexp) {
|
||||||
|
case "password": $eregexpr = '^([a-z]|[A-Z]|[0-9]|[\|]|[\#]|[\*]|[\,]|[\.]|[\;]|[\:]|[\_]|[\-]|[\+]|[\!]|[\%]|[\&]|[\/]|[\?]|[\{]|[\[]|[\(]|[\)]|[\]]|[\}])*$'; break;
|
||||||
|
case "username": $eregexpr = '^([a-z]|[A-Z]|[0-9]|[.]|[ ]|[-]|[_])+$'; break;
|
||||||
|
case "hostname": $eregexpr = '^([a-z0-9\\.-])+(([,])+([ ])*([a-z0-9\\.-])+)*$'; break;
|
||||||
|
case "realname": $eregexpr = ''; break;
|
||||||
|
case "telephone": $eregexpr = '^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/]|[-])*$'; break;
|
||||||
|
case "email": $eregexpr = '^(([0-9a-z\\._-])+[@]([0-9a-z-])+([.]([0-9a-z-])+)*)*$'; break;
|
||||||
|
case "street": $eregexpr = '^([0-9a-z])*$'; break; // ereg broken
|
||||||
|
case "postalAddress": $eregexpr = '^([0-9a-z])*$'; break; // ereg broken
|
||||||
|
case "postalCode": $eregexpr = '^([0-9a-z])*$'; break;
|
||||||
|
case "title": $eregexpr = '^([0-9a-z])*$'; break; // ereg broken
|
||||||
|
case "employeeType": $eregexpr = '^([0-9a-z])*$'; break; // ereg broken
|
||||||
|
case "homedir": $eregexpr = '^[/]([a-z])([a-z0-9\\._-])*([/]([a-z\\$])([a-z0-9\\._-])*)*$'; break;
|
||||||
|
case "naturalnumber": $eregexpr = '^[0-9]+$'; break;
|
||||||
|
case "UNC": $eregexpr = '^([\][\]([a-zA-Z0-9\\.%-])+([\]([a-z0-9\\.%-])+)+)|([/][a-z]([a-z0-9\\._%-])*([/][a-z]([a-z0-9\\._%-])*)*)$'; break;
|
||||||
|
case "logonscript": $eregexpr = '^([/])*([a-z0-9])+([/]([a-z0-9])+)*((\\.bat)|(\\.cmd))$'; break; // ereg broken
|
||||||
|
case "workstations": $eregexpr = '^([a-z0-9\\._-])+(,[a-z0-9\\._-])*$'; break;
|
||||||
|
case "domainname": $eregexpr = '^([a-z0-9_-])+$'; break;
|
||||||
|
case 'homepath': $eregexpr = '[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])+)+$'; break;
|
||||||
|
case 'naturalnumber2': $eregexpr = '^(([-][1])|([0-9]*))$'; break;
|
||||||
|
}
|
||||||
|
if ($eregexpr!='')
|
||||||
|
if (ereg($eregexpr, $argument)) return true;
|
||||||
|
// Now we check "negative" cases, characters which are not allowed
|
||||||
|
$eregexpr = '';
|
||||||
|
switch ($regexp) {
|
||||||
|
case "password": $eregexpr = '^([a-z]|[A-Z]|[0-9]|[\|]|[\#]|[\*]|[\,]|[\.]|[\;]|[\:]|[\_]|[\-]|[\+]|[\!]|[\%]|[\&]|[\/]|[\?]|[\{]|[\[]|[\(]|[\)]|[\]]|[\}])*$'; break;
|
||||||
|
}
|
||||||
|
if ($eregexpr!='')
|
||||||
|
if (!ereg($eregexpr, $argument)) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -347,10 +347,9 @@ class posixGroup extends baseModule {
|
||||||
/** this functin fills the error message array with messages
|
/** this functin fills the error message array with messages
|
||||||
**/
|
**/
|
||||||
function load_errorMessages() {
|
function load_errorMessages() {
|
||||||
// *** fixme really neccesarry for posixGroup?
|
$this->errormessages['minGID'][0] = array('ERROR', _('Minimum GID number'), _('Minimum GID number is invalid or empty!'));
|
||||||
//$this->errormessages['minGID'][0] = array('ERROR', _('Minimum GID number'), _('Minimum GID number is invalid or empty!'));
|
$this->errormessages['maxGID'][0] = array('ERROR', _('Maximum GID number'), _('Maximum GID number is invalid or empty!'));
|
||||||
//$this->errormessages['maxGID'][0] = array('ERROR', _('Maximum GID number'), _('Maximum GID number is invalid or empty!'));
|
$this->errormessages['cmpGID'][0] = array('ERROR', _('Maximum GID number'), _('Maximum GID number must be greater than minimum GID number!'));
|
||||||
//$this->errormessages['cmpGID'][1] = array('ERROR', _('Maximum GID number'), _('Maximum GID number must be greater than minimum GID number!'));
|
|
||||||
$this->errormessages['userPassword'][0] = array('ERROR', _('Password'), _('Please enter the same password in both password-fields.'));
|
$this->errormessages['userPassword'][0] = array('ERROR', _('Password'), _('Please enter the same password in both password-fields.'));
|
||||||
$this->errormessages['userPassword'][1] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!$%&/|?{[()]}= !'));
|
$this->errormessages['userPassword'][1] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!$%&/|?{[()]}= !'));
|
||||||
$this->errormessages['gidNumber'][0] = array('INFO', _('GID number'), _('GID number has changed. Please select checkbox to change GID number of users and hosts.'));
|
$this->errormessages['gidNumber'][0] = array('INFO', _('GID number'), _('GID number has changed. Please select checkbox to change GID number of users and hosts.'));
|
||||||
|
@ -474,7 +473,7 @@ class posixGroup extends baseModule {
|
||||||
if (($this->attributes['cn'][0] != $post['cn']) && ereg('[A-Z]$', $post['cn']))
|
if (($this->attributes['cn'][0] != $post['cn']) && ereg('[A-Z]$', $post['cn']))
|
||||||
$errors['cn'][] = $this->errormessages['cn'][0];
|
$errors['cn'][] = $this->errormessages['cn'][0];
|
||||||
// Check if Groupname contains only valid characters
|
// Check if Groupname contains only valid characters
|
||||||
if ( !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-]|[_])+$', $this->attributes['cn'][0]))
|
if ( !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[ ]|[-]|[_])+$', $this->attributes['cn'][0]))
|
||||||
$errors['cn'][] = $this->errormessages['cn'][2];
|
$errors['cn'][] = $this->errormessages['cn'][2];
|
||||||
// Create automatic useraccount with number if original user already exists
|
// Create automatic useraccount with number if original user already exists
|
||||||
// Reset name to original name if new name is in use
|
// Reset name to original name if new name is in use
|
||||||
|
|
Loading…
Reference in New Issue