trim some input fields to prevent copy+paste errors

This commit is contained in:
Roland Gruber 2013-05-25 12:47:07 +00:00
parent ed09935d4f
commit 88c1bd9476
2 changed files with 23 additions and 23 deletions

View File

@ -1035,9 +1035,9 @@ class inetOrgPerson extends baseModule implements passwordService {
}
$this->attributes['description'] = array_values($this->attributes['description']);
}
$this->attributes['sn'][0] = $_POST['sn'];
$this->attributes['sn'][0] = trim($_POST['sn']);
if (!get_preg($this->attributes['sn'][0], 'realname')) $errors[] = $this->messages['lastname'][0];
$this->attributes['givenName'][0] = $_POST['givenName'];
$this->attributes['givenName'][0] = trim($_POST['givenName']);
if (($this->attributes['givenName'][0] != '') && !get_preg($this->attributes['givenName'][0], 'realname')) $errors[] = $this->messages['givenName'][0];
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideJobTitle')) {
$titleCounter = 0;
@ -1059,7 +1059,7 @@ class inetOrgPerson extends baseModule implements passwordService {
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEMailAddress')) {
$mailCounter = 0;
while (isset($_POST['mail' . $mailCounter])) {
$this->attributes['mail'][$mailCounter] = $_POST['mail' . $mailCounter];
$this->attributes['mail'][$mailCounter] = trim($_POST['mail' . $mailCounter]);
if (($_POST['mail' . $mailCounter] != '') && !get_preg($this->attributes['mail'][$mailCounter], 'email')) $errors[] = $this->messages['email'][0];
if ($this->attributes['mail'][$mailCounter] == '') {
unset($this->attributes['mail'][$mailCounter]);
@ -1074,7 +1074,7 @@ class inetOrgPerson extends baseModule implements passwordService {
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideTelephoneNumber')) {
$telephoneNumberCounter = 0;
while (isset($_POST['telephoneNumber' . $telephoneNumberCounter])) {
$this->attributes['telephoneNumber'][$telephoneNumberCounter] = $_POST['telephoneNumber' . $telephoneNumberCounter];
$this->attributes['telephoneNumber'][$telephoneNumberCounter] = trim($_POST['telephoneNumber' . $telephoneNumberCounter]);
if (!get_preg($this->attributes['telephoneNumber'][$telephoneNumberCounter], 'telephone')) $errors[] = $this->messages['telephoneNumber'][0];
if ($this->attributes['telephoneNumber'][$telephoneNumberCounter] == '') {
unset($this->attributes['telephoneNumber'][$telephoneNumberCounter]);
@ -1089,7 +1089,7 @@ class inetOrgPerson extends baseModule implements passwordService {
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideMobileNumber')) {
$mobileCounter = 0;
while (isset($_POST['mobile' . $mobileCounter])) {
$this->attributes['mobile'][$mobileCounter] = $_POST['mobile' . $mobileCounter];
$this->attributes['mobile'][$mobileCounter] = trim($_POST['mobile' . $mobileCounter]);
if (!get_preg($this->attributes['mobile'][$mobileCounter], 'telephone')) $errors[] = $this->messages['mobileTelephone'][0];
if ($this->attributes['mobile'][$mobileCounter] == '') {
unset($this->attributes['mobile'][$mobileCounter]);
@ -1104,7 +1104,7 @@ class inetOrgPerson extends baseModule implements passwordService {
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideFaxNumber')) {
$facsimileTelephoneNumberCounter = 0;
while (isset($_POST['facsimileTelephoneNumber' . $facsimileTelephoneNumberCounter])) {
$this->attributes['facsimileTelephoneNumber'][$facsimileTelephoneNumberCounter] = $_POST['facsimileTelephoneNumber' . $facsimileTelephoneNumberCounter];
$this->attributes['facsimileTelephoneNumber'][$facsimileTelephoneNumberCounter] = trim($_POST['facsimileTelephoneNumber' . $facsimileTelephoneNumberCounter]);
if (!get_preg($this->attributes['facsimileTelephoneNumber'][$facsimileTelephoneNumberCounter], 'telephone')) $errors[] = $this->messages['facsimileNumber'][0];
if ($this->attributes['facsimileTelephoneNumber'][$facsimileTelephoneNumberCounter] == '') {
unset($this->attributes['facsimileTelephoneNumber'][$facsimileTelephoneNumberCounter]);
@ -1119,7 +1119,7 @@ class inetOrgPerson extends baseModule implements passwordService {
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideHomeTelephoneNumber')) {
$homePhoneCounter = 0;
while (isset($_POST['homePhone' . $homePhoneCounter])) {
$this->attributes['homePhone'][$homePhoneCounter] = $_POST['homePhone' . $homePhoneCounter];
$this->attributes['homePhone'][$homePhoneCounter] = trim($_POST['homePhone' . $homePhoneCounter]);
if (!get_preg($this->attributes['homePhone'][$homePhoneCounter], 'telephone')) $errors[] = $this->messages['homePhone'][0];
if ($this->attributes['homePhone'][$homePhoneCounter] == '') {
unset($this->attributes['homePhone'][$homePhoneCounter]);
@ -1193,7 +1193,7 @@ class inetOrgPerson extends baseModule implements passwordService {
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLabeledURI')) {
$labeledURICounter = 0;
while (isset($_POST['labeledURI' . $labeledURICounter])) {
$this->attributes['labeledURI'][$labeledURICounter] = $_POST['labeledURI' . $labeledURICounter];
$this->attributes['labeledURI'][$labeledURICounter] = trim($_POST['labeledURI' . $labeledURICounter]);
if ($this->attributes['labeledURI'][$labeledURICounter] == '') {
unset($this->attributes['labeledURI'][$labeledURICounter]);
}
@ -2543,7 +2543,7 @@ class inetOrgPerson extends baseModule implements passwordService {
if (!in_array("inetOrgPerson", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "inetOrgPerson";
// last name
if (get_preg($rawAccounts[$i][$ids['inetOrgPerson_lastName']], 'realname')) {
$partialAccounts[$i]['sn'] = $rawAccounts[$i][$ids['inetOrgPerson_lastName']];
$partialAccounts[$i]['sn'] = trim($rawAccounts[$i][$ids['inetOrgPerson_lastName']]);
}
else {
$errMsg = $this->messages['lastname'][1];
@ -2553,7 +2553,7 @@ class inetOrgPerson extends baseModule implements passwordService {
// first name
if ($rawAccounts[$i][$ids['inetOrgPerson_firstName']] != "") {
if (get_preg($rawAccounts[$i][$ids['inetOrgPerson_firstName']], 'realname')) {
$partialAccounts[$i]['givenName'] = $rawAccounts[$i][$ids['inetOrgPerson_firstName']];
$partialAccounts[$i]['givenName'] = trim($rawAccounts[$i][$ids['inetOrgPerson_firstName']]);
}
else {
$errMsg = $this->messages['givenName'][1];
@ -2711,7 +2711,7 @@ class inetOrgPerson extends baseModule implements passwordService {
}
// telephone
if (isset($ids['inetOrgPerson_telephone']) && ($rawAccounts[$i][$ids['inetOrgPerson_telephone']] != "")) {
$telephoneList = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_telephone']]);
$telephoneList = preg_split('/;[ ]*/', trim($rawAccounts[$i][$ids['inetOrgPerson_telephone']]));
$partialAccounts[$i]['telephoneNumber'] = $telephoneList;
for ($x = 0; $x < sizeof($telephoneList); $x++) {
if (!get_preg($telephoneList[$x], 'telephone')) {
@ -2724,7 +2724,7 @@ class inetOrgPerson extends baseModule implements passwordService {
}
// home telephone
if (isset($ids['inetOrgPerson_homePhone']) && ($rawAccounts[$i][$ids['inetOrgPerson_homePhone']] != "")) {
$homePhoneList = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_homePhone']]);
$homePhoneList = preg_split('/;[ ]*/', trim($rawAccounts[$i][$ids['inetOrgPerson_homePhone']]));
$partialAccounts[$i]['homePhone'] = $homePhoneList;
for ($x = 0; $x < sizeof($homePhoneList); $x++) {
if (!get_preg($homePhoneList[$x], 'telephone')) {
@ -2737,7 +2737,7 @@ class inetOrgPerson extends baseModule implements passwordService {
}
// mobile
if (isset($ids['inetOrgPerson_mobile']) && ($rawAccounts[$i][$ids['inetOrgPerson_mobile']] != "")) {
$mobileList = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_mobile']]);
$mobileList = preg_split('/;[ ]*/', trim($rawAccounts[$i][$ids['inetOrgPerson_mobile']]));
$partialAccounts[$i]['mobile'] = $mobileList;
for ($x = 0; $x < sizeof($mobileList); $x++) {
if (!get_preg($mobileList[$x], 'telephone')) {
@ -2750,7 +2750,7 @@ class inetOrgPerson extends baseModule implements passwordService {
}
// facsimile
if (isset($ids['inetOrgPerson_fax']) && ($rawAccounts[$i][$ids['inetOrgPerson_fax']] != "")) {
$facsimileTelephoneNumberList = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_fax']]);
$facsimileTelephoneNumberList = preg_split('/;[ ]*/', trim($rawAccounts[$i][$ids['inetOrgPerson_fax']]));
$partialAccounts[$i]['facsimileTelephoneNumber'] = $facsimileTelephoneNumberList;
for ($x = 0; $x < sizeof($facsimileTelephoneNumberList); $x++) {
if (!get_preg($facsimileTelephoneNumberList[$x], 'telephone')) {
@ -2763,7 +2763,7 @@ class inetOrgPerson extends baseModule implements passwordService {
}
// eMail
if (isset($ids['inetOrgPerson_email']) && ($rawAccounts[$i][$ids['inetOrgPerson_email']] != "")) {
$mailList = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_email']]);
$mailList = preg_split('/;[ ]*/', trim($rawAccounts[$i][$ids['inetOrgPerson_email']]));
$partialAccounts[$i]['mail'] = $mailList;
for ($x = 0; $x < sizeof($mailList); $x++) {
if (!get_preg($mailList[$x], 'email')) {
@ -2783,7 +2783,7 @@ class inetOrgPerson extends baseModule implements passwordService {
}
// labeledURI
if (isset($ids['inetOrgPerson_labeledURI']) && ($rawAccounts[$i][$ids['inetOrgPerson_labeledURI']] != "")) {
$partialAccounts[$i]['labeledURI'] = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_labeledURI']]);
$partialAccounts[$i]['labeledURI'] = preg_split('/;[ ]*/', trim($rawAccounts[$i][$ids['inetOrgPerson_labeledURI']]));
}
if (!in_array('posixAccount', $selectedModules)) {
// cn

View File

@ -910,7 +910,7 @@ class posixAccount extends baseModule implements passwordService {
if (!$this->isBooleanConfigOptionSet('posixAccount_hidegecos')) {
if (isset($_POST['gecos'])) $this->attributes['gecos'][0] = $_POST['gecos'];
}
if (isset($this->orig['uid'][0]) && ($this->orig['uid'][0] != '') && ($_POST['uid'] != $this->attributes['uid'][0])) {
if (isset($this->orig['uid'][0]) && ($this->orig['uid'][0] != '') && (trim($_POST['uid']) != $this->attributes['uid'][0])) {
$errors[] = $this->messages['uid'][0];
}
if (isset($this->orig['gidNumber'][0]) && ($this->orig['gidNumber'][0] != '') && ($_POST['gidNumber'] != $this->attributes['gidNumber'][0])) {
@ -918,7 +918,7 @@ class posixAccount extends baseModule implements passwordService {
$errorMessage[] = array($this->orig['gidNumber'][0], $this->orig['uidNumber'][0], $_POST['gidNumber']);
$errors[] = $errorMessage;
}
if (isset($this->orig['uidNumber'][0]) && $this->orig['uidNumber'][0]!='' && $_POST['uidNumber']!=$this->attributes['uidNumber'][0]) {
if (isset($this->orig['uidNumber'][0]) && $this->orig['uidNumber'][0]!='' && trim($_POST['uidNumber'])!=$this->attributes['uidNumber'][0]) {
$errorMessage = $this->messages['uidNumber'][5];
$errorMessage[] = array($this->orig['uidNumber'][0], $_POST['uidNumber']);
$errors[] = $errorMessage;
@ -958,7 +958,7 @@ class posixAccount extends baseModule implements passwordService {
if (!get_preg($this->attributes['cn'][0], 'cn')) {
$errors[] = $this->messages['cn'][0];
}
$this->attributes['uidNumber'][0] = $_POST['uidNumber'];
$this->attributes['uidNumber'][0] = trim($_POST['uidNumber']);
$this->attributes['gidNumber'][0] = $_POST['gidNumber'];
if ($this->get_scope()=='user') {
if (($this->attributes['uid'][0] != $_POST['uid']) && !get_preg($_POST['uid'], '!upper')) {
@ -968,7 +968,7 @@ class posixAccount extends baseModule implements passwordService {
$errors[] = $this->messages['homeDirectory'][0];
}
}
$this->attributes['uid'][0] = $_POST['uid'];
$this->attributes['uid'][0] = trim($_POST['uid']);
// Check if UID is valid. If none value was entered, the next useable value will be inserted
// load min and may uidNumber
if ($this->get_scope()=='user') {
@ -1031,7 +1031,7 @@ class posixAccount extends baseModule implements passwordService {
}
}
// Show warning if LAM has changed username
if ($this->attributes['uid'][0] != $_POST['uid']) {
if ($this->attributes['uid'][0] != trim($_POST['uid'])) {
if ($this->get_scope()=='user') $errors[] = $this->messages['uid'][5];
if ($this->get_scope()=='host') $errors[] = $this->messages['uid'][6];
}
@ -1787,7 +1787,7 @@ class posixAccount extends baseModule implements passwordService {
if ($this->get_scope() == 'user') {
if (($rawAccounts[$i][$ids['posixAccount_uid']] > $this->moduleSettings['posixAccount_minUID'][0]) &&
($rawAccounts[$i][$ids['posixAccount_uid']] < $this->moduleSettings['posixAccount_maxUID'][0])) {
$partialAccounts[$i]['uidNumber'] = $rawAccounts[$i][$ids['posixAccount_uid']];
$partialAccounts[$i]['uidNumber'] = trim($rawAccounts[$i][$ids['posixAccount_uid']]);
}
else {
$errMsg = $this->messages['uidNumber'][4];
@ -1798,7 +1798,7 @@ class posixAccount extends baseModule implements passwordService {
elseif ($this->get_scope() == 'host') {
if (($rawAccounts[$i][$ids['posixAccount_uid']] > $this->moduleSettings['posixAccount_minMachine'][0]) &&
($rawAccounts[$i][$ids['posixAccount_uid']] < $this->moduleSettings['posixAccount_maxMachine'][0])) {
$partialAccounts[$i]['uidNumber'] = $rawAccounts[$i][$ids['posixAccount_uid']];
$partialAccounts[$i]['uidNumber'] = trim($rawAccounts[$i][$ids['posixAccount_uid']]);
}
else {
$errMsg = $this->messages['uidNumber'][4];