Author Topic: RoundCube Webmail 0.1-beta changepassword patch  (Read 14770 times)

Offline igeoffi

  • Jr. Member
  • **
  • Posts: 27
RoundCube Webmail 0.1-beta changepassword patch
« on: June 27, 2006, 01:59:00 AM »
REPOST
originally posted by poison

this patch/plugin will allow you to change your password

please note: i did not make/create this hack therefore i am not offering any support for this hack or any gurantee that this hack will work for you

Quote
When I was deploying the new corporate mailserver I needed to re-install the webmail client. We used to work with SquirrelMail (http://www.squirrelmail.org/), a very decent and extendable webmail client. But we all know that the UI of SquirrelMail is ugly, really ugly.

So after some googling I came across this new great webmail client named RoundCube (http://www.roundcube.net/). This is a new fully featured AJAX-based webmail client with a very slick UI. From the first moment I saw that RoundCube was the way to go.

After I did the installation and played around with the webclient I wanted to extend it and give the ability to my users to change their password. The basic idea was to add a tab ‘Password’ in the settings window. Since I’ve configured my mailserver (postfix) with mysql (user fields are created dynamically) it’s just a matter of updating the correct row in the database and reconnect to the IMAP server (courier-imap).
The only problem is that the framework of RoundCube is creap, and I mean really crap. It took me 6 hours to create the tab and the underlaying forms / code. Not because I work that slow but because it’s not intuitive and you have to mess in 5 files in order to add a new action (Ok, I only worked at night on it so my mind wasn’t that clear but anyway).
Below I’ve attached the patch, so if some of you want to make your own tab you can read through the patch and see how it works.

It uses an external script (ext/change_password_function.inc) with one function in it: change_password_function ($user, $currentpass, $newpass).
In my case, it just updates the postfix mailbox database but you can modify this code to fit your needs (eg. if you use the courierpassd you can connect to the password-daemon and change the user’s password here).
Enjoy it,
Nicolas

download: click here

Source: http://www.poison.be/?p=8

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,533
    • http://SKaero.com/
Re: RoundCube Webmail 0.1-beta changepassword patch
« Reply #1 on: June 27, 2006, 02:17:24 AM »
Thanks For posting this, It will be a good tool!

Offline Hunteru

  • Newbie
  • *
  • Posts: 1
I made a few changes in the original file to work with vpopmail (mysql).

Code: [Select]
<?php

/*
 +-----------------------------------------------------------------------+
 | program/steps/settings/change_password.inc              |
 |                                    |
 | This file is part of the RoundCube Webmail client           |
 | Copyright (C) 2005, RoundCube Dev. - Switzerland           |
 | Licensed under the GNU GPL                      |
 |                                    |
 | PURPOSE:                               |
 |  Show edit form for a identity record or to add a new one      |
 |                                    |
 +-----------------------------------------------------------------------+
 | Author: Nicolas Van Eenaeme <nicolas@poison.be>            |
 +-----------------------------------------------------------------------+

 $Id: edit_identity.inc,v 1.1 2006/05/21 05:19:43 roundcube Exp $

*/

 // The host of the database
 
define ('RCUBE_EXT_CHANGE_PASS_HOST''localhost');

 
// The username to connect to the database
 
define ('RCUBE_EXT_CHANGE_PASS_USER''user');

 
// The password to connect to the database
 
define ('RCUBE_EXT_CHANGE_PASS_PASS''password');

 
// The name of the database
 
define ('RCUBE_EXT_CHANGE_PASS_NAME''vpopmail');

 
// The update query. You can use '%clear%' for the clear password,
 //                '%md5%'  for the md5 encrypted password,
 //                '%user%'  for the username,
 //                '%old%'  for the old password and
 //                '%oldmd5%' for the old md5 encrypted password.
 
define ('RCUBE_EXT_CHANGE_PASS_UPDATEQUERY''UPDATE vpopmail SET pw_clear_passwd = &quot;%clear%&quot;, pw_passwd = &quot;%md5%&quot; WHERE pw_name = &quot;%user%&quot; AND pw_passwd = &quot;%oldmd5%&quot; AND pw_domain = &quot;%domain%&quot;');

 
// The select query (needed to verify the md5.
 
define ('RCUBE_EXT_CHANGE_PASS_SELECTQUERY''SELECT pw_passwd FROM vpopmail WHERE pw_name = &quot;%user%&quot; AND pw_domain = &quot;%domain%&quot;');

 function 
split_user ($user)
  {
   list(
$s_user$s_domain) = split('[@]'$user);
   return array(
$s_user,$s_domain);
  }

 function 
change_password_function ($s_user$currentpass$newpass)
  {
list ($user$domain) = split_user ($s_user);

  
$dbh =& mysql_connect (RCUBE_EXT_CHANGE_PASS_HOSTRCUBE_EXT_CHANGE_PASS_USERRCUBE_EXT_CHANGE_PASS_PASS);
  if (!
is_resource ($dbh))
   return 
FALSE;

  if (!
mysql_select_db (RCUBE_EXT_CHANGE_PASS_NAME$dbh))
   return 
FALSE;

  
$q str_replace (array ('%user%''%domain%'), array ($user$domain), RCUBE_EXT_CHANGE_PASS_SELECTQUERY);
 
  
$dbr =& mysql_query ($q$dbh);
  if (!
is_resource ($dbr))
   return 
FALSE;

  
$data mysql_fetch_row ($dbr);
  
mysql_free_result ($dbr);

  
$newpassmd5 crypt ($newpass$data[0]);
  
$currentpassmd5 crypt ($currentpass$data[0]);
  
$q str_replace (array ('%user%''%domain%''%clear%''%md5%''%old%''%oldmd5%'), array ($user$domain$newpass$newpassmd5$currentpass$currentpassmd5), RCUBE_EXT_CHANGE_PASS_UPDATEQUERY);

  
$dbr =& mysql_query ($q$dbh);
  if (!
$dbr || mysql_affected_rows ($dbh) != 1)
    return 
FALSE;

  
mysql_close ($dbh);
  return 
TRUE;
  }

?>


Thx for the original tool. 8)

Offline chadsmith

  • Newbie
  • *
  • Posts: 1
Re: RoundCube Webmail 0.1-beta changepassword patch
« Reply #3 on: July 30, 2006, 02:37:21 AM »
Here are the changes if you are using Roundcube with hMailServer...

Code: [Select]
<?php

/*
 +-----------------------------------------------------------------------+
 | program/steps/settings/change_password.inc              |
 |                                    |
 | This file is part of the RoundCube Webmail client           |
 | Copyright (C) 2005, RoundCube Dev. - Switzerland           |
 | Licensed under the GNU GPL                      |
 |                                    |
 | PURPOSE:                               |
 |  Show edit form for a identity record or to add a new one      |
 |                                    |
 +-----------------------------------------------------------------------+
 | Author: Nicolas Van Eenaeme <nicolas@poison.be>            |
 +-----------------------------------------------------------------------+

 $Id: edit_identity.inc,v 1.1 2006/05/21 05:19:43 roundcube Exp $

*/

 // The host of the database
 
define ('RCUBE_EXT_CHANGE_PASS_HOST''localhost');

 
// The username to connect to the database
 
define ('RCUBE_EXT_CHANGE_PASS_USER''user');

 
// The password to connect to the database
 
define ('RCUBE_EXT_CHANGE_PASS_PASS''password');

 
// The name of the database
 
define ('RCUBE_EXT_CHANGE_PASS_NAME''database');

 
// The update query. You can use '%clear%' for the clear password,
 //                '%md5%'  for the md5 encrypted password,
 //                '%user%'  for the username,
 //                '%old%'  for the old password and
 //                '%oldmd5%' for the old md5 encrypted password.
 
define ('RCUBE_EXT_CHANGE_PASS_UPDATEQUERY''UPDATE hm_accounts SET accountpassword = &quot;%md5%&quot; WHERE accountaddress = &quot;%user%&quot; AND accountpassword = &quot;%oldmd5%&quot;');

 
// The select query (needed to verify the md5.
 
define ('RCUBE_EXT_CHANGE_PASS_SELECTQUERY''SELECT accountpassword FROM hm_accounts WHERE accountaddress = &quot;%user%&quot;');


 function 
change_password_function ($user$currentpass$newpass)
  {
  
$dbh =& mysql_connect (RCUBE_EXT_CHANGE_PASS_HOSTRCUBE_EXT_CHANGE_PASS_USERRCUBE_EXT_CHANGE_PASS_PASS);
  if (!
is_resource ($dbh))
   return 
FALSE;

  if (!
mysql_select_db (RCUBE_EXT_CHANGE_PASS_NAME$dbh))
   return 
FALSE;

  
$q str_replace ('%user%'$userRCUBE_EXT_CHANGE_PASS_SELECTQUERY);
  
$dbr =& mysql_query ($q$dbh);
  if (!
is_resource ($dbr))
   return 
FALSE;

  
$data mysql_fetch_row ($dbr);
  
mysql_free_result ($dbr);

  
$newpassmd5 md5($newpass);
  
$currentpassmd5 md5($currentpass);
  
$q str_replace (array ('%user%''%clear%''%md5%''%old%''%oldmd5%'), array ($user$newpass$newpassmd5$currentpass$currentpassmd5), RCUBE_EXT_CHANGE_PASS_UPDATEQUERY);

  
$dbr =& mysql_query ($q$dbh);
  if (!
$dbr || mysql_affected_rows ($dbh) != 1)
    return 
FALSE;

  
mysql_close ($dbh);
  return 
TRUE;
  }

?>

Offline Rick

  • Newbie
  • *
  • Posts: 2
Re: RoundCube Webmail 0.1-beta changepassword patch
« Reply #4 on: August 14, 2006, 12:40:51 AM »
I can use one of these Password patches if my server uses Qmail? I use a Virtual Server provided by a hosting company and can access the backend via Plesk configurations. The server comes with Horde (ugly interface) to handle "webmail functions." I am using RoundCube for my site members, but have to refer them to Horde to be able make a password change on their own. Can one of these patched noted here allow my members to change their email through RoundCube.  If the change is made via RoundCube/MySQL, does it change it everywhere like Horde does or just on MySQL? Sorry, if I should know this. I would love to just forget Horde, but it is the only option I have at the moment to let members change their own PWs.

Any advice or suggestions will be greatly apprecaited.  -- Rick

Offline 123123

  • Jr. Member
  • **
  • Posts: 13
Re: RoundCube Webmail 0.1-beta changepassword patch
« Reply #5 on: August 14, 2006, 11:40:57 AM »
can someone tell how to install the patch ;/

when i press download i get this :

Quote
diff -ruN roundcubemail-0.1beta.orig/ext/change_password_function.inc roundcubemail-0.1beta/ext/change_password_function.inc
--- roundcubemail-0.1beta.orig/ext/change_password_function.inc   1970-01-01 01:00:00.000000000 +0100
+++ roundcubemail-0.1beta/ext/change_password_function.inc   2006-05-21 05:19:43.000000000 +0200
@@ -0,0 +1,74 @@
++
+/*
+ +-----------------------------------------------------------------------+
+ | program/steps/settings/change_password.inc              |
+ |                                    |
+ | This file is part of the RoundCube Webmail client           |
+ | Copyright (C) 2005, RoundCube Dev. - Switzerland           |
+ | Licensed under the GNU GPL                      |
+ |                                    |
+ | PURPOSE:                               |
+ |  Show edit form for a identity record or to add a new one      |
+ |                                    |
+ +-----------------------------------------------------------------------+
+ | Author: Nicolas Van Eenaeme            |
+ +-----------------------------------------------------------------------+
+
+ $Id: edit_identity.inc,v 1.1 2006/05/21 05:19:43 roundcube Exp $
+
+*/
+
+ // The host of the database
+ define ('RCUBE_EXT_CHANGE_PASS_HOST', 'localhost');
+
+ // The username to connect to the database
+ define ('RCUBE_EXT_CHANGE_PASS_USER', 'postfix');
+
+ // The password to connect to the database
+ define ('RCUBE_EXT_CHANGE_PASS_PASS', 'password');
+
+ // The name of the database
+ define ('RCUBE_EXT_CHANGE_PASS_NAME', 'postfix');
+
+ // The update query. You can use '%clear%' for the clear password,
+ //                '%md5%'  for the md5 encrypted password,
+ //                '%user%'  for the username,
+ //                '%old%'  for the old password and
+ //                '%oldmd5%' for the old md5 encrypted password.
+ define ('RCUBE_EXT_CHANGE_PASS_UPDATEQUERY', 'UPDATE mailbox SET password = "%md5%" WHERE username = "%user%" AND password = "%oldmd5%"');
+
+ // The select query (needed to verify the md5.
+ define ('RCUBE_EXT_CHANGE_PASS_SELECTQUERY', 'SELECT password FROM mailbox WHERE username = "%user%"');
+
+
+ function change_password_function ($user, $currentpass, $newpass)
+  {
+  $dbh =& mysql_connect (RCUBE_EXT_CHANGE_PASS_HOST, RCUBE_EXT_CHANGE_PASS_USER, RCUBE_EXT_CHANGE_PASS_PASS);
+  if (!is_resource ($dbh))
+   return FALSE;
+
+  if (!mysql_select_db (RCUBE_EXT_CHANGE_PASS_NAME, $dbh))
+   return FALSE;
+
+  $q = str_replace ('%user%', $user, RCUBE_EXT_CHANGE_PASS_SELECTQUERY);
+  $dbr =& mysql_query ($q, $dbh);
+  if (!is_resource ($dbr))
+   return FALSE;
+
+  $data = mysql_fetch_row ($dbr);
+  mysql_free_result ($dbr);
+
+  $newpassmd5 = crypt ($newpass, $data[0]);
+  $currentpassmd5 = crypt ($currentpass, $data[0]);
+  $q = str_replace (array ('%user%', '%clear%', '%md5%', '%old%', '%oldmd5%'), array ($user, $newpass, $newpassmd5, $currentpass, $currentpassmd5), RCUBE_EXT_CHANGE_PASS_UPDATEQUERY);
+
+  $dbr =& mysql_query ($q, $dbh);
+  if (!$dbr || mysql_affected_rows ($dbh) != 1)
+    return FALSE;
+
+  mysql_close ($dbh);
+  return TRUE;
+  }
+
+?>
diff -ruN roundcubemail-0.1beta.orig/index.php roundcubemail-0.1beta/index.php
--- roundcubemail-0.1beta.orig/index.php   2006-02-21 00:29:13.000000000 +0100
+++ roundcubemail-0.1beta/index.php   2006-05-21 03:46:20.000000000 +0200
@@ -330,6 +330,8 @@
  if ($_action=='folders' || $_action=='subscribe' || $_action=='unsubscribe' || $_action=='create-folder' || $_action=='delete-folder')
   include('program/steps/settings/manage_folders.inc');
 
+ if ($_action=='password' || $_action=='change-password')
+  include('program/steps/settings/change_password.inc');
  }
 
 
