X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?p=squirrelmail-change-pass-cn.git;a=blobdiff_plain;f=change_pass%2Foptions.php;fp=change_pass%2Foptions.php;h=7649a3cc9c65391b1560585863836a110d923578;hp=9343685beefb8ea80fe9ce886a3762f28c656438;hb=83f37b8fd3d56064545b37748c3c511545eb9000;hpb=63141890938d804f336b8dbdba327f6c5c686738 diff --git a/change_pass/options.php b/change_pass/options.php index 9343685..7649a3c 100644 --- a/change_pass/options.php +++ b/change_pass/options.php @@ -1,183 +1,127 @@ - - - \n"; - echo " -
-
-
-\n"; - } - echo "
\n"; - } -?> -
- - 'cp_oldpass', - _("New Password") => 'cp_newpass', - _("Verify New Password") => 'cp_verify'); - foreach($values as $key=>$value) { -?> - - - - - - -
- -
- name="plugin_change_pass"> -
-
-
- - $strResp"; - } - } +// Make sure the plugin is activated +global $plugins; +if(!in_array('change_pass', $plugins)) { + exit; } -function change_pass_check($debug = 0) { - global $cp_oldpass, $cp_newpass, $cp_verify; - global $plugin_change_pass; - - sqgetGlobalVar('key', $key, SQ_COOKIE); - sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION); - $messages = array(); - $password = OneTimePadDecrypt($key, $onetimepad); +$min_pass_length = 0; +$max_pass_length = 99999999; - if ($cp_oldpass == '') { - $messages[] = _("You must type in your old password."); - } - if ($cp_newpass == '') { - $messages[] = _("You must type in a new password."); - } - if ($cp_verify == '') { - $messages[] = _("You must also type in your new password in the verify box."); - } - if ($cp_newpass != '' && ($cp_verify != $cp_newpass)) { - $messages[] = _("Your new password doesn't match the verify password."); - } - if ($cp_oldpass != '' && ($cp_oldpass != $password)) { - $messages[] = _("Your old password is not correct."); - } - if (count($messages)) { - $return = $messages; - } else { - $return = change_pass_go($password, $debug); - } - return $return; +if (!@include(SM_PATH . 'config/config_change_pass.php')) { + @include(SM_PATH . 'plugins/change_pass/config.php'); } -function change_pass_go($password, $debug) { - include_once(SM_PATH . 'plugins/change_pass/settings.php'); +include_once(SM_PATH . 'plugins/change_pass/functions.php'); - global $username; - global $cp_newpass, $key, $onetimepad; +global $color; +sqgetGlobalVar('change_pass_form', $change_pass_form, SQ_POST); - sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION); - $messages = array(); +$error_messages = array(); +$showform = true; - if ($debug) { - $messages[] = _("Connecting to Password Server"); - } - $pop_socket = fsockopen($poppass_server, $poppass_port, $errno, $errstr); - if (!$pop_socket) { - $messages[] = _("ERROR:") . "$errstr ($errno)"; - return $messages; - } +if (isset($change_pass_form)) { + sq_change_text_domain('change_pass'); + sqgetGlobalVar('change_pass_old', $change_pass_old, SQ_POST); + sqgetGlobalVar('change_pass_new', $change_pass_new, SQ_POST); + sqgetGlobalVar('change_pass_verify', $change_pass_verify, SQ_POST); - change_pass_readfb($pop_socket, $result, $messages, $debug); - if(!preg_match('/^2\d\d/', $result) ) { - change_pass_closeport($pop_socket, $messages, $debug); - return $messages; + if(!isset($change_pass_old) || $change_pass_old == '') { + $error_messages['cp_no_old'] = _("You must type in your current password."); } - fputs($pop_socket, "user $username\r\n"); - change_pass_readfb($pop_socket, $result, $messages, $debug); - if(!preg_match('/^[23]\d\d/', $result) ) { - change_pass_closeport($pop_socket, $messages, $debug); - return $messages; + if(!isset($change_pass_new) || $change_pass_new == '') { + $error_messages['cp_no_new'] = _("You must type in a new password."); } - fputs($pop_socket, "pass $password\r\n"); - change_pass_readfb($pop_socket, $result, $messages, $debug); - if(!preg_match('/^[23]\d\d/', $result) ) { - change_pass_closeport($pop_socket, $messages, $debug); - return $messages; + if(!isset($change_pass_verify) || $change_pass_verify == '') { + $error_messages['cp_no_verify'] = _("You must also type in your new password in the verify box."); } - fputs($pop_socket, "newpass $cp_newpass\r\n"); - change_pass_readfb($pop_socket, $result, $messages, $debug); - change_pass_closeport($pop_socket, $messages, $debug); - if(!preg_match('/^2\d\d/', $result) ) { - return $messages; + if(!isset($error_messages['cp_no_new']) && !isset($error_messages['cp_no_verify'])) { + if($change_pass_new != $change_pass_verify) { + $error_messages['cp_new_mismatch'] = _("Your new password does not match the verify password."); + } else { + if (strlen($change_pass_new) < $min_pass_length || + strlen($change_pass_new) > $max_pass_length) { + $error_messages[] = sprintf(_("Your new password should be %s to %s characters long."), + $min_pass_length, $max_pass_length); + } + } } - $messages[] = _("Password changed successfully."); + $old_pass = sqauth_read_password(); + if(!isset($error_messages['cp_no_old']) && $change_pass_old != $old_pass) { + $error_messages['cp_wrong_old'] = _("Your current password is not correct."); + } - // Write new cookies for the password - $onetimepad = OneTimePadCreate(strlen($cp_newpass)); - $key = OneTimePadEncrypt($cp_newpass, $onetimepad); - sqsession_register($onetimepad, 'onetimepad'); - setcookie('key', $key, 0, $base_uri); + if(count($error_messages) == 0) { + $error_messages = change_pass_dochange($change_pass_old, $change_pass_new, $debug); + if(count($error_messages) == 0) { + $showform = false; + } + } + sq_change_text_domain('squirrelmail'); +} +displayPageHeader($color, ''); +sq_change_text_domain('change_pass'); + +echo + html_tag('table', "\n" . + html_tag('tr', "\n" . + html_tag('td', '' . _("Change Password") . '', 'center', $color[0]) + ), + 'center', $color[9], 'width="95%" border="0" cellpadding="1" cellspacing="0"') . "
\n"; + +if(count($error_messages) > 0) { + echo html_tag('table', '', 'center', '', 'width="100%" border="0" cellpadding="1" cellspacing="0"'); + echo html_tag('tr'); + echo html_tag('td', '', 'center'); + echo html_tag('ul'); + foreach($error_messages as $line) { + echo html_tag('li', htmlspecialchars($line), '', '', 'style="color: ' . $color[2] . '"'); + } + echo html_tag('/ul'); + echo html_tag('tr', html_tag('td', ' ')) . "\n"; + echo html_tag('/table'); +} - return $messages; +if($showform) { + echo addForm($PHP_SELF); + echo + html_tag('table', "\n" . + html_tag('tr', "\n" . + html_tag('td', _("Current Password:"), 'right') . + html_tag('td', addPwField('change_pass_old', ''), 'left') + ) . + html_tag('tr', "\n" . + html_tag('td', _("New Password:"), 'right') . + html_tag('td', addPwField('change_pass_new', ''), 'left') + ) . + html_tag('tr', "\n" . + html_tag('td', _("Verify New Password:"), 'right') . + html_tag('td', addPwField('change_pass_verify', ''), 'left') + ) . + html_tag('tr', "\n" . + html_tag('td', addSubmit(_('Change Password'), 'change_pass_form'), 'center', '', 'colspan="2"') + ), + 'center', '', 'border="0" cellpadding="1" cellspacing="0"') . "\n"; + echo html_tag('/form'); + echo html_tag('/body'); + echo html_tag('/html'); } -?> +sq_change_text_domain('squirrelmail');