diff --git a/lam/templates/account/groupedit.php b/lam/templates/account/groupedit.php index e6ec2f50..ab199e4d 100644 --- a/lam/templates/account/groupedit.php +++ b/lam/templates/account/groupedit.php @@ -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; $jquota); $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; $jquota); $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; $jquota); $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; $jquota); $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 ""; echo _("Create new Account"); echo "\n". - "\n". + "\n". "\n". "\n". "\n". - "
\n"; + "\n". + "\n"; if (is_array($errors)) { echo "\n"; @@ -357,7 +389,7 @@ if (is_array($errors)) { echo "
"; } -// 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 "\n"; echo "\n
"; echo "\n
"; - if ($_SESSION['config']->is_samba3()) { + if ($config_intern->is_samba3()) { echo "\n
"; } - echo "scriptPath)) echo " disabled "; + echo "scriptPath)) echo " disabled "; echo "value=\""; echo _('Quota'); echo "\">\n
"; echo ""; - if (isset($_SESSION['account_old'])) { + if (isset($account_old)) { echo "

"; echo _("Reset all changes."); echo "
"; @@ -401,17 +433,17 @@ switch ($select_local) { // Select which part of page will be loaded echo "
"; echo _('Group members'); echo ""; - if (count($_SESSION['account']->unix_memberUid)!=0) { + if (count($account_new->unix_memberUid)!=0) { echo "\n"; } echo "
\n"; echo ""; echo " "; echo "\">

"; - echo ""._('Help')."\n"; + echo ""._('Help')."\n"; echo "
"; echo _('Available users'); echo "\n"; @@ -436,14 +468,14 @@ switch ($select_local) { // Select which part of page will be loaded echo "\n"; echo "\n
"; echo "\n
"; - if ($_SESSION['config']->is_samba3()) { + if ($config_intern->is_samba3()) { echo "\n
"; } - echo "scriptPath)) echo " disabled "; + echo "scriptPath)) echo " disabled "; echo "value=\""; echo _('Quota'); echo "\">\n
"; echo ""; - if (isset($_SESSION['account_old'])) { + if (isset($account_old)) { echo "

"; echo _("Reset all changes."); echo "
"; @@ -457,26 +489,26 @@ switch ($select_local) { // Select which part of page will be loaded echo "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n". - "\n\n\n\n\n". + "\n\n\n\n\n\n\n\n
"; echo _("Groupname")."*"; echo "". - "general_username."\">". - ""._('Help')."
"; + "general_username."\">". + ""._('Help')."
"; echo _('GID number'); - echo "general_uidNumber."\">". - ""._('Help'). + echo "general_uidNumber."\">". + ""._('Help'). "
"; echo _('Description'); - echo "general_gecos."\">"._('Help')."
"; + echo "general_gecos."\">"._('Help')."
"; echo _('Suffix'); echo ""._('Help'). + echo ""._('Help'). "
"; echo _('Values with * are required'); echo "
\n"; @@ -488,7 +520,7 @@ switch ($select_local) { // Select which part of page will be loaded foreach ($profilelist as $profile) echo " \n"; echo "\n". ""; + echo "\">"; echo _('Help')."\n\n\n\n"; } echo "\n\n\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 "\n"; echo "\n\n
"; echo "
"; @@ -505,11 +537,11 @@ switch ($select_local) { // Select which part of page will be loaded echo "\n
"; echo "\n
"; echo "\n
"; - echo "scriptPath)) echo " disabled "; + echo "scriptPath)) echo " disabled "; echo "value=\""; echo _('Quota'); echo "\">\n
"; echo ""; - if (isset($_SESSION['account_old'])) { + if (isset($account_old)) { echo "

"; echo _("Reset all changes."); echo "
"; @@ -521,22 +553,22 @@ switch ($select_local) { // Select which part of page will be loaded echo "\n\n\n\n\n\n\n\n\n\n\n'."\n".''."\n".''."\n"; + echo ''."\n".''."\n"; echo "
"; echo _("Display name"); echo "". - "smb_displayName."\">". - ""._('Help')."
"; + "smb_displayName."\">". + ""._('Help')."
"; echo _('Windows groupname'); echo "". - ''._('Help').''. + ''._('Help').''. '
'; echo _('Domain'); echo ''._('Help').'
'._('Help').'
\n
\n
\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 "\n"; echo "\n
"; echo "\n
"; - if ($_SESSION['config']->is_samba3()) { + if ($config_intern->is_samba3()) { echo "\n
"; } echo "\n
"; echo ""; - if (isset($_SESSION['account_old'])) { + if (isset($account_old)) { echo "

"; echo _("Reset all changes."); echo "
"; @@ -661,21 +693,21 @@ switch ($select_local) { // Select which part of page will be loaded echo _('Soft block limit'); echo ''."\n".''; echo _('Hard block limit'); echo ''."\n".''; echo _('Grace block period'); echo ''."\n".''; echo _('Used inodes'); echo ''."\n".''; echo _('Soft inode limit'); echo ''."\n".''; echo _('Hard inode limit'); echo ''."\n".''; echo _('Grace inode period'); echo ''."\n"; - echo ''._('Help').''."\n".''._('Help').''."\n".''. - ''._('Help').''."\n".''._('Help').''."\n".''. - ''._('Help').''."\n".''._('Help').''."\n".''. - ''._('Help').''."\n".''._('Help').''."\n".''. - ''._('Help').''."\n"; + echo ''._('Help').''."\n".''._('Help').''."\n".''. + ''._('Help').''."\n".''._('Help').''."\n".''. + ''._('Help').''."\n".''._('Help').''."\n".''. + ''._('Help').''."\n".''._('Help').''."\n".''. + ''._('Help').''."\n"; $i=0; - while ($_SESSION['account']->quota[$i][0]) { - echo ''.$_SESSION['account']->quota[$i][0].''.$_SESSION['account']->quota[$i][1].''; // used blocks - echo ''; // blocks soft limit - echo ''; // blocks hard limit - echo ''.$_SESSION['account']->quota[$i][4].''; // block grace period - echo ''.$_SESSION['account']->quota[$i][5].''; // used inodes - echo ''; // inodes soft limit - echo ''; // inodes hard limit - echo ''.$_SESSION['account']->quota[$i][8].''; // inodes grace period + while ($account_new->quota[$i][0]) { + echo ''.$account_new->quota[$i][0].''.$account_new->quota[$i][1].''; // used blocks + echo ''; // blocks soft limit + echo ''; // blocks hard limit + echo ''.$account_new->quota[$i][4].''; // block grace period + echo ''.$account_new->quota[$i][5].''; // used inodes + echo ''; // inodes soft limit + echo ''; // inodes hard limit + echo ''.$account_new->quota[$i][8].''; // inodes grace period $i++; } echo "\n\n\n\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 "\n"; echo "\n
"; echo "\n
"; - if ($_SESSION['config']->is_samba3()) { + if ($config_intern->is_samba3()) { echo "\n
"; } - echo "scriptPath)) echo " disabled "; + echo "scriptPath)) echo " disabled "; echo "value=\""; echo _('Quota'); echo "\">\n
"; echo ""; - if (isset($_SESSION['account_old'])) { + if (isset($account_old)) { echo "

"; echo _("Reset all changes."); echo "
"; @@ -720,21 +752,21 @@ switch ($select_local) { // Select which part of page will be loaded echo ''; echo "'._('Help'); + echo '">'._('Help'); echo "\n\n\n\n\n\n"; echo "
"; - if ($_SESSION['account_old']) echo _('Modify'); + if ($account_old) echo _('Modify'); else echo _('Create'); echo "\n"; echo ""; - 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 ''; 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 ''."\n"; echo ''."\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 ""; } - 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 ''; StatusMessage('WARN', _('ObjectClass sambaGroupMapping not found.'), _('Have to add objectClass sambaGroupMapping.')); echo "\n"; } - if (!in_array('posixGroup', $_SESSION['account_old']->general_objectClass)) { + if (!in_array('posixGroup', $account_old->general_objectClass)) { echo ''; StatusMessage('WARN', _('ObjectClass posixGroup not found.'), _('Have to add objectClass posixGroup.')); echo "\n"; } } echo "
'; echo ''; echo _('Change GID-Number of all users in group to new value'); echo '
'."\n"; echo "
\n\n"; @@ -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 ''; echo "
"._('Success')."\n"; echo ""; echo ''."\n".'\n\n
'; 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 '
'; - if (!$_SESSION['account_old']) + if (!$account_old) { echo' '; } 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 ''; + echo ''; echo _('Please press here if meta-refresh didn\'t work.'); echo "\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; } diff --git a/lam/templates/account/hostedit.php b/lam/templates/account/hostedit.php index ec7332a4..776f4ff9 100644 --- a/lam/templates/account/hostedit.php +++ b/lam/templates/account/hostedit.php @@ -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; $iname) { - $_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 ""; echo _("Create new Account"); echo "\n". - "\n". + "\n". "\n". "\n". "\n". - "\n"; + "\n". + "\n"; if (is_array($errors)) { echo "\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 "\n
"; echo ""; - if (isset($_SESSION['account_old'])) { + if (isset($account_old)) { echo "

