run lamdaemon.pl only if really needed.

This commit is contained in:
katagia 2003-10-04 18:44:18 +00:00
parent 3b5cab97f3
commit e75a2edc87
4 changed files with 912 additions and 815 deletions

View File

@ -33,49 +33,79 @@ include_once('../../lib/ldap.inc'); // LDAP-functions
session_save_path('../../sess');
@session_start();
setlanguage();
if (!isset($_POST['varkey'])) $varkey = session_id().time();
else $varkey = $_POST['varkey'];
if (!isset($_SESSION['account_'.$varkey.'_account_new'])) $_SESSION['account_'.$varkey.'_account_new'] = new account();
if (!isset($_SESSION['account_'.$varkey.'_account_old'])) $_SESSION['account_'.$varkey.'_account_old'] = new account();
if (!isset($_SESSION['account_'.$varkey.'_final_changegids'])) $_SESSION['account_'.$varkey.'_final_changegids'] = '';
// Register Session-Variables with references so we don't net to change to complete code if names changes
$account_new =& $_SESSION['account_'.$varkey.'_account_new'];
$final_changegids =& $_SESSION['account_'.$varkey.'_final_changegids'];
if (isset($_SESSION['account_'.$varkey.'_account_old'])) $account_old =& $_SESSION['account_'.$varkey.'_account_old'];
$ldap_intern =& $_SESSION['ldap'];
$config_intern =& $_SESSION['config'];
$lamurl_intern =& $_SESSION['lamurl'];
$header_intern =& $_SESSION['header'];
$userDN_intern =& $_SESSION['userDN'];
if (isset($_POST['select'])) $select =& $_POST['select'];
if (isset($_POST['load'])) $load =& $_POST['load'];
if (isset($_GET['DN'])) {
if (isset($_GET['DN']) && $_GET['DN']!='') {
if (isset($_SESSION['account_old'])) unset($_SESSION['account_old']);
if (isset($_SESSION['account_'.$varkey.'_account_old'])) {
unset($account_old);
unset($_SESSION['account_'.$varkey.'_account_old']);
$_SESSION['account_'.$varkey.'_account_old'] = new account();
$account_old =& $_SESSION['account_'.$varkey.'_account_old'];
}
$DN = str_replace("\'", '',$_GET['DN']);
$_SESSION['account'] = loadgroup($DN);
$_SESSION['account_old'] = $_SESSION['account'];
$_SESSION['account']->general_dn = substr($_SESSION['account']->general_dn, strpos($_SESSION['account']->general_dn, ',')+1);
$_SESSION['final_changegids'] = '';
$account_new = loadgroup($DN);
$account_old = $account_new;
$account_new->general_dn = substr($account_new->general_dn, strpos($account_new->general_dn, ',')+1);
$final_changegids = '';
}
}
else if (count($_POST)==0) { // Startcondition. groupedit.php was called from outside
$_SESSION['account'] = loadGroupProfile('default');
$_SESSION['account'] ->type = 'group';
// load quotas from profile and check if they are valid
$values = getquotas('group');
if (isset($_SESSION['account']->quota[0])) { // check quotas from profile
$i=0;
// check quota settings
while (isset($_SESSION['account']->quota[$i])) {
$found = (-1);
for ($j=0; $j<count($values->quota); $j++)
if ($values->quota[$j][0]==$_SESSION['account']->quota[$i][0]) $found = $j;
if ($found==-1) unset($_SESSION['account']->quota[$i]);
else {
$_SESSION['account']->quota[$i][1] = $values->quota[$found][1];
$_SESSION['account']->quota[$i][5] = $values->quota[$found][5];
$_SESSION['account']->quota[$i][4] = $values->quota[$found][4];
$_SESSION['account']->quota[$i][8] = $values->quota[$found][8];
$i++;
$account_new = loadGroupProfile('default');
$account_new ->type = 'group';
if ($config_intern->scriptServer) {
// load quotas from profile and check if they are valid
$values = getquotas('group');
if (isset($account_new->quota[0])) { // check quotas from profile
$i=0;
// check quota settings
while (isset($account_new->quota[$i])) {
$found = (-1);
for ($j=0; $j<count($values->quota); $j++)
if ($values->quota[$j][0]==$account_new->quota[$i][0]) $found = $j;
if ($found==-1) unset($account_new->quota[$i]);
else {
$account_new->quota[$i][1] = $values->quota[$found][1];
$account_new->quota[$i][5] = $values->quota[$found][5];
$account_new->quota[$i][4] = $values->quota[$found][4];
$account_new->quota[$i][8] = $values->quota[$found][8];
$i++;
}
}
$account_new->quota = array_values($account_new->quota);
}
else { // No quotas saved in profile
if (is_object($values)) {
while (list($key, $val) = each($values)) // Set only defined values
if (isset($val)) $account_new->$key = $val;
}
}
$_SESSION['account']->quota = array_values($_SESSION['account']->quota);
}
else { // No quotas saved in profile
if (is_object($values)) {
while (list($key, $val) = each($values)) // Set only defined values
if (isset($val)) $_SESSION['account']->$key = $val;
}
}
if (isset($_SESSION['account_old'])) unset($_SESSION['account_old']);
unset($account_old);
unset($_SESSION['account_'.$varkey.'_account_old']);
}
switch ($_POST['select']) { // Select which part of page should be loaded and check values
switch ($select) { // Select which part of page should be loaded and check values
// general = startpage, general account paramters
// samba = page with all samba-related parameters e.g. smbpassword
// quota = page with all quota-related parameters e.g. hard file quota
@ -87,18 +117,18 @@ switch ($_POST['select']) { // Select which part of page should be loaded and ch
do { // X-Or, only one if() can be true
if (isset($_POST['users']) && isset($_POST['add'])) { // Add users to list
// Add new user
$_SESSION['account']->unix_memberUid = array_merge($_SESSION['account']->unix_memberUid, $_POST['users']);
$account_new->unix_memberUid = array_merge($account_new->unix_memberUid, $_POST['users']);
// remove doubles
$_SESSION['account']->unix_memberUid = array_flip($_SESSION['account']->unix_memberUid);
array_unique($_SESSION['account']->unix_memberUid);
$_SESSION['account']->unix_memberUid = array_flip($_SESSION['account']->unix_memberUid);
$account_new->unix_memberUid = array_flip($account_new->unix_memberUid);
array_unique($account_new->unix_memberUid);
$account_new->unix_memberUid = array_flip($account_new->unix_memberUid);
// sort user
sort($_SESSION['account']->unix_memberUid);
sort($account_new->unix_memberUid);
// display groupmembers page
break;
}
if (isset($_POST['members']) && isset($_POST['remove'])) { // remove users fromlist
$_SESSION['account']->unix_memberUid = array_delete($_POST['members'], $_SESSION['account']->unix_memberUid);
$account_new->unix_memberUid = array_delete($_POST['members'], $account_new->unix_memberUid);
break;
}
} while(0);
@ -106,122 +136,122 @@ switch ($_POST['select']) { // Select which part of page should be loaded and ch
break;
case 'general':
// Write all general values into $_SESSION['account'] if no profile should be loaded
if (!$_POST['load']) {
$_SESSION['account']->general_dn = $_POST['f_general_suffix'];
$_SESSION['account']->general_username = $_POST['f_general_username'];
$_SESSION['account']->general_uidNumber = $_POST['f_general_uidNumber'];
$_SESSION['account']->general_gecos = $_POST['f_general_gecos'];
// Write all general values into $account_new if no profile should be loaded
if (!$load) {
$account_new->general_dn = $_POST['f_general_suffix'];
$account_new->general_username = $_POST['f_general_username'];
$account_new->general_uidNumber = $_POST['f_general_uidNumber'];
$account_new->general_gecos = $_POST['f_general_gecos'];
// Check if values are OK and set automatic values. if not error-variable will be set
// Check if Groupname contains only valid characters
if ( !ereg('^([a-z]|[0-9]|[.]|[-]|[_])*$', $_SESSION['account']->general_username))
if ( !ereg('^([a-z]|[0-9]|[.]|[-]|[_])*$', $account_new->general_username))
$errors[] = array('ERROR', _('Groupname'), _('Groupname contains invalid characters. Valid characters are: a-z, 0-9 and .-_ !'));
if ($_SESSION['account']->general_gecos=='') {
$_SESSION['account']->general_gecos = $_SESSION['account']->general_username ;
if ($account_new->general_gecos=='') {
$account_new->general_gecos = $account_new->general_username ;
$errors[] = array('INFO', _('Gecos'), _('Inserted groupname in gecos-field.'));
}
// Create automatic groupaccount with number if original group already exists
// Reset name to original name if new name is in use
if (ldapexists($_SESSION['account'], 'group', $_SESSION['account_old']) && is_object($_SESSION['account_old']))
$_SESSION['account']->general_username = $_SESSION['account_old']->general_username;
while ($temp = ldapexists($_SESSION['account'], 'group', $_SESSION['account_old'])) {
if (ldapexists($account_new, 'group', $account_old) && is_object($account_old))
$account_new->general_username = $account_old->general_username;
while ($temp = ldapexists($account_new, 'group', $account_old)) {
// get last character of username
$lastchar = substr($_SESSION['account']->general_username, strlen($_SESSION['account']->general_username)-1, 1);
$lastchar = substr($account_new->general_username, strlen($account_new->general_username)-1, 1);
// Last character is no number
if ( !ereg('^([0-9])+$', $lastchar))
$_SESSION['account']->general_username = $_SESSION['account']->general_username . '2';
$account_new->general_username = $account_new->general_username . '2';
else {
$i=strlen($_SESSION['account']->general_username)-1;
$i=strlen($account_new->general_username)-1;
$mark = false;
while (!$mark) {
if (ereg('^([0-9])+$',substr($_SESSION['account']->general_username, $i, strlen($_SESSION['account']->general_username)-$i))) $i--;
if (ereg('^([0-9])+$',substr($account_new->general_username, $i, strlen($account_new->general_username)-$i))) $i--;
else $mark=true;
}
// increase last number with one
$firstchars = substr($_SESSION['account']->general_username, 0, $i+1);
$lastchars = substr($_SESSION['account']->general_username, $i+1, strlen($_SESSION['account']->general_username)-$i);
$_SESSION['account']->general_username = $firstchars . (intval($lastchars)+1);
$firstchars = substr($account_new->general_username, 0, $i+1);
$lastchars = substr($account_new->general_username, $i+1, strlen($account_new->general_username)-$i);
$account_new->general_username = $firstchars . (intval($lastchars)+1);
}
}
if ($_SESSION['account']->general_username != $_POST['f_general_username']) $errors[] = array('WARN', _('Groupname'), _('Groupname already in use. Selected next free groupname.'));
if ($account_new->general_username != $_POST['f_general_username']) $errors[] = array('WARN', _('Groupname'), _('Groupname already in use. Selected next free groupname.'));
// Check if UID is valid. If none value was entered, the next useable value will be inserted
$_SESSION['account']->general_uidNumber = checkid($_SESSION['account'], 'group', $_SESSION['account_old']);
if (is_string($_SESSION['account']->general_uidNumber)) { // true if checkid has returned an error
$errors[] = array('ERROR', _('ID-Number'), $_SESSION['account']->general_uidNumber);
$account_new->general_uidNumber = checkid($account_new, 'group', $account_old);
if (is_string($account_new->general_uidNumber)) { // true if checkid has returned an error
$errors[] = array('ERROR', _('ID-Number'), $account_new->general_uidNumber);
unset($return->general_uidNumber);
}
// Check if Name-length is OK. minLength=3, maxLength=20
if ( !ereg('.{3,20}', $_SESSION['account']->general_username)) $errors[] = array('ERROR', _('Name'), _('Name must contain between 3 and 20 characters.'));
if ( !ereg('.{3,20}', $account_new->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']->general_username))
if ( !ereg('^([a-z]|[A-Z]).*$', $account_new->general_username))
$errors[] = array('ERROR', _('Name'), _('Name contains invalid characters. First character must be a letter'));
}
break;
case 'samba':
$samba3domains = $_SESSION['ldap']->search_domains($_SESSION[config]->get_domainSuffix());
$samba3domains = $ldap_intern->search_domains($config_intern->get_domainSuffix());
foreach ($samba3domains as $domain)
if ($_POST['f_smb_domain'] == $domain->name)
$_SESSION['account']->smb_domain = $domain;
$_SESSION['account']->smb_displayName = $_POST['f_smb_displayName'];
$account_new->smb_domain = $domain;
$account_new->smb_displayName = $_POST['f_smb_displayName'];
if ($_SESSION['config']->is_samba3())
if ($config_intern->is_samba3())
switch ($_POST['f_smb_mapgroup']) {
case '*'._('Domain Guests'): $_SESSION['account']->smb_mapgroup = $_SESSION['account']->smb_domain->SID . "-" . '514'; break;
case '*'._('Domain Users'): $_SESSION['account']->smb_mapgroup = $_SESSION['account']->smb_domain->SID . "-" . '513'; break;
case '*'._('Domain Admins'): $_SESSION['account']->smb_mapgroup = $_SESSION['account']->smb_domain->SID . "-" . '512'; break;
case $_SESSION['account']->general_username:
$_SESSION['account']->smb_mapgroup = $_SESSION['account']->smb_domain->SID . "-".
(2 * getgid($_SESSION['account']->general_username) + $_SESSION['account']->smb_domain->RIDbase +1);
case '*'._('Domain Guests'): $account_new->smb_mapgroup = $account_new->smb_domain->SID . "-" . '514'; break;
case '*'._('Domain Users'): $account_new->smb_mapgroup = $account_new->smb_domain->SID . "-" . '513'; break;
case '*'._('Domain Admins'): $account_new->smb_mapgroup = $account_new->smb_domain->SID . "-" . '512'; break;
case $account_new->general_username:
$account_new->smb_mapgroup = $account_new->smb_domain->SID . "-".
(2 * getgid($account_new->general_username) + $account_new->smb_domain->RIDbase +1);
break;
}
else
switch ($_POST['f_smb_mapgroup']) {
case '*'._('Domain Guests'): $_SESSION['account']->smb_mapgroup = '514'; break;
case '*'._('Domain Users'): $_SESSION['account']->smb_mapgroup = '513'; break;
case '*'._('Domain Admins'): $_SESSION['account']->smb_mapgroup = '512'; break;
case $_SESSION['account']->general_username:
$_SESSION['account']->smb_mapgroup = (2 * getgid($_SESSION['account']->general_username) + 1001);
case '*'._('Domain Guests'): $account_new->smb_mapgroup = '514'; break;
case '*'._('Domain Users'): $account_new->smb_mapgroup = '513'; break;
case '*'._('Domain Admins'): $account_new->smb_mapgroup = '512'; break;
case $account_new->general_username:
$account_new->smb_mapgroup = (2 * getgid($account_new->general_username) + 1001);
break;
}
// Check if value is set
if (($_SESSION['account']->smb_displayName=='') && isset($_SESSION['account']->general_gecos)) {
$_SESSION['account']->smb_displayName = $_SESSION['account']->general_gecos;
if (($account_new->smb_displayName=='') && isset($account_new->general_gecos)) {
$account_new->smb_displayName = $account_new->general_gecos;
$errors[] = array('INFO', _('Display name'), _('Inserted gecos-field as display name.'));
}
break;
case 'quota':
// Write all general values into $_SESSION['account']
// Write all general values into $account_new
$i=0;
while ($_SESSION['account']->quota[$i][0]) {
$_SESSION['account']->quota[$i][2] = $_POST['f_quota_'.$i.'_2'];
$_SESSION['account']->quota[$i][3] = $_POST['f_quota_'.$i.'_3'];
$_SESSION['account']->quota[$i][6] = $_POST['f_quota_'.$i.'_6'];
$_SESSION['account']->quota[$i][7] = $_POST['f_quota_'.$i.'_7'];
while ($account_new->quota[$i][0]) {
$account_new->quota[$i][2] = $_POST['f_quota_'.$i.'_2'];
$account_new->quota[$i][3] = $_POST['f_quota_'.$i.'_3'];
$account_new->quota[$i][6] = $_POST['f_quota_'.$i.'_6'];
$account_new->quota[$i][7] = $_POST['f_quota_'.$i.'_7'];
// Check if values are OK and set automatic values. if not error-variable will be set
if (!ereg('^([0-9])*$', $_SESSION['account']->quota[$i][2]))
if (!ereg('^([0-9])*$', $account_new->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']->quota[$i][3]))
if (!ereg('^([0-9])*$', $account_new->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']->quota[$i][6]))
if (!ereg('^([0-9])*$', $account_new->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']->quota[$i][7]))
if (!ereg('^([0-9])*$', $account_new->quota[$i][7]))
$errors[] = array('ERROR', _('Inode hard quota'), _('Inode hard quota contains invalid characters. Only natural numbers are allowed'));
$i++;
}
break;
case 'final':
// Write all general values into $_SESSION['account']
if ($_POST['f_final_changegids']) $_SESSION['final_changegids'] = $_POST['f_final_changegids'] ;
// Write all general values into $account_new
if ($_POST['f_final_changegids']) $final_changegids = $_POST['f_final_changegids'] ;
break;
}
@ -230,41 +260,41 @@ switch ($_POST['select']) { // Select which part of page should be loaded and ch
do { // X-Or, only one if() can be true
if ($_POST['next_members']) {
if (!is_array($errors)) $select_local='groupmembers';
else $select_local=$_POST['select'];
else $select_local=$select;
break;
}
if ($_POST['next_general']) {
if (!is_array($errors)) $select_local='general';
else $select_local=$_POST['select'];
else $select_local=$select;
break;
}
if ($_POST['next_samba']) {
if (!is_array($errors)) $select_local='samba';
else $select_local=$_POST['select'];
else $select_local=$select;
break;
}
if ($_POST['next_quota']) {
if (!is_array($errors)) $select_local='quota';
else $select_local=$_POST['select'];
else $select_local=$select;
break;
}
if ($_POST['next_final']) {
if (!isset($errors)) $select_local='final';
else $select_local=$_POST['select'];
else $select_local=$select;
break;
}
if ($_POST['next_reset']) {
$_SESSION['account'] = $_SESSION['account_old'];
$_SESSION['account']->unix_password='';
$_SESSION['account']->smb_password='';
$_SESSION['account']->smb_flagsW = 0;
$_SESSION['account']->general_dn = substr($_SESSION['account']->general_dn, strpos($_SESSION['account']->general_dn, ',')+1);
$select_local = $_POST['select'];
$account_new = $account_old;
$account_new->unix_password='';
$account_new->smb_password='';
$account_new->smb_flagsW = 0;
$account_new->general_dn = substr($account_new->general_dn, strpos($account_new->general_dn, ',')+1);
$select_local = $select;
break;
}
if ( $_POST['create'] ) { // Create-Button was pressed
if ($_SESSION['account_old']) $result = modifygroup($_SESSION['account'],$_SESSION['account_old']);
else $result = creategroup($_SESSION['account']); // account.inc
if ($account_old) $result = modifygroup($account_new,$account_old);
else $result = creategroup($account_new); // account.inc
if ( $result==1 || $result==3 ) $select_local = 'finish';
else $select_local = 'final';
break;
@ -272,62 +302,63 @@ do { // X-Or, only one if() can be true
// Reset variables if recreate-button was pressed
if ($_POST['createagain']) {
$select_local='general';
unset($_SESSION['account']);
$_SESSION['account'] = loadGroupProfile('default');
$_SESSION['account'] ->type = 'group';
unset($account_new);
$account_new = loadGroupProfile('default');
$account_new ->type = 'group';
break;
}
if ($_POST['backmain']) {
metaRefresh($_SESSION['lamurl']."templates/lists/listgroups.php");
metaRefresh($lamurl_intern."templates/lists/listgroups.php");
die;
break;
}
if ($_POST['load']) {
$_SESSION['account']->general_dn = $_POST['f_general_suffix'];
$_SESSION['account']->general_username = $_POST['f_general_username'];
$_SESSION['account']->general_uidNumber = $_POST['f_general_uidNumber'];
$_SESSION['account']->general_gecos = $_POST['f_general_gecos'];
if ($load) {
$account_new->general_dn = $_POST['f_general_suffix'];
$account_new->general_username = $_POST['f_general_username'];
$account_new->general_uidNumber = $_POST['f_general_uidNumber'];
$account_new->general_gecos = $_POST['f_general_gecos'];
// load profile
if ($_POST['f_general_selectprofile']!='') $values = loadGroupProfile($_POST['f_general_selectprofile']);
if (is_object($values)) {
while (list($key, $val) = each($values)) // Set only defined values
if (isset($val)) $_SESSION['account']->$key = $val;
if (isset($val)) $account_new->$key = $val;
}
// load quotas from profile and check if they are valid
$values = getquotas('group', $_SESSION['account_old']->general_username);
if (isset($_SESSION['account']->quota[0])) { // check quotas from profile
$i=0;
// check quota settings
while (isset($_SESSION['account']->quota[$i])) {
$found = (-1);
for ($j=0; $j<count($values->quota); $j++)
if ($values->quota[$j][0]==$_SESSION['account']->quota[$i][0]) $found = $j;
if ($found==-1) unset($_SESSION['account']->quota[$i]);
else {
$_SESSION['account']->quota[$i][1] = $values->quota[$found][1];
$_SESSION['account']->quota[$i][5] = $values->quota[$found][5];
$_SESSION['account']->quota[$i][4] = $values->quota[$found][4];
$_SESSION['account']->quota[$i][8] = $values->quota[$found][8];
$i++;
if ($config_intern->scriptServer) {
// load quotas from profile and check if they are valid
$values = getquotas('group', $account_old->general_username);
if (isset($account_new->quota[0])) { // check quotas from profile
$i=0;
// check quota settings
while (isset($account_new->quota[$i])) {
$found = (-1);
for ($j=0; $j<count($values->quota); $j++)
if ($values->quota[$j][0]==$account_new->quota[$i][0]) $found = $j;
if ($found==-1) unset($account_new->quota[$i]);
else {
$account_new->quota[$i][1] = $values->quota[$found][1];
$account_new->quota[$i][5] = $values->quota[$found][5];
$account_new->quota[$i][4] = $values->quota[$found][4];
$account_new->quota[$i][8] = $values->quota[$found][8];
$i++;
}
}
$account_new->quota = array_values($account_new->quota);
}
else { // No quotas saved in profile
if (is_object($values)) {
while (list($key, $val) = each($values)) // Set only defined values
if (isset($val)) $account_new->$key = $val;
}
}
$_SESSION['account']->quota = array_values($_SESSION['account']->quota);
}
else { // No quotas saved in profile
if (is_object($values)) {
while (list($key, $val) = each($values)) // Set only defined values
if (isset($val)) $_SESSION['account']->$key = $val;
}
}
// select general page after group has been loaded
$select_local='general';
break;
}
if ($_POST['save']) {
// save profile
saveGroupProfile($_SESSION['account'], $_POST['f_finish_safeProfile']);
saveGroupProfile($account_new, $_POST['f_finish_safeProfile']);
// select last page displayed before user is created
$select_local='final';
break;
@ -341,15 +372,16 @@ do { // X-Or, only one if() can be true
} while(0);
// Write HTML-Header
echo $_SESSION['header'];
echo $header_intern;
echo "<html><head><title>";
echo _("Create new Account");
echo "</title>\n".
"<link rel=\"stylesheet\" type=\"text/css\" href=\"".$_SESSION['lamurl']."style/layout.css\">\n".
"<link rel=\"stylesheet\" type=\"text/css\" href=\"".$lamurl_intern."style/layout.css\">\n".
"<meta http-equiv=\"pragma\" content=\"no-cache\">\n".
"<meta http-equiv=\"cache-control\" content=\"no-cache\">\n".
"</head><body>\n".
"<form action=\"groupedit.php\" method=\"post\">\n";
"<form action=\"groupedit.php\" method=\"post\">\n".
"<input name=\"varkey\" type=\"hidden\" value=\"".$varkey."\">\n";
if (is_array($errors)) {
echo "<table class=\"groupedit\" width=\"100%\">\n";
@ -357,7 +389,7 @@ if (is_array($errors)) {
echo "</table>";
}
// print_r($_SESSION['account']);
// print_r($account_old);
switch ($select_local) { // Select which part of page will be loaded
// general = startpage, general account paramters
@ -370,7 +402,7 @@ switch ($select_local) { // Select which part of page will be loaded
// finish = page shown after account has been created/modified
case 'groupmembers':
ldapreload('user');
$temp2 = $_SESSION['userDN'];
$temp2 = $userDN_intern;
unset($temp2[0]);
foreach ($temp2 as $temp) $users[] = $temp['cn'];
sort($users, SORT_STRING);
@ -381,14 +413,14 @@ switch ($select_local) { // Select which part of page will be loaded
echo "</b></legend>\n";
echo "<input name=\"next_general\" type=\"submit\" value=\""; echo _('General'); echo "\">\n<br>";
echo "<input name=\"next_members\" type=\"submit\" disabled value=\""; echo _('Members'); echo "\">\n<br>";
if ($_SESSION['config']->is_samba3()) {
if ($config_intern->is_samba3()) {
echo "<input name=\"next_samba\" type=\"submit\" value=\""; echo _('Samba'); echo "\">\n<br>";
}
echo "<input name=\"next_quota\" type=\"submit\""; if (!isset($_SESSION['config']->scriptPath)) echo " disabled ";
echo "<input name=\"next_quota\" type=\"submit\""; if (!isset($config_intern->scriptPath)) echo " disabled ";
echo "value=\""; echo _('Quota'); echo "\">\n<br>";
echo "<input name=\"next_final\" type=\"submit\" value=\""; echo _('Final');
echo "\">";
if (isset($_SESSION['account_old'])) {
if (isset($account_old)) {
echo "<br><br>";
echo _("Reset all changes.");
echo "<br>";
@ -401,17 +433,17 @@ switch ($select_local) { // Select which part of page will be loaded
echo "<tr><td valign=\"top\"><fieldset class=\"groupedit-middle\"><legend class=\"groupedit-bright\">";
echo _('Group members');
echo "</legend>";
if (count($_SESSION['account']->unix_memberUid)!=0) {
if (count($account_new->unix_memberUid)!=0) {
echo "<select name=\"members[]\" class=\"groupedit-bright\" size=15 multiple>\n";
for ($i=0; $i<count($_SESSION['account']->unix_memberUid); $i++)
if ($_SESSION['account']->unix_memberUid[$i]!='') echo " <option>".$_SESSION['account']->unix_memberUid[$i]."</option>\n";
for ($i=0; $i<count($account_new->unix_memberUid); $i++)
if ($account_new->unix_memberUid[$i]!='') echo " <option>".$account_new->unix_memberUid[$i]."</option>\n";
echo "</select>\n";
}
echo "</fieldset></td>\n";
echo "<td align=\"center\" width=\"10%\"><input type=\"submit\" name=\"add\" value=\"<=\">";
echo " ";
echo "<input type=\"submit\" name=\"remove\" value=\"=>\"><br><br>";
echo "<a href=\"".$_SESSION['lamurl']."templates/help.php?HelpNumber=419\" target=\"lamhelp\">"._('Help')."</a></td>\n";
echo "<a href=\"".$lamurl_intern."templates/help.php?HelpNumber=419\" target=\"lamhelp\">"._('Help')."</a></td>\n";
echo "<td valign=\"top\"><fieldset class=\"groupedit-middle\"><legend class=\"groupedit-bright\">";
echo _('Available users');
echo "</legend>\n";
@ -436,14 +468,14 @@ switch ($select_local) { // Select which part of page will be loaded
echo "</b></legend>\n";
echo "<input name=\"next_general\" type=\"submit\" disabled value=\""; echo _('General'); echo "\">\n<br>";
echo "<input name=\"next_members\" type=\"submit\" value=\""; echo _('Members'); echo "\">\n<br>";
if ($_SESSION['config']->is_samba3()) {
if ($config_intern->is_samba3()) {
echo "<input name=\"next_samba\" type=\"submit\" value=\""; echo _('Samba'); echo "\">\n<br>";
}
echo "<input name=\"next_quota\" type=\"submit\""; if (!isset($_SESSION['config']->scriptPath)) echo " disabled ";
echo "<input name=\"next_quota\" type=\"submit\""; if (!isset($config_intern->scriptPath)) echo " disabled ";
echo "value=\""; echo _('Quota'); echo "\">\n<br>";
echo "<input name=\"next_final\" type=\"submit\" value=\""; echo _('Final');
echo "\">";
if (isset($_SESSION['account_old'])) {
if (isset($account_old)) {
echo "<br><br>";
echo _("Reset all changes.");
echo "<br>";
@ -457,26 +489,26 @@ switch ($select_local) { // Select which part of page will be loaded
echo "</b></legend>\n<table border=0 width=\"100%\">\n<tr>\n<td>";
echo _("Groupname")."*";
echo "</td>\n<td>".
"<input name=\"f_general_username\" type=\"text\" size=\"30\" maxlength=\"20\" value=\"".$_SESSION['account']->general_username."\">".
"</td>\n<td><a href=\"".$_SESSION['lamurl']."templates/help.php?HelpNumber=407\" target=\"lamhelp\">"._('Help')."</a></td>\n</tr>\n<tr>\n<td>";
"<input name=\"f_general_username\" type=\"text\" size=\"30\" maxlength=\"20\" value=\"".$account_new->general_username."\">".
"</td>\n<td><a href=\"".$lamurl_intern."templates/help.php?HelpNumber=407\" target=\"lamhelp\">"._('Help')."</a></td>\n</tr>\n<tr>\n<td>";
echo _('GID number');
echo "</td>\n<td><input name=\"f_general_uidNumber\" type=\"text\" size=\"30\" maxlength=\"6\" value=\"".$_SESSION['account']->general_uidNumber."\">".
"</td>\n<td><a href=\"".$_SESSION['lamurl']."templates/help.php?HelpNumber=408\" target=\"lamhelp\">"._('Help').
echo "</td>\n<td><input name=\"f_general_uidNumber\" type=\"text\" size=\"30\" maxlength=\"6\" value=\"".$account_new->general_uidNumber."\">".
"</td>\n<td><a href=\"".$lamurl_intern."templates/help.php?HelpNumber=408\" target=\"lamhelp\">"._('Help').
"</a></td>\n</tr>\n<tr>\n<td>";
echo _('Description');
echo "</td>\n<td><input name=\"f_general_gecos\" type=\"text\" size=\"30\" value=\"".$_SESSION['account']->general_gecos."\"></td>\n".
"<td><a href=\"".$_SESSION['lamurl']."templates/help.php?HelpNumber=409\" target=\"lamhelp\">"._('Help')."</a></td>\n</tr>\n<tr>\n<td>";
echo "</td>\n<td><input name=\"f_general_gecos\" type=\"text\" size=\"30\" value=\"".$account_new->general_gecos."\"></td>\n".
"<td><a href=\"".$lamurl_intern."templates/help.php?HelpNumber=409\" target=\"lamhelp\">"._('Help')."</a></td>\n</tr>\n<tr>\n<td>";
echo _('Suffix'); echo "</td>\n<td><select name=\"f_general_suffix\">";
foreach ($_SESSION['ldap']->search_units($_SESSION['config']->get_GroupSuffix()) as $suffix) {
if ($_SESSION['account']->general_dn) {
if ($_SESSION['account']->general_dn == $suffix)
foreach ($ldap_intern->search_units($config_intern->get_GroupSuffix()) as $suffix) {
if ($account_new->general_dn) {
if ($account_new->general_dn == $suffix)
echo " <option selected>$suffix</option>\n";
else echo " <option>$suffix</option>\n";
}
else echo " <option>$suffix</option>\n";
}
echo "</select></td>\n<td><a href=\"".$_SESSION['lamurl']."templates/help.php?HelpNumber=462\" target=\"lamhelp\">"._('Help').
echo "</select></td>\n<td><a href=\"".$lamurl_intern."templates/help.php?HelpNumber=462\" target=\"lamhelp\">"._('Help').
"</a></td>\n</tr>\n</table>";
echo _('Values with * are required');
echo "</fieldset>\n</td></tr><tr><td>";
@ -488,7 +520,7 @@ switch ($select_local) { // Select which part of page will be loaded
foreach ($profilelist as $profile) echo " <option>$profile</option>\n";
echo "</select>\n".
"<input name=\"load\" type=\"submit\" value=\""; echo _('Load Profile');
echo "\"></td><td><a href=\"".$_SESSION['lamurl']."templates/help.php?HelpNumber=421\" target=\"lamhelp\">";
echo "\"></td><td><a href=\"".$lamurl_intern."templates/help.php?HelpNumber=421\" target=\"lamhelp\">";
echo _('Help')."</a></td>\n</tr>\n</table>\n</fieldset>\n";
}
echo "</td></tr>\n</table>\n</td></tr></table>\n";
@ -496,7 +528,7 @@ switch ($select_local) { // Select which part of page will be loaded
case 'samba':
// Samba Settings
$samba3domains = $_SESSION['ldap']->search_domains($_SESSION[config]->get_domainSuffix());
$samba3domains = $ldap_intern->search_domains($config_intern->get_domainSuffix());
echo "<input name=\"select\" type=\"hidden\" value=\"samba\">\n";
echo "<table border=0 width=\"100%\">\n<tr><td valign=\"top\" width=\"15%\" >";
echo "<table border=0><tr><td><fieldset class=\"groupedit-middle\"><legend class=\"groupedit-bright\"><b>";
@ -505,11 +537,11 @@ switch ($select_local) { // Select which part of page will be loaded
echo "<input name=\"next_general\" type=\"submit\" value=\""; echo _('General'); echo "\">\n<br>";
echo "<input name=\"next_members\" type=\"submit\" value=\""; echo _('Members'); echo "\">\n<br>";
echo "<input name=\"next_samba\" type=\"submit\" disabled value=\""; echo _('Samba'); echo "\">\n<br>";
echo "<input name=\"next_quota\" type=\"submit\""; if (!isset($_SESSION['config']->scriptPath)) echo " disabled ";
echo "<input name=\"next_quota\" type=\"submit\""; if (!isset($config_intern->scriptPath)) echo " disabled ";
echo "value=\""; echo _('Quota'); echo "\">\n<br>";
echo "<input name=\"next_final\" type=\"submit\" value=\""; echo _('Final');
echo "\">";
if (isset($_SESSION['account_old'])) {
if (isset($account_old)) {
echo "<br><br>";
echo _("Reset all changes.");
echo "<br>";
@ -521,22 +553,22 @@ switch ($select_local) { // Select which part of page will be loaded
echo "<table border=0 width=\"100%\"><tr><td>";
echo _("Display name");
echo "</td>\n<td>".
"<input name=\"f_smb_displayName\" type=\"text\" size=\"30\" maxlength=\"50\" value=\"".$_SESSION['account']->smb_displayName."\">".
"</td>\n<td><a href=\"".$_SESSION['lamurl']."templates/help.php?HelpNumber=420\" target=\"lamhelp\">"._('Help')."</a></td>\n</tr>\n<tr>\n<td>";
"<input name=\"f_smb_displayName\" type=\"text\" size=\"30\" maxlength=\"50\" value=\"".$account_new->smb_displayName."\">".
"</td>\n<td><a href=\"".$lamurl_intern."templates/help.php?HelpNumber=420\" target=\"lamhelp\">"._('Help')."</a></td>\n</tr>\n<tr>\n<td>";
echo _('Windows groupname');
echo "</td>\n<td><select name=\"f_smb_mapgroup\">";
if ($_SESSION['config']->samba3=='yes') {
if ( $_SESSION['account']->smb_mapgroup == $_SESSION['account']->smb_domain->SID . "-".
(2 * getgid($_SESSION['account']->general_username) + $values->smb_domain->RIDbase+1)) {
if ($config_intern->samba3=='yes') {
if ( $account_new->smb_mapgroup == $account_new->smb_domain->SID . "-".
(2 * getgid($account_new->general_username) + $values->smb_domain->RIDbase+1)) {
echo '<option selected> ';
echo $_SESSION['account']->general_username;
echo $account_new->general_username;
echo "</option>\n"; }
else {
echo '<option> ';
echo $_SESSION['account']->general_username;
echo $account_new->general_username;
echo "</option>\n";
}
if ( $_SESSION['account']->smb_mapgroup == $_SESSION['account']->smb_domain->SID . "-" . '514' ) {
if ( $account_new->smb_mapgroup == $account_new->smb_domain->SID . "-" . '514' ) {
echo '<option selected> *';
echo _('Domain Guests');
echo "</option>\n"; }
@ -545,7 +577,7 @@ switch ($select_local) { // Select which part of page will be loaded
echo _('Domain Guests');
echo "</option>\n";
}
if ( $_SESSION['account']->smb_mapgroup == $_SESSION['account']->smb_domain->SID . "-" . '513' ) {
if ( $account_new->smb_mapgroup == $account_new->smb_domain->SID . "-" . '513' ) {
echo '<option selected> *';
echo _('Domain Users');
echo "</option>\n"; }
@ -554,7 +586,7 @@ switch ($select_local) { // Select which part of page will be loaded
echo _('Domain Users');
echo "</option>\n";
}
if ( $_SESSION['account']->smb_mapgroup == $_SESSION['account']->smb_domain->SID . "-" . '512' ) {
if ( $account_new->smb_mapgroup == $account_new->smb_domain->SID . "-" . '512' ) {
echo '<option selected> *';
echo _('Domain Admins');
echo "</option>\n"; }
@ -565,16 +597,16 @@ switch ($select_local) { // Select which part of page will be loaded
}
}
else {
if ( $_SESSION['account']->smb_mapgroup == (2 * getgid($_SESSION['account']->general_username) +1001)) {
if ( $account_new->smb_mapgroup == (2 * getgid($account_new->general_username) +1001)) {
echo '<option selected> ';
echo $_SESSION['account']->general_username;
echo $account_new->general_username;
echo "</option>\n"; }
else {
echo '<option> ';
echo $_SESSION['account']->general_username;
echo $account_new->general_username;
echo "</option>\n";
}
if ( $_SESSION['account']->smb_mapgroup == '514' ) {
if ( $account_new->smb_mapgroup == '514' ) {
echo '<option selected> *';
echo _('Domain Guests');
echo "</option>\n"; }
@ -583,7 +615,7 @@ switch ($select_local) { // Select which part of page will be loaded
echo _('Domain Guests');
echo "</option>\n";
}
if ( $_SESSION['account']->smb_mapgroup == '513' ) {
if ( $account_new->smb_mapgroup == '513' ) {
echo '<option selected> *';
echo _('Domain Users');
echo "</option>\n"; }
@ -592,7 +624,7 @@ switch ($select_local) { // Select which part of page will be loaded
echo _('Domain Users');
echo "</option>\n";
}
if ( $_SESSION['account']->smb_mapgroup == '512' ) {
if ( $account_new->smb_mapgroup == '512' ) {
echo '<option selected> *';
echo _('Domain Admins');
echo "</option>\n"; }
@ -603,33 +635,33 @@ switch ($select_local) { // Select which part of page will be loaded
}
}
echo "</select></td>\n<td>".
'<a href="'.$_SESSION['lamurl'].'templates/help.php?HelpNumber=464" target="lamhelp">'._('Help').'</a>'.
'<a href="'.$lamurl_intern.'templates/help.php?HelpNumber=464" target="lamhelp">'._('Help').'</a>'.
'</td></tr>'."\n".'<tr><td>';
echo _('Domain');
echo '</td><td><select name="f_smb_domain">';
for ($i=0; $i<sizeof($samba3domains); $i++) {
if ($_SESSION['account']->smb_domain->name) {
if ($_SESSION['account']->smb_domain->name == $samba3domains[$i]->name)
if ($account_new->smb_domain->name) {
if ($account_new->smb_domain->name == $samba3domains[$i]->name)
echo '<option selected>' . $samba3domains[$i]->name. '</option>';
else echo '<option>' . $samba3domains[$i]->name. '</option>';
}
else echo '<option>' . $samba3domains[$i]->name. '</option>';
}
echo '</select></td>'."\n".'<td><a href="'.$_SESSION['lamurl'].'templates/help.php?HelpNumber=467" target="lamhelp">'._('Help').'</a></td></tr>'."\n";
echo '</select></td>'."\n".'<td><a href="'.$lamurl_intern.'templates/help.php?HelpNumber=467" target="lamhelp">'._('Help').'</a></td></tr>'."\n";
echo "</table>\n</fieldset>\n</td></tr></table></td></tr>\n</table>\n";
break;
case 'quota':
// Quota Settings
if (!isset($_SESSION['account']->quota[0]) ) { // load quotas
$values = getquotas('group', $_SESSION['account']->general_username);
if ($config_intern->scriptServer && !isset($account_new->quota[0]) ) { // load quotas
$values = getquotas('group', $account_new->general_username);
if (is_object($values)) {
while (list($key, $val) = each($values)) // Set only defined values
if (isset($val)) $_SESSION['account']->$key = $val;
if (isset($val)) $account_new->$key = $val;
}
if (is_object($values) && isset($_SESSION['account_old'])) {
if (is_object($values) && isset($account_old)) {
while (list($key, $val) = each($values)) // Set only defined values
if (isset($val)) $_SESSION['account_old']->$key = $val;
if (isset($val)) $account_old->$key = $val;
}
}
@ -640,13 +672,13 @@ switch ($select_local) { // Select which part of page will be loaded
echo "</b></legend>\n";
echo "<input name=\"next_general\" type=\"submit\" value=\""; echo _('General'); echo "\">\n<br>";
echo "<input name=\"next_members\" type=\"submit\" value=\""; echo _('Members'); echo "\">\n<br>";
if ($_SESSION['config']->is_samba3()) {
if ($config_intern->is_samba3()) {
echo "<input name=\"next_samba\" type=\"submit\" value=\""; echo _('Samba'); echo "\">\n<br>";
}
echo "<input name=\"next_quota\" type=\"submit\" disabled value=\""; echo _('Quota'); echo "\">\n<br>";
echo "<input name=\"next_final\" type=\"submit\" value=\""; echo _('Final');
echo "\">";
if (isset($_SESSION['account_old'])) {
if (isset($account_old)) {
echo "<br><br>";
echo _("Reset all changes.");
echo "<br>";
@ -661,21 +693,21 @@ switch ($select_local) { // Select which part of page will be loaded
echo _('Soft block limit'); echo '</td>'."\n".'<td>'; echo _('Hard block limit'); echo '</td>'."\n".'<td>'; echo _('Grace block period');
echo '</td>'."\n".'<td>'; echo _('Used inodes'); echo '</td>'."\n".'<td>'; echo _('Soft inode limit'); echo '</td>'."\n".'<td>';
echo _('Hard inode limit'); echo '</td>'."\n".'<td>'; echo _('Grace inode period'); echo '</td></tr>'."\n";
echo '<tr><td><a href="'.$_SESSION['lamurl'].'templates/help.php?HelpNumber=439" target="lamhelp">'._('Help').'</a></td>'."\n".'<td><a href="'.$_SESSION['lamurl'].'templates/help.php?HelpNumber=440" target="lamhelp">'._('Help').'</a></td>'."\n".'<td>'.
'<a href="'.$_SESSION['lamurl'].'templates/help.php?HelpNumber=441" target="lamhelp">'._('Help').'</a></td>'."\n".'<td><a href="'.$_SESSION['lamurl'].'templates/help.php?HelpNumber=442" target="lamhelp">'._('Help').'</a></td>'."\n".'<td>'.
'<a href="'.$_SESSION['lamurl'].'templates/help.php?HelpNumber=443" target="lamhelp">'._('Help').'</a></td>'."\n".'<td><a href="'.$_SESSION['lamurl'].'templates/help.php?HelpNumber=444" target="lamhelp">'._('Help').'</a></td>'."\n".'<td>'.
'<a href="'.$_SESSION['lamurl'].'templates/help.php?HelpNumber=445" target="lamhelp">'._('Help').'</a></td>'."\n".'<td><a href="'.$_SESSION['lamurl'].'templates/help.php?HelpNumber=446" target="lamhelp">'._('Help').'</a></td>'."\n".'<td>'.
'<a href="'.$_SESSION['lamurl'].'templates/help.php?HelpNumber=447" target="lamhelp">'._('Help').'</a></td></tr>'."\n";
echo '<tr><td><a href="'.$lamurl_intern.'templates/help.php?HelpNumber=439" target="lamhelp">'._('Help').'</a></td>'."\n".'<td><a href="'.$lamurl_intern.'templates/help.php?HelpNumber=440" target="lamhelp">'._('Help').'</a></td>'."\n".'<td>'.
'<a href="'.$lamurl_intern.'templates/help.php?HelpNumber=441" target="lamhelp">'._('Help').'</a></td>'."\n".'<td><a href="'.$lamurl_intern.'templates/help.php?HelpNumber=442" target="lamhelp">'._('Help').'</a></td>'."\n".'<td>'.
'<a href="'.$lamurl_intern.'templates/help.php?HelpNumber=443" target="lamhelp">'._('Help').'</a></td>'."\n".'<td><a href="'.$lamurl_intern.'templates/help.php?HelpNumber=444" target="lamhelp">'._('Help').'</a></td>'."\n".'<td>'.
'<a href="'.$lamurl_intern.'templates/help.php?HelpNumber=445" target="lamhelp">'._('Help').'</a></td>'."\n".'<td><a href="'.$lamurl_intern.'templates/help.php?HelpNumber=446" target="lamhelp">'._('Help').'</a></td>'."\n".'<td>'.
'<a href="'.$lamurl_intern.'templates/help.php?HelpNumber=447" target="lamhelp">'._('Help').'</a></td></tr>'."\n";
$i=0;
while ($_SESSION['account']->quota[$i][0]) {
echo '<tr><td>'.$_SESSION['account']->quota[$i][0].'</td><td>'.$_SESSION['account']->quota[$i][1].'</td>'; // used blocks
echo '<td><input name="f_quota_'.$i.'_2" type="text" size="12" maxlength="20" value="'.$_SESSION['account']->quota[$i][2].'"></td>'; // blocks soft limit
echo '<td><input name="f_quota_'.$i.'_3" type="text" size="12" maxlength="20" value="'.$_SESSION['account']->quota[$i][3].'"></td>'; // blocks hard limit
echo '<td>'.$_SESSION['account']->quota[$i][4].'</td>'; // block grace period
echo '<td>'.$_SESSION['account']->quota[$i][5].'</td>'; // used inodes
echo '<td><input name="f_quota_'.$i.'_6" type="text" size="12" maxlength="20" value="'.$_SESSION['account']->quota[$i][6].'"></td>'; // inodes soft limit
echo '<td><input name="f_quota_'.$i.'_7" type="text" size="12" maxlength="20" value="'.$_SESSION['account']->quota[$i][7].'"></td>'; // inodes hard limit
echo '<td>'.$_SESSION['account']->quota[$i][8].'</td></tr>'; // inodes grace period
while ($account_new->quota[$i][0]) {
echo '<tr><td>'.$account_new->quota[$i][0].'</td><td>'.$account_new->quota[$i][1].'</td>'; // used blocks
echo '<td><input name="f_quota_'.$i.'_2" type="text" size="12" maxlength="20" value="'.$account_new->quota[$i][2].'"></td>'; // blocks soft limit
echo '<td><input name="f_quota_'.$i.'_3" type="text" size="12" maxlength="20" value="'.$account_new->quota[$i][3].'"></td>'; // blocks hard limit
echo '<td>'.$account_new->quota[$i][4].'</td>'; // block grace period
echo '<td>'.$account_new->quota[$i][5].'</td>'; // used inodes
echo '<td><input name="f_quota_'.$i.'_6" type="text" size="12" maxlength="20" value="'.$account_new->quota[$i][6].'"></td>'; // inodes soft limit
echo '<td><input name="f_quota_'.$i.'_7" type="text" size="12" maxlength="20" value="'.$account_new->quota[$i][7].'"></td>'; // inodes hard limit
echo '<td>'.$account_new->quota[$i][8].'</td></tr>'; // inodes grace period
$i++;
}
echo "</table>\n</fieldset>\n</td></tr></table></td></tr>\n</table>\n";
@ -684,8 +716,8 @@ switch ($select_local) { // Select which part of page will be loaded
case 'final':
// Final Settings
$disabled = "";
if ($_SESSION['config']->is_samba3()) {
if (!isset($_SESSION['account']->smb_domain)) { // Samba page nit viewd; can not create group because if missing options
if ($config_intern->is_samba3()) {
if (!isset($account_new->smb_domain)) { // Samba page nit viewd; can not create group because if missing options
$disabled = "disabled";
}
}
@ -698,14 +730,14 @@ switch ($select_local) { // Select which part of page will be loaded
echo "</b></legend>\n";
echo "<input name=\"next_general\" type=\"submit\" value=\""; echo _('General'); echo "\">\n<br>";
echo "<input name=\"next_members\" type=\"submit\" value=\""; echo _('Members'); echo "\">\n<br>";
if ($_SESSION['config']->is_samba3()) {
if ($config_intern->is_samba3()) {
echo "<input name=\"next_samba\" type=\"submit\" value=\""; echo _('Samba'); echo "\">\n<br>";
}
echo "<input name=\"next_quota\" type=\"submit\""; if (!isset($_SESSION['config']->scriptPath)) echo " disabled ";
echo "<input name=\"next_quota\" type=\"submit\""; if (!isset($config_intern->scriptPath)) echo " disabled ";
echo "value=\""; echo _('Quota'); echo "\">\n<br>";
echo "<input name=\"next_final\" type=\"submit\" disabled value=\""; echo _('Final');
echo "\">";
if (isset($_SESSION['account_old'])) {
if (isset($account_old)) {
echo "<br><br>";
echo _("Reset all changes.");
echo "<br>";
@ -720,21 +752,21 @@ switch ($select_local) { // Select which part of page will be loaded
echo '<input name="f_finish_safeProfile" type="text" size="30" maxlength="50">';
echo "</td><td><input name=\"save\" type=\"submit\" $disabled value=\"";
echo _('Save profile');
echo '"></td><td><a href="'.$_SESSION['lamurl'].'templates/help.php?HelpNumber=457" target="lamhelp">'._('Help');
echo '"></td><td><a href="'.$lamurl_intern.'templates/help.php?HelpNumber=457" target="lamhelp">'._('Help');
echo "</a></td>\n</tr>\n</table>\n</fieldset>\n</td></tr>\n<tr><td>\n";
echo "<fieldset class=\"groupedit-bright\"><legend class=\"groupedit-bright\"><b>";
if ($_SESSION['account_old']) echo _('Modify');
if ($account_old) echo _('Modify');
else echo _('Create');
echo "</b></legend>\n";
echo "<table border=0 width=\"100%\">";
if (($_SESSION['account_old']) && ($_SESSION['account']->general_uidNumber != $_SESSION['account_old']->general_uidNumber)) {
if (($account_old) && ($account_new->general_uidNumber != $account_old->general_uidNumber)) {
echo '<tr>';
StatusMessage ('INFO', _('GID-number has changed. You have to run the following command as root in order to change existing file-permissions:'),
'find / -gid ' . $_SESSION['account_old' ]->general_uidNumber . ' -exec chgrp ' . $_SESSION['account']->general_uidNumber . ' {} \;');
'find / -gid ' . $account_old->general_uidNumber . ' -exec chgrp ' . $account_new->general_uidNumber . ' {} \;');
echo '</tr>'."\n";
echo '<tr><td>';
echo '<input name="f_final_changegids" type="checkbox"';
if ($_SESSION['final_changegids']) echo ' checked ';
if ($final_changegids) echo ' checked ';
echo ' >';
echo _('Change GID-Number of all users in group to new value');
echo '</td></tr>'."\n";
@ -744,20 +776,20 @@ switch ($select_local) { // Select which part of page will be loaded
StatusMessage("ERROR", _("Samba Options not set!"), _("Please check settings on samba page."));
echo "</tr>";
}
if (isset($_SESSION['account_old']->general_objectClass)) {
if (($_SESSION['config']->is_samba3()) && (!in_array('sambaGroupMapping', $_SESSION['account_old']->general_objectClass))) {
if (isset($account_old->general_objectClass)) {
if (($config_intern->is_samba3()) && (!in_array('sambaGroupMapping', $account_old->general_objectClass))) {
echo '<tr>';
StatusMessage('WARN', _('ObjectClass sambaGroupMapping not found.'), _('Have to add objectClass sambaGroupMapping.'));
echo "</tr>\n";
}
if (!in_array('posixGroup', $_SESSION['account_old']->general_objectClass)) {
if (!in_array('posixGroup', $account_old->general_objectClass)) {
echo '<tr>';
StatusMessage('WARN', _('ObjectClass posixGroup not found.'), _('Have to add objectClass posixGroup.'));
echo "</tr>\n";
}
}
echo "<tr><td><input name=\"create\" type=\"submit\" $disabled value=\"";
if ($_SESSION['account_old']) echo _('Modify Account');
if ($account_old) echo _('Modify Account');
else echo _('Create Account');
echo '">'."\n";
echo "</td></tr></table></fieldset>\n</td></tr></table>\n</tr></table>";
@ -765,18 +797,18 @@ switch ($select_local) { // Select which part of page will be loaded
case 'finish':
// Final Settings
if (($_SESSION['config']->samba3 =='yes') && !isset($_SESSION['account']->smb_mapgroup)) $disabled = 'disabled';
if (($config_intern->samba3 =='yes') && !isset($account_new->smb_mapgroup)) $disabled = 'disabled';
else $disabled = '';
echo '<input name="select" type="hidden" value="finish">';
echo "<fieldset class=\"groupedit-bright\"><legend class=\"groupedit-bright\"><b>"._('Success')."</b></legend>\n";
echo "<table border=0 width=\"100%\">";
echo '<tr><td>';
echo _('Group').' ';
echo $_SESSION['account']->general_username;
if ($_SESSION['account_old']) echo ' '._('has been modified').'.';
echo $account_new->general_username;
if ($account_old) echo ' '._('has been modified').'.';
else echo ' '._('has been created').'.';
echo '</td></tr>'."\n".'<tr><td>';
if (!$_SESSION['account_old'])
if (!$account_old)
{ echo' <input name="createagain" type="submit" value="'; echo _('Create another group'); echo '">'; }
echo '</td><td></td><td>'.
'<input name="backmain" type="submit" value="'; echo _('Back to group list'); echo '">'.
@ -785,12 +817,12 @@ switch ($select_local) { // Select which part of page will be loaded
case 'backmain':
// unregister sessionvar and select which list should be shown
echo '<a href="'.$_SESSION['lamurl'].'templates/lists/listgroups.php">';
echo '<a href="'.$lamurl_intern.'templates/lists/listgroups.php">';
echo _('Please press here if meta-refresh didn\'t work.');
echo "</a>\n";
if (isset($_SESSION['shelllist'])) unset($_SESSION['shelllist']);
if (isset($_SESSION['account'])) unset($_SESSION['account']);
if (isset($_SESSION['account_old'])) unset($_SESSION['account_old']);
if (isset($_SESSION['account_'.$varkey.'_account_new'])) unset($_SESSION['account_'.$varkey.'_account_new']);
if (isset($_SESSION['account_'.$varkey.'_account_old'])) unset($_SESSION['account_'.$varkey.'_account_old']);
if (isset($_SESSION['account_'.$varkey.'_final_changegids'])) unset($_SESSION['account_'.$varkey.'_final_changegids']);
break;
}

View File

@ -33,27 +33,53 @@ include_once('../../lib/ldap.inc'); // LDAP-functions
session_save_path('../../sess');
@session_start();
setlanguage();
if (!isset($_POST['varkey'])) $varkey = session_id().time();
else $varkey = $_POST['varkey'];
if (!isset($_SESSION['account_'.$varkey.'_account_new'])) $_SESSION['account_'.$varkey.'_account_new'] = new account();
if (!isset($_SESSION['account_'.$varkey.'_account_old'])) $_SESSION['account_'.$varkey.'_account_old'] = new account();
// Register Session-Variables with references so we don't net to change to complete code if names changes
$account_new =& $_SESSION['account_'.$varkey.'_account_new'];
if (isset($_SESSION['account_'.$varkey.'_account_old'])) $account_old =& $_SESSION['account_'.$varkey.'_account_old'];
$ldap_intern =& $_SESSION['ldap'];
$config_intern =& $_SESSION['config'];
$lamurl_intern =& $_SESSION['lamurl'];
$header_intern =& $_SESSION['header'];
if (isset($_GET['DN'])) {
if (isset($_GET['DN']) && $_GET['DN']!='') {
if (isset($_SESSION['account_old'])) unset($_SESSION['account_old']);
if (isset($_SESSION['account_'.$varkey.'_account_old'])) {
unset($account_old);
unset($_SESSION['account_'.$varkey.'_account_old']);
$_SESSION['account_'.$varkey.'_account_old'] = new account();
$account_old =& $_SESSION['account_'.$varkey.'_account_old'];
}
$DN = str_replace("\'", '',$_GET['DN']);
$_SESSION['account'] = loadhost($DN);
$_SESSION['account']->smb_flagsW = 1;
$_SESSION['account']->smb_flagsX = 1;
$_SESSION['account_old'] = $_SESSION['account'];
$account_new = loadhost($DN);
$account_new->smb_flagsW = 1;
$account_new->smb_flagsX = 1;
$account_old = $account_new;
// Store only DN without uid=$name
$_SESSION['account']->general_dn = substr($_SESSION['account']->general_dn, strpos($_SESSION['account']->general_dn, ',')+1);
$account_new->general_dn = substr($account_new->general_dn, strpos($account_new->general_dn, ',')+1);
$_SESSION['final_changegids'] = '';
}
}
else if (count($_POST)==0) { // Startcondition. hostedit.php was called from outside
$_SESSION['account'] = loadHostProfile('default');
$_SESSION['account'] ->type = 'host';
$_SESSION['account']->smb_flagsW = 1;
$_SESSION['account']->smb_flagsX = 1;
$_SESSION['account']->general_homedir = '/dev/null';
$_SESSION['account']->general_shell = '/bin/false';
if (isset($_SESSION['account_old'])) unset($_SESSION['account_old']);
$account_new = loadHostProfile('default');
$account_new ->type = 'host';
$account_new->smb_flagsW = 1;
$account_new->smb_flagsX = 1;
$account_new->general_homedir = '/dev/null';
$account_new->general_shell = '/bin/false';
if (isset($_SESSION['account_'.$varkey.'_account_old'])) {
unset($account_old);
unset($_SESSION['account_'.$varkey.'_account_old']);
}
}
switch ($_POST['select']) { // Select which part of page should be loaded and check values
@ -66,101 +92,101 @@ switch ($_POST['select']) { // Select which part of page should be loaded and ch
// if account is modified commands might be ran are shown
// finish = page shown after account has been created/modified
case 'general':
// Write all general values into $_SESSION['account'] if no profile should be loaded
// Write all general values into $account_new if no profile should be loaded
if (!$_POST['load']) {
$_SESSION['account']->general_dn = $_POST['f_general_suffix'];
$_SESSION['account']->general_username = $_POST['f_general_username'];
$_SESSION['account']->general_uidNumber = $_POST['f_general_uidNumber'];
$_SESSION['account']->general_group = $_POST['f_general_group'];
$_SESSION['account']->general_gecos = $_POST['f_general_gecos'];
$account_new->general_dn = $_POST['f_general_suffix'];
$account_new->general_username = $_POST['f_general_username'];
$account_new->general_uidNumber = $_POST['f_general_uidNumber'];
$account_new->general_group = $_POST['f_general_group'];
$account_new->general_gecos = $_POST['f_general_gecos'];
// Check if values are OK and set automatic values. if not error-variable will be set
if ( substr($_SESSION['account']->general_username, strlen($_SESSION['account']->general_username)-1, strlen($_SESSION['account']->general_username)) != '$' ) {
$_SESSION['account']->general_username = $_SESSION['account']->general_username . '$';
if ( substr($account_new->general_username, strlen($account_new->general_username)-1, strlen($account_new->general_username)) != '$' ) {
$account_new->general_username = $account_new->general_username . '$';
$errors[] = array('WARN', _('Host name'), _('Added $ to hostname.'));
}
$tempname = $_SESSION['account']->general_username;
$tempname = $account_new->general_username;
// Check if Hostname contains only valid characters
if ( !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-]|[$])*$', $_SESSION['account']->general_username))
if ( !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-]|[$])*$', $account_new->general_username))
$errors[] = array('ERROR', _('Host name'), _('Hostname contains invalid characters. Valid characters are: a-z, 0-9 and .-_ !'));
if ($_SESSION['account']->general_gecos=='') {
$_SESSION['account']->general_gecos = $_SESSION['account']->general_username;
if ($account_new->general_gecos=='') {
$account_new->general_gecos = $account_new->general_username;
$errors[] = array('INFO', _('Gecos'), _('Inserted hostname in gecos-field.'));
}
// Create automatic Hostname with number if original user already exists
// Reset name to original name if new name is in use
if (ldapexists($_SESSION['account'], 'host', $_SESSION['account_old']) && is_object($_SESSION['account_old']))
$_SESSION['account']->general_username = $_SESSION['account_old']->general_username;
while ($temp = ldapexists($_SESSION['account'], 'host', $_SESSION['account_old'])) {
if (ldapexists($account_new, 'host', $account_old) && is_object($account_old))
$account_new->general_username = $account_old->general_username;
while ($temp = ldapexists($account_new, 'host', $account_old)) {
// get last character of username
$_SESSION['account']->general_username = substr($_SESSION['account']->general_username, 0, $_SESSION['account']->general_username-1);
$lastchar = substr($_SESSION['account']->general_username, strlen($_SESSION['account']->general_username)-2, 1);
$account_new->general_username = substr($account_new->general_username, 0, $account_new->general_username-1);
$lastchar = substr($account_new->general_username, strlen($account_new->general_username)-2, 1);
// Last character is no number
if ( !ereg('^([0-9])+$', $lastchar))
$_SESSION['account']->general_username = $_SESSION['account']->general_username . '2';
$account_new->general_username = $account_new->general_username . '2';
else {
$i=strlen($_SESSION['account']->general_username)-3;
$i=strlen($account_new->general_username)-3;
$mark = false;
while (!$mark) {
if (ereg('^([0-9])+$',substr($_SESSION['account']->general_username, $i, strlen($_SESSION['account']->general_username)-1))) $i--;
if (ereg('^([0-9])+$',substr($account_new->general_username, $i, strlen($account_new->general_username)-1))) $i--;
else $mark=true;
}
// increase last number with one
$firstchars = substr($_SESSION['account']->general_username, 0, $i+1);
$lastchars = substr($_SESSION['account']->general_username, $i+1, strlen($_SESSION['account']->general_username)-$i);
$_SESSION['account']->general_username = $firstchars . (intval($lastchars)+1). '$';
$firstchars = substr($account_new->general_username, 0, $i+1);
$lastchars = substr($account_new->general_username, $i+1, strlen($account_new->general_username)-$i);
$account_new->general_username = $firstchars . (intval($lastchars)+1). '$';
}
$_SESSION['account']->general_username = $_SESSION['account']->general_username . "$";
$account_new->general_username = $account_new->general_username . "$";
}
if ($_SESSION['account']->general_username != $tempname)
if ($account_new->general_username != $tempname)
$errors[] = array('WARN', _('Host name'), _('Hostname already in use. Selected next free hostname.'));
// Check if UID is valid. If none value was entered, the next useable value will be inserted
$_SESSION['account']->general_uidNumber = checkid($_SESSION['account'], 'host', $_SESSION['account_old']);
if (is_string($_SESSION['account']->general_uidNumber)) { // true if checkid has returned an error
$errors[] = array('ERROR', _('ID-Number'), $_SESSION['account']->general_uidNumber);
unset($_SESSION['account']->general_uidNumber);
$account_new->general_uidNumber = checkid($account_new, 'host', $account_old);
if (is_string($account_new->general_uidNumber)) { // true if checkid has returned an error
$errors[] = array('ERROR', _('ID-Number'), $account_new->general_uidNumber);
unset($account_new->general_uidNumber);
}
// Check if Name-length is OK. minLength=3, maxLength=20
if ( !ereg('.{3,20}', $_SESSION['account']->general_username)) $errors[] = array('ERROR', _('Name'), _('Name must contain between 3 and 20 characters.'));
if ( !ereg('.{3,20}', $account_new->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']->general_username))
if ( !ereg('^([a-z]|[A-Z]).*$', $account_new->general_username))
$errors[] = array('ERROR', _('Name'), _('Name contains invalid characters. First character must be a letter'));
}
break;
case 'samba':
// Write all general values into $_SESSION['account']
$_SESSION['account']->smb_displayName = $_POST['f_smb_displayName'];
// Write all general values into $account_new
$account_new->smb_displayName = $_POST['f_smb_displayName'];
if (isset($_POST['f_smb_flagsD'])) $_SESSION['account']->smb_flagsD = true;
else $_SESSION['account']->smb_flagsD = false;
if (isset($_POST['f_smb_flagsD'])) $account_new->smb_flagsD = true;
else $account_new->smb_flagsD = false;
if ($_SESSION['config']->is_samba3()) {
$samba3domains = $_SESSION['ldap']->search_domains($_SESSION[config]->get_domainSuffix());
if ($config_intern->is_samba3()) {
$samba3domains = $ldap_intern->search_domains($config_intern->get_domainSuffix());
for ($i=0; $i<sizeof($samba3domains); $i++)
if ($_POST['f_smb_domain'] == $samba3domains[$i]->name) {
$_SESSION['account']->smb_domain = $samba3domains[$i];
$account_new->smb_domain = $samba3domains[$i];
}
}
else {
$_SESSION['account']->smb_domain = $_POST['f_smb_domain'];
$account_new->smb_domain = $_POST['f_smb_domain'];
}
// Check if values are OK and set automatic values. if not error-variable will be set
if (($_SESSION['account']->smb_displayName=='') && isset($_SESSION['account']->general_gecos)) {
$_SESSION['account']->smb_displayName = $_SESSION['account']->general_gecos;
if (($account_new->smb_displayName=='') && isset($account_new->general_gecos)) {
$account_new->smb_displayName = $account_new->general_gecos;
$errors[] = array('INFO', _('Display name'), _('Inserted gecos-field as display name.'));
}
if ((!$_SESSION['account']->smb_domain=='') && !ereg('^([a-z]|[A-Z]|[0-9]|[-])+$', $_SESSION['account']->smb_domain))
if ((!$account_new->smb_domain=='') && !ereg('^([a-z]|[A-Z]|[0-9]|[-])+$', $account_new->smb_domain))
$errors[] = array('ERROR', _('Domain name'), _('Domain name contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and -.'));
// Reset password if reset button was pressed. Button only vissible if account should be modified
if ($_POST['respass']) {
$_SESSION['account']->unix_password_no=true;
$_SESSION['account']->smb_password_no=true;
$account_new->unix_password_no=true;
$account_new->smb_password_no=true;
$select_local = 'samba';
}
break;
@ -187,39 +213,39 @@ do { // X-Or, only one if() can be true
break;
}
if ($_POST['next_reset']) {
$_SESSION['account'] = $_SESSION['account_old'];
$_SESSION['account']->unix_password='';
$_SESSION['account']->smb_password='';
$_SESSION['account']->smb_flagsW = 0;
$_SESSION['account']->general_dn = substr($_SESSION['account']->general_dn, strpos($_SESSION['account']->general_dn, ',')+1);
$account_new = $account_old;
$account_new->unix_password='';
$account_new->smb_password='';
$account_new->smb_flagsW = 0;
$account_new->general_dn = substr($account_new->general_dn, strpos($account_new->general_dn, ',')+1);
$select_local = $_POST['select'];
break;
}
if ( $_POST['create'] ) { // Create-Button was pressed
// Create or modify an account
if ($_SESSION['account_old']) $result = modifyhost($_SESSION['account'],$_SESSION['account_old']);
else $result = createhost($_SESSION['account']); // account.inc
if ($account_old) $result = modifyhost($account_new,$account_old);
else $result = createhost($account_new); // account.inc
if ( $result==1 || $result==3 ) $select_local = 'finish';
else $select_local = 'final';
}
if ($_POST['createagain']) {
$select_local='general';
unset($_SESSION['account']);
$_SESSION['account'] = loadHostProfile('default');
$_SESSION['account'] ->type = 'host';
unset($account_new);
$account_new = loadHostProfile('default');
$account_new ->type = 'host';
break;
}
if ($_POST['load']) {
$_SESSION['account']->general_dn = $_POST['f_general_suffix'];
$_SESSION['account']->general_username = $_POST['f_general_username'];
$_SESSION['account']->general_uidNumber = $_POST['f_general_uidNumber'];
$_SESSION['account']->general_group = $_POST['f_general_group'];
$_SESSION['account']->general_gecos = $_POST['f_general_gecos'];
$account_new->general_dn = $_POST['f_general_suffix'];
$account_new->general_username = $_POST['f_general_username'];
$account_new->general_uidNumber = $_POST['f_general_uidNumber'];
$account_new->general_group = $_POST['f_general_group'];
$account_new->general_gecos = $_POST['f_general_gecos'];
// load profile
if ($_POST['f_general_selectprofile']!='') $values = loadHostProfile($_POST['f_general_selectprofile']);
if (is_object($values)) {
while (list($key, $val) = each($values)) // Set only defined values
if (isset($val)) $_SESSION['account']->$key = $val;
if (isset($val)) $account_new->$key = $val;
}
// select general page after group has been loaded
$select_local='general';
@ -227,13 +253,13 @@ do { // X-Or, only one if() can be true
}
if ($_POST['save']) {
// save profile
saveHostProfile($_SESSION['account'], $_POST['f_finish_safeProfile']);
saveHostProfile($account_new, $_POST['f_finish_safeProfile']);
// select last page displayed before user is created
$select_local='final';
break;
}
if ($_POST['backmain']) {
metaRefresh($_SESSION['lamurl']."templates/lists/listhosts.php");
metaRefresh($lamurl_intern."templates/lists/listhosts.php");
die;
break;
}
@ -241,15 +267,16 @@ do { // X-Or, only one if() can be true
} while(0);
// Write HTML-Header
echo $_SESSION['header'];
echo $header_intern;
echo "<html><head><title>";
echo _("Create new Account");
echo "</title>\n".
"<link rel=\"stylesheet\" type=\"text/css\" href=\"".$_SESSION['lamurl']."style/layout.css\">\n".
"<link rel=\"stylesheet\" type=\"text/css\" href=\"".$lamurl_intern."style/layout.css\">\n".
"<meta http-equiv=\"pragma\" content=\"no-cache\">\n".
"<meta http-equiv=\"cache-control\" content=\"no-cache\">\n".
"</head><body>\n".
"<form action=\"hostedit.php\" method=\"post\">\n";
"<form action=\"hostedit.php\" method=\"post\">\n".
"<input name=\"varkey\" type=\"hidden\" value=\"".$varkey."\">\n";
if (is_array($errors)) {
echo "<table class=\"account\" width=\"100%\">\n";
@ -258,7 +285,7 @@ if (is_array($errors)) {
}
// print_r($_SESSION['account']);
// print_r($account_new);
switch ($select_local) { // Select which part of page will be loaded
@ -286,7 +313,7 @@ switch ($select_local) { // Select which part of page will be loaded
echo "<input name=\"next_samba\" type=\"submit\" value=\""; echo _('Samba'); echo "\">\n<br>";
echo "<input name=\"next_final\" type=\"submit\" value=\""; echo _('Final');
echo "\">";
if (isset($_SESSION['account_old'])) {
if (isset($account_old)) {
echo "<br><br>";
echo _("Reset all changes.");
echo "<br>";
@ -300,40 +327,40 @@ switch ($select_local) { // Select which part of page will be loaded
echo "</b></legend>\n<table border=0 width=\"100%\">\n<tr>\n<td>";
echo _('Host name').'*';
echo '</td>'."\n".'<td>'.
'<input name="f_general_username" type="text" size="20" maxlength="20" value="' . $_SESSION['account']->general_username . '">'.
'<input name="f_general_username" type="text" size="20" maxlength="20" value="' . $account_new->general_username . '">'.
'</td><td>'.
'<a href="'.$_SESSION['lamurl'].'templates/help.php?HelpNumber=410" target="lamhelp">'._('Help').'</a>'.
'<a href="'.$lamurl_intern.'templates/help.php?HelpNumber=410" target="lamhelp">'._('Help').'</a>'.
'</td></tr>'."\n".'<tr><td>';
echo _('UID number');
echo '</td>'."\n".'<td>'.
'<input name="f_general_uidNumber" type="text" size="6" maxlength="6" value="' . $_SESSION['account']->general_uidNumber . '">'.
'<input name="f_general_uidNumber" type="text" size="6" maxlength="6" value="' . $account_new->general_uidNumber . '">'.
'</td>'."\n".'<td>'.
'<a href="'.$_SESSION['lamurl'].'templates/help.php?HelpNumber=411" target="lamhelp">'._('Help').'</a>'.
'<a href="'.$lamurl_intern.'templates/help.php?HelpNumber=411" target="lamhelp">'._('Help').'</a>'.
'</td></tr>'."\n".'<tr><td>';
echo _('Primary group').'*';
echo '</td>'."\n".'<td><select name="f_general_group">';
foreach ($groups as $group) {
if ($_SESSION['account']->general_group == $group) echo '<option selected>' . $group. '</option>';
if ($account_new->general_group == $group) echo '<option selected>' . $group. '</option>';
else echo '<option>' . $group. '</option>';
}
echo '</select></td><td>'.
'<a href="'.$_SESSION['lamurl'].'templates/help.php?HelpNumber=412" target="lamhelp">'._('Help').'</a>'.
'<a href="'.$lamurl_intern.'templates/help.php?HelpNumber=412" target="lamhelp">'._('Help').'</a>'.
'</td></tr>'."\n".'<tr><td>';
echo _('Gecos');
echo '</td><td><input name="f_general_gecos" type="text" size="30" value="' . $_SESSION['account']->general_gecos . '">'.
echo '</td><td><input name="f_general_gecos" type="text" size="30" value="' . $account_new->general_gecos . '">'.
'</td>'."\n".'<td>'.
'<a href="'.$_SESSION['lamurl'].'templates/help.php?HelpNumber=413" target="lamhelp">'._('Help').'</a>'.
'<a href="'.$lamurl_intern.'templates/help.php?HelpNumber=413" target="lamhelp">'._('Help').'</a>'.
'</td></tr><tr><td>';
echo _('Suffix'); echo '</td><td><select name="f_general_suffix">';
foreach ($_SESSION['ldap']->search_units($_SESSION['config']->get_HostSuffix()) as $suffix) {
if ($_SESSION['account']->general_dn) {
if ($_SESSION['account']->general_dn == $suffix)
foreach ($ldap_intern->search_units($config_intern->get_HostSuffix()) as $suffix) {
if ($account_new->general_dn) {
if ($account_new->general_dn == $suffix)
echo '<option selected>' . $suffix. '</option>';
else echo '<option>' . $suffix. '</option>';
}
else echo '<option>' . $suffix. '</option>';
}
echo '</select></td><td><a href="'.$_SESSION['lamurl'].'templates/help.php?HelpNumber=463" target="lamhelp">'._('Help').'</a>'.
echo '</select></td><td><a href="'.$lamurl_intern.'templates/help.php?HelpNumber=463" target="lamhelp">'._('Help').'</a>'.
"</td>\n</tr>\n</table>";
echo _('Values with * are required');
echo "</fieldset>\n</td></tr><tr><td>";
@ -345,7 +372,7 @@ switch ($select_local) { // Select which part of page will be loaded
foreach ($profilelist as $profile) echo " <option>$profile</option>\n";
echo "</select></td><td>\n".
"<input name=\"load\" type=\"submit\" value=\""; echo _('Load Profile');
echo "\"></td><td><a href=\"".$_SESSION['lamurl']."templates/help.php?HelpNumber=421\" target=\"lamhelp\">";
echo "\"></td><td><a href=\"".$lamurl_intern."templates/help.php?HelpNumber=421\" target=\"lamhelp\">";
echo _('Help')."</a></td>\n</tr>\n</table>\n</fieldset>\n";
}
echo "</td></tr></table>\n</td></tr>\n</table>\n";
@ -353,8 +380,8 @@ switch ($select_local) { // Select which part of page will be loaded
case 'samba':
// Samba Settings
if ($_SESSION['config']->is_samba3()) $samba3domains = $_SESSION['ldap']->search_domains($_SESSION[config]->get_domainSuffix());
if ($_SESSION['account']->smb_password_no) echo '<input name="f_smb_password_no" type="hidden" value="1">';
if ($config_intern->is_samba3()) $samba3domains = $ldap_intern->search_domains($config_intern->get_domainSuffix());
if ($account_new->smb_password_no) echo '<input name="f_smb_password_no" type="hidden" value="1">';
echo '<input name="select" type="hidden" value="samba">';
echo "<table border=0 width=\"100%\">\n<tr><td valign=\"top\" width=\"15%\" >";
echo "<table><tr><td><fieldset class=\"hostedit-dark\"><legend class=\"hostedit-bright\"><b>";
@ -364,7 +391,7 @@ switch ($select_local) { // Select which part of page will be loaded
echo "<input name=\"next_samba\" type=\"submit\" disabled value=\""; echo _('Samba'); echo "\">\n<br>";
echo "<input name=\"next_final\" type=\"submit\" value=\""; echo _('Final');
echo "\">";
if (isset($_SESSION['account_old'])) {
if (isset($account_old)) {
echo "<br><br>";
echo _("Reset all changes.");
echo "<br>";
@ -376,28 +403,28 @@ switch ($select_local) { // Select which part of page will be loaded
echo "<table border=0 width=\"100%\"><tr><td>";
echo _("Display name");
echo "</td>\n<td>".
"<input name=\"f_smb_displayName\" type=\"text\" size=\"30\" maxlength=\"50\" value=\"".$_SESSION['account']->smb_displayName."\">".
"</td>\n<td><a href=\"".$_SESSION['lamurl']."templates/help.php?HelpNumber=420\" target=\"lamhelp\">"._('Help')."</a></td>\n</tr>\n<tr>\n<td>";
"<input name=\"f_smb_displayName\" type=\"text\" size=\"30\" maxlength=\"50\" value=\"".$account_new->smb_displayName."\">".
"</td>\n<td><a href=\"".$lamurl_intern."templates/help.php?HelpNumber=420\" target=\"lamhelp\">"._('Help')."</a></td>\n</tr>\n<tr>\n<td>";
echo _('Password');
echo '</td><td>';
if (isset($_SESSION['account_old'])) {
if (isset($account_old)) {
echo '<input name="respass" type="submit" value="';
echo _('Reset password'); echo '">';
}
echo '</td></tr>'."\n".'<tr><td>';
echo _('Account is deactivated');
echo '</td>'."\n".'<td><input name="f_smb_flagsD" type="checkbox"';
if ($_SESSION['account']->smb_flagsD) echo ' checked ';
if ($account_new->smb_flagsD) echo ' checked ';
echo '></td><td>'.
'<a href="'.$_SESSION['lamurl'].'templates/help.php?HelpNumber=432" target="lamhelp">'._('Help').'</a>'.
'<a href="'.$lamurl_intern.'templates/help.php?HelpNumber=432" target="lamhelp">'._('Help').'</a>'.
'</td></tr>'."\n".'<tr><td>';
echo '</td></tr>'."\n".'<tr><td>';
echo _('Domain');
if ($_SESSION['config']->is_samba3()) {
if ($config_intern->is_samba3()) {
echo '</td><td><select name="f_smb_domain">';
for ($i=0; $i<sizeof($samba3domains); $i++) {
if ($_SESSION['account']->smb_domain->name) {
if ($_SESSION['account']->smb_domain->name == $samba3domains[$i]->name)
if ($account_new->smb_domain->name) {
if ($account_new->smb_domain->name == $samba3domains[$i]->name)
echo '<option selected>' . $samba3domains[$i]->name. '</option>';
else echo '<option>' . $samba3domains[$i]->name. '</option>';
}
@ -406,9 +433,9 @@ switch ($select_local) { // Select which part of page will be loaded
echo '</select>';
}
else {
echo '</td>'."\n".'<td><input name="f_smb_domain" type="text" size="20" maxlength="80" value="' . $_SESSION['account']->smb_domain . '">';
echo '</td>'."\n".'<td><input name="f_smb_domain" type="text" size="20" maxlength="80" value="' . $account_new->smb_domain . '">';
}
echo '</td>'."\n".'<td><a href="'.$_SESSION['lamurl'].'templates/help.php?HelpNumber=460" target="lamhelp">'._('Help').'</a></td></tr>'."\n";
echo '</td>'."\n".'<td><a href="'.$lamurl_intern.'templates/help.php?HelpNumber=460" target="lamhelp">'._('Help').'</a></td></tr>'."\n";
echo "</table>\n</fieldset>\n</td></tr></table></td></tr>\n</table>\n";
break;
@ -423,7 +450,7 @@ switch ($select_local) { // Select which part of page will be loaded
echo "<input name=\"next_samba\" type=\"submit\" value=\""; echo _('Samba'); echo "\">\n<br>";
echo "<input name=\"next_final\" type=\"submit\" disabled value=\""; echo _('Final');
echo "\">";
if (isset($_SESSION['account_old'])) {
if (isset($account_old)) {
echo "<br><br>";
echo _("Reset all changes.");
echo "<br>";
@ -438,39 +465,39 @@ switch ($select_local) { // Select which part of page will be loaded
echo '<input name="f_finish_safeProfile" type="text" size="30" maxlength="50">';
echo '</td><td><input name="save" type="submit" value="';
echo _('Save profile');
echo '"></td><td><a href="'.$_SESSION['lamurl'].'templates/help.php?HelpNumber=457" target="lamhelp">'._('Help');
echo '"></td><td><a href="'.$lamurl_intern.'templates/help.php?HelpNumber=457" target="lamhelp">'._('Help');
echo "</a></td>\n</tr>\n</table>\n</fieldset>\n</td></tr>\n<tr><td>\n";
echo "<fieldset class=\"hostedit-bright\"><legend class=\"hostedit-bright\"><b>";
if ($_SESSION['account_old']) echo _('Modify');
if ($account_old) echo _('Modify');
else echo _('Create');
echo "</b></legend>\n";
echo "<table border=0 width=\"100%\"><tr><td>";
if (isset($_SESSION['account_old']->general_objectClass)) {
if (!in_array('posixAccount', $_SESSION['account_old']->general_objectClass)) {
if (isset($account_old->general_objectClass)) {
if (!in_array('posixAccount', $account_old->general_objectClass)) {
echo '<tr>';
StatusMessage('WARN', _('ObjectClass posixAccount not found.'), _('Have to add objectClass posixAccount.'));
echo "</tr>\n";
}
if (!in_array('shadowAccount', $_SESSION['account_old']->general_objectClass)) {
if (!in_array('shadowAccount', $account_old->general_objectClass)) {
echo '<tr>';
StatusMessage('WARN', _('ObjectClass shadowAccount not found.'), _('Have to add objectClass shadowAccount.'));
echo "</tr>\n";
}
if ($_SESSION['config']->is_samba3()) {
if (!in_array('sambaSamAccount', $_SESSION['account_old']->general_objectClass)) {
if ($config_intern->is_samba3()) {
if (!in_array('sambaSamAccount', $account_old->general_objectClass)) {
echo '<tr>';
StatusMessage('WARN', _('ObjectClass sambaSamAccount not found.'), _('Have to add objectClass sambaSamAccount. Host with sambaAccount will be updated.'));
echo "</tr>\n";
}}
else
if (!in_array('sambaAccount', $_SESSION['account_old']->general_objectClass)) {
if (!in_array('sambaAccount', $account_old->general_objectClass)) {
echo '<tr>';
StatusMessage('WARN', _('ObjectClass sambaAccount not found.'), _('Have to add objectClass sambaSamAccount. Host with sambaSamAccount will be set back to sambaAccount.'));
echo "</tr>\n";
}
}
echo '<input name="create" type="submit" value="';
if ($_SESSION['account_old']) echo _('Modify Account');
if ($account_old) echo _('Modify Account');
else echo _('Create Account');
echo '">'."\n";
echo "</td></tr></table></fieldset>\n</td></tr></table></td></tr></table>\n</tr></table>";
@ -482,11 +509,11 @@ switch ($select_local) { // Select which part of page will be loaded
echo "<table border=0 width=\"100%\"><tr><td>";
echo '<tr><td>';
echo _('Host');
echo ' '.$_SESSION['account']->general_username.' ';
if ($_SESSION['account_old']) echo ' '._('has been modified').'.';
echo ' '.$account_new->general_username.' ';
if ($account_old) echo ' '._('has been modified').'.';
else echo ' '._('has been created').'.';
echo '</td></tr>'."\n".'<tr><td>';
if (!$_SESSION['account_old'])
if (!$account_old)
{ echo '<input name="createagain" type="submit" value="'; echo _('Create another host'); echo '">'; }
echo '</td><td>'."\n".'</td><td>'.
'<input name="backmain" type="submit" value="'; echo _('Back to host list'); echo '">'.
@ -494,12 +521,11 @@ switch ($select_local) { // Select which part of page will be loaded
break;
case 'backmain':
// unregister sessionvar and select which list should be shown
echo '<a href="'.$_SESSION['lamurl'].'templates/lists/listhosts.php">';
echo '<a href="'.$lamurl_intern.'templates/lists/listhosts.php">';
echo _('Please press here if meta-refresh didn\'t work.');
echo "</a>\n";
if (isset($_SESSION['shelllist'])) unset($_SESSION['shelllist']);
if (isset($_SESSION['account'])) unset($_SESSION['account']);
if (isset($_SESSION['account_old'])) unset($_SESSION['account_old']);
if (isset($_SESSION['account_'.$varkey.'_account_new'])) unset($_SESSION['account_'.$varkey.'_account_new']);
if (isset($_SESSION['account_'.$varkey.'_account_old'])) unset($_SESSION['account_'.$varkey.'_account_old']);
break;
}

File diff suppressed because it is too large Load Diff

View File

@ -29,18 +29,24 @@ session_save_path('../sess');
@session_start();
setlanguage();
$ldap_intern =& $_SESSION['ldap'];
$header_intern =& $_SESSION['header'];
$lamurl_intern =& $_SESSION['lamurl'];
$config_intern =& $_SESSION['config'];
$delete_dn =& $_SESSION['delete_dn'];
if ($_POST['backmain']) { // back to list page
if (isset($_SESSION['delete_dn'])) unset ($_SESSION['delete_dn']);
metaRefresh($_SESSION['lamurl']."templates/lists/list".$_POST['type5']."s.php");
metaRefresh($lamurl_intern."templates/lists/list".$_POST['type5']."s.php");
die;
}
echo $_SESSION['header'];
echo $header_intern;
echo '<html><head><title>';
echo _('Delete Account');
echo '</title>'."\n".
'<link rel="stylesheet" type="text/css" href="'.$_SESSION['lamurl'].'style/layout.css">'."\n".
'<link rel="stylesheet" type="text/css" href="'.$lamurl_intern.'style/layout.css">'."\n".
'<meta http-equiv="pragma" content="no-cache">'."\n".
'<meta http-equiv="cache-control" content="no-cache">'."\n".
'</head>'."\n".
@ -72,9 +78,9 @@ if ($_GET['type']) {
}
echo "<br>\n";
echo "<table border=0 width=\"100%\">\n";
foreach ($_SESSION['delete_dn'] as $dn) echo '<tr><td>'.$dn.'</td></tr>';
foreach ($delete_dn as $dn) echo '<tr><td>'.$dn.'</td></tr>';
echo "</table>\n";
if (($_GET['type']== user) && $_SESSION['config']->scriptServer) {
if (($_GET['type']== user) && $config_intern->scriptServer) {
echo "<br>\n";
echo "<table border=0>\n";
echo '<tr><td>';
@ -115,50 +121,50 @@ if ($_POST['delete_yes'] && !$_POST['backmain']) {
}
echo "<br><table border=0 >\n";
echo '<input name="type5" type="hidden" value="'.$_POST['type5'].'">';
foreach ($_SESSION['delete_dn'] as $dn) {
foreach ($delete_dn as $dn) {
switch ($_POST['type5']) {
case 'user':
$temp=explode(',', $dn);
$username = str_replace('uid=', '', $temp[0]);
if ($_SESSION['config']->scriptServer) {
if ($config_intern->scriptServer) {
if ($_POST['f_rem_home']) remhomedir($username);
remquotas($username, $_POST['type5']);
}
$result = ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_GroupSuffix(), 'objectClass=PosixGroup', array('memberUid'));
$entry = ldap_first_entry($_SESSION['ldap']->server(), $result);
$result = ldap_search($ldap_intern->server(), $config_intern->get_GroupSuffix(), 'objectClass=PosixGroup', array('memberUid'));
$entry = ldap_first_entry($ldap_intern->server(), $result);
while ($entry) {
$attr2 = ldap_get_attributes($_SESSION['ldap']->server(), $entry);
$attr2 = ldap_get_attributes($ldap_intern->server(), $entry);
if ($attr2['memberUid']) {
array_shift($attr2['memberUid']);
foreach ($attr2['memberUid'] as $nam) {
if ($nam==$username) {
$todelete['memberUid'] = $nam;
$success = ldap_mod_del($_SESSION['ldap']->server(), ldap_get_dn($_SESSION['ldap']->server(), $entry) ,$todelete);
$success = ldap_mod_del($ldap_intern->server(), ldap_get_dn($ldap_intern->server(), $entry) ,$todelete);
}
}
}
$entry = ldap_next_entry($_SESSION['ldap']->server(), $entry);
$entry = ldap_next_entry($ldap_intern->server(), $entry);
}
$success = ldap_delete($_SESSION['ldap']->server(), $dn);
$success = ldap_delete($ldap_intern->server(), $dn);
if (!$success) $error = _('Could not delete user:').' '.$dn;
break;
case 'host':
$success = ldap_delete($_SESSION['ldap']->server(), $dn);
$success = ldap_delete($ldap_intern->server(), $dn);
if (!$success) $error = _('Could not delete host:').' '.$dn;
break;
case 'group':
$temp=explode(',', $dn);
$groupname = str_replace('cn=', '', $temp[0]);
$result = ldap_search($_SESSION['ldap']->server(), $dn, 'objectClass=*', array('gidNumber'));
$entry = ldap_first_entry($_SESSION['ldap']->server(), $result);
$result = ldap_search($ldap_intern->server(), $dn, 'objectClass=*', array('gidNumber'));
$entry = ldap_first_entry($ldap_intern->server(), $result);
while ($entry) {
$attr2 = ldap_get_attributes($_SESSION['ldap']->server(), $entry);
$attr2 = ldap_get_attributes($ldap_intern->server(), $entry);
if ($attr2['gidNumber']==getgid($groupname)) $error = _('Could not delete group. Still users in group:').' '.$dn;
$entry = ldap_next_entry($_SESSION['ldap']->server(), $entry);
$entry = ldap_next_entry($ldap_intern->server(), $entry);
}
if (!$error) {
if ($_SESSION['config']->scriptServer) remquotas($groupname, $_POST['type5']);
$success = ldap_delete($_SESSION['ldap']->server(), $dn);
if ($config_intern->scriptServer) remquotas($groupname, $_POST['type5']);
$success = ldap_delete($ldap_intern->server(), $dn);
if (!$success) $error = _('Could not delete group:').' '.$dn;
}
break;