--- roundcubemail-0.1beta.orig/program/include/main.inc   2006-02-21 00:29:13.000000000 +0100
+++ roundcubemail-0.1beta/program/include/main.inc   2006-05-20 02:04:38.000000000 +0200
@@ -1072,7 +1072,8 @@
     'identityform' => 'rcube_identity_form',
     'foldersubscription' => 'rcube_subscription_form',
     'createfolder' => 'rcube_create_folder_form',
-    'composebody' => 'rcmail_compose_body'
+    'composebody' => 'rcmail_compose_body',
+    'changepassform' => 'rcmail_change_pass_form'
    );
 
   
diff -ruN roundcubemail-0.1beta.orig/program/js/app.js roundcubemail-0.1beta/program/js/app.js
--- roundcubemail-0.1beta.orig/program/js/app.js   2006-02-19 21:21:58.000000000 +0100
+++ roundcubemail-0.1beta/program/js/app.js   2006-05-21 15:37:23.000000000 +0200
@@ -194,7 +194,7 @@
 
 
    case 'settings':
-    this.enable_command('preferences', 'identities', 'save', 'folders', true);
+    this.enable_command('preferences', 'identities', 'save', 'folders', 'password', true);
     
     if (this.env.action=='identities' || this.env.action=='edit-identity' || this.env.action=='add-identity')
      this.enable_command('edit', 'add', 'delete', true);