"; echo _("Reset all changes."); echo "
"; @@ -300,40 +327,40 @@ switch ($select_local) { // Select which part of page will be loaded echo "\n
\n\n'."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".'\n\n
"; echo _('Host name').'*'; echo ''. - ''. + ''. ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('UID number'); echo ''. - ''. + ''. ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Primary group').'*'; echo ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Gecos'); - echo ''. + echo ''. ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Suffix'); echo ''._('Help').''. + echo ''._('Help').''. "
"; echo _('Values with * are required'); echo "\n
"; @@ -345,7 +372,7 @@ switch ($select_local) { // Select which part of page will be loaded foreach ($profilelist as $profile) echo " \n"; echo "\n". ""; + echo "\">"; echo _('Help')."
\n
\n"; } echo "\n\n\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 ''; + if ($config_intern->is_samba3()) $samba3domains = $ldap_intern->search_domains($config_intern->get_domainSuffix()); + if ($account_new->smb_password_no) echo ''; echo ''; echo "\n\n
"; echo "
"; @@ -364,7 +391,7 @@ switch ($select_local) { // Select which part of page will be loaded echo "\n
"; echo ""; - if (isset($_SESSION['account_old'])) { + if (isset($account_old)) { echo "

"; echo _("Reset all changes."); echo "
"; @@ -376,28 +403,28 @@ switch ($select_local) { // Select which part of page will be loaded echo "\n\n\n\n\n\n\n\n\n'."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n"; + echo ''."\n".''."\n"; echo "
"; echo _("Display name"); echo "". - "smb_displayName."\">". - ""._('Help')."
"; + "smb_displayName."\">". + ""._('Help')."
"; echo _('Password'); echo ''; - if (isset($_SESSION['account_old'])) { + if (isset($account_old)) { echo ''; } echo '
'; echo _('Account is deactivated'); echo 'smb_flagsD) echo ' checked '; + if ($account_new->smb_flagsD) echo ' checked '; echo '>'. - ''._('Help').''. + ''._('Help').''. '
'; echo '
'; echo _('Domain'); - if ($_SESSION['config']->is_samba3()) { + if ($config_intern->is_samba3()) { echo ''; } else { - echo ''; + echo ''; } - echo ''._('Help').'
'._('Help').'
\n
\n
\n"; break; @@ -423,7 +450,7 @@ switch ($select_local) { // Select which part of page will be loaded echo "\n
"; echo ""; - if (isset($_SESSION['account_old'])) { + if (isset($account_old)) { echo "

