4 * Licensed under the GNU GPL. For full terms see the file COPYING.
6 * $Id: options.php,v 1.8 2009/12/09 00:21:11 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 if(!sqgetGlobalVar('smtoken', $submitted_token, SQ_POST)) {
17 $submitted_token = '';
20 // Make sure the plugin is activated
22 if(!in_array('change_pass', $plugins)) {
27 $max_pass_length = 99999999;
29 if (!@include(SM_PATH . 'config/config_change_pass.php')) {
30 @include(SM_PATH . 'plugins/change_pass/config.php');
33 include_once(SM_PATH . 'plugins/change_pass/functions.php');
36 sqgetGlobalVar('change_pass_form', $change_pass_form, SQ_POST);
38 $error_messages = array();
41 if (isset($change_pass_form)) {
42 sm_validate_security_token($submitted_token, 3600, TRUE);
43 sq_change_text_domain('change_pass');
44 sqgetGlobalVar('change_pass_old', $change_pass_old, SQ_POST);
45 sqgetGlobalVar('change_pass_new', $change_pass_new, SQ_POST);
46 sqgetGlobalVar('change_pass_verify', $change_pass_verify, SQ_POST);
48 if(!isset($change_pass_old) || $change_pass_old == '') {
49 $error_messages['cp_no_old'] = _("You must type in your current password.");
52 if(!isset($change_pass_new) || $change_pass_new == '') {
53 $error_messages['cp_no_new'] = _("You must type in a new password.");
56 if(!isset($change_pass_verify) || $change_pass_verify == '') {
57 $error_messages['cp_no_verify'] = _("You must also type in your new password in the verify box.");
60 if(!isset($error_messages['cp_no_new']) && !isset($error_messages['cp_no_verify'])) {
61 if($change_pass_new != $change_pass_verify) {
62 $error_messages['cp_new_mismatch'] = _("Your new password does not match the verify password.");
64 if (strlen($change_pass_new) < $min_pass_length ||
65 strlen($change_pass_new) > $max_pass_length) {
66 $error_messages[] = sprintf(_("Your new password should be %s to %s characters long."),
67 $min_pass_length, $max_pass_length);
72 $old_pass = sqauth_read_password();
73 if(!isset($error_messages['cp_no_old']) && $change_pass_old != $old_pass) {
74 $error_messages['cp_wrong_old'] = _("Your current password is not correct.");
77 if(count($error_messages) == 0) {
78 $error_messages = change_pass_dochange($change_pass_old, $change_pass_new, $debug);
79 if(count($error_messages) == 0) {
83 sq_change_text_domain('squirrelmail');
85 displayPageHeader($color, '');
86 sq_change_text_domain('change_pass');
89 html_tag('table', "\n" .
91 html_tag('td', '<b>' . _("Change Password") . '</b>', 'center', $color[0])
93 'center', $color[9], 'width="95%" border="0" cellpadding="1" cellspacing="0"') . "<br>\n";
95 if(count($error_messages) > 0) {
96 echo html_tag('table', '', 'center', '', 'width="100%" border="0" cellpadding="1" cellspacing="0"');
98 echo html_tag('td', '', 'center');
100 foreach($error_messages as $line) {
101 echo html_tag('li', htmlspecialchars($line), '', '', 'style="color: ' . $color[2] . '"');
103 echo html_tag('/ul');
104 echo html_tag('tr', html_tag('td', ' ')) . "\n";
105 echo html_tag('/table');
109 echo addForm(sqm_baseuri() . 'plugins/change_pass/options.php');
110 echo addHidden('smtoken', sm_generate_security_token());
112 html_tag('table', "\n" .
113 html_tag('tr', "\n" .
114 html_tag('td', _("Current Password:"), 'right') .
115 html_tag('td', addPwField('change_pass_old', ''), 'left')
117 html_tag('tr', "\n" .
118 html_tag('td', _("New Password:"), 'right') .
119 html_tag('td', addPwField('change_pass_new', ''), 'left')
121 html_tag('tr', "\n" .
122 html_tag('td', _("Verify New Password:"), 'right') .
123 html_tag('td', addPwField('change_pass_verify', ''), 'left')
125 html_tag('tr', "\n" .
126 html_tag('td', addSubmit(_('Change Password'), 'change_pass_form'), 'center', '', 'colspan="2"')
128 'center', '', 'border="0" cellpadding="1" cellspacing="0"') . "\n";
129 echo html_tag('/form');
130 echo html_tag('/body');
131 echo html_tag('/html');
133 sq_change_text_domain('squirrelmail');