From 4994c3786b5954d1283a02aec0e90a03d9f97ee8 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 31 May 2003 23:26:25 +0000 Subject: [PATCH] finished implementation of user profiles --- lam/templates/profedit/profilecreate.php | 236 ++++++++++++++++++++++- lam/templates/profedit/profileuser.php | 70 ++++--- 2 files changed, 282 insertions(+), 24 deletions(-) diff --git a/lam/templates/profedit/profilecreate.php b/lam/templates/profedit/profilecreate.php index 908a9715..ea8e26a2 100644 --- a/lam/templates/profedit/profilecreate.php +++ b/lam/templates/profedit/profilecreate.php @@ -23,4 +23,238 @@ $Id$ */ -?> \ No newline at end of file +include_once("../../lib/status.inc"); +include_once("../../lib/account.inc"); +include_once("../../lib/profiles.inc"); +include_once("../../lib/ldap.inc"); + +// start session +session_save_path("../../sess"); +@session_start(); + +// abort button was pressed in profileuser/~host.php +// back to profile editor +if ($_POST['abort']) { + echo(""); + exit; +} + +// check if user is logged in, if not go to login +if (!$_SESSION['ldap'] || !$_SESSION['ldap']->server()) { + echo("\n"); + exit; +} + +// print header +echo ("\n"); +echo ("\n"); +echo ("\n\n\n
\n"); + +// save user profile +if ($_GET['type'] == "user") { + $acct = new account(); + // check input + if ($_POST['general_group'] && eregi("^[a-z]([a-z0-9_\\-])*$", $_POST['general_group'])) { + $acct->general_group = $_POST['general_group']; + } + else { + StatusMessage("ERROR", "", _("Primary group name is invalid!") . " " . $_POST['general_group']); + echo ("

" . _("Back to profile editor...") . ""); + exit; + } + if ($_POST['general_groupadd']) { + $acct->general_groupadd = $_POST['general_groupadd']; + } + if ($_POST['general_homedir'] && eregi("^[/]([a-z0-9])+([/][a-z0-9_\\-\\$]+)*$", $_POST['general_homedir'])) { + $acct->general_homedir = $_POST['general_homedir']; + } + elseif ($_POST['general_homedir']) { + StatusMessage("ERROR", "", _("Homedir is invalid!") . " " . $_POST['general_homedir']); + echo ("

" . _("Back to profile editor...") . ""); + exit; + } + if ($_POST['general_shell'] && eregi("^[/]([a-z])+([/][a-z]+)*$", $_POST['general_shell'])) { + $acct->general_shell = $_POST['general_shell']; + } + else { + StatusMessage("ERROR", "", _("Shell is invalid!") . " " . $_POST['general_shell']); + echo ("

" . _("Back to profile editor...") . ""); + exit; + } + if (($_POST['unix_password_no'] == "1") || ($_POST['unix_password_no'] == "0")) { + $acct->unix_password_no = $_POST['unix_password_no']; + } + else { + StatusMessage("ERROR", "", _("Wrong parameter for login disable!") . " " . $_POST['unix_password_no']); + echo ("

" . _("Back to profile editor...") . ""); + exit; + } + if ($_POST['unix_pwdwarn'] && is_numeric($_POST['unix_pwdwarn'])) { + $acct->unix_pwdwarn = $_POST['unix_pwdwarn']; + } + elseif ($_POST['unix_pwdwarn']) { + StatusMessage("ERROR", "", _("Wrong parameter for Unix password warning!") . " " . $_POST['unix_pwdwarn']); + echo ("

" . _("Back to profile editor...") . ""); + exit; + } + if ($_POST['unix_pwdminage'] && is_numeric($_POST['unix_pwdminage'])) { + $acct->unix_pwdminage = $_POST['unix_pwdminage']; + } + elseif ($_POST['unix_pwdminage']) { + StatusMessage("ERROR", "", _("Password minimum age is not numeric!") . " " . $_POST['unix_pwdminage']); + echo ("