"; echo _("Reset all changes."); echo "
"; @@ -438,39 +465,39 @@ switch ($select_local) { // Select which part of page will be loaded echo ''; echo ''._('Help'); + echo '">'._('Help'); echo "\n\n\n\n\n\n"; echo "
"; - if ($_SESSION['account_old']) echo _('Modify'); + if ($account_old) echo _('Modify'); else echo _('Create'); echo "\n"; echo "'; StatusMessage('WARN', _('ObjectClass posixAccount not found.'), _('Have to add objectClass posixAccount.')); echo "\n"; } - if (!in_array('shadowAccount', $_SESSION['account_old']->general_objectClass)) { + if (!in_array('shadowAccount', $account_old->general_objectClass)) { echo ''; StatusMessage('WARN', _('ObjectClass shadowAccount not found.'), _('Have to add objectClass shadowAccount.')); echo "\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 ''; StatusMessage('WARN', _('ObjectClass sambaSamAccount not found.'), _('Have to add objectClass sambaSamAccount. Host with sambaAccount will be updated.')); echo "\n"; }} else - if (!in_array('sambaAccount', $_SESSION['account_old']->general_objectClass)) { + if (!in_array('sambaAccount', $account_old->general_objectClass)) { echo ''; StatusMessage('WARN', _('ObjectClass sambaAccount not found.'), _('Have to add objectClass sambaSamAccount. Host with sambaSamAccount will be set back to sambaAccount.')); echo "\n"; } } echo ''."\n"; echo "
"; - 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 '
\n\n"; @@ -482,11 +509,11 @@ switch ($select_local) { // Select which part of page will be loaded echo "'."\n".'
"; echo '
'; 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 '
'; - if (!$_SESSION['account_old']) + if (!$account_old) { echo ''; } echo ''."\n".''. ''. @@ -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 ''; + echo ''; echo _('Please press here if meta-refresh didn\'t work.'); echo "\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; } diff --git a/lam/templates/account/useredit.php b/lam/templates/account/useredit.php index 4ad093a4..b91b516c 100644 --- a/lam/templates/account/useredit.php +++ b/lam/templates/account/useredit.php @@ -33,53 +33,85 @@ include_once('../../lib/ldap.inc'); // LDAP-functions session_save_path('../../sess'); @session_start(); setlanguage(); -$_SESSION['shelllist'] = getshells(); // Write List of all valid shells in variable + +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'] = ''; +if (!isset($_SESSION['account_'.$varkey.'_shelllist'])) $_SESSION['account_'.$varkey.'_shelllist'] = getshells(); + +// 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']; +$shelllist =& $_SESSION['account_'.$varkey.'_shelllist']; +$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']; +$hostDN_intern =& $_SESSION['hostDN']; + + + 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'] = loaduser($DN); - $_SESSION['account'] ->type = 'user'; - $_SESSION['account_old'] = $_SESSION['account']; - $_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); - $_SESSION['final_changegids'] = ''; + $account_new = loaduser($DN); + $account_new ->type = 'user'; + $account_old = $account_new; + $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); + $final_changegids = ''; } } else if (count($_POST)==0) { // Startcondition. useredit.php was called from outside - $_SESSION['account'] = loadUserProfile('default'); - $_SESSION['account'] ->type = 'user'; - $_SESSION['account']->smb_flagsW = 0; + $account_new = loadUserProfile('default'); + $account_new ->type = 'user'; + $account_new->smb_flagsW = 0; // load quotas from profile and check if they are valid - $values = getquotas('user'); - 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; $jquota); $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) { + $values = getquotas('user'); + 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; $jquota); $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_'.$varkey.'_account_old'])) { + unset($account_old); + unset($_SESSION['account_'.$varkey.'_account_old']); } - if (isset($_SESSION['account_old'])) unset($_SESSION['account_old']); } @@ -96,7 +128,7 @@ switch ($_POST['select']) { // Select which part of page should be loaded and ch case 'workstations': do { // X-Or, only one if() can be true if (isset($_POST['hosts']) && isset($_POST['add'])) { // Add users to list - $temp = str_replace(' ', '', $_SESSION['account']->smb_smbuserworkstations); + $temp = str_replace(' ', '', $account_new->smb_smbuserworkstations); $workstations = explode (',', $temp); for ($i=0; $ismb_smbuserworkstations = $workstations[0]; + $account_new->smb_smbuserworkstations = $workstations[0]; for ($i=1; $ismb_smbuserworkstations = $_SESSION['account']->smb_smbuserworkstations . ", " . $workstations[$i]; + $account_new->smb_smbuserworkstations = $account_new->smb_smbuserworkstations . ", " . $workstations[$i]; } // display groupmembers page break; } if (isset($_POST['members']) && isset($_POST['remove'])) { // remove users fromlist - $temp = str_replace(' ', '', $_SESSION['account']->smb_smbuserworkstations); + $temp = str_replace(' ', '', $account_new->smb_smbuserworkstations); $workstations = explode (',', $temp); for ($i=0; $ismb_smbuserworkstations = $workstations[0]; + $account_new->smb_smbuserworkstations = $workstations[0]; for ($i=1; $ismb_smbuserworkstations = $_SESSION['account']->smb_smbuserworkstations . ", " . $workstations[$i]; + $account_new->smb_smbuserworkstations = $account_new->smb_smbuserworkstations . ", " . $workstations[$i]; } break; } @@ -135,186 +167,186 @@ switch ($_POST['select']) { // Select which part of page should be loaded and ch 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_surname = $_POST['f_general_surname']; - $_SESSION['account']->general_givenname = $_POST['f_general_givenname']; - $_SESSION['account']->general_uidNumber = $_POST['f_general_uidNumber']; - $_SESSION['account']->general_group = $_POST['f_general_group']; - if (isset($_POST['f_general_groupadd'])) $_SESSION['account']->general_groupadd = $_POST['f_general_groupadd']; - else $_SESSION['account']->general_groupadd = array(''); - $_SESSION['account']->general_homedir = $_POST['f_general_homedir']; - $_SESSION['account']->general_shell = $_POST['f_general_shell']; - $_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_surname = $_POST['f_general_surname']; + $account_new->general_givenname = $_POST['f_general_givenname']; + $account_new->general_uidNumber = $_POST['f_general_uidNumber']; + $account_new->general_group = $_POST['f_general_group']; + if (isset($_POST['f_general_groupadd'])) $account_new->general_groupadd = $_POST['f_general_groupadd']; + else $account_new->general_groupadd = array(''); + $account_new->general_homedir = $_POST['f_general_homedir']; + $account_new->general_shell = $_POST['f_general_shell']; + $account_new->general_gecos = $_POST['f_general_gecos']; // Check if Homedir is valid - $_SESSION['account']->general_homedir = str_replace('$group', $_SESSION['account']->general_group, $_SESSION['account']->general_homedir); - if ($_SESSION['account']->general_username != '') - $_SESSION['account']->general_homedir = str_replace('$user', $_SESSION['account']->general_username, $_SESSION['account']->general_homedir); - if ($_SESSION['account']->general_homedir != $_POST['f_general_homedir']) $errors[] = array('INFO', _('Home directory'), _('Replaced $user or $group in 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']->general_homedir )) + $account_new->general_homedir = str_replace('$group', $account_new->general_group, $account_new->general_homedir); + if ($account_new->general_username != '') + $account_new->general_homedir = str_replace('$user', $account_new->general_username, $account_new->general_homedir); + if ($account_new->general_homedir != $_POST['f_general_homedir']) $errors[] = array('INFO', _('Home directory'), _('Replaced $user or $group in homedir.')); + if ( !ereg('^[/]([a-z]|[A-Z])([a-z]|[A-Z]|[0-9]|[.]|[-]|[_])*([/]([a-z]|[A-Z])([a-z]|[A-Z]|[0-9]|[.]|[-]|[_])*)*$', $account_new->general_homedir )) $errors[] = array('ERROR', _('Home directory'), _('Homedirectory contains invalid characters.')); // Check if givenname is valid - if ( !ereg('^([a-z]|[A-Z]|[-]|[ ]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+$', $_SESSION['account']->general_givenname)) $errors[] = array('ERROR', _('Given name'), _('Given name contains invalid characters')); + if ( !ereg('^([a-z]|[A-Z]|[-]|[ ]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+$', $account_new->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']->general_surname)) $errors[] = array('ERROR', _('Surname'), _('Surname contains invalid characters')); - if ( ($_SESSION['account']->general_gecos=='') || ($_SESSION['account']->general_gecos==' ')) { - $_SESSION['account']->general_gecos = $_SESSION['account']->general_givenname . " " . $_SESSION['account']->general_surname ; + if ( !ereg('^([a-z]|[A-Z]|[-]|[ ]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+$', $account_new->general_surname)) $errors[] = array('ERROR', _('Surname'), _('Surname contains invalid characters')); + if ( ($account_new->general_gecos=='') || ($account_new->general_gecos==' ')) { + $account_new->general_gecos = $account_new->general_givenname . " " . $account_new->general_surname ; $errors[] = array('INFO', _('Gecos'), _('Inserted sur- and given name in gecos-field.')); } - if ($_SESSION['account']->general_group=='') $errors[] = array('ERROR', _('Primary group'), _('No primary group defined!')); + if ($account_new->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']->general_username)) + if ( !ereg('^([a-z]|[0-9]|[.]|[-]|[_])*$', $account_new->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']->general_groupadd) && in_array($_SESSION['account']->general_group, $_SESSION['account']->general_groupadd)) { - for ($i=0; $igeneral_groupadd); $i++ ) - if ($_SESSION['account']->general_groupadd[$i] == $_SESSION['account']->general_group) { - unset ($_SESSION['account']->general_groupadd[$i]); - $_SESSION['account']->general_groupadd = array_values($_SESSION['account']->general_groupadd); + if (isset($account_new->general_groupadd) && in_array($account_new->general_group, $account_new->general_groupadd)) { + for ($i=0; $igeneral_groupadd); $i++ ) + if ($account_new->general_groupadd[$i] == $account_new->general_group) { + unset ($account_new->general_groupadd[$i]); + $account_new->general_groupadd = array_values($account_new->general_groupadd); } } // Create automatic useraccount with number if original user already exists // Reset name to original name if new name is in use - if (ldapexists($_SESSION['account'], 'user', $_SESSION['account_old']) && is_object($_SESSION['account_old'])) - $_SESSION['account']->general_username = $_SESSION['account_old']->general_username; - while ($temp = ldapexists($_SESSION['account'], 'user', $_SESSION['account_old'])) { + if (ldapexists($account_new, 'user', $account_old) && is_object($account_old)) + $account_new->general_username = $account_old->general_username; + while ($temp = ldapexists($account_new, 'user', $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', _('Username'), _('Username in use. Selected next free username.')); + if ($account_new->general_username != $_POST['f_general_username']) $errors[] = array('WARN', _('Username'), _('Username in use. Selected next free username.')); // Check if UID is valid. If none value was entered, the next useable value will be inserted - $_SESSION['account']->general_uidNumber = checkid($_SESSION['account'], 'user', $_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, 'user', $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 'unix': - // Write all general values into $_SESSION['account'] + // Write all general values into $account_new if (isset($_POST['f_unix_password'])) { // Encraypt password $iv = base64_decode($_COOKIE["IV"]); $key = base64_decode($_COOKIE["Key"]); - $_SESSION['account']->unix_password = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $_POST['f_unix_password'], MCRYPT_MODE_ECB, $iv)); + $account_new->unix_password = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $_POST['f_unix_password'], MCRYPT_MODE_ECB, $iv)); } - else $_SESSION['account']->unix_password = ''; - if ($_POST['f_unix_password_no']) $_SESSION['account']->unix_password_no = true; - else $_SESSION['account']->unix_password_no = false; - $_SESSION['account']->unix_pwdwarn = $_POST['f_unix_pwdwarn']; - $_SESSION['account']->unix_pwdallowlogin = $_POST['f_unix_pwdallowlogin']; - $_SESSION['account']->unix_pwdmaxage = $_POST['f_unix_pwdmaxage']; - $_SESSION['account']->unix_pwdminage = $_POST['f_unix_pwdminage']; - $_SESSION['account']->unix_host = $_POST['f_unix_host']; - $_SESSION['account']->unix_pwdexpire = mktime(10, 0, 0, $_POST['f_unix_pwdexpire_mon'], + else $account_new->unix_password = ''; + if ($_POST['f_unix_password_no']) $account_new->unix_password_no = true; + else $account_new->unix_password_no = false; + $account_new->unix_pwdwarn = $_POST['f_unix_pwdwarn']; + $account_new->unix_pwdallowlogin = $_POST['f_unix_pwdallowlogin']; + $account_new->unix_pwdmaxage = $_POST['f_unix_pwdmaxage']; + $account_new->unix_pwdminage = $_POST['f_unix_pwdminage']; + $account_new->unix_host = $_POST['f_unix_host']; + $account_new->unix_pwdexpire = mktime(10, 0, 0, $_POST['f_unix_pwdexpire_mon'], $_POST['f_unix_pwdexpire_day'], $_POST['f_unix_pwdexpire_yea']); - if ($_POST['f_unix_deactivated']) $_SESSION['account']->unix_deactivated = $_POST['f_unix_deactivated']; - else $_SESSION['account']->unix_deactivated = false; + if ($_POST['f_unix_deactivated']) $account_new->unix_deactivated = $_POST['f_unix_deactivated']; + else $account_new->unix_deactivated = false; if ($_POST['genpass']) { // Generate a random password if generate-button was pressed $iv = base64_decode($_COOKIE["IV"]); $key = base64_decode($_COOKIE["Key"]); - $_SESSION['account']->unix_password = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, genpasswd(), MCRYPT_MODE_ECB, $iv)); + $account_new->unix_password = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, genpasswd(), MCRYPT_MODE_ECB, $iv)); // Keep unix-page acitve $select_local = 'unix'; } // Check if values are OK and set automatic values. if not error-variable will be set else { // account.inc - if ($_SESSION['account']->unix_password != '') { + if ($account_new->unix_password != '') { $iv = base64_decode($_COOKIE["IV"]); $key = base64_decode($_COOKIE["Key"]); - $password = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($_SESSION['account']->unix_password), MCRYPT_MODE_ECB, $iv); + $password = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($account_new->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']->unix_pwdminage)) $errors[] = array('ERROR', _('Password minage'), _('Password minage must be are natural number.')); - if ( $_SESSION['account']->unix_pwdminage > $_SESSION['account']->unix_pwdmaxage ) $errors[] = array('ERROR', _('Password maxage'), _('Password maxage must bigger as Password Minage.')); - if ( !ereg('^([0-9]*)$', $_SESSION['account']->unix_pwdmaxage)) $errors[] = array('ERROR', _('Password maxage'), _('Password maxage must be are natural number.')); - if ( !ereg('^(([-][1])|([0-9]*))$', $_SESSION['account']->unix_pwdallowlogin)) + if ( !ereg('^([0-9])*$', $account_new->unix_pwdminage)) $errors[] = array('ERROR', _('Password minage'), _('Password minage must be are natural number.')); + if ( $account_new->unix_pwdminage > $account_new->unix_pwdmaxage ) $errors[] = array('ERROR', _('Password maxage'), _('Password maxage must bigger as Password Minage.')); + if ( !ereg('^([0-9]*)$', $account_new->unix_pwdmaxage)) $errors[] = array('ERROR', _('Password maxage'), _('Password maxage must be are natural number.')); + if ( !ereg('^(([-][1])|([0-9]*))$', $account_new->unix_pwdallowlogin)) $errors[] = array('ERROR', _('Password Expire'), _('Password expire must be are natural number or -1.')); - if ( !ereg('^([0-9]*)$', $_SESSION['account']->unix_pwdwarn)) $errors[] = array('ERROR', _('Password warn'), _('Password warn must be are natural number.')); - if ((!$_SESSION['account']->unix_host=='') && !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-])+(([,])+([ ])*([a-z]|[A-Z]|[0-9]|[.]|[-])+)*$', $_SESSION['account']->unix_host)) + if ( !ereg('^([0-9]*)$', $account_new->unix_pwdwarn)) $errors[] = array('ERROR', _('Password warn'), _('Password warn must be are natural number.')); + if ((!$account_new->unix_host=='') && !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-])+(([,])+([ ])*([a-z]|[A-Z]|[0-9]|[.]|[-])+)*$', $account_new->unix_host)) $errors[] = array('ERROR', _('Unix workstations'), _('Unix workstations is invalid.')); } break; case 'samba': - // Write all general values into $_SESSION['account'] - $_SESSION['account']->smb_pwdcanchange = mktime($_POST['f_smb_pwdcanchange_s'], $_POST['f_smb_pwdcanchange_m'], $_POST['f_smb_pwdcanchange_h'], + // Write all general values into $account_new + $account_new->smb_pwdcanchange = mktime($_POST['f_smb_pwdcanchange_s'], $_POST['f_smb_pwdcanchange_m'], $_POST['f_smb_pwdcanchange_h'], $_POST['f_smb_pwdcanchange_mon'], $_POST['f_smb_pwdcanchange_day'], $_POST['f_smb_pwdcanchange_yea']); - $_SESSION['account']->smb_pwdmustchange = mktime($_POST['f_smb_pwdmustchange_s'], $_POST['f_smb_pwdmustchange_m'], $_POST['f_smb_pwdmustchange_h'], + $account_new->smb_pwdmustchange = mktime($_POST['f_smb_pwdmustchange_s'], $_POST['f_smb_pwdmustchange_m'], $_POST['f_smb_pwdmustchange_h'], $_POST['f_smb_pwdmustchange_mon'], $_POST['f_smb_pwdmustchange_day'], $_POST['f_smb_pwdmustchange_yea']); - if ($_POST['f_smb_password_no']) $_SESSION['account']->smb_password_no = true; - else $_SESSION['account']->smb_password_no = false; - if ($_POST['f_smb_useunixpwd']) $_SESSION['account']->smb_useunixpwd = $_POST['f_smb_useunixpwd']; - else $_SESSION['account']->smb_useunixpwd = false; - $_SESSION['account']->smb_homedrive = $_POST['f_smb_homedrive']; - $_SESSION['account']->smb_scriptPath = $_POST['f_smb_scriptpath']; - $_SESSION['account']->smb_smbhome = stripslashes($_POST['f_smb_smbhome']); - $_SESSION['account']->smb_profilePath = stripslashes($_POST['f_smb_profilePath']); - $_SESSION['account']->smb_displayName = $_POST['f_smb_displayName']; - if ($_POST['f_smb_flagsW']) $_SESSION['account']->smb_flagsW = true; - else $_SESSION['account']->smb_flagsW = false; - if ($_POST['f_smb_flagsD']) $_SESSION['account']->smb_flagsD = true; - else $_SESSION['account']->smb_flagsD = false; - if ($_POST['f_smb_flagsX']) $_SESSION['account']->smb_flagsX = true; - else $_SESSION['account']->smb_flagsX = false; + if ($_POST['f_smb_password_no']) $account_new->smb_password_no = true; + else $account_new->smb_password_no = false; + if ($_POST['f_smb_useunixpwd']) $account_new->smb_useunixpwd = $_POST['f_smb_useunixpwd']; + else $account_new->smb_useunixpwd = false; + $account_new->smb_homedrive = $_POST['f_smb_homedrive']; + $account_new->smb_scriptPath = $_POST['f_smb_scriptpath']; + $account_new->smb_smbhome = stripslashes($_POST['f_smb_smbhome']); + $account_new->smb_profilePath = stripslashes($_POST['f_smb_profilePath']); + $account_new->smb_displayName = $_POST['f_smb_displayName']; + if ($_POST['f_smb_flagsW']) $account_new->smb_flagsW = true; + else $account_new->smb_flagsW = false; + if ($_POST['f_smb_flagsD']) $account_new->smb_flagsD = true; + else $account_new->smb_flagsD = false; + if ($_POST['f_smb_flagsX']) $account_new->smb_flagsX = true; + else $account_new->smb_flagsX = 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; $iname) { - $_SESSION['account']->smb_domain = $samba3domains[$i]; + $account_new->smb_domain = $samba3domains[$i]; } } else { - if (isset($_POST['f_smb_domain'])) $_SESSION['account']->smb_domain = $_POST['f_smb_domain']; - else $_SESSION['account']->smb_domain = ''; + if (isset($_POST['f_smb_domain'])) $account_new->smb_domain = $_POST['f_smb_domain']; + else $account_new->smb_domain = ''; } - 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_group: - $_SESSION['account']->smb_mapgroup = $_SESSION['account']->smb_domain->SID . "-". - (2 * getgid($_SESSION['account']->general_group) + $_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_group: + $account_new->smb_mapgroup = $account_new->smb_domain->SID . "-". + (2 * getgid($account_new->general_group) + $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_group: - $_SESSION['account']->smb_mapgroup = (2 * getgid($_SESSION['account']->general_group) + 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_group: + $account_new->smb_mapgroup = (2 * getgid($account_new->general_group) + 1001); break; } @@ -325,113 +357,113 @@ switch ($_POST['select']) { // Select which part of page should be loaded and ch $iv = base64_decode($_COOKIE["IV"]); $key = base64_decode($_COOKIE["Key"]); if (($values->smb_useunixpwd) &&($values->unix_password != '')) { - $smb_password = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($_SESSION['account']->unix_password), MCRYPT_MODE_ECB, $iv); + $smb_password = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($account_new->unix_password), MCRYPT_MODE_ECB, $iv); $smb_password = str_replace(chr(00), '', $smb_password); } // Check values - $_SESSION['account']->smb_scriptPath = str_replace('$user', $_SESSION['account']->general_username, $_SESSION['account']->smb_scriptPath); - $_SESSION['account']->smb_scriptPath = str_replace('$group', $_SESSION['account']->general_group, $_SESSION['account']->smb_scriptPath); - if ($_SESSION['account']->smb_scriptPath != $_POST['f_smb_scriptpath']) $errors[] = array('INFO', _('Script path'), _('Inserted user- or groupname in scriptpath.')); + $account_new->smb_scriptPath = str_replace('$user', $account_new->general_username, $account_new->smb_scriptPath); + $account_new->smb_scriptPath = str_replace('$group', $account_new->general_group, $account_new->smb_scriptPath); + if ($account_new->smb_scriptPath != $_POST['f_smb_scriptpath']) $errors[] = array('INFO', _('Script path'), _('Inserted user- or groupname in scriptpath.')); - $_SESSION['account']->smb_profilePath = str_replace('$user', $_SESSION['account']->general_username, $_SESSION['account']->smb_profilePath); - $_SESSION['account']->smb_profilePath = str_replace('$group', $_SESSION['account']->general_group, $_SESSION['account']->smb_profilePath); - if ($_SESSION['account']->smb_profilePath != stripslashes($_POST['f_smb_profilePath'])) $errors[] = array('INFO', _('Profile path'), _('Inserted user- or groupname in profilepath.')); + $account_new->smb_profilePath = str_replace('$user', $account_new->general_username, $account_new->smb_profilePath); + $account_new->smb_profilePath = str_replace('$group', $account_new->general_group, $account_new->smb_profilePath); + if ($account_new->smb_profilePath != stripslashes($_POST['f_smb_profilePath'])) $errors[] = array('INFO', _('Profile path'), _('Inserted user- or groupname in profilepath.')); - $_SESSION['account']->smb_smbhome = str_replace('$user', $_SESSION['account']->general_username, $_SESSION['account']->smb_smbhome); - $_SESSION['account']->smb_smbhome = str_replace('$group', $_SESSION['account']->general_group, $_SESSION['account']->smb_smbhome); - if ($_SESSION['account']->smb_smbhome != stripslashes($_POST['f_smb_smbhome'])) $errors[] = array('INFO', _('Home path'), _('Inserted user- or groupname in HomePath.')); + $account_new->smb_smbhome = str_replace('$user', $account_new->general_username, $account_new->smb_smbhome); + $account_new->smb_smbhome = str_replace('$group', $account_new->general_group, $account_new->smb_smbhome); + if ($account_new->smb_smbhome != stripslashes($_POST['f_smb_smbhome'])) $errors[] = array('INFO', _('Home path'), _('Inserted user- or groupname in HomePath.')); - if ( (!$_SESSION['account']->smb_smbhome=='') && (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+)+$', $_SESSION['account']->smb_smbhome))) + if ( (!$account_new->smb_smbhome=='') && (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+)+$', $account_new->smb_smbhome))) $errors[] = array('ERROR', _('Home path'), _('Home path is invalid.')); if ( !ereg('^([a-z]|[A-Z]|[0-9]|[\|]|[\#]|[\*]|[\,]|[\.]|[\;]|[\:]|[\_]|[\-]|[\+]|[\!]|[\%]|[\&]|[\/]|[\?]|[\{]|[\[]|[\(]|[\)]|[\]]|[\}])*$', $smb_password)) $errors[] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!$%&/|?{[()]}= !')); - if ( (!$_SESSION['account']->smb_scriptPath=='') && (!ereg('^([/])*([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])*'. - '([/]([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])*)*(([.][b][a][t])|([.][c][m][d]))$', $_SESSION['account']->smb_scriptPath))) + if ( (!$account_new->smb_scriptPath=='') && (!ereg('^([/])*([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])*'. + '([/]([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])*)*(([.][b][a][t])|([.][c][m][d]))$', $account_new->smb_scriptPath))) $errors[] = array('ERROR', _('Script path'), _('Script path is invalid!')); - if ( (!$_SESSION['account']->smb_profilePath=='') && (!ereg('^[/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*([/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*)*$', $_SESSION['account']->smb_profilePath)) - && (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+)+$', $_SESSION['account']->smb_profilePath))) + if ( (!$account_new->smb_profilePath=='') && (!ereg('^[/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*([/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*)*$', $account_new->smb_profilePath)) + && (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+)+$', $account_new->smb_profilePath))) $errors[] = array('ERROR', _('Profile path'), _('Profile path is invalid!')); - if ((!$_SESSION['account']->smb_domain=='') && (!is_object($_SESSION['account']->smb_domain)) && !ereg('^([a-z]|[A-Z]|[0-9]|[-])+$', $_SESSION['account']->smb_domain)) + if ((!$account_new->smb_domain=='') && (!is_object($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 -.')); - if ($_SESSION['account']->smb_useunixpwd) $_SESSION['account']->smb_useunixpwd = 1; else $_SESSION['account']->smb_useunixpwd = 0; + if ($account_new->smb_useunixpwd) $account_new->smb_useunixpwd = 1; else $account_new->smb_useunixpwd = 0; - 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 ($smb_password!='') { // Encrypt password - $_SESSION['account']->smb_password = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $smb_password, + $account_new->smb_password = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $smb_password, MCRYPT_MODE_ECB, $iv)); } 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 'personal': - // Write all general values into $_SESSION['account'] - $_SESSION['account']->personal_title = $_POST['f_personal_title']; - $_SESSION['account']->personal_mail = $_POST['f_personal_mail']; - $_SESSION['account']->personal_telephoneNumber = $_POST['f_personal_telephoneNumber']; - $_SESSION['account']->personal_mobileTelephoneNumber = $_POST['f_personal_mobileTelephoneNumber']; - $_SESSION['account']->personal_facsimileTelephoneNumber = $_POST['f_personal_facsimileTelephoneNumber']; - $_SESSION['account']->personal_street = $_POST['f_personal_street']; - $_SESSION['account']->personal_postalCode = $_POST['f_personal_postalCode']; - $_SESSION['account']->personal_postalAddress = $_POST['f_personal_postalAddress']; - $_SESSION['account']->personal_employeeType = $_POST['f_personal_employeeType']; + // Write all general values into $account_new + $account_new->personal_title = $_POST['f_personal_title']; + $account_new->personal_mail = $_POST['f_personal_mail']; + $account_new->personal_telephoneNumber = $_POST['f_personal_telephoneNumber']; + $account_new->personal_mobileTelephoneNumber = $_POST['f_personal_mobileTelephoneNumber']; + $account_new->personal_facsimileTelephoneNumber = $_POST['f_personal_facsimileTelephoneNumber']; + $account_new->personal_street = $_POST['f_personal_street']; + $account_new->personal_postalCode = $_POST['f_personal_postalCode']; + $account_new->personal_postalAddress = $_POST['f_personal_postalAddress']; + $account_new->personal_employeeType = $_POST['f_personal_employeeType']; // Check if values are OK and set automatic values. if not error-variable will be set - if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/])*$', $_SESSION['account']->personal_telephoneNumber)) $errors[] = array('ERROR', _('Telephone number'), _('Please enter a valid telephone number!')); - if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/])*$', $_SESSION['account']->personal_mobileTelephoneNumber)) $errors[] = array('ERROR', _('Mobile number'), _('Please enter a valid mobile number!')); - if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/])*$', $_SESSION['account']->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']->personal_mail)) $errors[] = array('ERROR', _('eMail address'), _('Please enter a valid eMail address!')); - if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $_SESSION['account']->personal_street)) $errors[] = array('ERROR', _('Street'), _('Please enter a valid street name!')); - if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $_SESSION['account']->personal_postalAddress)) $errors[] = array('ERROR', _('Postal address'), _('Please enter a valid postal address!')); - if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $_SESSION['account']->personal_title)) $errors[] = array('ERROR', _('Title'), _('Please enter a valid title!')); - if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $_SESSION['account']->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!')); + if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/])*$', $account_new->personal_telephoneNumber)) $errors[] = array('ERROR', _('Telephone number'), _('Please enter a valid telephone number!')); + if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/])*$', $account_new->personal_mobileTelephoneNumber)) $errors[] = array('ERROR', _('Mobile number'), _('Please enter a valid mobile number!')); + if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/])*$', $account_new->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]|[-])+)*)*$', $account_new->personal_mail)) $errors[] = array('ERROR', _('eMail address'), _('Please enter a valid eMail address!')); + if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $account_new->personal_street)) $errors[] = array('ERROR', _('Street'), _('Please enter a valid street name!')); + if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $account_new->personal_postalAddress)) $errors[] = array('ERROR', _('Postal address'), _('Please enter a valid postal address!')); + if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $account_new->personal_title)) $errors[] = array('ERROR', _('Title'), _('Please enter a valid title!')); + if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $account_new->personal_employeeType)) $errors[] = array('ERROR', _('Employee type'), _('Please enter a valid employee type!')); + if ( !ereg('^([0-9]|[A-Z]|[a-z])*$', $account_new->personal_postalCode)) $errors[] = array('ERROR', _('Postal code'), _('Please enter a valid postal code!')); 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'] ; // Check which part Site should be displayed next break; case 'finish': // Check if pdf-file should be created if ($_POST['outputpdf']) { // Quota Settings - if (!isset($_SESSION['account']->quota[0])) { // load quotas - $values = getquotas('user', $_SESSION['account_old']->general_username); + if ($config_intern->scriptServer && !isset($account_new->quota[0])) { // load quotas + $values = getquotas('user', $account_old->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; } } - createUserPDF(array($_SESSION['account'])); + createUserPDF(array($account_new)); $select_local = 'pdf'; } break; @@ -476,105 +508,105 @@ 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 = modifyuser($_SESSION['account'],$_SESSION['account_old']); - else $result = createuser($_SESSION['account']); // account.inc + if ($account_old) $result = modifyuser($account_new,$account_old); + else $result = createuser($account_new); // account.inc if ( $result==1 || $result==3 ) $select_local = 'finish'; else $select_local = 'final'; break; } if ($_POST['createagain']) { $select_local='general'; - unset($_SESSION['account']); - $_SESSION['account'] = loadUserProfile('default'); - $_SESSION['account'] ->type = 'user'; + unset($account_new); + $account_new = loadUserProfile('default'); + $account_new ->type = 'user'; break; } if ($_POST['load']) { // load profile - $_SESSION['account']->general_dn = $_POST['f_general_suffix']; - $_SESSION['account']->general_username = $_POST['f_general_username']; - $_SESSION['account']->general_surname = $_POST['f_general_surname']; - $_SESSION['account']->general_givenname = $_POST['f_general_givenname']; - $_SESSION['account']->general_uidNumber = $_POST['f_general_uidNumber']; - $_SESSION['account']->general_group = $_POST['f_general_group']; - if (isset($_POST['f_general_groupadd'])) $_SESSION['account']->general_groupadd = $_POST['f_general_groupadd']; - else $_SESSION['account']->general_groupadd = array(''); - $_SESSION['account']->general_homedir = $_POST['f_general_homedir']; - $_SESSION['account']->general_shell = $_POST['f_general_shell']; - $_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_surname = $_POST['f_general_surname']; + $account_new->general_givenname = $_POST['f_general_givenname']; + $account_new->general_uidNumber = $_POST['f_general_uidNumber']; + $account_new->general_group = $_POST['f_general_group']; + if (isset($_POST['f_general_groupadd'])) $account_new->general_groupadd = $_POST['f_general_groupadd']; + else $account_new->general_groupadd = array(''); + $account_new->general_homedir = $_POST['f_general_homedir']; + $account_new->general_shell = $_POST['f_general_shell']; + $account_new->general_gecos = $_POST['f_general_gecos']; if ($_POST['f_general_selectprofile']!='') $values = loadUserProfile($_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; } // insert autoreplace values - $_SESSION['account']->general_homedir = str_replace('$group', $_SESSION['account']->general_group, $_SESSION['account']->general_homedir); - if ($_SESSION['account']->general_username != '') - $_SESSION['account']->general_homedir = str_replace('$user', $_SESSION['account']->general_username, $_SESSION['account']->general_homedir); - $_SESSION['account']->smb_scriptPath = str_replace('$group', $_SESSION['account']->general_group, $_SESSION['account']->smb_scriptPath); - if ($_SESSION['account']->general_username != '') - $_SESSION['account']->smb_scriptPath = str_replace('$user', $_SESSION['account']->general_username, $_SESSION['account']->smb_scriptPath); + $account_new->general_homedir = str_replace('$group', $account_new->general_group, $account_new->general_homedir); + if ($account_new->general_username != '') + $account_new->general_homedir = str_replace('$user', $account_new->general_username, $account_new->general_homedir); + $account_new->smb_scriptPath = str_replace('$group', $account_new->general_group, $account_new->smb_scriptPath); + if ($account_new->general_username != '') + $account_new->smb_scriptPath = str_replace('$user', $account_new->general_username, $account_new->smb_scriptPath); - $_SESSION['account']->smb_profilePath = str_replace('$group', $_SESSION['account']->general_group, $_SESSION['account']->smb_profilePath); - if ($_SESSION['account']->general_username != '') - $_SESSION['account']->smb_profilePath = str_replace('$user', $_SESSION['account']->general_username, $_SESSION['account']->smb_profilePath); + $account_new->smb_profilePath = str_replace('$group', $account_new->general_group, $account_new->smb_profilePath); + if ($account_new->general_username != '') + $account_new->smb_profilePath = str_replace('$user', $account_new->general_username, $account_new->smb_profilePath); - $_SESSION['account']->smb_smbhome = str_replace('$group', $_SESSION['account']->general_group, $_SESSION['account']->smb_smbhome); - if ($_SESSION['account']->general_username != '') - $_SESSION['account']->smb_smbhome = str_replace('$user', $_SESSION['account']->general_username, $_SESSION['account']->smb_smbhome); + $account_new->smb_smbhome = str_replace('$group', $account_new->general_group, $account_new->smb_smbhome); + if ($account_new->general_username != '') + $account_new->smb_smbhome = str_replace('$user', $account_new->general_username, $account_new->smb_smbhome); - - // load quotas from profile and check if they are valid - $values = getquotas('user', $_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; $jquota); $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('user', $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; $jquota); $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); + $account_old->quota = $values->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; - } - } - $_SESSION['account_old']->quota = $values->quota; - // select general page after group has been loaded $select_local='general'; break; } if ($_POST['save']) { // save profile - saveUserProfile($_SESSION['account'], $_POST['f_finish_safeProfile']); + saveUserProfile($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/listusers.php"); + metaRefresh($lamurl_intern."templates/lists/listusers.php"); die; break; } @@ -584,15 +616,16 @@ do { // X-Or, only one if() can be true if ($select_local != 'pdf') { // Write HTML-Header - echo $_SESSION['header']; + echo $header_intern; echo ""; echo _("Create new Account"); echo "\n". - "\n". + "\n". "\n". "\n". "\n". - "\n"; + "\n". + "\n"; if (is_array($errors)) { echo "\n"; @@ -601,7 +634,7 @@ if ($select_local != 'pdf') { } } -// print_r($_SESSION['account']); +// print_r($account_new); // print_r($_POST); switch ($select_local) { // Select which part of page will be loaded @@ -616,14 +649,13 @@ switch ($select_local) { // Select which part of page will be loaded case 'workstations': ldapreload('host'); - $temp2 = $_SESSION['hostDN']; + $temp2 = $hostDN_intern; unset($temp2[0]); foreach ($temp2 as $temp) $hosts[] = $temp['cn']; sort($hosts, SORT_STRING); // get workstation array - $temp = str_replace(' ', '', $_SESSION['account']->smb_smbuserworkstations); + $temp = str_replace(' ', '', $account_new->smb_smbuserworkstations); $workstations = explode (',', $temp); - echo ''; echo "
\n\n
"; echo "\n"; + echo ""._('Help-XX')."\n"; echo "\n\n
"; @@ -632,12 +664,12 @@ switch ($select_local) { // Select which part of page will be loaded echo "\n
"; echo "\n
"; echo "\n
"; - echo "scriptPath)) echo " disabled "; + echo "scriptPath)) echo " disabled "; echo "value=\""; echo _('Quota'); echo "\">\n
"; echo "\n
"; echo ""; - if (isset($_SESSION['account_old'])) { + if (isset($account_old)) { echo "

