diff -Naur roundcubemail-0.1-rc1-dep/config/db.inc.php.dist roundcubemail-0.1-rc1-dep-pw1/config/db.inc.php.dist --- roundcubemail-0.1-rc1-dep/config/db.inc.php.dist 2007-05-18 21:11:22.000000000 +0800 +++ roundcubemail-0.1-rc1-dep-pw1/config/db.inc.php.dist 2007-07-05 15:24:44.000000000 +0800 @@ -62,5 +62,14 @@ $rcmail_config['db_sequence_messages'] = 'message_ids'; +// The 'change_pwd_proc' can be 'change_pwd_for_db' or 'change_pwd_for_cpanel' now, +// If 'change_pwd_for_cpanel' is selected, the value of 'db_imap_xxxxxx' is omitted +$rcmail_config['change_pwd_proc'] = 'change_pwd_for_db'; +$rcmail_config['db_imap_dsn'] = 'mysql://dbuser:your_passwd@localhost/mail_db'; +$rcmail_config['db_imap_users_table'] = 'accountuser'; +$rcmail_config['db_imap_user_field'] = 'username'; +$rcmail_config['db_imap_passwd_field'] = 'password'; +$rcmail_config['db_imap_passwd_type'] = ''; // '' (Plaintext), 'PASSWORD', 'MD5CRYPT', or 'ENCRYPT' + // end db config file -?> \ 文件结尾缺少空行 +?> diff -Naur roundcubemail-0.1-rc1-dep/index.php roundcubemail-0.1-rc1-dep-pw1/index.php --- roundcubemail-0.1-rc1-dep/index.php 2007-06-13 15:03:59.000000000 +0800 +++ roundcubemail-0.1-rc1-dep-pw1/index.php 2007-07-05 13:41:29.000000000 +0800 @@ -342,6 +342,9 @@ { include_once('program/steps/settings/func.inc'); + if ($_action=='passwd' || $_action=='save-passwd') + include('program/steps/settings/passwd.inc'); + if ($_action=='save-identity') include('program/steps/settings/save_identity.inc'); diff -Naur roundcubemail-0.1-rc1-dep/program/js/app.js roundcubemail-0.1-rc1-dep-pw1/program/js/app.js --- roundcubemail-0.1-rc1-dep/program/js/app.js 2007-06-13 13:57:44.000000000 +0800 +++ roundcubemail-0.1-rc1-dep-pw1/program/js/app.js 2007-07-05 14:17:01.000000000 +0800 @@ -261,7 +261,22 @@ case 'settings': - this.enable_command('preferences', 'identities', 'save', 'folders', true); + this.enable_command('preferences', 'identities', 'save', 'folders', 'passwd', true); + + if (this.env.action=='passwd' || this.env.action=='save-passwd') + { + var input_curpasswd = rcube_find_object('_curpasswd'); + var input_newpasswd = rcube_find_object('_newpasswd'); + var input_confpasswd = rcube_find_object('_confpasswd'); + if (input_curpasswd && input_curpasswd.value=='') + input_curpasswd.focus(); + else if (input_newpasswd && input_newpasswd.value=='') + input_newpasswd.focus(); + else if (input_confpasswd) + input_confpasswd.focus(); + + this.enable_command('save-passwd', true); + } if (this.env.action=='identities' || this.env.action=='edit-identity' || this.env.action=='add-identity') this.enable_command('edit', 'add', 'delete', true); @@ -900,6 +915,31 @@ this.goto_url(''); break; + case 'passwd': + this.goto_url('passwd'); + break; + + case 'save-passwd': + var input_newpasswd = rcube_find_object('_newpasswd'); + var input_confpasswd = rcube_find_object('_confpasswd'); + if ((input_newpasswd && input_newpasswd.value=='') && (input_confpasswd && input_confpasswd.value=='')) + { + alert(this.get_label('nopassword')); + input_newpasswd.value=''; + input_confpasswd.value=''; + input_newpasswd.focus(); + } + else if ((input_newpasswd && input_confpasswd) && ( input_newpasswd.value != input_confpasswd.value)) + { + alert(this.get_label('passwordinconsistency')); + input_newpasswd.value=''; + input_confpasswd.value=''; + input_newpasswd.focus(); + } + else + this.gui_objects.editform.submit(); + break; + case 'identities': this.goto_url('identities'); break; diff -Naur roundcubemail-0.1-rc1-dep/program/localization/en_US/labels.inc roundcubemail-0.1-rc1-dep-pw1/program/localization/en_US/labels.inc --- roundcubemail-0.1-rc1-dep/program/localization/en_US/labels.inc 2007-04-29 02:07:12.000000000 +0800 +++ roundcubemail-0.1-rc1-dep-pw1/program/localization/en_US/labels.inc 2007-07-05 13:37:42.000000000 +0800 @@ -229,4 +229,9 @@ $labels['sortasc'] = 'Sort ascending'; $labels['sortdesc'] = 'Sort descending'; -?> \ 文件结尾缺少空行 +$labels['changepasswd'] = 'Change Password'; +$labels['curpasswd'] = 'Current Password'; +$labels['newpasswd'] = 'New Password'; +$labels['confpasswd'] = 'Confirm New Password'; + +?> diff -Naur roundcubemail-0.1-rc1-dep/program/localization/en_US/messages.inc roundcubemail-0.1-rc1-dep-pw1/program/localization/en_US/messages.inc --- roundcubemail-0.1-rc1-dep/program/localization/en_US/messages.inc 2007-04-29 02:07:12.000000000 +0800 +++ roundcubemail-0.1-rc1-dep-pw1/program/localization/en_US/messages.inc 2007-07-05 13:38:27.000000000 +0800 @@ -76,4 +76,8 @@ $messages['sourceisreadonly'] = 'This address source is read only'; $messages['errorsavingcontact'] = 'Could not save the contact address'; +$messages['nopassword'] = "Please input new password."; +$messages['passwordincorrectly'] = "Current password incorrectly."; +$messages['passwordinconsistency'] = "Inconsistency of password, please try again."; + ?> diff -Naur roundcubemail-0.1-rc1-dep/program/steps/settings/func.inc roundcubemail-0.1-rc1-dep-pw1/program/steps/settings/func.inc --- roundcubemail-0.1-rc1-dep/program/steps/settings/func.inc 2007-05-18 21:11:22.000000000 +0800 +++ roundcubemail-0.1-rc1-dep-pw1/program/steps/settings/func.inc 2007-07-05 13:58:19.000000000 +0800 @@ -267,9 +267,10 @@ // register UI objects $OUTPUT->add_handlers(array( + 'userpasswd' => 'rcmail_passwd_form', 'userprefs' => 'rcmail_user_prefs_form', 'itentitieslist' => 'rcmail_identities_list' )); -?> \ 文件结尾缺少空行 +?> diff -Naur roundcubemail-0.1-rc1-dep/program/steps/settings/passwd.inc roundcubemail-0.1-rc1-dep-pw1/program/steps/settings/passwd.inc --- roundcubemail-0.1-rc1-dep/program/steps/settings/passwd.inc 1970-01-01 08:00:00.000000000 +0800 +++ roundcubemail-0.1-rc1-dep-pw1/program/steps/settings/passwd.inc 2007-07-06 10:37:33.000000000 +0800 @@ -0,0 +1,179 @@ + | + +-----------------------------------------------------------------------+ + $Id: passwd.inc, v0.5 2007-07-06 10:37:23 roundcube Exp $ +*/ + + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// Special procedure to change password (e.g. cpanel, db, etc.), +// and you can define a new procedure for yourself. + +function change_pwd_for_cpanel($curpasswd, $newpasswd) +{ + global $_SESSION; + + // Define successful respond from cPanel + $success = "Changed password"; + + // Prepare ... + $curuser = $_SESSION['username']; + $authstr = "$curuser:$curpasswd"; + $authstr = base64_encode($authstr); + $request_str = "GET /dowebmailpasswd.cgi?oldpass=$curpasswd&newpass=$newpasswd&B1=" + ."Change+Password HTTP/1.0\r\nAuthorization: Basic $authstr \r\n\r\n"; + + // Send request + $socket = fsockopen("localhost", 2095); + socket_set_timeout($socket, 30); + fputs($socket, $request_str); + $resp = ""; + while (!feof($socket)) { + $resp .= htmlspecialchars(fgets($socket, 128)); + } + fclose( $socket ); + + // Check respond and return. + return (false !== strpos($resp, $success)); +} + +function change_pwd_for_db($curpasswd, $newpasswd) +{ + global $CONFIG, $_SESSION; + + // add md5 crypt, thanks to Diego + $sqlset = "?"; + if('MD5CRYPT' == $CONFIG['db_imap_passwd_type']){ + $newpasswd = crypt($newpasswd); + }else{ + $sqlset = $CONFIG['db_imap_passwd_type'] . "(?)"; + } + + $sqlset = "UPDATE " . $CONFIG['db_imap_users_table'] . " SET " . $CONFIG['db_imap_passwd_field'] . " = " . $sqlset . + " WHERE " . $CONFIG['db_imap_user_field'] . "=? OR (" . $CONFIG['db_imap_user_field'] . "=? AND domain_name = '')"; + + $IMAPDB = new rcube_db($CONFIG['db_imap_dsn'], '', FALSE); + $IMAPDB->db_connect('w'); + $IMAPDB->query($sqlset, $newpasswd, $_SESSION['username'], $_SESSION['username']); + + return ($IMAPDB->affected_rows() && ($IMAPDB->affected_rows() > 0)); +} + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// Generally, you may not change the code below. + +function rcmail_save_passwd($curpasswd, $newpasswd) +{ + global $CONFIG, $_SESSION; + + if (! $CONFIG['change_pwd_proc']){ + return false; + } + $run_change_pwd = $CONFIG['change_pwd_proc']; + + // Dispatch command and get the result. + $is_ok = $run_change_pwd($curpasswd, $newpasswd); + + if ($is_ok) { + $_SESSION['password'] = encrypt_passwd($newpasswd); + } + + return $is_ok; +} + +function rcmail_passwd_form($attrib) +{ + global $CONFIG, $JS_OBJECT_NAME; + + list($form_start, $form_end) = get_form_tags($attrib, 'save-passwd'); + unset($attrib['form']); + + if (!$attrib['id']) + $attrib['id'] = 'rcmSavepassword'; + + // allow the following attributes to be added to the tag + $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary')); + + // return the complete edit form as table + $out = "$form_start\n\n"; + + $a_show_cols = array('curpasswd' => array('type' => 'text'), + 'newpasswd' => array('type' => 'text'), + 'confpasswd' => array('type' => 'text')); + + // show current password selection + $field_id = 'curpasswd'; + $input_newpasswd = new passwordfield(array('name' => '_curpasswd', 'id' => $field_id, 'size' => 30)); + + $out .= sprintf("\n", + $field_id, + rep_specialchars_output(rcube_label('curpasswd')), + $input_newpasswd->show($CONFIG['curpasswd'])); + + // show new password selection + $field_id = 'newpasswd'; + $input_newpasswd = new passwordfield(array('name' => '_newpasswd', 'id' => $field_id, 'size' => 30)); + + $out .= sprintf("\n", + $field_id, + rep_specialchars_output(rcube_label('newpasswd')), + $input_newpasswd->show($CONFIG['newpasswd'])); + + // show confirm password selection + $field_id = 'confpasswd'; + $input_confpasswd = new passwordfield(array('name' => '_confpasswd', 'id' => $field_id, 'size' => 30)); + + $out .= sprintf("\n", + $field_id, + rep_specialchars_output(rcube_label('confpasswd')), + $input_confpasswd->show($CONFIG['confpasswd'])); + + $out .= "\n
%s
%s
%s
$form_end"; + return $out; +} + +// Handle user request +if ($_action=='save-passwd') +{ + global $_SESSION; + + if (! ( isset($_POST['_curpasswd']) and isset($_POST['_newpasswd']))) + $OUTPUT->show_message('nopassword', 'error'); + else { + $curpwd = get_input_value('_curpasswd', RCUBE_INPUT_POST); + $newpwd = get_input_value('_newpasswd', RCUBE_INPUT_POST); + if ($_SESSION['password'] != encrypt_passwd($curpwd)) + $OUTPUT->show_message('passwordincorrectly', 'error'); + else if (rcmail_save_passwd($curpwd, $newpwd)) + $OUTPUT->show_message('successfullysaved', 'confirmation'); + else + $OUTPUT->show_message('errorsaving', 'error'); + } + + // go to next step + rcmail_overwrite_action('passwd'); +} + +// add some labels to client +rcube_add_label('nopassword'); +rcube_add_label('passwordinconsistency'); + +parse_template('passwd'); +?> diff -Naur roundcubemail-0.1-rc1-dep/skins/default/includes/settingstabs.html roundcubemail-0.1-rc1-dep-pw1/skins/default/includes/settingstabs.html --- roundcubemail-0.1-rc1-dep/skins/default/includes/settingstabs.html 2005-09-25 22:18:03.000000000 +0800 +++ roundcubemail-0.1-rc1-dep-pw1/skins/default/includes/settingstabs.html 2007-07-05 13:34:22.000000000 +0800 @@ -1,3 +1,3 @@
- +
diff -Naur roundcubemail-0.1-rc1-dep/skins/default/templates/passwd.html roundcubemail-0.1-rc1-dep-pw1/skins/default/templates/passwd.html --- roundcubemail-0.1-rc1-dep/skins/default/templates/passwd.html 1970-01-01 08:00:00.000000000 +0800 +++ roundcubemail-0.1-rc1-dep-pw1/skins/default/templates/passwd.html 2007-07-05 14:17:25.000000000 +0800 @@ -0,0 +1,27 @@ + + + +<roundcube:object name="pagetitle" /> + + + + + + + + + +
+
+ +
+ + +


+
+
+ + + + +