" . _("Back to profile editor...") . ""); + exit; + } + if ($_POST['unix_pwdmaxage'] && is_numeric($_POST['unix_pwdmaxage'])) { + $acct->unix_pwdmaxage = $_POST['unix_pwdmaxage']; + } + elseif ($_POST['unix_pwdmaxage']) { + StatusMessage("ERROR", "", _("Password maximum age is not numeric!") . " " . $_POST['unix_pwdmaxage']); + echo ("

" . _("Back to profile editor...") . ""); + exit; + } + if ($_POST['unix_pwdexpire_day'] && is_numeric($_POST['unix_pwdexpire_day'])) { + $acct->unix_pwdexpire_day = $_POST['unix_pwdexpire_day']; + } + else { + StatusMessage("ERROR", "", _("Wrong parameter for password expiry day!") . " " . $_POST['unix_pwdexpire_day']); + echo ("

" . _("Back to profile editor...") . ""); + exit; + } + if ($_POST['unix_pwdexpire_mon'] && is_numeric($_POST['unix_pwdexpire_mon'])) { + $acct->unix_pwdexpire_mon = $_POST['unix_pwdexpire_mon']; + } + else { + StatusMessage("ERROR", "", _("Wrong parameter for password expiry month!") . " " . $_POST['unix_pwdexpire_mon']); + echo ("

" . _("Back to profile editor...") . ""); + exit; + } + if ($_POST['unix_pwdexpire_yea'] && is_numeric($_POST['unix_pwdexpire_yea'])) { + $acct->unix_pwdexpire_yea = $_POST['unix_pwdexpire_yea']; + } + else { + StatusMessage("ERROR", "", _("Wrong parameter for password expiry year!") . " " . $_POST['unix_pwdexpire_yea']); + echo ("

" . _("Back to profile editor...") . ""); + exit; + } + if (($_POST['unix_deactivated'] == "1") || ($_POST['unix_deactivated'] == "0")) { + $acct->unix_deactivated = $_POST['unix_deactivated']; + } + else { + StatusMessage("ERROR", "", _("Wrong parameter for Unix account activation!") . " " . $_POST['unix_deactivated']); + echo ("

" . _("Back to profile editor...") . ""); + exit; + } + if ($_POST['unix_pwdallowlogin'] && is_numeric($_POST['unix_pwdallowlogin'])) { + $acct->unix_pwdallowlogin = $_POST['unix_pwdallowlogin']; + } + elseif ($_POST['unix_pwdallowlogin']) { + StatusMessage("ERROR", "", _("Password expiry is not numeric!") . " " . $_POST['unix_pwdallowlogin']); + echo ("

" . _("Back to profile editor...") . ""); + exit; + } + if (($_POST['smb_password_no'] == "1") || ($_POST['smb_password_no'] == "0")) { + $acct->smb_password_no = $_POST['smb_password_no']; + } + else { + StatusMessage("ERROR", "", _("Wrong parameter for Samba option: no password!") . " " . $_POST['smb_password_no']); + echo ("

" . _("Back to profile editor...") . ""); + exit; + } + if (($_POST['smb_useunixpwd'] == "1") || ($_POST['smb_useunixpwd'] == "0")) { + $acct->smb_useunixpwd = $_POST['smb_useunixpwd']; + } + else { + StatusMessage("ERROR", "", _("Wrong parameter for Samba option: use Unix password!") . " " . $_POST['smb_useunixpwd']); + echo ("

" . _("Back to profile editor...") . ""); + exit; + } + if (($_POST['smb_pwdcanchange'] == "1") || ($_POST['smb_pwdcanchange'] == "0")) { + $acct->smb_pwdcanchange = $_POST['smb_pwdcanchange']; + } + else { + StatusMessage("ERROR", "", _("Wrong parameter for Samba option: user can change password!") . " " . $_POST['smb_pwdcanchange']); + echo ("

" . _("Back to profile editor...") . ""); + exit; + } + if (($_POST['smb_pwdmustchange'] == "1") || ($_POST['smb_pwdmustchange'] == "0")) { + $acct->smb_pwdmustchange = $_POST['smb_pwdmustchange']; + } + else { + StatusMessage("ERROR", "", _("Wrong parameter for Samba option: user must change password!") . " " . $_POST['smb_pwdmustchange']); + echo ("