"; echo _("Reset all changes."); echo "
"; @@ -662,7 +694,7 @@ switch ($select_local) { // Select which part of page will be loaded echo "
"; echo " "; echo "\">

"; - echo ""._('Help-XX')."
"; echo _('Available workstations'); echo "\n"; @@ -695,12 +727,12 @@ switch ($select_local) { // Select which part of page will be loaded echo "\n
"; echo "\n
"; echo "\n
"; - echo "scriptPath)) echo " disabled "; + echo "scriptPath)) echo " disabled "; echo "value=\""; echo _('Quota'); echo "\">\n
"; echo "\n
"; echo ""; - if (isset($_SESSION['account_old'])) { + if (isset($account_old)) { echo "

"; echo _("Reset all changes."); echo "
"; @@ -714,80 +746,80 @@ switch ($select_local) { // Select which part of page will be loaded echo "\n\n\n\n'."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".'\n\n
"; echo _('Username').'*'; echo "". - ''. + ''. ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('UID number'); echo ''. - ''. + ''. ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Given name').'*'; echo ''. - ''. + ''. ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Surname').'*'; echo ''. - ''. + ''. ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Primary group').'*'; echo ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Additional groups'); echo ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Home directory').'*'; - echo ''. + echo ''. ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Gecos'); - echo ''. + echo ''. ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Login shell').'*'; echo ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Suffix'); echo ''._('Help'). + echo ''._('Help'). "
"; echo _('Values with * are required'); echo "
\n
"; @@ -799,7 +831,7 @@ switch ($select_local) { // Select which part of page will be loaded foreach ($profilelist as $profile) echo " \n"; echo "\n". ""; + echo "\">"; echo _('Help')."
\n\n"; } echo "
\n
\n"; @@ -808,14 +840,14 @@ switch ($select_local) { // Select which part of page will be loaded case 'unix': // Unix Password Settings // decrypt password - if ($_SESSION['account']->unix_password != '') { + if ($account_new->unix_password != '') { $iv = base64_decode($_COOKIE["IV"]); $key = base64_decode($_COOKIE["Key"]); - $password = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($_SESSION['account']->unix_password), MCRYPT_MODE_ECB, $iv); + $password = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($account_new->unix_password), MCRYPT_MODE_ECB, $iv); $password = str_replace(chr(00), '', $password); } else $password=''; - $date = getdate ($_SESSION['account']->unix_pwdexpire); + $date = getdate ($account_new->unix_pwdexpire); echo "\n"; echo "\n
"; echo "'."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".'\n\n
"; @@ -824,12 +856,12 @@ switch ($select_local) { // Select which part of page will be loaded echo "\n
"; echo "\n
"; echo "\n
"; - echo "scriptPath)) echo " disabled "; + echo "scriptPath)) echo " disabled "; echo "value=\""; echo _('Quota'); echo "\">\n
"; echo "\n
"; echo ""; - if (isset($_SESSION['account_old'])) { + if (isset($account_old)) { echo "