@@ -205,6 +205,9 @@
     if (this.env.action=='folders')
      this.enable_command('subscribe', 'unsubscribe', 'create-folder', 'delete-folder', true);
     
+    if (this.env.action=='password')
+     this.enable_command('change-password', true);
+    
     var identities_list = this.gui_objects.identitieslist;
     if (identities_list)
      this.init_identitieslist(identities_list);
@@ -946,6 +949,41 @@
      this.delete_folder(props);
     break;
 
+   case 'password':
+    location.href = this.env.comm_path+'&_action=password';
+    break;
+
+   case 'change-password':
+    if (this.gui_objects.editform)
+     {
+     var input_currentpass = rcube_find_object('_currentpass');
+     var input_newpass = rcube_find_object('_newpass');
+     var input_confirmpass = rcube_find_object('_confirmpass');
+
+     if (input_currentpass.value == "")
+      {
+      alert(this.get_label('nocurrentpasswarning'));
+      input_currentpass.focus();
+      break;
+      }
+
+     if (input_newpass.value == "")
+      {
+      alert(this.get_label('nonewpasswarning'));
+      input_newpass.focus();
+      break;
+      }
+
+     if (input_newpass.value != input_confirmpass.value)
+      {
+      alert(this.get_label('nomatchpasswarning'));
+      input_confirmpass.focus();
+      break;
+      }
+
+     this.gui_objects.editform.submit();
+     }
+    break;
    }
 
   return obj ? false : true;
