fixed some quota issues. Group quotas should be working now
This commit is contained in:
parent
35ff466d26
commit
e14de2e72c
|
@ -708,14 +708,7 @@ function loadgroup($dn) { // Will load all needed values from an existing group
|
|||
}
|
||||
if (isset($attr['gidNumber'][0])) $return->general_uidNumber = $attr['gidNumber'][0];
|
||||
if (isset($attr['description'][0])) $return->general_gecos = utf8_decode($attr['description'][0]);
|
||||
if (isset($attr['cn'][0])) {
|
||||
$return->general_username = $attr['cn'][0];
|
||||
$values = getquotas('group', $attr['cn'][0]);
|
||||
if (is_object($values)) {
|
||||
while (list($key, $val) = each($values)) // Set only defined values
|
||||
if (isset($val)) $return->$key = $val;
|
||||
}
|
||||
}
|
||||
if (isset($attr['cn'][0])) $return->general_username = $attr['cn'][0];
|
||||
if (isset($attr['sambaSID'][0])) { // Samba3 Samba 2.0 don't have any objects 4 groups
|
||||
$return->smb_mapgroup = $attr['sambaSID'][0];
|
||||
if (isset($attr['displayName'][0])) $return->smb_displayName = utf8_decode($attr['displayName'][0]);
|
||||
|
@ -726,6 +719,7 @@ function loadgroup($dn) { // Will load all needed values from an existing group
|
|||
for ($i=0; $i<sizeof($samba3domains); $i++)
|
||||
if ($SID == $samba3domains[$i]->SID) $return->smb_domain = $samba3domains[$i];
|
||||
}
|
||||
// load quotas
|
||||
if ($_SESSION['config']->scriptServer) {
|
||||
$values = getquotas('group',$return->general_username);
|
||||
if (is_object($values)) {
|
||||
|
|
|
@ -77,7 +77,7 @@ sub get_fs { # Load mountpoints from mtab if enabled quotas
|
|||
$quota_usr[$j][3] = $args[$i][3];
|
||||
$j++;
|
||||
}
|
||||
elsif ( $args[$i][3] =~ m/grpquota/ ) {
|
||||
if ( $args[$i][3] =~ m/grpquota/ ) {
|
||||
$quota_grp[$k][0] = $args[$i][0];
|
||||
$quota_grp[$k][1] = $args[$i][1];
|
||||
$quota_grp[$k][2] = $args[$i][2];
|
||||
|
@ -151,6 +151,7 @@ if ($found==true) {
|
|||
get_fs(); # Load list of devices with enabled quotas
|
||||
# Store quota information in array
|
||||
@quota_temp1 = split (':', $vals[6]);
|
||||
$group=0;
|
||||
$i=0;
|
||||
while ($quota_temp1[$i]) {
|
||||
$j=0;
|
||||
|
@ -162,7 +163,7 @@ if ($found==true) {
|
|||
$i++;
|
||||
}
|
||||
if ($vals[5] eq 'u') { $group=false; } else {
|
||||
$group=true;
|
||||
$group=1;
|
||||
@quota_usr = @quota_grp;
|
||||
}
|
||||
switch2: {
|
||||
|
@ -171,7 +172,6 @@ if ($found==true) {
|
|||
($<, $>) = ($>, $<); # Get root privileges
|
||||
while ($quota_usr[$i][0]) {
|
||||
$dev = Quota::getqcarg($quota_usr[$i][1]);
|
||||
print "$user[2]\n";
|
||||
$return = Quota::setqlim($dev,$user[2],0,0,0,0,1,$group);
|
||||
$i++;
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ if ($found==true) {
|
|||
if ($vals[2]ne'+') {
|
||||
$dev = Quota::getqcarg($quota_usr[$i][1]);
|
||||
@temp = Quota::query($dev,$user[2],$group);
|
||||
if ($temp[0]) {
|
||||
if ($temp[0]ne'') {
|
||||
$return = "$quota_usr[$i][1],$temp[0],$temp[1],$temp[2],$temp[3],$temp[4],$temp[5],$temp[6],$temp[7]:$return";
|
||||
}
|
||||
else { $return = "$quota_usr[$i][1],0,0,0,0,0,0,0,0:$return"; }
|
||||
|
|
|
@ -47,13 +47,13 @@ if (isset($_GET['DN'])) {
|
|||
$_SESSION['account'] ->type = 'group';
|
||||
if (isset($_SESSION['account_old'])) unset($_SESSION['account_old']);
|
||||
$_SESSION['account_old'] = false;
|
||||
}
|
||||
$values = getquotas($type);
|
||||
$values = getquotas('group');
|
||||
if (is_object($values)) {
|
||||
while (list($key, $val) = each($values)) // Set only defined values
|
||||
if (isset($val)) $_SESSION['account']->$key = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (count($_POST)==0) { // Startcondition. groupedit.php was called from outside
|
||||
$_SESSION['account'] = loadGroupProfile('default');
|
||||
$_SESSION['account'] ->type = 'group';
|
||||
|
|
|
@ -53,6 +53,11 @@ if (isset($_GET['DN'])) {
|
|||
$_SESSION['account']->smb_flagsW = 0;
|
||||
if (isset($_SESSION['account_old'])) unset($_SESSION['account_old']);
|
||||
$_SESSION['account_old'] = false;
|
||||
$values = getquotas('user');
|
||||
if (is_object($values)) {
|
||||
while (list($key, $val) = each($values)) // Set only defined values
|
||||
if (isset($val)) $_SESSION['account']->$key = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (count($_POST)==0) { // Startcondition. useredit.php was called from outside
|
||||
|
@ -183,7 +188,7 @@ switch ($_POST['select']) { // Select which part of page should be loaded and ch
|
|||
$select_local = 'unix';
|
||||
}
|
||||
// Check if values are OK and set automatic values. if not error-variable will be set
|
||||
else { // $errors = checkunix($_SESSION['account'], $_SESSION['account']->type); // account.inc
|
||||
else { // account.inc
|
||||
if ($_SESSION['account']->unix_password != '') {
|
||||
$iv = base64_decode($_COOKIE["IV"]);
|
||||
$key = base64_decode($_COOKIE["Key"]);
|
||||
|
@ -479,7 +484,7 @@ if ($select_local != 'pdf') {
|
|||
}
|
||||
}
|
||||
|
||||
print_r($_SESSION['account']);
|
||||
// print_r($_SESSION['account']);
|
||||
// print_r($_POST);
|
||||
|
||||
switch ($select_local) { // Select which part of page will be loaded
|
||||
|
|
|
@ -51,9 +51,7 @@ if ($_POST['backmain'])
|
|||
}
|
||||
echo '</head>'."\n".
|
||||
'<body>'."\n".
|
||||
'<form action="delete.php" method="post">'."\n".
|
||||
'<table class="delete" width="100%">'."\n".
|
||||
'<tr><td>';
|
||||
'<form action="delete.php" method="post">'."\n";
|
||||
|
||||
if ($_GET['type']) {
|
||||
$DN2 = explode(";", str_replace("\'", '',$_GET['DN']));
|
||||
|
@ -61,31 +59,66 @@ if ($_GET['type']) {
|
|||
echo '<input name="DN" type="hidden" value="'.$_GET['DN'].'">';
|
||||
switch ($_GET['type']) {
|
||||
case 'user':
|
||||
echo _('Do you really want to delete user(s):');
|
||||
echo "<fieldset class=\"useredit-bright\"><legend class=\"useredit-bright\"><b>";
|
||||
echo _('Delete user(s)');
|
||||
echo "</b></legend>\n";
|
||||
echo _('<b>Do you really want to delete user(s):</b>');
|
||||
break;
|
||||
case 'host':
|
||||
echo _('Do you really want to delete host(s):');
|
||||
echo "<fieldset class=\"hostedit-bright\"><legend class=\"hostedit-bright\"><b>";
|
||||
echo _('Delete host(s)');
|
||||
echo "</b></legend>\n";
|
||||
echo _('<b>Do you really want to delete host(s):</b>');
|
||||
break;
|
||||
case 'group':
|
||||
echo _('Do you really want to delete group(s):');
|
||||
echo "<fieldset class=\"groupedit-bright\"><legend class=\"groupedit-bright\"><b>";
|
||||
echo _('Delete group(s)');
|
||||
echo "</b></legend>\n";
|
||||
echo _('<b>Do you really want to delete group(s):</b>');
|
||||
break;
|
||||
}
|
||||
echo '</td></tr>'."\n";
|
||||
echo "<table border=0 width=\"100%\">\n";
|
||||
foreach ($DN2 as $dn) echo '<tr><td>'.$dn.'</td></tr>';
|
||||
echo '<tr><td>';
|
||||
echo "</table>\n";
|
||||
if (($_GET['type']== user) && $_SESSION['config']->scriptServer) {
|
||||
echo "<table border=0 width=\"100%\">\n";
|
||||
echo '<tr><td>';
|
||||
echo _('Delete also Homedirectories');
|
||||
echo '</td>'."\n".'<td><input name="f_rem_home" type="checkbox">'.
|
||||
'</td></tr>'."\n".'<tr><td>';
|
||||
'</td></tr>'."\n";
|
||||
echo "</table>\n";
|
||||
}
|
||||
echo '<br></td></tr>'."\n".'<tr><td>'.
|
||||
|
||||
echo "<br><table border=0 width=\"100%\">\n";
|
||||
echo '<tr><td>'.
|
||||
'<input name="delete_no" type="submit" value="';
|
||||
echo _('Cancel'); echo '"></td><td></td><td>'.
|
||||
'<input name="delete_yes" type="submit" value="';
|
||||
echo _('Commit'); echo '"></td></tr>';
|
||||
echo "</table></fieldset>\n";
|
||||
}
|
||||
|
||||
|
||||
if ($_POST['delete_yes'] && !$_POST['backmain']) {
|
||||
|
||||
switch ($_POST['type5']) {
|
||||
case 'user':
|
||||
echo "<fieldset class=\"useredit-bright\"><legend class=\"useredit-bright\"><b>";
|
||||
echo _('Deleting user(s)...');
|
||||
echo "</b></legend>\n";
|
||||
break;
|
||||
case 'host':
|
||||
echo "<fieldset class=\"hostedit-bright\"><legend class=\"hostedit-bright\"><b>";
|
||||
echo _('Deleting host(s)...');
|
||||
echo "</b></legend>\n";
|
||||
break;
|
||||
case 'group':
|
||||
echo "<fieldset class=\"groupedit-bright\"><legend class=\"groupedit-bright\"><b>";
|
||||
echo _('Deleting group(s)...');
|
||||
echo "</b></legend>\n";
|
||||
break;
|
||||
}
|
||||
echo "<br><table border=0 width=\"100%\">\n";
|
||||
$DN2 = explode(";", str_replace("\\", '',str_replace("\'", '',$_POST['DN'])));
|
||||
foreach ($DN2 as $dn) {
|
||||
echo '<input name="type5" type="hidden" value="'.$_POST['type5'].'">';
|
||||
|
@ -136,48 +169,74 @@ if ($_POST['delete_yes'] && !$_POST['backmain']) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
if (!$error) echo $dn.' '. _('deleted').'.';
|
||||
else echo $error;
|
||||
echo '</td></tr>'."\n".'<tr><td>';
|
||||
if (!$error) echo "<tr><td><b>$dn ". _('deleted').".</b></td></tr>\n";
|
||||
else echo "<tr><td><b>$error</b></td></tr>\n";
|
||||
}
|
||||
echo "</table><br>\n";
|
||||
switch ($_POST['type5']) {
|
||||
case 'user':
|
||||
echo '<input name="backmain" type="submit" value="'; echo _('Back to user list'); echo '">'.
|
||||
'</td></tr>'."\n";
|
||||
echo '<input name="backmain" type="submit" value="'; echo _('Back to user list'); echo '">';
|
||||
break;
|
||||
case 'group':
|
||||
echo '<input name="backmain" type="submit" value="'; echo _('Back to group list'); echo '">'.
|
||||
'</td></tr>'."\n";
|
||||
echo '<input name="backmain" type="submit" value="'; echo _('Back to group list'); echo '">';
|
||||
break;
|
||||
case 'host':
|
||||
echo '<input name="backmain" type="submit" value="'; echo _('Back to host list'); echo '">'.
|
||||
'</td></tr>'."\n";
|
||||
echo '<input name="backmain" type="submit" value="'; echo _('Back to host list'); echo '">';
|
||||
break;
|
||||
}
|
||||
echo "</fieldset>\n";
|
||||
}
|
||||
|
||||
if ($_POST['delete_no']) {
|
||||
echo _('Nothing was deleted').'</td></tr>';
|
||||
switch ($_POST['type5']) {
|
||||
case 'user':
|
||||
echo "<fieldset class=\"useredit-bright\"><legend class=\"useredit-bright\"><b>";
|
||||
echo _('Deleting user(s) canceled.');
|
||||
echo "</b></legend>\n";
|
||||
echo _('No user(s) were deleted');
|
||||
echo "<br>";
|
||||
echo '<input name="backmain" type="submit" value="'; echo _('Back to user list'); echo '">';
|
||||
echo "</fieldset>\n";
|
||||
break;
|
||||
case 'host':
|
||||
echo "<fieldset class=\"hostedit-bright\"><legend class=\"hostedit-bright\"><b>";
|
||||
echo _('Deleting host(s) canceled.');
|
||||
echo "</b></legend>\n";
|
||||
echo _('No host(s) were deleted');
|
||||
echo "<br>";
|
||||
echo '<input name="backmain" type="submit" value="'; echo _('Back to host list'); echo '">';
|
||||
echo "</fieldset>\n";
|
||||
break;
|
||||
case 'group':
|
||||
echo "<fieldset class=\"groupedit-bright\"><legend class=\"groupedit-bright\"><b>";
|
||||
echo _('Deleting group(s) canceled.');
|
||||
echo "</b></legend>\n";
|
||||
echo _('No group(s) were deleted');
|
||||
echo "<br>";
|
||||
echo '<input name="backmain" type="submit" value="'; echo _('Back to group list'); echo '">';
|
||||
echo "</fieldset>\n";
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($_POST['backmain'])
|
||||
switch ( $_POST['type5'] ) {
|
||||
case 'user' :
|
||||
echo '<tr><td><a href="lists/listusers.php">';
|
||||
echo '<a href="lists/listusers.php">';
|
||||
echo _('Please press here if meta-refresh didn\'t work.');
|
||||
echo "</a></td></tr>\n";
|
||||
echo "</a>\n";
|
||||
break;
|
||||
case 'group' :
|
||||
echo '<tr><td><a href="lists/listgroup.php">';
|
||||
echo '<a href="lists/listgroups.php">';
|
||||
echo _('Please press here if meta-refresh didn\'t work.');
|
||||
echo "</a></td></tr>\n";
|
||||
echo "</a>\n";
|
||||
break;
|
||||
case 'host' :
|
||||
echo '<tr><td><a href="lists/listhost.php">';
|
||||
echo '<a href="lists/listhosts.php">';
|
||||
echo _('Please press here if meta-refresh didn\'t work.');
|
||||
echo "</a></td></tr>\n";
|
||||
echo "</a>\n";
|
||||
break;
|
||||
}
|
||||
echo '</table></form></body></html>'."\n";
|
||||
echo '</form></body></html>'."\n";
|
||||
?>
|
||||
|
|
|
@ -355,33 +355,117 @@ function loadfile() {
|
|||
}
|
||||
if ($values->general_username != $return->general_username) $error[] = array('WARN', _('Username'), _('Username in use. Selected next free username.'));
|
||||
$_SESSION['errors'][$row2] = array_merge($_SESSION['errors'][$row2], $error);
|
||||
list($values, $error) = checkglobal($_SESSION['accounts'][$row2], 'user'); // account.inc
|
||||
$_SESSION['errors'][$row2] = array_merge($_SESSION['errors'][$row2], $error);
|
||||
if (is_object($values)) {
|
||||
while (list($key, $val) = each($values)) // Set only defined values
|
||||
if ($val) $_SESSION['accounts'][$row2]->$key = $val;
|
||||
$_SESSION['accounts'][$row2]->general_uidNumber="";
|
||||
// Check if Homedir is valid
|
||||
$_SESSION['account'][$row2]->general_homedir = str_replace('$group', $_SESSION['account'][$row2]->general_group, $_SESSION['account'][$row2]->general_homedir);
|
||||
if ($_SESSION['account'][$row2]->general_username != '')
|
||||
$_SESSION['account'][$row2]->general_homedir = str_replace('$user', $_SESSION['account'][$row2]->general_username, $_SESSION['account'][$row2]->general_homedir);
|
||||
if ( !ereg('^[/]([a-z]|[A-Z])([a-z]|[A-Z]|[0-9]|[.]|[-]|[_])*([/]([a-z]|[A-Z])([a-z]|[A-Z]|[0-9]|[.]|[-]|[_])*)*$', $_SESSION['account'][$row2]->general_homedir ))
|
||||
$errors[] = array('ERROR', _('Home directory'), _('Homedirectory contains invalid characters.'));
|
||||
// Check if givenname is valid
|
||||
if ( !ereg('^([a-z]|[A-Z]|[-]|[ ]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+$', $_SESSION['account'][$row2]->general_givenname)) $errors[] = array('ERROR', _('Given name'), _('Given name contains invalid characters'));
|
||||
// Check if surname is valid
|
||||
if ( !ereg('^([a-z]|[A-Z]|[-]|[ ]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+$', $_SESSION['account'][$row2]->general_surname)) $errors[] = array('ERROR', _('Surname'), _('Surname contains invalid characters'));
|
||||
if ( ($_SESSION['account'][$row2]->general_gecos=='') || ($_SESSION['account'][$row2]->general_gecos==' ')) {
|
||||
$_SESSION['account'][$row2]->general_gecos = $_SESSION['account'][$row2]->general_givenname . " " . $_SESSION['account'][$row2]->general_surname ;
|
||||
$errors[] = array('INFO', _('Gecos'), _('Inserted sur- and given name in gecos-field.'));
|
||||
}
|
||||
$error = checkunix($_SESSION['accounts'][$row2], 'user'); // account.inc
|
||||
$_SESSION['errors'][$row2] = array_merge($_SESSION['errors'][$row2], $error);
|
||||
list($values, $error) = checksamba($_SESSION['accounts'][$row2], 'user'); // account.inc
|
||||
if (is_object($values)) {
|
||||
while (list($key, $val) = each($values)) // Set only defined values
|
||||
if ($val) $_SESSION['accounts'][$row2]->$key = $val;
|
||||
if ($_SESSION['account'][$row2]->general_group=='') $errors[] = array('ERROR', _('Primary group'), _('No primary group defined!'));
|
||||
// Check if Username contains only valid characters
|
||||
if ( !ereg('^([a-z]|[0-9]|[.]|[-]|[_])*$', $_SESSION['account'][$row2]->general_username))
|
||||
$errors[] = array('ERROR', _('Username'), _('Username contains invalid characters. Valid characters are: a-z, 0-9 and .-_ !'));
|
||||
// Check if user already exists
|
||||
if (isset($_SESSION['account'][$row2]->general_groupadd) && in_array($_SESSION['account'][$row2]->general_group, $_SESSION['account'][$row2]->general_groupadd)) {
|
||||
for ($i=0; $i<count($_SESSION['account'][$row2]->general_groupadd); $i++ )
|
||||
if ($_SESSION['account'][$row2]->general_groupadd[$i] == $_SESSION['account'][$row2]->general_group) {
|
||||
unset ($_SESSION['account'][$row2]->general_groupadd[$i]);
|
||||
$_SESSION['account'][$row2]->general_groupadd = array_values($_SESSION['account'][$row2]->general_groupadd);
|
||||
}
|
||||
$_SESSION['errors'][$row2] = array_merge($_SESSION['errors'][$row2], $error);
|
||||
list($values, $error) = checkquota($_SESSION['accounts'][$row2], 'user'); // account.inc
|
||||
if (is_object($values)) {
|
||||
while (list($key, $val) = each($values)) // Set only defined values
|
||||
if ($val) $_SESSION['accounts'][$row2]->$key = $val;
|
||||
}
|
||||
$_SESSION['errors'][$row2] = array_merge($_SESSION['errors'][$row2], $error);
|
||||
list($values, $error) = checkpersonal($_SESSION['accounts'][$row2], 'user'); // account.inc
|
||||
if (is_object($values)) {
|
||||
while (list($key, $val) = each($values)) // Set only defined values
|
||||
if ($val) $_SESSION['accounts'][$row2]->$key = $val;
|
||||
// Create automatic useraccount with number if original user already exists
|
||||
// Reset name to original name if new name is in use
|
||||
while ($temp = ldapexists($_SESSION['account'][$row2], 'user')) {
|
||||
// get last character of username
|
||||
$lastchar = substr($_SESSION['account'][$row2]->general_username, strlen($_SESSION['account'][$row2]->general_username)-1, 1);
|
||||
// Last character is no number
|
||||
if ( !ereg('^([0-9])+$', $lastchar))
|
||||
$_SESSION['account'][$row2]->general_username = $_SESSION['account'][$row2]->general_username . '2';
|
||||
else {
|
||||
$i=strlen($_SESSION['account'][$row2]->general_username)-1;
|
||||
$mark = false;
|
||||
while (!$mark) {
|
||||
if (ereg('^([0-9])+$',substr($_SESSION['account'][$row2]->general_username, $i, strlen($_SESSION['account'][$row2]->general_username)-$i))) $i--;
|
||||
else $mark=true;
|
||||
}
|
||||
$_SESSION['errors'][$row2] = array_merge($_SESSION['errors'][$row2], $error);
|
||||
// increase last number with one
|
||||
$firstchars = substr($_SESSION['account'][$row2]->general_username, 0, $i+1);
|
||||
$lastchars = substr($_SESSION['account'][$row2]->general_username, $i+1, strlen($_SESSION['account'][$row2]->general_username)-$i);
|
||||
$_SESSION['account'][$row2]->general_username = $firstchars . (intval($lastchars)+1);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if UID is valid. If none value was entered, the next useable value will be inserted
|
||||
$_SESSION['account'][$row2]->general_uidNumber = checkid($_SESSION['account'][$row2], 'user');
|
||||
if (is_string($_SESSION['account'][$row2]->general_uidNumber)) { // true if checkid has returned an error
|
||||
$errors[] = array('ERROR', _('ID-Number'), $_SESSION['account'][$row2]->general_uidNumber);
|
||||
unset($_SESSION['account'][$row2]->general_uidNumber);
|
||||
}
|
||||
// Check if Name-length is OK. minLength=3, maxLength=20
|
||||
if ( !ereg('.{3,20}', $_SESSION['account'][$row2]->general_username)) $errors[] = array('ERROR', _('Name'), _('Name must contain between 3 and 20 characters.'));
|
||||
// Check if Name starts with letter
|
||||
if ( !ereg('^([a-z]|[A-Z]).*$', $_SESSION['account'][$row2]->general_username))
|
||||
$errors[] = array('ERROR', _('Name'), _('Name contains invalid characters. First character must be a letter'));
|
||||
$_SESSION['errors'][$row2] = array_merge($_SESSION['errors'][$row2], $errors);
|
||||
if (isset($errors)) unset ($errors);
|
||||
|
||||
if ($_SESSION['account'][$row2]->unix_password != '') {
|
||||
$iv = base64_decode($_COOKIE["IV"]);
|
||||
$key = base64_decode($_COOKIE["Key"]);
|
||||
$password = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($_SESSION['account'][$row2]->unix_password), MCRYPT_MODE_ECB, $iv);
|
||||
$password = str_replace(chr(00), '', $password);
|
||||
}
|
||||
if (!ereg('^([a-z]|[A-Z]|[0-9]|[\|]|[\#]|[\*]|[\,]|[\.]|[\;]|[\:]|[\_]|[\-]|[\+]|[\!]|[\%]|[\&]|[\/]|[\?]|[\{]|[\[]|[\(]|[\)]|[\]]|[\}])*$', $password))
|
||||
$errors[] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!$%&/|?{[()]}= !'));
|
||||
if ( !ereg('^([0-9])*$', $_SESSION['account'][$row2]->unix_pwdminage)) $errors[] = array('ERROR', _('Password minage'), _('Password minage must be are natural number.'));
|
||||
if ( $_SESSION['account'][$row2]->unix_pwdminage > $_SESSION['account'][$row2]->unix_pwdmaxage ) $errors[] = array('ERROR', _('Password maxage'), _('Password maxage must bigger as Password Minage.'));
|
||||
if ( !ereg('^([0-9]*)$', $_SESSION['account'][$row2]->unix_pwdmaxage)) $errors[] = array('ERROR', _('Password maxage'), _('Password maxage must be are natural number.'));
|
||||
if ( !ereg('^(([-][1])|([0-9]*))$', $_SESSION['account'][$row2]->unix_pwdallowlogin))
|
||||
$errors[] = array('ERROR', _('Password Expire'), _('Password expire must be are natural number or -1.'));
|
||||
if ( !ereg('^([0-9]*)$', $_SESSION['account'][$row2]->unix_pwdwarn)) $errors[] = array('ERROR', _('Password warn'), _('Password warn must be are natural number.'));
|
||||
if ((!$_SESSION['account'][$row2]->unix_host=='') && !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-])+(([,])+([ ])*([a-z]|[A-Z]|[0-9]|[.]|[-])+)*$', $_SESSION['account']->unix_host))
|
||||
$errors[] = array('ERROR', _('Unix workstations'), _('Unix workstations is invalid.'));
|
||||
$_SESSION['errors'][$row2] = array_merge($_SESSION['errors'][$row2], $errors);
|
||||
if (isset($errors)) unset ($errors);
|
||||
|
||||
$_SESSION['account'][$row2]->smb_displayName = $_SESSION['account'][$row2]->general_gecos;
|
||||
|
||||
$i=0;
|
||||
while ($_SESSION['account'][$row2]->quota[$i][0]) {
|
||||
// Check if values are OK and set automatic values. if not error-variable will be set
|
||||
if (!ereg('^([0-9])*$', $_SESSION['account'][$row2]->quota[$i][2]))
|
||||
$errors[] = array('ERROR', _('Block soft quota'), _('Block soft quota contains invalid characters. Only natural numbers are allowed'));
|
||||
if (!ereg('^([0-9])*$', $_SESSION['account'][$row2]->quota[$i][3]))
|
||||
$errors[] = array('ERROR', _('Block hard quota'), _('Block hard quota contains invalid characters. Only natural numbers are allowed'));
|
||||
if (!ereg('^([0-9])*$', $_SESSION['account'][$row2]->quota[$i][6]))
|
||||
$errors[] = array('ERROR', _('Inode soft quota'), _('Inode soft quota contains invalid characters. Only natural numbers are allowed'));
|
||||
if (!ereg('^([0-9])*$', $_SESSION['account'][$row2]->quota[$i][7]))
|
||||
$errors[] = array('ERROR', _('Inode hard quota'), _('Inode hard quota contains invalid characters. Only natural numbers are allowed'));
|
||||
$i++;
|
||||
}
|
||||
$_SESSION['errors'][$row2] = array_merge($_SESSION['errors'][$row2], $errors);
|
||||
if (isset($errors)) unset ($errors);
|
||||
|
||||
if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/])*$', $_SESSION['account'][$row2]->personal_telephoneNumber)) $errors[] = array('ERROR', _('Telephone number'), _('Please enter a valid telephone number!'));
|
||||
if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/])*$', $_SESSION['account'][$row2]->personal_mobileTelephoneNumber)) $errors[] = array('ERROR', _('Mobile number'), _('Please enter a valid mobile number!'));
|
||||
if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/])*$', $_SESSION['account'][$row2]->personal_facsimileTelephoneNumber)) $errors[] = array('ERROR', _('Fax number'), _('Please enter a valid fax number!'));
|
||||
if ( !ereg('^(([0-9]|[A-Z]|[a-z]|[.]|[-]|[_])+[@]([0-9]|[A-Z]|[a-z]|[-])+([.]([0-9]|[A-Z]|[a-z]|[-])+)*)*$', $_SESSION['account'][$row2]->personal_mail)) $errors[] = array('ERROR', _('eMail address'), _('Please enter a valid eMail address!'));
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $_SESSION['account'][$row2]->personal_street)) $errors[] = array('ERROR', _('Street'), _('Please enter a valid street name!'));
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $_SESSION['account'][$row2]->personal_postalAddress)) $errors[] = array('ERROR', _('Postal address'), _('Please enter a valid postal address!'));
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $_SESSION['account'][$row2]->personal_title)) $errors[] = array('ERROR', _('Title'), _('Please enter a valid title!'));
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $_SESSION['account'][$row2]->personal_employeeType)) $errors[] = array('ERROR', _('Employee type'), _('Please enter a valid employee type!'));
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z])*$', $_SESSION['account']->personal_postalCode)) $errors[] = array('ERROR', _('Postal code'), _('Please enter a valid postal code!'));
|
||||
$_SESSION['errors'][$row2] = array_merge($_SESSION['errors'][$row2], $errors);
|
||||
if (isset($errors)) unset ($errors);
|
||||
|
||||
}
|
||||
}
|
||||
if ($_FILES['userfile']['size']>0) {
|
||||
|
|
|
@ -29,7 +29,6 @@ include_once('../lib/config.inc'); // File with configure-functions
|
|||
session_save_path('../sess');
|
||||
@session_start();
|
||||
|
||||
echo $_SESSION['account'];
|
||||
echo '<html><head><title>';
|
||||
echo _('Create new accounts');
|
||||
echo '</title>'.
|
||||
|
@ -38,8 +37,7 @@ echo '</title>'.
|
|||
'<meta http-equiv="cache-control" content="no-cache">'.
|
||||
'</head><body>'.
|
||||
'<form enctype="multipart/form-data" action="massdetail.php" method="post">'.
|
||||
'<table class="massdetail" width="100%">'.
|
||||
'<tr><td></td></tr>';
|
||||
'<table class="massdetail" width="100%">';
|
||||
|
||||
if ($_GET) {
|
||||
$row = $_GET['row'];
|
||||
|
@ -51,51 +49,104 @@ if ($_POST) {
|
|||
}
|
||||
|
||||
if ($_POST['apply']) {
|
||||
if ($_POST['f_general_surname']) $_SESSION['accounts'][$row]->general_surname = $_POST['f_general_surname'];
|
||||
else $_SESSION['accounts'][$row]->general_surname='';
|
||||
if ($_POST['f_general_givenname']) $_SESSION['accounts'][$row]->general_givenname = $_POST['f_general_givenname'];
|
||||
else $_SESSION['accounts'][$row]->general_givenname='';
|
||||
if ($_POST['f_general_username']) $_SESSION['accounts'][$row]->general_username = $_POST['f_general_username'];
|
||||
else $_SESSION['accounts'][$row]->general_username='';
|
||||
if ($_POST['f_general_group']) $_SESSION['accounts'][$row]->general_group = $_POST['f_general_group'];
|
||||
else $_SESSION['accounts'][$row]->general_group='';
|
||||
if ($_POST['f_personal_title']) $_SESSION['accounts'][$row]->personal_title = $_POST['f_personal_title'];
|
||||
else $_SESSION['accounts'][$row]->personal_title='';
|
||||
if ($_POST['f_personal_employeeType']) $_SESSION['accounts'][$row]->personal_employeeType = $_POST['f_personal_employeeType'];
|
||||
else $_SESSION['accounts'][$row]->personal_employeeType='';
|
||||
if ($_POST['f_personal_street']) $_SESSION['accounts'][$row]->personal_street = $_POST['f_personal_street'];
|
||||
else $_SESSION['accounts'][$row]->personal_street='';
|
||||
if ($_POST['f_personal_postalCode']) $_SESSION['accounts'][$row]->personal_postalCode = $_POST['f_personal_postalCode'];
|
||||
else $_SESSION['accounts'][$row]->personal_postalCode='';
|
||||
if ($_POST['f_personal_postalAddress']) $_SESSION['accounts'][$row]->personal_postalAddress = $_POST['f_personal_postalAddress'];
|
||||
else $_SESSION['accounts'][$row]->personal_postalAddress='';
|
||||
if ($_POST['f_personal_telephoneNumber']) $_SESSION['accounts'][$row]->personal_telephoneNumber = $_POST['f_personal_telephoneNumber'];
|
||||
else $_SESSION['accounts'][$row]->personal_telephoneNumber='';
|
||||
if ($_POST['f_personal_mobileTelephoneNumber']) $_SESSION['accounts'][$row]->personal_mobileTelephoneNumber = $_POST['f_personal_mobileTelephoneNumber'];
|
||||
else $_SESSION['accounts'][$row]->personal_mobileTelephoneNumber='';
|
||||
if ($_POST['f_personal_facsimileTelephoneNumber']) $_SESSION['accounts'][$row]->personal_facsimileTelephoneNumber = $_POST['f_personal_facsimileTelephoneNumber'];
|
||||
else $_SESSION['accounts'][$row]->personal_facsimileTelephoneNumber='';
|
||||
if ($_POST['f_personal_mail']) $_SESSION['accounts'][$row]->personal_mail = $_POST['f_personal_mail'];
|
||||
else $_SESSION['accounts'][$row]->personal_mail='';
|
||||
|
||||
|
||||
// Check if surname is valid
|
||||
if ( !ereg('^([a-z]|[A-Z]|[-]|[ ]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+$', $_POST['f_general_surname'])) $errors[] = array('ERROR', _('Surname'), _('Surname contains invalid characters'));
|
||||
else $_SESSION['accounts'][$row]->general_surname = $_POST['f_general_surname'];
|
||||
// Check if givenname is valid
|
||||
if ( !ereg('^([a-z]|[A-Z]|[-]|[ ]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+$', $_POST['f_general_givenname'])) $errors[] = array('ERROR', _('Given name'), _('Given name contains invalid characters'));
|
||||
else $_SESSION['accounts'][$row]->general_givenname = $_POST['f_general_givenname'];
|
||||
// Check if username is valid
|
||||
if ( !ereg('^([a-z]|[0-9]|[.]|[-]|[_])*$', $_POST['f_general_username']))
|
||||
$errors[] = array('ERROR', _('Username'), _('Username contains invalid characters. Valid characters are: a-z, 0-9 and .-_ !'));
|
||||
else {
|
||||
$_SESSION['accounts'][$row]->general_username = $_POST['f_general_username'];
|
||||
// Check if user already exists
|
||||
if (isset($_SESSION['account'][$row]->general_groupadd) && in_array($_SESSION['account'][$row]->general_group, $_SESSION['account'][$row]->general_groupadd)) {
|
||||
for ($i=0; $i<count($_SESSION['account'][$row]->general_groupadd); $i++ )
|
||||
if ($_SESSION['account'][$row]->general_groupadd[$i] == $_SESSION['account'][$row]->general_group) {
|
||||
unset ($_SESSION['account'][$row]->general_groupadd[$i]);
|
||||
$_SESSION['account'][$row]->general_groupadd = array_values($_SESSION['account'][$row]->general_groupadd);
|
||||
}
|
||||
}
|
||||
// Create automatic useraccount with number if original user already exists
|
||||
// Reset name to original name if new name is in use
|
||||
while ($temp = ldapexists($_SESSION['account'][$row], 'user')) {
|
||||
// get last character of username
|
||||
$lastchar = substr($_SESSION['account'][$row]->general_username, strlen($_SESSION['account'][$row]->general_username)-1, 1);
|
||||
// Last character is no number
|
||||
if ( !ereg('^([0-9])+$', $lastchar))
|
||||
$_SESSION['account'][$row]->general_username = $_SESSION['account'][$row]->general_username . '2';
|
||||
else {
|
||||
$i=strlen($_SESSION['account'][$row]->general_username)-1;
|
||||
$mark = false;
|
||||
while (!$mark) {
|
||||
if (ereg('^([0-9])+$',substr($_SESSION['account'][$row]->general_username, $i, strlen($_SESSION['account'][$row]->general_username)-$i))) $i--;
|
||||
else $mark=true;
|
||||
}
|
||||
// increase last number with one
|
||||
$firstchars = substr($_SESSION['account'][$row]->general_username, 0, $i+1);
|
||||
$lastchars = substr($_SESSION['account'][$row]->general_username, $i+1, strlen($_SESSION['account'][$row]->general_username)-$i);
|
||||
$_SESSION['account'][$row]->general_username = $firstchars . (intval($lastchars)+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
// check if group is valid
|
||||
if ($_POST['f_general_group']!='') $_SESSION['accounts'][$row]->general_group = $_POST['f_general_group'];
|
||||
else $errors[] = array('Error', _('Primary group'), _('No primary group defined.'));
|
||||
if (in_array($_POST['f_general_group'], findgroups)) $_SESSION['accounts'][$row]->general_group = $_POST['f_general_group'];
|
||||
else $errors[] = array('Warning', _('Primary group'), _('Primary group does not exist. Will create group automaticly.'));
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $_POST['f_personal_title'])) $errors[] = array('ERROR', _('Title'), _('Please enter a valid title!'));
|
||||
else $_SESSION['accounts'][$row]->personal_title = $_POST['f_personal_title'];
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $_POST['f_personal_employeeType'])) $errors[] = array('ERROR', _('Employee type'), _('Please enter a valid employee type!'));
|
||||
else $_SESSION['accounts'][$row]->personal_employeeType = $_POST['f_personal_employeeType'];
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $_POST['f_personal_street'])) $errors[] = array('ERROR', _('Street'), _('Please enter a valid street name!'));
|
||||
else $_SESSION['accounts'][$row]->personal_street = $_POST['f_personal_street'];
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z])*$', $_POST['f_personal_postalCode'])) $errors[] = array('ERROR', _('Postal code'), _('Please enter a valid postal code!'));
|
||||
else $_SESSION['accounts'][$row]->personal_postalCode = $_POST['f_personal_postalCode'];
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $_POST['f_personal_postalAddress'])) $errors[] = array('ERROR', _('Postal address'), _('Please enter a valid postal address!'));
|
||||
else $_SESSION['accounts'][$row]->personal_postalAddress = $_POST['f_personal_postalAddress'];
|
||||
if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/])*$', $_POST['f_personal_telephoneNumber'])) $errors[] = array('ERROR', _('Telephone number'), _('Please enter a valid telephone number!'));
|
||||
else $_SESSION['accounts'][$row]->personal_telephoneNumber = $_POST['f_personal_telephoneNumber'];
|
||||
if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/])*$', $_POST['f_personal_mobileTelephoneNumber'])) $errors[] = array('ERROR', _('Mobile number'), _('Please enter a valid mobile number!'));
|
||||
else $_SESSION['accounts'][$row]->personal_mobileTelephoneNumber = $_POST['f_personal_mobileTelephoneNumber'];
|
||||
|
||||
if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/])*$', $_POST['f_personal_facsimileTelephoneNumber'])) $errors[] = array('ERROR', _('Fax number'), _('Please enter a valid fax number!'));
|
||||
else $_SESSION['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'])) $errors[] = array('ERROR', _('eMail address'), _('Please enter a valid eMail address!'));
|
||||
else $_SESSION['accounts'][$row]->personal_mail = $_POST['f_personal_mail'];
|
||||
|
||||
}
|
||||
|
||||
echo '<tr><td><input name="type" type="hidden" value="'.$select.'">';
|
||||
echo '<tr><td><input name="row" type="hidden" value="'.$row.'">';
|
||||
echo '<tr><td><input name="type" type="hidden" value="'.$select.'"></td></tr>';
|
||||
echo '<tr><td><input name="row" type="hidden" value="'.$row.'"></td></tr>';
|
||||
|
||||
if (is_array($errors)) {
|
||||
for ($i=0; $i<sizeof($errors); $i++) {
|
||||
StatusMessage($errors[$i][0], $errors[$i][1], $errors[$i][2]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch ($select) {
|
||||
case 'error':
|
||||
for ($i=0; $i<sizeof($_SESSION['errors'][$row]); $i++)
|
||||
if ($_SESSION['errors'][$row][$i][0] == 'ERROR')
|
||||
if ($_SESSION['errors'][$row][$i][0] == 'ERROR') {
|
||||
StatusMessage('ERROR', _('Invalid Value!'), $_SESSION['errors'][$row][$i][2]);
|
||||
}
|
||||
break;
|
||||
case 'info':
|
||||
for ($i=0; $i<sizeof($_SESSION['errors'][$row]); $i++)
|
||||
if ($_SESSION['errors'][$row][$i][0] == 'INFO')
|
||||
if ($_SESSION['errors'][$row][$i][0] == 'INFO') {
|
||||
StatusMessage('INFO', _('Check values.'), $_SESSION['errors'][$row][$i][2]);
|
||||
}
|
||||
break;
|
||||
case 'warn':
|
||||
for ($i=0; $i<sizeof($_SESSION['errors'][$row]); $i++)
|
||||
if ($_SESSION['errors'][$row][$i][0] == 'WARN')
|
||||
if ($_SESSION['errors'][$row][$i][0] == 'WARN') {
|
||||
StatusMessage('WARN', _('Check values.'), $_SESSION['errors'][$row][$i][2]);
|
||||
}
|
||||
break;
|
||||
case 'detail':
|
||||
echo '<tr><td>';
|
||||
|
|
Loading…
Reference in New Issue