"; echo _("Reset all changes."); echo "
"; @@ -847,29 +879,29 @@ switch ($select_local) { // Select which part of page will be loaded echo _('Generate password'); echo '">
'; echo _('Use no password'); echo 'unix_password_no) echo ' checked '; + if ($account_new->unix_password_no) echo ' checked '; echo '>'. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Password warn'); - echo ''. + echo ''. ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Password expire'); - echo ''. + echo ''. ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Maximum password age'); - echo ''. + echo ''. ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Minimum password age'); - echo ''. + echo ''. ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Expire date'); echo ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Account deactivated'); echo 'unix_deactivated) echo ' checked '; + if ($account_new->unix_deactivated) echo ' checked '; echo '>'. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Unix workstations'); - echo ''. + echo ''. ''. - ''._('Help'). + ''._('Help'). "
"; echo _('Values with * are required'); echo "\n
\n\n"; @@ -909,15 +941,15 @@ switch ($select_local) { // Select which part of page will be loaded case 'samba': // Samba Settings // decrypt password - if ($_SESSION['account']->smb_password != '') { + if ($account_new->smb_password != '') { $iv = base64_decode($_COOKIE["IV"]); $key = base64_decode($_COOKIE["Key"]); - $password = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($_SESSION['account']->smb_password), MCRYPT_MODE_ECB, $iv); + $password = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($account_new->smb_password), MCRYPT_MODE_ECB, $iv); $password = str_replace(chr(00), '', $password); } - if ($_SESSION['config']->is_samba3()) $samba3domains = $_SESSION['ldap']->search_domains($_SESSION[config]->get_domainSuffix()); - $canchangedate = getdate($_SESSION['account']->smb_pwdcanchange); - $mustchangedate = getdate($_SESSION['account']->smb_pwdmustchange); + if ($config_intern->is_samba3()) $samba3domains = $ldap_intern->search_domains($config_intern->get_domainSuffix()); + $canchangedate = getdate($account_new->smb_pwdcanchange); + $mustchangedate = getdate($account_new->smb_pwdmustchange); echo ''; echo ''. @@ -933,12 +965,12 @@ switch ($select_local) { // Select which part of page will be loaded echo "\n
"; echo "\n
"; echo "\n
"; - echo "scriptPath)) echo " disabled "; + echo "scriptPath)) echo " disabled "; echo "value=\""; echo _('Quota'); echo "\">\n
"; echo "\n
"; echo ""; - if (isset($_SESSION['account_old'])) { + if (isset($account_old)) { echo "