diff -ruN roundcubemail-0.1beta.orig/program/localization/en_US/labels.inc roundcubemail-0.1beta/program/localization/en_US/labels.inc
--- roundcubemail-0.1beta.orig/program/localization/en_US/labels.inc   2006-02-04 19:05:36.000000000 +0100
+++ roundcubemail-0.1beta/program/localization/en_US/labels.inc   2006-05-21 03:53:49.000000000 +0200
@@ -179,6 +179,12 @@
 $labels['newitem'] = 'New item';
 $labels['edititem'] = 'Edit item';
 
+$labels['changepassword'] = 'Change your password';
+
+$labels['currentpass'] = 'Current password';
+$labels['newpass'] = 'New password';
+$labels['confirmpass'] = 'Confirm new password';
+
 $labels['setdefault'] = 'Set default';
 $labels['language'] = 'Language';
 $labels['timezone'] = 'Time zone';
diff -ruN roundcubemail-0.1beta.orig/program/localization/en_US/messages.inc roundcubemail-0.1beta/program/localization/en_US/messages.inc
--- roundcubemail-0.1beta.orig/program/localization/en_US/messages.inc   2006-01-25 21:10:12.000000000 +0100
+++ roundcubemail-0.1beta/program/localization/en_US/messages.inc   2006-05-21 14:46:15.000000000 +0200
@@ -88,4 +88,12 @@
 
 $messages['nosearchname'] = 'Please enter a contact name or email address';
 
