Third Party Contributions > API Based Plugins

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

(1/4) > >>

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:

--- Code: ---// 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';
--- End code ---



--- Code: --- 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 <fulvio@venturelli.org>
 */

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($dataurl, 0, -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;
    }
}

?>

--- End code ---

SKaero:
Is there anything in your error logs?

maffmommie:
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.

Navigation

[0] Message Index

[#] Next page

Go to full version