"; echo _("Reset all changes."); echo "
"; @@ -952,28 +984,28 @@ switch ($select_local) { // Select which part of page will be loaded echo "\n\n\n\n\n\n\n\n\n\n\n\n'."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n"; + echo ''."\n".''."\n"; echo "
"; echo _("Display name"); echo "". - "smb_displayName."\">". - ""._('Help')."
"; + "smb_displayName."\">". + ""._('Help')."
"; echo _('Samba password'); echo ''. '
'; echo _('Use unix password'); echo 'smb_useunixpwd) echo ' checked '; + if ($account_new->smb_useunixpwd) echo ' checked '; echo '>'. - ''._('Help').''; + ''._('Help').''; echo '
'; echo _('Use no password'); echo 'smb_password_no) echo ' checked '; + if ($account_new->smb_password_no) echo ' checked '; echo '>'. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Password does not expire'); echo 'smb_flagsX) echo ' checked '; + if ($account_new->smb_flagsX) echo ' checked '; echo '>'. - ''._('Help').''. + ''._('Help').''. '
'; echo _('User can change password'); echo ''; - echo ''._('Help').''. + echo ''._('Help').''. '
'; echo _('User must change password'); echo ''; - echo ''._('Help').''. + echo ''._('Help').''. '
'; echo _('Account is deactivated'); echo 'smb_flagsD) echo ' checked '; + if ($account_new->smb_flagsD) echo ' checked '; echo '>'. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Home drive'); echo ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Home path'); - echo ''. + echo ''. ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Profile path'); - echo ''. + echo ''. ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Script path'); - echo ''. + echo ''. ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Samba workstations'); echo ''. ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Windows groupname'); echo ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Domain'); - if ($_SESSION['config']->is_samba3()) { + if ($config_intern->is_samba3()) { echo ''; } else { - echo ''; + echo ''; } - echo ''._('Help').'
'._('Help').'
\n\n\n\n"; break; case 'quota': // Quota Settings - if (!isset($_SESSION['account']->quota[0])) { // load quotas - $values = getquotas('user', $_SESSION['account_old']->general_username); + if ($config_intern->scriptServer && !isset($account_new->quota[0])) { // load quotas + $values = getquotas('user', $account_old->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; } } echo "\n"; @@ -1172,7 +1204,7 @@ switch ($select_local) { // Select which part of page will be loaded echo "\n
"; echo ""; - if (isset($_SESSION['account_old'])) { + if (isset($account_old)) { echo "