+$messages['nocurrentpasswarning'] = 'Please enter your current password';
+
+$messages['nonewpasswarning'] = 'Please enter your new password';
+
+$messages['nomatchpasswarning'] = 'The new password and it\'s confirmation doesn\'t match';
+
+$messages['invalidpassword'] = 'Your current password is invalid';
+
 ?>
diff -ruN roundcubemail-0.1beta.orig/program/steps/settings/change_password.inc roundcubemail-0.1beta/program/steps/settings/change_password.inc
--- roundcubemail-0.1beta.orig/program/steps/settings/change_password.inc   1970-01-01 01:00:00.000000000 +0100
+++ roundcubemail-0.1beta/program/steps/settings/change_password.inc   2006-05-21 14:46:33.000000000 +0200
@@ -0,0 +1,103 @@
++
+/*
+ +-----------------------------------------------------------------------+
+ | program/steps/settings/change_password.inc              |
+ |                                    |
+ | This file is part of the RoundCube Webmail client           |
+ | Copyright (C) 2005, RoundCube Dev. - Switzerland           |
+ | Licensed under the GNU GPL                      |
+ |                                    |
+ | PURPOSE:                               |
+ |  Change the current password into a new one             |
+ |                                    |
+ +-----------------------------------------------------------------------+
+ | Author: Nicolas Van Eenaeme            |
+ +-----------------------------------------------------------------------+
+
+ $Id: edit_identity.inc,v 1.1 2006/05/21 14:46:33 roundcube Exp $
+
+*/
+
+// init IAMP connection
+rcmail_imap_init(TRUE);
+
+if ($_POST['_action'] == 'change-password')
+ {
+ include ('ext/change_password_function.inc');
+ if ($_SESSION['password'] != encrypt_passwd($_POST['_currentpass']))
+  {
+  show_message('invalidpassword', 'error');
+  }
+ elseif (false || change_password_function ($_SESSION['username'], $_POST['_currentpass'], $_POST['_newpass']))
+  {
+  $IMAP->pass = $_POST['_newpass'];
+  $IMAP->reconnect ();
+  $_SESSION['password'] = encrypt_passwd($_POST['_newpass']);
+
+  show_message('successfullysaved', 'confirmation');
+  }
+ else
+  show_message('errorsaving', 'error');
+
+  // go to next step
+  $_action = 'password';
+
+  // overwrite action variable
+  $OUTPUT->add_script(sprintf("\n%s.set_env('action', '%s');", $JS_OBJECT_NAME, $_action));
+  }
+
+ $PAGE_TITLE = rcube_label('changepassword');
+
+
+function rcmail_change_pass_form($attrib)
+ {
+ global $IDENTITY_RECORD, $JS_OBJECT_NAME;
+
+ // add some labels to client
+ rcube_add_label('nocurrentpasswarning');
+ rcube_add_label('nonewpasswarning');
+ rcube_add_label('nomatchpasswarning');
+
+ list($form_start, $form_end) = get_form_tags($attrib, 'change-password');
+ unset($attrib['form']);
+
+
+ // return the complete edit form as table
+ $out = "$form_start\n\n";
+
+ // show the current password field
+ $field_id = 'rcmfd_currentpass';
+ $input_currentpass = new passwordfield(array('name' => '_currentpass', 'id' => $field_id, 'size' => 20));
+
+ $out .= sprintf("\n",
+         $field_id,
+         rep_specialchars_output(rcube_label('currentpass')),
+         $input_currentpass->show());
+
+ // show the new password field
+ $field_id = 'rcmfd_newpass';
+ $input_newpass = new passwordfield(array('name' => '_newpass', 'id' => $field_id, 'size' => 20));
+
+ $out .= sprintf("\n",
+         $field_id,
+         rep_specialchars_output(rcube_label('newpass')),
+         $input_newpass->show());
+
+ // show the confirm password field
+ $field_id = 'rcmfd_confirmpass';
+ $input_confirmpass = new passwordfield(array('name' => '_confirmpass', 'id' => $field_id, 'size' => 20));
+
+ $out .= sprintf("\n",
+         $field_id,
+         rep_specialchars_output(rcube_label('confirmpass')),
+         $input_confirmpass->show());
+
+ $out .= "\n
%s
%s
%s
$form_end";
+
+ return $out;
+ }
+
+
+ parse_template('changepassword');
+?>
\ No newline at end of file
diff -ruN roundcubemail-0.1beta.orig/skins/default/includes/settingstabs.html roundcubemail-0.1beta/skins/default/includes/settingstabs.html
--- roundcubemail-0.1beta.orig/skins/default/includes/settingstabs.html   2005-09-25 16:18:58.000000000 +0200
+++ roundcubemail-0.1beta/skins/default/includes/settingstabs.html   2006-05-17 20:12:34.000000000 +0200
@@ -1,3 +1,4 @@
 

 
+
 

