4 * Licensed under the GNU GPL. For full terms see the file COPYING.
6 * $Id: options.php,v 1.7 2009/05/05 03:09:22 indiri69 Exp $
9 define('SM_PATH', '../../');
10 require_once(SM_PATH . 'include/validate.php');
11 require_once(SM_PATH . 'functions/html.php');
12 require_once(SM_PATH . 'functions/forms.php');
16 // Make sure the plugin is activated
18 if(!in_array('change_pass', $plugins)) {
23 $max_pass_length = 99999999;
25 if (!@include(SM_PATH . 'config/config_change_pass.php')) {
26 @include(SM_PATH . 'plugins/change_pass/config.php');
29 include_once(SM_PATH . 'plugins/change_pass/functions.php');
32 sqgetGlobalVar('change_pass_form', $change_pass_form, SQ_POST);
34 $error_messages = array();
37 if (isset($change_pass_form)) {
38 sq_change_text_domain('change_pass');
39 sqgetGlobalVar('change_pass_old', $change_pass_old, SQ_POST);
40 sqgetGlobalVar('change_pass_new', $change_pass_new, SQ_POST);
41 sqgetGlobalVar('change_pass_verify', $change_pass_verify, SQ_POST);
43 if(!isset($change_pass_old) || $change_pass_old == '') {
44 $error_messages['cp_no_old'] = _("You must type in your current password.");
47 if(!isset($change_pass_new) || $change_pass_new == '') {
48 $error_messages['cp_no_new'] = _("You must type in a new password.");
51 if(!isset($change_pass_verify) || $change_pass_verify == '') {
52 $error_messages['cp_no_verify'] = _("You must also type in your new password in the verify box.");
55 if(!isset($error_messages['cp_no_new']) && !isset($error_messages['cp_no_verify'])) {
56 if($change_pass_new != $change_pass_verify) {
57 $error_messages['cp_new_mismatch'] = _("Your new password does not match the verify password.");
59 if (strlen($change_pass_new) < $min_pass_length ||
60 strlen($change_pass_new) > $max_pass_length) {
61 $error_messages[] = sprintf(_("Your new password should be %s to %s characters long."),
62 $min_pass_length, $max_pass_length);
67 $old_pass = sqauth_read_password();
68 if(!isset($error_messages['cp_no_old']) && $change_pass_old != $old_pass) {
69 $error_messages['cp_wrong_old'] = _("Your current password is not correct.");
72 if(count($error_messages) == 0) {
73 $error_messages = change_pass_dochange($change_pass_old, $change_pass_new, $debug);
74 if(count($error_messages) == 0) {
78 sq_change_text_domain('squirrelmail');
80 displayPageHeader($color, '');
81 sq_change_text_domain('change_pass');
84 html_tag('table', "\n" .
86 html_tag('td', '<b>' . _("Change Password") . '</b>', 'center', $color[0])
88 'center', $color[9], 'width="95%" border="0" cellpadding="1" cellspacing="0"') . "<br>\n";
90 if(count($error_messages) > 0) {
91 echo html_tag('table', '', 'center', '', 'width="100%" border="0" cellpadding="1" cellspacing="0"');
93 echo html_tag('td', '', 'center');
95 foreach($error_messages as $line) {
96 echo html_tag('li', htmlspecialchars($line), '', '', 'style="color: ' . $color[2] . '"');
99 echo html_tag('tr', html_tag('td', ' ')) . "\n";
100 echo html_tag('/table');
104 echo addForm($PHP_SELF);
106 html_tag('table', "\n" .
107 html_tag('tr', "\n" .
108 html_tag('td', _("Current Password:"), 'right') .
109 html_tag('td', addPwField('change_pass_old', ''), 'left')
111 html_tag('tr', "\n" .
112 html_tag('td', _("New Password:"), 'right') .
113 html_tag('td', addPwField('change_pass_new', ''), 'left')
115 html_tag('tr', "\n" .
116 html_tag('td', _("Verify New Password:"), 'right') .
117 html_tag('td', addPwField('change_pass_verify', ''), 'left')
119 html_tag('tr', "\n" .
120 html_tag('td', addSubmit(_('Change Password'), 'change_pass_form'), 'center', '', 'colspan="2"')
122 'center', '', 'border="0" cellpadding="1" cellspacing="0"') . "\n";
123 echo html_tag('/form');
124 echo html_tag('/body');
125 echo html_tag('/html');
127 sq_change_text_domain('squirrelmail');