"; echo _("Reset all changes."); echo "
"; @@ -1186,21 +1218,21 @@ switch ($select_local) { // Select which part of page will be loaded echo _('Soft block limit'); echo ''."\n".''; echo _('Hard block limit'); echo ''."\n".''; echo _('Grace block period'); echo ''."\n".''; echo _('Used inodes'); echo ''."\n".''; echo _('Soft inode limit'); echo ''."\n".''; echo _('Hard inode limit'); echo ''."\n".''; echo _('Grace inode period'); echo ''."\n"; - echo ''._('Help').''."\n".''._('Help').''."\n".''. - ''._('Help').''."\n".''._('Help').''."\n".''. - ''._('Help').''."\n".''._('Help').''."\n".''. - ''._('Help').''."\n".''._('Help').''."\n".''. - ''._('Help').''."\n"; + echo ''._('Help').''."\n".''._('Help').''."\n".''. + ''._('Help').''."\n".''._('Help').''."\n".''. + ''._('Help').''."\n".''._('Help').''."\n".''. + ''._('Help').''."\n".''._('Help').''."\n".''. + ''._('Help').''."\n"; $i=0; - while ($_SESSION['account']->quota[$i][0]) { - echo ''.$_SESSION['account']->quota[$i][0].''.$_SESSION['account']->quota[$i][1].''; // used blocks - echo ''; // blocks soft limit - echo ''; // blocks hard limit - echo ''.$_SESSION['account']->quota[$i][4].''; // block grace period - echo ''.$_SESSION['account']->quota[$i][5].''; // used inodes - echo ''; // inodes soft limit - echo ''; // inodes hard limit - echo ''.$_SESSION['account']->quota[$i][8].''; // inodes grace period + while ($account_new->quota[$i][0]) { + echo ''.$account_new->quota[$i][0].''.$account_new->quota[$i][1].''; // used blocks + echo ''; // blocks soft limit + echo ''; // blocks hard limit + echo ''.$account_new->quota[$i][4].''; // block grace period + echo ''.$account_new->quota[$i][5].''; // used inodes + echo ''; // inodes soft limit + echo ''; // inodes hard limit + echo ''.$account_new->quota[$i][8].''; // inodes grace period $i++; } echo "\n\n\n\n"; @@ -1216,12 +1248,12 @@ switch ($select_local) { // Select which part of page will be loaded echo "\n
"; echo "\n
"; echo "\n
"; - echo "scriptPath)) echo " disabled "; + echo "scriptPath)) echo " disabled "; echo "value=\""; echo _('Quota'); echo "\">\n
"; echo "\n
"; echo ""; - if (isset($_SESSION['account_old'])) { + if (isset($account_old)) { echo "

