Roundcube Community Forum

Third Party Contributions => Old Style Plug-Ins => Topic started by: matheusmo on April 06, 2014, 12:47:58 PM

Title: Password Plugin BlueHost
Post by: matheusmo on April 06, 2014, 12:47:58 PM
I have tried everything but nothing works!

My Cpanel URL :
Code: [Select]
https://box971.bluehost.com:2083/cpsess266199684/frontend/bluehost/index.html?post_login=95687211713545
I'am using the new cpanel.php driver
Code: [Select]
<?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 '/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 :
Code: [Select]
// 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';



Title: Re: Password Plugin BlueHost
Post by: SKaero on April 06, 2014, 08:47:56 PM
Your cPanel username is incorrect, hosts like Bluehost use the domain as an alias for the actual cPanel username.
Title: Re: Password Plugin BlueHost
Post by: matheusmo on April 07, 2014, 06:34:13 AM
Changed to "mywebsite" and still no success, it gives me an error saying that it was unable to save the new password.
Title: Re: Password Plugin BlueHost
Post by: SKaero on April 07, 2014, 04:31:07 PM
The actual cPanel username is tends to be different than your website name/url you need to ask bluehost for it.
Title: Re: Password Plugin BlueHost
Post by: matheusmo on April 07, 2014, 04:38:04 PM
I asked them.. they told me it was the website name.. Strange.
What else could it be?
Title: Re: Password Plugin BlueHost
Post by: SKaero on April 07, 2014, 05:13:10 PM
In cPanel what does it say your home directory is (typically its on the sidebar)?
Title: Re: Password Plugin BlueHost
Post by: matheusmo on April 07, 2014, 07:46:42 PM
Home Directory:    /home4/mywebsite
Title: Re: Password Plugin BlueHost
Post by: SKaero on April 08, 2014, 01:18:43 PM
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.
Title: Re: Password Plugin BlueHost
Post by: matheusmo on April 08, 2014, 04:26:11 PM
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.
Title: Re: Password Plugin BlueHost
Post by: SKaero on April 08, 2014, 09:36:12 PM
Whats in the Roundcube error log?
Title: Re: Password Plugin BlueHost
Post by: matheusmo on April 08, 2014, 11:05:22 PM
[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
Title: Re: Password Plugin BlueHost
Post by: SKaero on April 08, 2014, 11:33:48 PM
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
Title: Re: Password Plugin BlueHost
Post by: matheusmo on April 09, 2014, 10:05:31 AM
WORKED!!!! Almost a month to get it working! Searched for 10000 forums and nothing worked, now its perfect!

Thank-You very much
Title: Re: Password Plugin BlueHost
Post by: yecintron on July 23, 2014, 06:35:46 PM
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!!  :-[
Title: Re: Password Plugin BlueHost
Post by: SKaero on July 23, 2014, 08:58:00 PM
Its most likely a problem with php include path, try putting it in the <RC root>/plugins/password/drivers folder.
Title: Re: Password Plugin BlueHost
Post by: yecintron on July 24, 2014, 12:31:50 PM
I upload the file to the folder you said... but still getting a blank page when saving the new password... but wasn't saved.

The error log file gave me this --->

[23-Jul-2014 15:48:24 America/Denver] PHP Warning:  require_once(xmlapi.php): failed to open stream: No such file or directory in /home2/mywebsite/public_html/email/plugins/password/drivers/cpanel.php on line 24

In order to install the xmlapi.php what I did, was to go to the link at github, save the page, it saved as xmlapi.php, and just uploaded it on the programs/lib and then in password/drivers... That's it in order to install?  ???  'Cause it's not working! :-[
Title: Re: Password Plugin BlueHost
Post by: SKaero on July 24, 2014, 03:15:47 PM
It maybe a permission problem then, if the web server can't access the file it wont be able to read it. Make sure the xmlapi.php file has the same owner and the permissions are the same as the cpanel.php file.