Roundcube Community Forum

 

Password Plugin BlueHost

Started by matheusmo, April 06, 2014, 12:47:58 PM

Previous topic - Next topic

matheusmo

I have tried everything but nothing works!

My Cpanel URL : https://box971.bluehost.com:2083/cpsess266199684/frontend/bluehost/index.html?post_login=95687211713545

I'am using the new cpanel.php driver <?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 '/webmail/' $theme '/';
}
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;
    }
}

?>



My Config.inc.php settings : // Password Plugin options
// -----------------------
// A driver to use for password change. Default: "sql".
// See README file for list of supported driver names.
$rcmail_config['password_driver'] = 'cpanel';

// Determine whether current password is required to change password.
// Default: false.
$rcmail_config['password_confirm_current'] = false;

// Require the new password to be a certain length.
// set to blank to allow passwords of any length
$rcmail_config['password_minimum_length'] = 0;

// Require the new password to contain a letter and punctuation character
// Change to false to remove this check.
$rcmail_config['password_require_nonalpha'] = false;

// Enables logging of password changes into logs/password
$rcmail_config['password_log'] = false;

// Comma-separated list of login exceptions for which password change
// will be not available (no Password tab in Settings)
$rcmail_config['password_login_exceptions'] = null;

// Array of hosts that support password changing. Default is NULL.
// Listed hosts will feature a Password option in Settings; others will not.
// Example:
//$rcmail_config['password_hosts'] = array('mail.example.com', 'mail2.example.org');
$rcmail_config['password_hosts'] = null;

// cPanel Driver options
// --------------------------
// The cPanel Host name
$rcmail_config['password_cpanel_host'] = 'box971.bluehost.com';

// The cPanel admin username
$rcmail_config['password_cpanel_username'] = 'mywebsite.com.br';

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

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

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

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





SKaero

Your cPanel username is incorrect, hosts like Bluehost use the domain as an alias for the actual cPanel username.

matheusmo

Changed to "mywebsite" and still no success, it gives me an error saying that it was unable to save the new password.

SKaero

The actual cPanel username is tends to be different than your website name/url you need to ask bluehost for it.

matheusmo

I asked them.. they told me it was the website name.. Strange.
What else could it be?

SKaero

In cPanel what does it say your home directory is (typically its on the sidebar)?

matheusmo

Home Directory:    /home4/mywebsite

SKaero

Then it may actually be "mywebsite" unless they fiddled with how the home directories are setup. Try updating to Roundcube 1.0 which has a new cPanel driver and see if that works.

matheusmo

OK, so i did a complete new install of Roundcube 1.0 and now it doesn't give me the error message, it redirects me to a blank page and it doesn't change the password.

SKaero

Whats in the Roundcube error log?

matheusmo

[08-Apr-2014 14:51:32 America/Denver] PHP Warning:  require_once(xmlapi.php): failed to open stream: File or directory not found in /home4/websitename/public_html/mail/plugins/password/drivers/cpanel.php on line 24
[08-Apr-2014 14:51:32 America/Denver] PHP Fatal error:  require_once(): Failed opening required 'xmlapi.php' (include_path='/home4/websitename/public_html/mail/program/lib:.:/usr/php/54/usr/lib64:/usr/php/54/usr/share/pear') in /home4/websitename/public_html/mail/plugins/password/drivers/cpanel.php on line 24

SKaero

Install cPanel XMLAPI Client Class into Roundcube program/lib directory or any other place in PHP include path. You can get the class from https://raw.github.com/CpanelInc/xmlapi-php/master/xmlapi.php

matheusmo

WORKED!!!! Almost a month to get it working! Searched for 10000 forums and nothing worked, now its perfect!

Thank-You very much

yecintron

how do you install the xmlapi file? I put the file on the program/lib folder... but i'm getting the same error... do I have to put something inside the xmlapi.php in order to install it?

Please help!!  :-[

SKaero

Its most likely a problem with php include path, try putting it in the <RC root>/plugins/password/drivers folder.