" . _("Back to profile editor...") . ""); + exit; + } + if ($_POST['smb_homedrive'] && ereg("^[D-Z]:$", $_POST['smb_homedrive'])) { + $acct->smb_homedrive = $_POST['smb_homedrive']; + } + else { + StatusMessage("ERROR", "", _("Wrong parameter for Samba option: home drive!") . " " . $_POST['smb_homedrive']); + echo ("

" . _("Back to profile editor...") . ""); + exit; + } + if ($_POST['smb_smbhome'] && eregi("^[/]([a-z0-9])+([/][a-z0-9_\\-\\$]+)*$", $_POST['smb_smbhome'])) { + $acct->smb_smbhome = $_POST['smb_smbhome']; + } + elseif ($_POST['smb_smbhome']) { + StatusMessage("ERROR", "", _("Samba home directory is invalid!") . " " . $_POST['smb_smbhome']); + echo ("

" . _("Back to profile editor...") . ""); + exit; + } + if ($_POST['smb_profilepath'] && eregi("^[/]([a-z0-9])+([/][a-z0-9_\\-\\$]+)*$", $_POST['smb_profilepath'])) { + $acct->smb_profilePath = $_POST['smb_profilepath']; + } + elseif ($_POST['smb_profilepath']) { + StatusMessage("ERROR", "", _("Profile path is invalid!") . " " . $_POST['smb_profilepath']); + echo ("

" . _("Back to profile editor...") . ""); + exit; + } + if ($_POST['smb_scriptpath'] && eregi("^[/]([a-z0-9])+([/][a-z0-9_\\-\\$]+)*$", $_POST['smb_scriptpath'])) { + $acct->smb_scriptpath = $_POST['smb_scriptpath']; + } + elseif ($_POST['smb_scriptpath']) { + StatusMessage("ERROR", "", _("Script path is invalid!") . " " . $_POST['smb_scriptpath']); + echo ("

" . _("Back to profile editor...") . ""); + exit; + } + if ($_POST['smb_smbuserworkstations'] && eregi("^[a-z0-9\\.\\-_]+( [a-z0-9\\.\\-_]+)*$", $_POST['smb_smbuserworkstations'])) { + $acct->smb_smbuserworkstations = $_POST['smb_smbuserworkstations']; + } + elseif ($_POST['smb_smbuserworkstations']) { + StatusMessage("ERROR", "", _("Samba workstations are invalid!") . " " . $_POST['smb_smbuserworkstations']); + echo ("

" . _("Back to profile editor...") . ""); + exit; + } + if ($_POST['smb_domain'] && eregi("^[a-z0-9_\\-]+$", $_POST['smb_domain'])) { + $acct->smb_domain = $_POST['smb_domain']; + } + elseif ($_POST['smb_domain']) { + StatusMessage("ERROR", "", _("Domain name is invalid!") . " " . $_POST['smb_domain']); + echo ("

" . _("Back to profile editor...") . ""); + exit; + } + if ($_POST['profname'] && eregi("^[0-9a-z\\-_]+$", $_POST['profname'])) { + $profname = $_POST['profname']; + } + else { + StatusMessage("ERROR", "", _("Invalid profile name!")); + echo ("

" . _("Back to profile editor...") . ""); + exit; + } + // save profile + saveUserProfile($acct, $profname); + echo ("

" . _("Profile ") . $profname . _(" was saved.") . "

"); + echo ("

" . _("Back to profile editor") . "

