Roundcube自动登录

时间:2016-06-07 08:52:53

标签: php html webmail roundcube

我有Roundcube,我需要更改登录...

我发现只有:

<roundcube:form name="form" method="post">
<roundcube:object name="loginform" form="form" size="40" submit=true />

我有登录脚本:

 <a class="hiddenanchor" id="toregister"></a>
                    <a class="hiddenanchor" id="tologin"></a>
                    <div id="wrapper">
                        <div id="login" class="animate form">
                            <form  action="?????.php" method="post"> 
                                <h1>Webmail Login</h1> 
                                <p> 
                                    <label for="username" class="uname" data-icon="u" > Email </label>
                                    <input id="username" name="username" required="required" type="text" placeholder="papduser@domain.us"/>
                                </p>
                                <p> 
                                    <label for="password" class="youpasswd" data-icon="p"> Passwort </label>
                                    <input id="password" name="password" required="required" type="password" placeholder="eg. X8df!90EO" /> 
                                </p>
                                <p class="keeplogin"> 
									<input type="checkbox" name="loginkeeping" id="loginkeeping" value="loginkeeping" /> 
									<label for="loginkeeping">Keep me logged in</label>
								</p>
                                <p class="login button"> 
                                    <input type="submit" value="Login" /> 
								</p>
                                <p class="change_link">
									Noch kein Mitglied ?
									<a href="#toregister" class="register">Registrieren</a>
								</p>
                            </form>
                        </div>

我已激活“自动登录”插件。

我现在需要什么?

2 个答案:

答案 0 :(得分:1)

注意:正在开发 RoundCube 1.4.11 版本。

第 1 步:更新 config.inc.php

更新插件
$config['plugins'] = array('autologon');
真实路径:ROUNDCUBE/config/config.inc.php


第 2 步:更新 autologon.php
真实路径:ROUNDCUBE/plugins/autologon/autologon.php

function authenticate($args)
  {       
    if (!empty($_POST['_autologin']) && $this->is_localhost()) {
      $args['user'] = $_POST['_user'];
      $args['pass'] = $_POST['_pass'];
      $args['host'] = 'ssl://mail.YOUR DOMAIN NAME.com';
      $args['cookiecheck'] = false;
      $args['valid'] = true;
    } 
    return $args;
  }

第 3 步:更新 index.php
在此行之前更新此代码
真实路径:ROUNDCUBE/index.php

if ($auth['valid'] && !$auth['abort'] && $RCMAIL->login($auth['user'], $auth['pass'], $auth['host'], $auth['cookiecheck'])) {

代码在这里 如果用户名和密码要发布,则此过程使身份验证验证为真
如果需要,请尝试更多自定义条件

        // Custom Code
        {
        
            // if login detail post and check post server detail
            if( $RCMAIL->login($auth['user'], $auth['pass']) && $_POST['_user'] && !empty($_POST['_user']) && $_POST['_pass'] && !empty($_POST['_pass']) ){
                $auth['valid'] = true;
                $auth['abort'] = false;
            }
        
        }

第 4 步:为 POST 数据创建表单到 index.php

<form name="form" action="//YOUR DOMAIN NAME.com/index.php" method="post">
    <input type="hidden" name="_action" value="login" />
    <input type="hidden" name="_task" value="login" />
    <input type="hidden" name="_autologin" value="1" />
    <table>
        <tr>
            <td>Utente</td>
            <td><input name="_user" id="rcmloginuser" value="" type="text" /></td>
        </tr>
        <tr>
            <td>Password</td>
            <td><input name="_pass" id="rcmloginpwd" type="password" /></td>
        </tr>
        <tr>
            <td colspan="2"><input type="submit" value="Login" /></td>
        </tr>
    </table>
</form>

答案 1 :(得分:0)

我使用RoundcubeAutoLogin类自动登录:https://github.com/alexjeen/Roundcube-AutoLogin

我称之为:

require_once 'RoundcubeAutoLogin.php';

$rc = new RoundcubeAutoLogin('http://your_domain/roundcube/'); // set your roundcube domain path

$cookies = $rc->login('your_email@domain.com', 'email_password');

// now you can set the cookies with setcookie php function, or using any other function of a framework you are using

foreach($cookies as $cookie_name => $cookie_value)
{
    setcookie($cookie_name, $cookie_value, 0, '/', '');
}
// and redirect to roundcube with the set cookies
$rc->redirect();

我希望这会对你有所帮助