"; echo _("Reset all changes."); echo "
"; @@ -1233,64 +1265,64 @@ switch ($select_local) { // Select which part of page will be loaded echo "'."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n"; + ''._('Help').''."\n"; echo "
"; echo _('Title'); echo ''. - ' '; - echo $_SESSION['account']->general_surname . ' ' . $_SESSION['account']->general_givenname . ''. - ''._('Help').''. + ' '; + echo $account_new->general_surname . ' ' . $account_new->general_givenname . ''. + ''._('Help').''. '
'; echo _('Employee type'); echo ''. - ''. + ''. ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Street'); echo ''. - ''. + ''. ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Postal code'); echo ''. - ''. + ''. ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Postal address'); echo ''. - ''. + ''. ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Telephone number'); echo ''. - ''. + ''. ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Mobile number'); echo ''. - ''. + ''. ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('Fax number'); echo ''. - ''. + ''. ''. - ''._('Help').''. + ''._('Help').''. '
'; echo _('eMail address'); echo ''. - ''. + ''. ''. - ''._('Help').'
\n\n\n\n"; break; 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"; } } @@ -1302,12 +1334,12 @@ switch ($select_local) { // Select which part of page will be loaded echo "\n
"; echo "\n
"; echo "\n
"; - echo "scriptPath)) echo " disabled "; + echo "scriptPath)) echo " disabled "; echo "value=\""; echo _('Quota'); echo "\">\n
"; echo "\n
"; echo ""; - if (isset($_SESSION['account_old'])) { + if (isset($account_old)) { echo "

"; echo _("Reset all changes."); echo "
"; @@ -1322,29 +1354,29 @@ switch ($select_local) { // Select which part of page will be loaded echo ''; echo "'._('Help'); + echo '">'._('Help'); echo "\n\n\n\n\n\n"; echo "
"; - if ($_SESSION['account_old']) echo _('Modify'); + if ($account_old) echo _('Modify'); else echo _('Create'); echo "\n"; echo ""; - 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 ''; StatusMessage ('INFO', _('UID-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 chown ' . $_SESSION['account']->general_uidNumber . ' {} \;'); + 'find / -gid ' . $account_old->general_uidNumber . ' -exec chown ' . $account_new->general_uidNumber . ' {} \;'); echo ''."\n"; } - if (($_SESSION['account_old']) && ($_SESSION['account']->general_group != $_SESSION['account_old']->general_group)) { + if (($account_old) && ($account_new->general_group != $account_old->general_group)) { echo ''; StatusMessage ('INFO', _('Primary group has changed. You have to run the following command as root in order to change existing file-permissions:'), - 'find / -uid ' . $_SESSION['account']->general_uidNumber . ' -gid ' . getgid($_SESSION['account_old']->general_group) .' -exec chown ' . $_SESSION['account']->general_uidNumber . ':'.getgid($_SESSION['account' ]->general_group). ' {} \;'); + 'find / -uid ' . $account_new->general_uidNumber . ' -gid ' . getgid($account_old->general_group) .' -exec chown ' . $account_new->general_uidNumber . ':'.getgid($account_new->general_group). ' {} \;'); echo ''."\n"; } - if (($_SESSION['account_old']) && ($_SESSION['account']->general_homedir != $_SESSION['account_old']->general_homedir)) { + if (($account_old) && ($account_new->general_homedir != $account_old->general_homedir)) { echo ''; StatusMessage ('INFO', _('Home Directory has changed. You have to run the following command as root in order to change the existing homedirectory:'), - 'mv ' . $_SESSION['account_old' ]->general_homedir . ' ' . $_SESSION['account']->general_homedir); + 'mv ' . $account_old->general_homedir . ' ' . $account_new->general_homedir); echo ''."\n"; } @@ -1356,12 +1388,12 @@ switch ($select_local) { // Select which part of page will be loaded else { $found = false; - if (strstr($_SESSION['account']->smb_scriptPath, '$group')) $found = true; - if (strstr($_SESSION['account']->smb_scriptPath, '$user')) $found = true; - if (strstr($_SESSION['account']->smb_profilePath, '$group')) $found = true; - if (strstr($_SESSION['account']->smb_profilePath, '$user')) $found = true; - if (strstr($_SESSION['account']->smb_smbhome, '$group')) $found = true; - if (strstr($_SESSION['account']->smb_smbhome, '$user')) $found = true; + if (strstr($account_new->smb_scriptPath, '$group')) $found = true; + if (strstr($account_new->smb_scriptPath, '$user')) $found = true; + if (strstr($account_new->smb_profilePath, '$group')) $found = true; + if (strstr($account_new->smb_profilePath, '$user')) $found = true; + if (strstr($account_new->smb_smbhome, '$group')) $found = true; + if (strstr($account_new->smb_smbhome, '$user')) $found = true; if ($found) { // Samba page nit viewd; can not create group because if missing options $disabled = "disabled"; echo ""; @@ -1370,25 +1402,25 @@ switch ($select_local) { // Select which part of page will be loaded } } - 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 ''; StatusMessage('WARN', _('ObjectClass posixAccount not found.'), _('Have to add objectClass posixAccount.')); echo "\n"; } - if (!in_array('shadowAccount', $_SESSION['account_old']->general_objectClass)) { + if (!in_array('shadowAccount', $account_old->general_objectClass)) { echo ''; StatusMessage('WARN', _('ObjectClass shadowAccount.'), _('Have to add objectClass shadowAccount.')); echo "\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 ''; StatusMessage('WARN', _('ObjectClass sambaSamAccount not found.'), _('Have to add objectClass sambaSamAccount. USer with sambaAccount will be updated.')); echo "\n"; }} else - if (!in_array('sambaAccount', $_SESSION['account_old']->general_objectClass)) { + if (!in_array('sambaAccount', $account_old->general_objectClass)) { echo ''; StatusMessage('WARN', _('ObjectClass sambaAccount not found.'), _('Have to add objectClass sambaAccount. User with sambaSamAccount will be set back to sambaAccount.')); echo "\n"; @@ -1399,7 +1431,7 @@ switch ($select_local) { // Select which part of page will be loaded echo "
'."\n"; echo "
\n\n"; @@ -1411,11 +1443,11 @@ switch ($select_local) { // Select which part of page will be loaded echo "'."\n".''."\n".'\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']); + if (isset($_SESSION['account_'.$varkey.'_shelllist'])) unset($_SESSION['account_'.$varkey.'_shelllist']); break; } diff --git a/lam/templates/delete.php b/lam/templates/delete.php index 9ccde034..2a955dc1 100644 --- a/lam/templates/delete.php +++ b/lam/templates/delete.php @@ -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 ''; echo _('Delete Account'); echo ''."\n". - ''."\n". + ''."\n". ''."\n". ''."\n". ''."\n". @@ -72,9 +78,9 @@ if ($_GET['type']) { } echo "
\n"; echo "
"; echo '
'; echo _('User '); - 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 '
'; - if (!$_SESSION['account_old']) + if (!$account_old) { echo ''; } echo ''. ''. @@ -1425,12 +1457,13 @@ switch ($select_local) { // Select which part of page will be loaded break; case 'backmain': // unregister sessionvar and select which list should be shown - echo '
'; + echo '
'; echo _('Please press here if meta-refresh didn\'t work.'); echo "
\n"; - foreach ($_SESSION['delete_dn'] as $dn) echo ''; + foreach ($delete_dn as $dn) echo ''; echo "
'.$dn.'
'.$dn.'
\n"; - if (($_GET['type']== user) && $_SESSION['config']->scriptServer) { + if (($_GET['type']== user) && $config_intern->scriptServer) { echo "
\n"; echo "\n"; echo '
'; @@ -115,50 +121,50 @@ if ($_POST['delete_yes'] && !$_POST['backmain']) { } echo "
\n"; echo ''; - 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;