具有多个Cpanel帐户的RoundCube密码配置插件

时间:2014-06-20 15:48:34

标签: php cpanel roundcube

我有多个cpanel帐户,我想使用RoundCube的密码更改插件。在插件的config.inc.php文件中(如下所示),我包含了一个设置配置变量的函数,它整合了代码(请参阅case语句,我的意思)。

我尝试过返回函数数组,添加全局变量等等。在我死机的时候,我无法获得密码插件来理解变量的配置。我将结果打印到switch语句内的一个日志文件中(在一个点上),它返回了函数内定义的每个变量。但是,由于某种原因,插件没有在password.php文件中获取这些变量。

用户端的结果是密码更改失败并显示错误消息。

// Password Plugin options
    $rcmail_config['password_driver'] = 'cpanel';

// LOAD USER CONFIGURATION
    global $CONFIG, $RCMAIL;
    $rcmail = rcmail::get_instance();
    $user = $rcmail->user;

// GET THE USER'S DOMAIN NAME
function getDomainFromEmail($email)
{
    $domain = substr(strrchr($email, "@"), 1);
    return $domain;
}


// CONFIGURE PASSWORD PLUG-IN BASED ON THE EMAIL DOMAIN NAME
function setConfiguration($password_cpanel_host, $password_cpanel_username, $password_cpanel_password, $password_cpanel_port, $password_cpanel_ssl, $password_cpanel_theme)
{   global $rcmail, $rcmail_config;
    $rcmail_config['password_cpanel_host']      = $password_cpanel_host;
    $rcmail_config['password_cpanel_username']  = $password_cpanel_username;
    $rcmail_config['password_cpanel_password']  = $password_cpanel_password;
    $rcmail_config['password_cpanel_port']      = $password_cpanel_port;
    $rcmail_config['password_cpanel_ssl']       = $password_cpanel_ssl;
    $rcmail_config['password_cpanel_theme']     = $password_cpanel_theme;

    //return $rcmail_config;    
}

// CHECK THE DOMAIN NAME AND APPLY THE PLUG-IN SETTINGS
switch (getDomainFromEmail($user->get_username()))
{
case "domain1.com":
    // DOES NOT WORK WHEN DEFINED THIS WAY (AFTER RETURN IS UNCOMMENTED IN FUNCTION)
    $rcmail_config = setConfiguration('xxx', 'xxx', 'xxx', 2083, true, 'x3');
    // OR THIS WAY
    setConfiguration('xxx', 'xxx', 'xxx', 2083, true, 'x3');

    break;

case "domain2.org":
    // WORKS WHEN DEFINED THIS WAY
    $rcmail_config['password_cpanel_host']      = 'xxx';
    $rcmail_config['password_cpanel_username']  = 'xxx';
    $rcmail_config['password_cpanel_password']  = 'xxx';
    $rcmail_config['password_cpanel_port']      = '2083';
    $rcmail_config['password_cpanel_ssl']       = true;
    $rcmail_config['password_cpanel_theme']     = 'x3';
    break;
}

1 个答案:

答案 0 :(得分:0)

我不知道你是否已经解决了这个问题,但我遇到了完全相同的问题,并在cPanel社区的帮助下解决了这个问题。我无法工作的一个场景(但最终确实如此)是使用停放域名时

您需要使用WHM登录详细信息而不是cPanel登录详细信息,然后在作为管理员完成时使用端口2087。我希望这会有所帮助。

我在这里发布了最终代码

http://forums.cpanel.net/f42/finding-account-username-parked-domain-428501.html