From dca6d7def9327e54ecd46ea9aadc95b96562a727 Mon Sep 17 00:00:00 2001 From: katagia Date: Thu, 5 Jun 2003 11:36:54 +0000 Subject: [PATCH] Quota did't work Profile weren't saved Started to make code HTML-compliant --- lam/config/profiles/users/samba.pru | 2 +- lam/lib/account.inc | 26 ++++- lam/templates/account.php | 166 ++++++++++++++-------------- lam/templates/delete.php | 10 +- lam/templates/masscreate.php | 24 ++-- 5 files changed, 130 insertions(+), 98 deletions(-) diff --git a/lam/config/profiles/users/samba.pru b/lam/config/profiles/users/samba.pru index 2b07d625..fca1a9ab 100644 --- a/lam/config/profiles/users/samba.pru +++ b/lam/config/profiles/users/samba.pru @@ -1,5 +1,5 @@ general_group: staff -general_homedir: /home/$user +general_homedir: /home2/$user general_shell: /bin/bash unix_pwdwarn: 10 unix_pwdallowlogin: 10 diff --git a/lam/lib/account.inc b/lam/lib/account.inc index 8c657329..833a72de 100644 --- a/lam/lib/account.inc +++ b/lam/lib/account.inc @@ -117,7 +117,6 @@ function initvars($type=false,$DN=false) { // This function registers all needes } else { if (session_is_registered("account_old")) session_unregister("account_old"); - if ( (($type=='user')||($type=='group')) && ($_SESSION['config']->scriptServer)) $_SESSION['account'] = getquotas($type); switch ($type) { case 'user': $_SESSION['account'] = loadUserProfile('default'); @@ -129,6 +128,13 @@ function initvars($type=false,$DN=false) { // This function registers all needes $_SESSION['account'] = loadHostProfile('default'); break; } + if ( (($type=='user')||($type=='group')) && ($_SESSION['config']->scriptServer)) { + $values = getquotas($type); + if (is_object($values)) { + while (list($key, $val) = each($values)) // Set only defined values + if ($val) $_SESSION['account']->$key = $val; + } + } } } } @@ -594,6 +600,13 @@ function loaduser($dn) { // Will load all needed values from an existing account if (substr(str_replace('{CRYPT}', '',$attr['userPassword'][0]),0,1) == '!' ) $return->unix_deactivated=true; if ($attr['userPassword'][0]) $return->unix_password = $attr['userPassword'][0]; if ($attr['ntPassword'][0]) $return->smb_password = $attr['ntPassword'][0]; + if ($_SESSION['config']->scriptServer) { + $values = getquotas('user',$return->general_username); + if (is_object($values)) { + while (list($key, $val) = each($values)) // Set only defined values + if ($val) $return->$key = $val; + } + } return $return; } @@ -667,6 +680,13 @@ function loadgroup($dn) { // Will load all needed values from an existing group if ($attr['memberUid']) $return->general_memberUid = $attr['memberUid']; if (is_array($return->general_memberUid)) array_shift($return->general_memberUid); $return->general_dn = $dn; + if ($_SESSION['config']->scriptServer) { + $values = getquotas('group',$return->general_username); + if (is_object($values)) { + while (list($key, $val) = each($values)) // Set only defined values + if ($val) $return->$key = $val; + } + } return $return; } @@ -777,7 +797,7 @@ function modifyuser($values,$values_old) { // Will modify the LDAP-Account // Value stored in shadowExpire, days since 1.1.1970 $date = mktime(10,0,0, $values->unix_pwdexpire_mon, $values->unix_pwdexpire_day, $values->unix_pwdexpire_yea) / 86400 ; settype($date, 'integer'); - $values->general_dn = 'uid=' . $values->general_username . ',' . $values->get_UserSuffix(); + $values->general_dn = 'uid=' . $values->general_username . ',' . $_SESSION['config']->get_UserSuffix(); if ($values->general_username != $values_old->general_username) { $attr['cn'] = $values->general_username; // posixAccount_req shadowAccount_req sambaAccount_may $attr['uid'] = $values->general_username; // posixAccount_req @@ -876,7 +896,7 @@ function modifyuser($values,$values_old) { // Will modify the LDAP-Account if ($values->smb_pwdcanchange==0 && $values_old->smb_pwdcanchange==1) $attr_rem['pwdCanChange'] = "1"; else $attr['pwdCanChange'] = "0"; // sambaAccount_may if ($values->smb_pwdmustchange && $values->smb_pwdmustchange==0) $attr['pwdMustChange'] = "1"; else $attr['pwdMustChange'] = "0"; // sambaAccount_may if ($values->smb_pwdmustchange==0 && $values->smb_pwdmustchange==1) $attr_rem['pwdMustChange'] = "1"; else $attr['pwdMustChange'] = "0"; // sambaAccount_may - $attr['acctFlags'] = smbflag(); // sambaAccount_may + $attr['acctFlags'] = smbflag($values); // sambaAccount_may if (($values->smb_smbhome!='') && ($values->smb_smbhome!=$values_old->smb_smbhome)) $attr['smbHome'] = $values->smb_smbhome; // sambaAccount_may if (($values->smb_smbhome=='') && ($values->smb_smbhome!=$values_old->smb_smbhome)) $attr_rem['smbHome'] = $values_old->smb_smbhome; // sambaAccount_may if (($values->smb_homedrive!='') && ($values->smb_homedrive!=$values_old->smb_homedrive)) $attr['homeDrive'] = $values->smb_homedrive; // sambaAccount_may diff --git a/lam/templates/account.php b/lam/templates/account.php index 9052b597..5b11a0bb 100644 --- a/lam/templates/account.php +++ b/lam/templates/account.php @@ -245,20 +245,6 @@ if ( $_POST['create'] ) { // Create-Button was pressed } -// Write HTML-Header and part of Table -echo ''; -echo _('Create new Account'); -echo ' - - - - -
'; - if ($error != "0") StatusMessage('ERROR', _('Invalid Value!'), $error); - echo ' - '; - - if (!$select_local) $select_local='general'; if ($_POST['createagain']) { $select_local='general'; @@ -272,13 +258,78 @@ if ($_POST['load']) $select_local='load'; if ($_POST['save']) $select_local='save'; +// Write HTML-Header and part of Table +echo ''; +echo ''; +echo _('Create new Account'); +echo ' + + + + '; + +switch ($select_local) { + case 'backmain': + if (session_is_registered("shelllist")) session_unregister("shelllist"); + if (session_is_registered("account")) session_unregister("account"); + if (session_is_registered("account_old")) session_unregister("account_old"); + switch ( $_SESSION['type2'] ) { + case 'user' : + if (session_is_registered("type2")) session_unregister("type2"); + echo ''; + break; + case 'group' : + if (session_is_registered("type2")) session_unregister("type2"); + echo ''; + break; + case 'host' : + if (session_is_registered("type2")) session_unregister("type2"); + echo ''; + break; + } + break; + case 'load': + switch ( $_SESSION['type2'] ) { + case 'user': + $_SESSION['account'] = loadUserProfile($_POST['f_general_selectprofile']); + break; + case 'host': + $_SESSION['account'] = loadHostProfile($_POST['f_general_selectprofile']); + break; + case 'group': + $_SESSION['account'] = loadGroupProfile($_POST['f_general_selectprofile']); + break; + } + $select_local='general'; + break; + case 'save': + switch ( $_SESSION['type2'] ) { + case 'user': + saveUserProfile($_SESSION['account'], $_POST['f_finish_safeProfile']); + break; + case 'host': + saveHostProfile($_SESSION['account'], $_POST['f_finish_safeProfile']); + break; + case 'group': + saveGroupProfile($_SESSION['account'], $_POST['f_finish_safeProfile']); + break; + } + $select_local='final'; + break; + } + + echo ' + '; + if ($error != "0") StatusMessage('ERROR', _('Invalid Value!'), $error); + echo ''; + + switch ($select_local) { case 'general': // General Account Settings $groups = findgroups(); - echo ' - - '; switch ( $_SESSION['type2'] ) { @@ -309,7 +360,7 @@ switch ($select_local) { if ($_SESSION['account']->general_group == $group) echo ''; + echo ''; switch ( $_SESSION['type2'] ) { case 'user' : echo ''; + echo ''; switch ( $_SESSION['type2'] ) { case 'user': echo ''; @@ -786,12 +835,10 @@ switch ($select_local) { echo ''; switch ( $_SESSION['type2'] ) { @@ -848,52 +894,8 @@ switch ($select_local) { break; } break; - case 'backmain': - if (session_is_registered("shelllist")) session_unregister("shelllist"); - if (session_is_registered("account")) session_unregister("account"); - if (session_is_registered("account_old")) session_unregister("account_old"); - switch ( $_SESSION['type2'] ) { - case 'user' : - if (session_is_registered("type2")) session_unregister("type2"); - echo ''; - break; - case 'group' : - if (session_is_registered("type2")) session_unregister("type2"); - echo ''; - break; - case 'host' : - if (session_is_registered("type2")) session_unregister("type2"); - echo ''; - break; - } - break; - case 'load': - switch ( $_SESSION['type2'] ) { - case 'user': - $_SESSION['account'] = loadUserProfile($_POST['f_general_selectprofile']); - break; - case 'host': - $_SESSION['account'] = loadHostProfile($_POST['f_general_selectprofile']); - break; - case 'group': - $_SESSION['account'] = loadGroupProfile($_POST['f_general_selectprofile']); - break; - } - echo ''; - break; - case 'save': - switch ( $_SESSION['type2'] ) { - case 'user': - saveUserProfile($_SESSION['account'], $f_finish_safeProfile); - break; - case 'host': - saveHostProfile($_SESSION['account'], $f_finish_safeProfile); - break; - } - echo ''; - break; } // Print end of HTML-Page -echo ''; +echo ''; ?> diff --git a/lam/templates/delete.php b/lam/templates/delete.php index 25b44d7e..f5872058 100644 --- a/lam/templates/delete.php +++ b/lam/templates/delete.php @@ -28,14 +28,16 @@ include_once('../lib/config.inc'); session_save_path('../sess'); @session_start(); - +echo ''; echo ''; echo _('Delete Account'); echo ' - + +
@@ -58,7 +60,7 @@ if ($_GET['type']) { } echo ''; foreach ($DN2 as $dn) echo ''; - echo '
'.$dn.'
+ echo '

'; echo ''; echo _('Create new Accounts'); echo ' - + '; + +switch ($select) { + case 'cancel': + if ( session_is_registered("accounts")) session_unregister("accounts"); + echo ''; + break; + } + +echo ' '; echo ''; @@ -58,8 +69,7 @@ switch ($select) { if ( session_is_registered("accounts")) session_unregister("accounts"); session_register("accounts"); $profilelist = getUserProfiles(); - echo ''; - echo '
'; + echo '
'; echo _('Mass Creation'); echo '
'; echo _('Please provide a csv-file with the following syntax. Values with * are required:'); @@ -112,6 +122,7 @@ switch ($select) { if (is_object($values)) { while (list($key, $val) = each($values)) // Set only defined values if ($val) $_SESSION['accounts'][$row]->$key = $val; + $_SESSION['accounts'][$row]->general_uidNumber=""; } else $error = $values; if (!$error) { @@ -170,10 +181,6 @@ switch ($select) { echo ''; echo ''; break; - case 'cancel': - if ( session_is_registered("accounts")) session_unregister("accounts"); - echo ''; - break; case 'create': $row=0; $stay=true; @@ -185,6 +192,7 @@ switch ($select) { $group->general_gecos=$_SESSION['accounts'][$row]->general_group; creategroup($group); } + $_SESSION['accounts'][$row]->general_uidNumber = checkid($_SESSION['accounts'][$row], 'user'); $error = createuser($_SESSION['accounts'][$row]); if ($error==1) $row++; else { @@ -204,5 +212,5 @@ switch ($select) { } -echo ''; +echo '
'; ?>