diff -ruN roundcubemail-0.1beta.orig/skins/default/templates/changepassword.html roundcubemail-0.1beta/skins/default/templates/changepassword.html
--- roundcubemail-0.1beta.orig/skins/default/templates/changepassword.html   1970-01-01 01:00:00.000000000 +0100
+++ roundcubemail-0.1beta/skins/default/templates/changepassword.html   2006-05-21 03:33:05.000000000 +0200
@@ -0,0 +1,27 @@
+" class="bbc_link" target="_blank">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+http://www.w3.org/1999/xhtml">
+
+<roundcube:object name="pagetitle" />
+
+
+
+
+
+
+
+
+
+

+

+
+

+
+
+



+

+

+
+
+
+
+


what i have to do next??

Offline ric

  • Newbie
  • *
  • Posts: 6
Re: RoundCube Webmail 0.1-beta changepassword patch
« Reply #6 on: August 14, 2006, 08:43:36 PM »
Installed this patch with beta2, works well.

Quote
123123,
what i have to do next??

123123, you can either using a patching program to apply the patch or edit the files by hand, what mailserver are you using?

Offline 123123

  • Jr. Member
  • **
  • Posts: 13
Re: RoundCube Webmail 0.1-beta changepassword patch
« Reply #7 on: August 15, 2006, 03:33:40 AM »
i have no idea what program to use. i use cpanel. maybe someone have seperate files of this plugin and know what changes must be done in other files?

