Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37504262
en ru br
ALT Linux repos
S:1.6.2-alt3
5.0: 0.1.rc1.1-alt3
4.1: 0.1.rc1.1-alt3

Group :: Networking/Mail
RPM: roundcube

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

Patch: roundcubemail-0.1-rc1-dep-pw1.diff
Download


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 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | program/steps/settings/passwd.inc                                     |
+ |                                                                       |
+ | This file is part of the RoundCube Webmail client                     |
+ | Copyright (C) 2007, RoundCube Dev. - Switzerland                      |
+ | Licensed under the GNU GPL                                            |
+ |                                                                       |
+ | PURPOSE:                                                              |
+ |   Change IMAP user password                                           |
+ |                                                                       |
+ | TESTED:                                                               |
+ | IMAP account store in database(mysql,postgresql)                      |
+ | cPanel [10.9.0-RELEASE_57] (pro)                                      |
+ | cPanel Pro   1.0 (RC36)                                               |
+ +-----------------------------------------------------------------------+
+ | Author: Mo Nianliang <roc.ddk@+++@gmail.+++.com>                      |
+ +-----------------------------------------------------------------------+
+ $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 <table> 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<table" . $attrib_str . ">\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("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\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("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\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("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
+                $field_id,
+                rep_specialchars_output(rcube_label('confpasswd')),
+                $input_confpasswd->show($CONFIG['confpasswd']));
+
+    $out .= "\n</table>$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 @@
 <div id="tabsbar">
-<span id="settingstabdefault" class="tablink"><roundcube:button command="preferences" type="link" label="preferences" title="editpreferences" /></span><span id="settingstabfolders" class="tablink"><roundcube:button command="folders" type="link" label="folders" title="managefolders" class="tablink" /></span><span id="settingstabidentities" class="tablink"><roundcube:button command="identities" type="link" label="identities" title="manageidentities" class="tablink" /></span>
+<span id="settingstabdefault" class="tablink"><roundcube:button command="preferences" type="link" label="preferences" title="editpreferences" /></span><span id="settingstabfolders" class="tablink"><roundcube:button command="folders" type="link" label="folders" title="managefolders" class="tablink" /></span><span id="settingstabidentities" class="tablink"><roundcube:button command="identities" type="link" label="identities" title="manageidentities" class="tablink" /></span><span id="settingstabpasswd" class="tablink"><roundcube:button command="passwd" type="link" label="password" title="changepasswd" class="tablink" /></span>
 </div>
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 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title><roundcube:object name="pagetitle" /></title>
+<roundcube:include file="/includes/links.html" />
+<link rel="stylesheet" type="text/css" href="/settings.css" />
+</head>
+<body>
+
+<roundcube:include file="/includes/taskbar.html" />
+<roundcube:include file="/includes/header.html" />
+<roundcube:include file="/includes/settingstabs.html" />
+
+<div id="userprefs-box">
+<div id="userprefs-title"><roundcube:label name="changepasswd" /></div>
+
+<div style="padding:15px">
+<roundcube:object name="userpasswd">
+
+<p><br /><roundcube:button command="save-passwd" type="input" class="button" label="save" /></p>
+</div>
+</div>
+
+<roundcube:include file="/includes/settingscripts.html" />
+
+</body>
+</html>
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin