Fixed pwdcanchange and pwdmustchange

This commit is contained in:
katagia 2003-07-11 13:53:28 +00:00
parent 01a0b4bea0
commit d9cbf3639a
3 changed files with 87 additions and 28 deletions

View File

@ -89,13 +89,15 @@ function initvars($type=false,$DN=false) { // This function registers all needes
@session_start();
if ($type) {
if (session_is_registered("type2")) session_unregister("type2");
else session_register("type2"); // $type2 stores the kind of account (User|Group|Host)
session_register("type2"); // $type2 stores the kind of account (User|Group|Host)
$_SESSION['type2'] = $type;
if (session_is_registered("shelllist")) session_unregister("shelllist");
else session_register("shelllist"); // $shelllist contains all shells defined in /etc/shells
session_register("shelllist"); // $shelllist contains all shells defined in /etc/shells
$_SESSION['shelllist'] = getshells(); // Write List of all valid shells in variable
if (session_is_registered("account")) session_unregister("account");
else session_register("account"); // The new Accout properties are stored here
session_register("account"); // The new Accout properties are stored here
if (session_is_registered("errors")) session_unregister("errors");
session_register("errors"); // $type2 stores the kind of account (User|Group|Host)
if ($DN) {
if (session_is_registered("account_old")) session_unregister("account_old");
else session_register("account_old"); // Only valid if an account should be modified. It'll contains the existing account properties
@ -358,8 +360,6 @@ function checksamba($values, $type) { // This function checks all samba account
if ((!$values->smb_domain=='') && !ereg('^([a-z]|[A-Z]|[0-9]|[-])+$', $values->smb_domain))
$errors[] = array('ERROR', _('Domain Name'), _('Domain Name contents invalid characters. Valid characters are: a-z, A-Z, 0-9 and -.'));
if ($values->smb_useunixpwd) $return->smb_useunixpwd = 1; else $return->smb_useunixpwd = 0;
if ($values->smb_pwdcanchange) $return->smb_pwdcanchange = 1; else $return->smb_pwdcanchange = 0;
if ($values->smb_pwdmustchange) $return->smb_pwdmustchange = 1; else $return->smb_pwdmustchange = 0;
if ($values->smb_password) {
// Encrypt password
$return->smb_password = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $values->smb_password,
@ -373,8 +373,6 @@ function checksamba($values, $type) { // This function checks all samba account
if ((!$values->smb_domain=='') && !ereg('^([a-z]|[A-Z]|[0-9]|[-])+$', $values->smb_domain))
$errors[] = array('ERROR', _('Domain Name'), _('Domain Name contents invalid characters. Valid characters are: a-z, A-Z, 0-9 and -.'));
if ($values->smb_useunixpwd) $return->smb_useunixpwd = 1; else $return->smb_useunixpwd = 0;
if ($values->smb_pwdcanchange) $return->smb_pwdcanchange = 1; else $return->smb_pwdcanchange = 0;
if ($values->smb_pwdmustchange) $return->smb_pwdmustchange = 1; else $return->smb_pwdmustchange = 0;
if ($values->smb_password) {
// Encrypt password
$return->smb_password = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $values->smb_password,

View File

@ -133,14 +133,14 @@ switch ($_POST['select']) { // Select which part of page should be loaded and ch
MCRYPT_MODE_ECB, base64_decode($_COOKIE['IV'])));
}
else $_SESSION['account']->smb_password = "";
$_SESSION['account']->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'],
$_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;
if ($_POST['f_smb_pwdcanchange']) $_SESSION['account']->smb_pwdcanchange = $_POST['f_smb_pwdcanchange'];
else $_SESSION['account']->smb_pwdcanchange = false;
if ($_POST['f_smb_pwdmustchange']) $_SESSION['account']->smb_pwdmustchange = $_POST['f_smb_pwdmustchange'];
else $_SESSION['account']->smb_pwdmustchange = false;
if ($_POST['f_smb_homedrive']) $_SESSION['account']->smb_homedrive = $_POST['f_smb_homedrive'];
if ($_POST['f_smb_scriptpath']) $_SESSION['account']->smb_scriptPath = $_POST['f_smb_scriptpath'];
else $_SESSION['account']->smb_scriptPath = '';
@ -321,7 +321,6 @@ if ($select_local != 'pdf') {
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-15\">";
}
switch ($select_local) {
// backmain = back to lists
// load = load profile
@ -389,6 +388,7 @@ if ($select_local != 'pdf') {
for ($i=0; $i<sizeof($errors); $i++) StatusMessage($errors[$i][0], $errors[$i][1], $errors[$i][2]);
}
//print_r($_SESSION['account']);
//print_r($_POST);
switch ($select_local) { // Select which part of page will be loaded
// general = startpage, general account paramters
@ -714,8 +714,16 @@ switch ($select_local) { // Select which part of page will be loaded
switch ( $_SESSION['type2'] ) {
case 'user':
// Set Account is samba-workstation to false
$canchangedate = getdate($_SESSION['account']->smb_pwdcanchange);
$mustchangedate = getdate($_SESSION['account']->smb_pwdmustchange);
$_SESSION['account']->smb_flagsW = 0;
echo '<tr><td>';
echo '<input name="f_smb_pwdcanchange_h" type="hidden" value="'.$canchangedate['hours'].'">
<input name="f_smb_pwdcanchange_m" type="hidden" value="'.$canchangedate['minutes'].'">
<input name="f_smb_pwdcanchange_s" type="hidden" value="'.$canchangedate['seconds'].'">
<input name="f_smb_pwdmustchange_h" type="hidden" value="'.$mustchangedate['hours'].'">
<input name="f_smb_pwdmustchange_m" type="hidden" value="'.$mustchangedate['minutes'].'">
<input name="f_smb_pwdmustchange_s" type="hidden" value="'.$mustchangedate['seconds'].'">';
echo _('Samba Password');
echo '</td>'."\n".'<td><input name="f_smb_password" type="text" size="20" maxlength="20" value="' . $password . '">
</td>'."\n".'<td><input name="f_smb_useunixpwd" type="checkbox"';
@ -736,16 +744,42 @@ switch ($select_local) { // Select which part of page will be loaded
<a href="help.php?HelpNumber=429" target="lamhelp">'._('Help').'</a>
</td></tr>'."\n".'<tr><td>';
echo _('User can change Password');
echo '</td>'."\n".'<td><input name="f_smb_pwdcanchange" type="checkbox"';
if ($_SESSION['account']->smb_pwdcanchange) echo ' checked ';
echo '></td>'."\n".'<td>
<a href="help.php?HelpNumber=430" target="lamhelp">'._('Help').'</a>
echo '</td>'."\n".'<td><select name="f_smb_pwdcanchange_day">';
for ( $i=1; $i<=31; $i++ ) {
if ($canchangedate['mday']==$i) echo "<option selected> $i". '</option>';
else echo "<option> $i". '</option>';
}
echo '</select><select name="f_smb_pwdcanchange_mon">';
for ( $i=1; $i<=12; $i++ ) {
if ($canchangedate['mon'] == $i) echo "<option selected> $i". '</option>';
else echo "<option> $i". '</option>';
}
echo '</select><select name="f_smb_pwdcanchange_yea">';
for ( $i=2003; $i<=2030; $i++ ) {
if ($canchangedate['year']==$i) echo "<option selected> $i". '</option>';
else echo "<option> $i". '</option>';
}
echo '</select></td>'."\n".'<td>';
echo '<a href="help.php?HelpNumber=430" target="lamhelp">'._('Help').'</a>
</td></tr>'."\n".'<tr><td>';
echo _('User must change Password');
echo '</td>'."\n".'<td><input name="f_smb_pwdmustchange" type="checkbox"';
if ($_SESSION['account']->smb_pwdmustchange) echo ' checked ';
echo '></td>'."\n".'<td>
<a href="help.php?HelpNumber=431" target="lamhelp">'._('Help').'</a>
echo '</td>'."\n".'<td><select name="f_smb_pwdmustchange_day">';
for ( $i=1; $i<=31; $i++ ) {
if ($mustchangedate['mday']==$i) echo "<option selected> $i". '</option>';
else echo "<option> $i". '</option>';
}
echo '</select><select name="f_smb_pwdmustchange_mon">';
for ( $i=1; $i<=12; $i++ ) {
if ($mustchangedate['mon'] == $i) echo "<option selected> $i". '</option>';
else echo "<option> $i". '</option>';
}
echo '</select><select name="f_smb_pwdmustchange_yea">';
for ( $i=2003; $i<=2030; $i++ ) {
if ($mustchangedate['year']==$i) echo "<option selected> $i". '</option>';
else echo "<option> $i". '</option>';
}
echo '</select></td>'."\n".'<td>';
echo '<a href="help.php?HelpNumber=431" target="lamhelp">'._('Help').'</a>
</td></tr>'."\n".'<tr><td>';
echo _('Accout is deactivated');
echo '</td>'."\n".'<td><input name="f_smb_flagsD" type="checkbox"';
@ -838,16 +872,42 @@ switch ($select_local) { // Select which part of page will be loaded
<a href="help.php?HelpNumber=429" target="lamhelp">'._('Help').'</a>
</td></tr>'."\n".'<tr><td>';
echo _('Host can change Password');
echo '</td>'."\n".'<td><input name="f_smb_pwdcanchange" type="checkbox"';
if ($_SESSION['account']->smb_pwdcanchange) echo ' checked ';
echo '></td><td>
<a href="help.php?HelpNumber=458" target="lamhelp">'._('Help').'</a>
echo '</td>'."\n".'<td><select name="f_smb_pwdcanchange_day">';
for ( $i=1; $i<=31; $i++ ) {
if ($canchangedate['mday']==$i) echo "<option selected> $i". '</option>';
else echo "<option> $i". '</option>';
}
echo '</select><select name="f_smb_pwdcanchange_mon">';
for ( $i=1; $i<=12; $i++ ) {
if ($canchangedate['mon'] == $i) echo "<option selected> $i". '</option>';
else echo "<option> $i". '</option>';
}
echo '</select><select name="f_smb_pwdcanchange_yea">';
for ( $i=2003; $i<=2030; $i++ ) {
if ($canchangedate['year']==$i) echo "<option selected> $i". '</option>';
else echo "<option> $i". '</option>';
}
echo '</select></td>'."\n".'<td>';
echo '<a href="help.php?HelpNumber=430" target="lamhelp">'._('Help').'</a>
</td></tr>'."\n".'<tr><td>';
echo _('Host must change Password');
echo '</td>'."\n".'<td><input name="f_smb_pwdmustchange" type="checkbox"';
if ($_SESSION['account']->smb_pwdmustchange) echo ' checked ';
echo '></td><td>
<a href="help.php?HelpNumber=459" target="lamhelp">'._('Help').'</a>
echo '</td>'."\n".'<td><select name="f_smb_pwdmustchange_day">';
for ( $i=1; $i<=31; $i++ ) {
if ($mustchangedate['mday']==$i) echo "<option selected> $i". '</option>';
else echo "<option> $i". '</option>';
}
echo '</select><select name="f_smb_pwdmustchange_mon">';
for ( $i=1; $i<=12; $i++ ) {
if ($mustchangedate['mon'] == $i) echo "<option selected> $i". '</option>';
else echo "<option> $i". '</option>';
}
echo '</select><select name="f_smb_pwdmustchange_yea">';
for ( $i=2003; $i<=2030; $i++ ) {
if ($mustchangedate['year']==$i) echo "<option selected> $i". '</option>';
else echo "<option> $i". '</option>';
}
echo '</select></td>'."\n".'<td>';
echo '<a href="help.php?HelpNumber=431" target="lamhelp">'._('Help').'</a>
</td></tr>'."\n".'<tr><td>';
echo _('Accout is deactivated');
echo '</td>'."\n".'<td><input name="f_smb_flagsD" type="checkbox"';

View File

@ -64,6 +64,7 @@ switch ($select) {
case 'cancel':
if ( session_is_registered("accounts")) session_unregister("accounts");
if ( session_is_registered("pointer")) session_unregister("pointer");
if ( session_is_registered("errors")) session_unregister("errors");
echo '<meta http-equiv="refresh" content="0; URL=lists/listusers.php">';
break;
case 'create':