"); +} + +// save host profile +elseif ($_GET['type'] == "host") { + +} + +// error: no or wrong type +else echo (StatusMessage("ERROR", "", _("No type specified!"))); + +echo ("\n"); + +?> diff --git a/lam/templates/profedit/profileuser.php b/lam/templates/profedit/profileuser.php index 3496be45..830f9677 100644 --- a/lam/templates/profedit/profileuser.php +++ b/lam/templates/profedit/profileuser.php @@ -44,6 +44,15 @@ echo ("\n\n\n"); +echo ("
\n"); // Unix part @@ -75,9 +84,10 @@ echo ("\n"); // additional groups echo ("\n"); echo ("" . _("Additional groups") . ": \n"); -echo ("\n"); for ($i = 0; $i < sizeof($groups); $i++) { - if ($acct->general_group == $groups[$i]) echo ("\n"); + echo "
hallo"; + if (in_array($groups[$i], $acct->general_groupadd)) echo ("\n"); else echo ("\n"); } echo ("\n"); @@ -97,7 +107,12 @@ echo ("\n"); // login shell echo ("\n"); echo ("" . _("Login Shell") . ": \n"); -echo ("general_shell . "\" name=\"general_shell\">\n"); +echo ("\n"); echo ("" . _("Help") . "\n"); echo ("\n"); @@ -108,31 +123,38 @@ echo ("   \n"); echo ("\n"); echo ("" . _("Set Unix Password") . ": \n"); echo ("\n"); echo ("" . _("Help") . "\n"); echo ("\n"); +// Unix: password expiry warn +echo ("\n"); +echo ("" . _("Password warning") . ": \n"); +echo ("unix_pwdwarn . "\">\n"); +echo ("" . _("Help") . "\n"); +echo ("\n"); + // Unix: password expiry echo ("\n"); echo ("" . _("Password expiry") . ": \n"); echo ("unix_pwdallowlogin . "\">\n"); -echo ("" . _("Help") . "\n"); +echo ("" . _("Help") . "\n"); echo ("\n"); // maximum password age echo ("\n"); echo ("" . _("Maximum password age") . ": \n"); echo ("unix_pwdmaxage . "\">\n"); -echo ("" . _("Help") . "\n"); +echo ("" . _("Help") . "\n"); echo ("\n"); // minimum password age echo ("\n"); echo ("" . _("Minimum password age") . ": \n"); echo ("unix_pwdminage . "\">\n"); -echo ("" . _("Help") . "\n"); +echo ("" . _("Help") . "\n"); echo ("\n"); // password expire date @@ -157,7 +179,7 @@ for ( $i=2003; $i<=2030; $i++ ) { else echo "\n"; } echo (""); -echo ("" . _("Help") . "\n"); +echo ("" . _("Help") . "\n"); echo ("\n"); // empty row @@ -167,10 +189,10 @@ echo ("   \n"); echo ("\n"); echo ("" . _("Account is deactivated") . ": \n"); echo ("\n"); -echo ("" . _("Help") . "\n"); +echo ("" . _("Help") . "\n"); echo ("\n"); @@ -188,8 +210,8 @@ echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); @@ -198,8 +220,8 @@ echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); @@ -208,8 +230,8 @@ echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); @@ -218,8 +240,8 @@ echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); @@ -268,14 +290,14 @@ echo ("\n"); // path to profile echo ("\n"); echo ("\n"); -echo ("\n"); +echo ("\n"); echo ("\n"); echo ("\n"); // path to logon scripts echo ("\n"); echo ("\n"); -echo ("\n"); +echo ("\n"); echo ("\n"); echo ("\n"); @@ -310,6 +332,7 @@ echo ("
" . _("Set Samba Password") . ": " . _("Help") . "
" . _("Set Unix Password for Samba") . ": " . _("Help") . "
" . _("User can change password") . ": " . _("Help") . "
" . _("User must change password") . ": " . _("Help") . "
" . _("Profile path") . ": profilepath . "\" name=\"smb_profilepath\">smb_profilePath . "\" name=\"smb_profilepath\">" . _("Help") . "
" . _("Script path") . ": scriptpath . "\" name=\"smb_scriptpath\">smb_scriptpath . "\" name=\"smb_scriptpath\">" . _("Help") . "
\n"); echo ("\n"); echo ("\n"); echo ("\n"); +echo ("\n"); echo ("\n"); echo ("\n"); echo (""); @@ -318,6 +341,7 @@ echo ("\n"); echo ("\n"); echo ("\n"); +echo (""); echo ("\n"); echo ("
" . _("Profile Name") . ":" . _("Help") . "
 
\n"); echo (" 
\n");