general_surname = $_POST['f_general_surname']; // Check if givenname is valid if ( !eregi('^([a-z φόδί-])+$', $_POST['f_general_givenname'])) $errors2[] = array('ERROR', _('Given name'), _('Given name contains invalid characters')); else $_SESSION['mass_accounts'][$row]->general_givenname = $_POST['f_general_givenname']; // Check if username is valid if ( !eregi('^([a-z]|[0-9]|[.]|[-]|[_])*$', $_POST['f_general_username'])) $errors2[] = array('ERROR', _('Username'), _('Username contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ !')); else if ( !ereg('^([a-z]|[A-Z]).*$', $_POST['f_general_username'])) $errors2[] = array('ERROR', _('Name'), _('Name contains invalid characters. First character must be a letter.')); else { // Create Array with all users in ldap and in array // Validate cache-array ldapreload('user'); // Get List with all existing usernames foreach ($_SESSION['userDN'] as $user_array) $users[] = $user_array['uid']; // Get List with all users in array foreach ($_SESSION['mass_accounts'] as $user_array) $users[] = $user_array->general_username; // unset old username in user-array $users = @array_flip($users); unset ($users[$_SESSION['mass_accounts'][$row]->general_username]); $users = array_flip($users); // Store new username $_SESSION['mass_accounts'][$row]->general_username = $_POST['f_general_username']; // Set all usernames to unique usernames while (in_array($_SESSION['mass_accounts'][$row2]->general_username, $users)) { // get last character of username $lastchar = substr($_SESSION['mass_accounts'][$row2]->general_username, strlen($_SESSION['mass_accounts'][$row2]->general_username)-1, 1); // Last character is no number if ( !ereg('^([0-9])+$', $lastchar)) /* Last character is no number. Therefore we only have to * add "2" to it. */ $_SESSION['mass_accounts'][$row2]->general_username = $_SESSION['mass_accounts'][$row2]->general_username . '2'; else { /* Last character is a number -> we have to increase the number until we've * found a groupname with trailing number which is not in use. * * $i will show us were we have to split groupname so we get a part * with the groupname and a part with the trailing number */ $i=strlen($_SESSION['mass_accounts'][$row2]->general_username)-1; $mark = false; // Set $i to the last character which is a number in $account_new->general_username while (!$mark) { if (ereg('^([0-9])+$',substr($_SESSION['mass_accounts'][$row2]->general_username, $i, strlen($_SESSION['mass_accounts'][$row2]->general_username)-$i))) $i--; else $mark=true; } // increase last number with one $firstchars = substr($_SESSION['mass_accounts'][$row2]->general_username, 0, $i+1); $lastchars = substr($_SESSION['mass_accounts'][$row2]->general_username, $i+1, strlen($_SESSION['mass_accounts'][$row2]->general_username)-$i); // Put username together $_SESSION['mass_accounts'][$row2]->general_username = $firstchars . (intval($lastchars)+1); } // Show warning if lam has changed username $errors2[] = array('WARN', _('Username'), _('Username in use. Selected next free username.')); } } // Check personal settings if ( !eregi('^([a-z φόδί\\.-])*$', $_POST['f_personal_title'])) $errors2[] = array('ERROR', _('Job title'), _('Please enter a valid job title!')); else $_SESSION['mass_accounts'][$row]->personal_title = $_POST['f_personal_title']; if ( !eregi('^([a-z0-9 φόδί\\.-])*$', $_POST['f_personal_employeeType'])) $errors2[] = array('ERROR', _('Employee type'), _('Please enter a valid employee type!')); else $_SESSION['mass_accounts'][$row]->personal_employeeType = $_POST['f_personal_employeeType']; if ( !eregi('^([a-z0-9 φόδί\\.-])*$', $_POST['f_personal_street'])) $errors2[] = array('ERROR', _('Street'), _('Please enter a valid street name!')); else $_SESSION['mass_accounts'][$row]->personal_street = $_POST['f_personal_street']; if ( !ereg('^([0-9]|[A-Z]|[a-z])*$', $_POST['f_personal_postalCode'])) $errors2[] = array('ERROR', _('Postal code'), _('Please enter a valid postal code!')); else $_SESSION['mass_accounts'][$row]->personal_postalCode = $_POST['f_personal_postalCode']; if ( !eregi('^([a-z φόδί\\.-])*$', $_POST['f_personal_postalAddress'])) $errors2[] = array('ERROR', _('Postal address'), _('Please enter a valid postal address!')); else $_SESSION['mass_accounts'][$row]->personal_postalAddress = $_POST['f_personal_postalAddress']; if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/])*$', $_POST['f_personal_telephoneNumber'])) $errors2[] = array('ERROR', _('Telephone number'), _('Please enter a valid telephone number!')); else $_SESSION['mass_accounts'][$row]->personal_telephoneNumber = $_POST['f_personal_telephoneNumber']; if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/])*$', $_POST['f_personal_mobileTelephoneNumber'])) $errors2[] = array('ERROR', _('Mobile number'), _('Please enter a valid mobile number!')); else $_SESSION['mass_accounts'][$row]->personal_mobileTelephoneNumber = $_POST['f_personal_mobileTelephoneNumber']; if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/])*$', $_POST['f_personal_facsimileTelephoneNumber'])) $errors2[] = array('ERROR', _('Fax number'), _('Please enter a valid fax number!')); else $_SESSION['mass_accounts'][$row]->personal_facsimileTelephoneNumber = $_POST['f_personal_facsimileTelephoneNumber']; if ( !ereg('^(([0-9]|[A-Z]|[a-z]|[.]|[-]|[_])+[@]([0-9]|[A-Z]|[a-z]|[-])+([.]([0-9]|[A-Z]|[a-z]|[-])+)*)*$', $_POST['f_personal_mail'])) $errors2[] = array('ERROR', _('eMail address'), _('Please enter a valid eMail address!')); else $_SESSION['mass_accounts'][$row]->personal_mail = $_POST['f_personal_mail']; } // Print header and part of body echo $_SESSION['header']; echo '