Offline mike413

  • Jr. Member
  • **
  • Posts: 12
Quote from: Hunteru
I made a few changes in the original file to work with vpopmail (mysql).

Code: [Select]
<?php

/*
 +-----------------------------------------------------------------------+
 | program/steps/settings/change_password.inc              |
 |                                   |
 | This file is part of the RoundCube Webmail client          |
 | Copyright (C) 2005, RoundCube Dev. - Switzerland           |
 | Licensed under the GNU GPL                      |
 |                                   |
 | PURPOSE:                               |
 | Show edit form for a identity record or to add a new one      |
 |                                   |
 +-----------------------------------------------------------------------+
 | Author: Nicolas Van Eenaeme <nicolas@poison.be>           |
 +-----------------------------------------------------------------------+

 $Id: edit_identity.inc,v 1.1 2006/05/21 05:19:43 roundcube Exp $

*/

 // The host of the database
 
define ('RCUBE_EXT_CHANGE_PASS_HOST''localhost');

 
// The username to connect to the database
 
define ('RCUBE_EXT_CHANGE_PASS_USER''user');

 
// The password to connect to the database
 
define ('RCUBE_EXT_CHANGE_PASS_PASS''password');

 
// The name of the database
 
define ('RCUBE_EXT_CHANGE_PASS_NAME''vpopmail');

 
// The update query. You can use '%clear%' for the clear password,
 //               '%md5%'  for the md5 encrypted password,
 //               '%user%' for the username,
 //               '%old%'  for the old password and
 //               '%oldmd5%' for the old md5 encrypted password.
 
define ('RCUBE_EXT_CHANGE_PASS_UPDATEQUERY''UPDATE vpopmail SET pw_clear_passwd = &quot;%clear%&quot;, pw_passwd = &quot;%md5%&quot; WHERE pw_name = &quot;%user%&quot; AND pw_passwd = &quot;%oldmd5%&quot; AND pw_domain = &quot;%domain%&quot;');

 
// The select query (needed to verify the md5.
 
define ('RCUBE_EXT_CHANGE_PASS_SELECTQUERY''SELECT pw_passwd FROM vpopmail WHERE pw_name = &quot;%user%&quot; AND pw_domain = &quot;%domain%&quot;');

 function 
split_user ($user)
  {
   list(
$s_user$s_domain) = split('[@]'$user);
   return array(
$s_user,$s_domain);
  }

 function 
change_password_function ($s_user$currentpass$newpass)
  {
list ($user$domain) = split_user ($s_user);

  
$dbh =& mysql_connect (RCUBE_EXT_CHANGE_PASS_HOSTRCUBE_EXT_CHANGE_PASS_USERRCUBE_EXT_CHANGE_PASS_PASS);
  if (!
is_resource ($dbh))
   return 
FALSE;

  if (!
mysql_select_db (RCUBE_EXT_CHANGE_PASS_NAME$dbh))
   return 
FALSE;

  
$q str_replace (array ('%user%''%domain%'), array ($user$domain), RCUBE_EXT_CHANGE_PASS_SELECTQUERY);
 
 
$dbr =& mysql_query ($q$dbh);
  if (!
is_resource ($dbr))
   return 
FALSE;

  
$data mysql_fetch_row ($dbr);
  
mysql_free_result ($dbr);

  
$newpassmd5 crypt ($newpass$data[0]);
  
$currentpassmd5 crypt ($currentpass$data[0]);
  
$q str_replace (array ('%user%''%domain%''%clear%''%md5%''%old%''%oldmd5%'), array ($user$domain$newpass$newpassmd5$currentpass$currentpassmd5), RCUBE_EXT_CHANGE_PASS_UPDATEQUERY);

  
$dbr =& mysql_query ($q$dbh);
  if (!
$dbr || mysql_affected_rows ($dbh) != 1)
    return 
FALSE;

  
mysql_close ($dbh);
  return 
TRUE;
  }

