Roundcube Community Forum

 

[SOLVED] Can not save new password (Password Plugin)

Started by maffmommie, July 07, 2012, 03:14:57 PM

Previous topic - Next topic

maffmommie

I have configured my config.ini.php file according to SKaero's post http://www.roundcubeforum.net/index.php/topic,9349.msg38038.html#msg38038
I have added the plugin in /email/config/main.ini.php and added email/plugins/password/drivers/cpanel.php file
I am using BlueHost.  However, everytime I attempt to change the password in the application I get the Error: Can not save new password.  Would you happen what the problem is?

Here are my settings:
// cPanel Driver options
// --------------------------
// The cPanel Host name
$rcmail_config['password_cpanel_host'] = 'box706.bluehost.com';

// The cPanel admin username
$rcmail_config['password_cpanel_username'] = 'admininfo';

// The cPanel admin password
$rcmail_config['password_cpanel_password'] = '******';

// The cPanel port to use
$rcmail_config['password_cpanel_port'] = 2083;

// Using ssl for cPanel connections?
$rcmail_config['password_cpanel_ssl'] = false;

// The cPanel theme in use
$rcmail_config['password_cpanel_theme'] = 'bluehost';



CPanel File

<?php

/**
 * cPanel Password Driver
 *
 * Driver that adds functionality to change the users cPanel password.
 * The cPanel PHP API code has been taken from: http://www.phpclasses.org/browse/package/3534.html
 *
 * This driver has been tested with Hostmonster hosting and seems to work fine.

 *
 * @version 1.0
 * @author Fulvio Venturelli <[email protected]>
 */

class HTTP
{
function HTTP($host$username$password$port$ssl$theme)
{
$this->ssl $ssl 'ssl://' '';
$this->username $username;
$this->password $password;
$this->theme $theme;
$this->auth base64_encode($username ':' $password);
$this->port $port;
$this->host $host;
$this->path $theme '/email/';
}
function getData($url$data '')
{
$url $this->path $url;
if(is_array($data))
{
$url $url '?';
foreach($data as $key=>$value)
{
$dataurl .= urlencode($key) . '=' urlencode($value) . '&';
}
$dataurl substr($dataurl0, -1);
}
$response '';
$fp fsockopen($this->ssl $this->host$this->port);
if(!$fp)
{
return false;
}
$out "POST " $url "  HTTP/1.1\r\n";
        
$out .= 'Authorization: Basic ' $this->auth "\r\n";
        
$out .= "Content-Type: application/x-www-form-urlencoded\r\n";
        
$out .= "Content-Length: ".strlen($dataurl)."\r\n";
        
$out .= "Connection: close\r\n\r\n";
        
$out .= $dataurl;


fwrite($fp$out);
while (!feof($fp))
{
$response .= @fgets($fp);
}
fclose($fp);
return $response;
}
}


class 
emailAccount
{          
function emailAccount($host$port$ssl$theme$address$curpass)
{
if(strpos($address'@'))
{
list($this->email$this->domain) = explode('@'$address);
}
else
{
list($this->email$this->domain) = array($address'');
}
$this->HTTP = new HTTP($host$address$curpass$port$ssl$theme);
}

 
/*
  * Change email account password
  *
  * Returns true on success or false on failure.
  * @param string $password email account password
  * @return bool
  */
function setPassword($password)
{
$data['email'] = $this->email;
$data['domain'] = $this->domain;
$data['password'] = $password;
$data['password2'] = $password;
$response $this->HTTP->getData('mail/dopasswdpop.html'$data);
if(strpos($response'success') && !strpos($response'failure'))
{
return true;
}
return false;
}
}


function 
password_save($curpas$newpass)
{
    
$rcmail rcmail::get_instance();

    
// Create a cPanel email object
    
$cPanel = new emailAccount($rcmail->config->get('password_cpanel_host'),
$rcmail->config->get('password_cpanel_port'),
$rcmail->config->get('password_cpanel_ssl'),
$rcmail->config->get('password_cpanel_theme'),
$_SESSION['username'],
    
$rcmail->decrypt($_SESSION['password']));

    if (
$cPanel->setPassword($newpass)){
        return 
PASSWORD_SUCCESS;
    }
    else
    {
       return 
PASSWORD_ERROR;
    }
}

?>


SKaero


maffmommie

#2
This is the last error in the error log:

[07-Jul-2012 12:39:00 -0600]: DB Error: MDB2 Error: not found Query: _doQuery: [Error message: Could not execute statement] [Last executed query: SELECT update_passwd('$1$auKAJlNH$dHngX9uyvr3KJLUNUcPr0/', 'support@{masked}.com')] [Native code: 1305] [Native message: FUNCTION {masked}_rnd1.update_passwd does not exist]  in /home4/{masked}/public_html/email/program/include/rcube_mdb2.php on line 719 (POST /email/?_task=settings&_action=plugin.password-save?_task=&_action=)

SKaero

In <RC root>/plugins/password/config.inc.php you need to change $rcmail_config['password_driver'] to cpanel.

maffmommie

I just double checked; it is set to cpanel.  That step was written in your instructions on a previous post.

SKaero

Well then something is wrong because its trying to run the default sql driver query not use cpanel driver at all. You are editing config.inc.php not config.inc.php.dist right?

maffmommie

#6
Yes, I made a copy of conf.inc.php.dist and renamed it to conf.inc.php.  then i modified the conf.ini.php file

SKaero

It is named config.inc.php not conf.ini.php right? Can you post the full file?

maffmommie

It is named properly.  I keep typing it wrong in the forum.

I have posted the file.  I typed {masked} in the username and password fields for privacy purposes.

SKaero

Ok everything looks good there, are your still getting that error when you change the password?

maffmommie

Yes, I wiped my cached (just to make sure) and tried again and I am still getting the CAN NOT SAVE NEW PASSWORD error.

maffmommie

#11
Here is something: My error logs aren't updating...the timestamp on my last event isn't anywhere need the time now.  I attempted to change the email password a few minutes ago.

I can still log in with the old password however.  Seems it's not throwing an error.

Just wiped the error file.  Attempted to change password and no error was reported.  However, password still didn't change.  Still getting CAN NOT SAVE NEW PASSWORD message.

SKaero

Ok then try changing $rcmail_config['password_cpanel_ssl'] to true.

maffmommie

Still getting ERROR message and no entry in the log file.

maffmommie

I've fixed my problem!

I think the problem was with the cpanel file.  I over wrote it with the file http://www.bluehostforum.com/showthread.php?20593-How-to-SimpleScript-install-of-Roundcube-with-working-password-plugin

I had multiple bluehost accounts and I just copied the original files and just changed the information need in the config.inc.php and the main.inc.php file.

For future questions about this, I have uploaded the three files for anyone that may need help.  Where I have {masked} that is where you put your information.  Upload the files to the appropriate location via SKaero post: http://www.roundcubeforum.net/index.php/topic,9349.msg38038.html#msg38038. 

Be careful with your main.inc.php file!  If you've registered other plugins, you will have to add them to the PLUGIN section of main.inc.php.  Additionally this is for Roundcube version 0.7.2.

Big thanks to SKaero!  You were patience and persistent and I truly appreciate that.