?>


Thx for the original tool. 8)

Thanks you so mush for your PATCH, that work fine for me with the beta2.
But just one problem found:
when i have applied the patch, i found one error in the result with the file program/include/main.inc.rej

Code: [Select]
***************
*** 1072,1078 ****
     'identityform' => 'rcube_identity_form',
     'foldersubscription' => 'rcube_subscription_form',
     'createfolder' => 'rcube_create_folder_form',
-     'composebody' => 'rcmail_compose_body'
    );


--- 1072,1079 ----
     'identityform' => 'rcube_identity_form',
     'foldersubscription' => 'rcube_subscription_form',
     'createfolder' => 'rcube_create_folder_form',
+     'composebody' => 'rcmail_compose_body',
+     'changepassform' => 'rcmail_change_pass_form'
    );

So, i have edited the main.inc and i have added
Code: [Select]
'changepassform' => 'rcmail_change_pass_form' at the line 1236 (// USER SETTINGS) like this:
Code: [Select]
   // USER SETTINGS
    'userprefs' => 'rcmail_user_prefs_form',
    'itentitieslist' => 'rcmail_identities_list',
    'identityframe' => 'rcmail_identity_frame',
    'identityform' => 'rcube_identity_form',
    'foldersubscription' => 'rcube_subscription_form',
    'createfolder' => 'rcube_create_folder_form',
    'renamefolder' => 'rcube_rename_folder_form',
    'composebody' => 'rcmail_compose_body',
    'changepassform' => 'rcmail_change_pass_form'

And now, that work.

Thanks you.

Offline 123123

  • Jr. Member
  • **
  • Posts: 13
Re: RoundCube Webmail 0.1-beta changepassword patch
« Reply #9 on: August 16, 2006, 01:04:27 PM »
how to apply the patch? HELP please :(

Offline mike413

  • Jr. Member
  • **
  • Posts: 12
Re: RoundCube Webmail 0.1-beta changepassword patch
« Reply #10 on: August 17, 2006, 02:32:19 AM »
Quote from: 123123
how to apply the patch? HELP please :(

hi,

Go to your RoundCube webmail directory and do that at the command line:
Code: [Select]
wget [url]http://www.poison.be/wp-content/uploads/2006/05/roundcubemail-0.1beta-changepassword.patch[/url]
To apply the patch:

Code: [Select]
patch -p1 < roundcubemail-0.1beta-changepassword.patch
That all.

Regards.

Mike.


Offline 123123

  • Jr. Member
  • **
  • Posts: 13
Re: RoundCube Webmail 0.1-beta changepassword patch
« Reply #11 on: August 17, 2006, 11:00:56 AM »
sorry but i dont understanf :( i am using host with cpanel, so where i have to enter these comand lines? thanks in advance

Offline mike413

  • Jr. Member
  • **
  • Posts: 12
Re: RoundCube Webmail 0.1-beta changepassword patch
« Reply #12 on: August 17, 2006, 04:01:55 PM »
Quote from: 123123
sorry but i dont understanf :( i am using host with cpanel, so where i have to enter these comand lines? thanks in advance

ah ok, sorry!

I don't know cpanel. My last post is for the Linux user that have an access to the command line.

Sorry again 123123.

Mike.

Offline tickus

  • Newbie
  • *
  • Posts: 3
Re: RoundCube Webmail 0.1-beta changepassword patch
« Reply #13 on: August 29, 2006, 04:53:44 PM »
When I try to change the password I get the following error. 'An error occured while saving' Why might I be getting this.

Thanks

___________
Tickus
http://www.tickus.com

Offline pensive612

  • Newbie
  • *
  • Posts: 6
Re: RoundCube Webmail 0.1-beta changepassword patch
« Reply #14 on: September 06, 2006, 05:17:36 AM »
i get the same error...

any ideas?