1

当您多次输入错误密码但不知道如何操作时,我正在尝试在屏幕上弹出验证码。我已经找到了很多关于此的页面,但它们都涉及使用模板,并且这些页面都没有解释我必须在表单中输入的内容。

这是我到目前为止所得到的。

define('IN_PHPBB', true);
    global $auth, $db, $cache, $config, $user, $phpbb_root_path, $phpEx, $template;
    $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : '../main/';
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);

    $user->session_begin();
    $auth->acl($user->data);

    $remember = $remember==1?true:false;
    $result = $auth->login($username, $password, $remember);

    if ($result['status'] == LOGIN_SUCCESS){
        return "LOGIN_SUCCESS";
        //Launch captcha
    }else{
        if($result['status']==LOGIN_ERROR_ATTEMPTS){
            return "LOGIN_ERROR_ATTEMPTS";
        }
        if($result['status'] == LOGIN_ERROR_EXTERNAL_AUTH){
            return "No profile exists.";
        }elseif($result['status'] == LOGIN_BREAK){
            return "Failed to create session.";
        }elseif($result['status'] == LOGIN_ERROR_PASSWORD){
            return "Incorrect Password.";
        }elseif($result['status'] == LOGIN_ERROR_USERNAME){
            return "Invalid Username.";
        }elseif($result['status'] == LOGIN_ERROR_PASSWORD_CONVERT){
            return "Internal error, failed to convert password.";
        }elseif($result['status'] == LOGIN_ERROR_ACTIVE){
            return "User is inactive.";
        }
    }
4

1 回答 1

1
define('IN_PHPBB', true);
global $auth, $db, $cache, $config, $user, $phpbb_root_path, $phpEx, $template;
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
if (!class_exists('phpbb_captcha_factory'))
{
    include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx);
}
$user->session_begin();
$auth->acl($user->data);
$username = isset($_POST['username']) ? $_POST['username'] : '';
$password = isset($_POST['password']) ? $_POST['password'] : '';
$remember = isset($_POST['remember']) ? $_POST['remember'] : '' ;
$remember = $remember==1?true:false;
$result = $auth->login($username, $password, $remember);
$err = '';

    switch ($result['status'])
    {
        case LOGIN_SUCCESS:
            $err .= 'Welcome ' . $user->data['username'];
        break;

        case LOGIN_ERROR_EXTERNAL_AUTH:
            $err .= 'No profile exists';
        break;

        case LOGIN_ERROR_ATTEMPTS:
            $err .= '<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=your_public_key">' . "/n"
            . '</script>' . "/n"
            . '<noscript>' . "/n"
            . '<iframe src="http://www.google.com/recaptcha/api/noscript?k=your_public_key" height="300" width="500" frameborder="0"></iframe><br>' . "/n"
            . '<textarea name="recaptcha_challenge_field" rows="3" cols="40">' . "/n"
            . ' </textarea>' . "/n"
            . ' <input type="hidden" name="recaptcha_response_field" value="manual_challenge">' . "/n"
            . '</noscript>';
            $err .= 'LOGIN_ERROR_ATTEMPTS';
        break;

        case LOGIN_ERROR_PASSWORD_CONVERT:
            $err .= 'Internal error, failed to convert password.';
        break;

        case LOGIN_BREAK:
            $err .= "Failed to create session.";
        break;

        case LOGIN_ERROR_PASSWORD:
            $err .= "Incorrect Password.";
        break;

        case LOGIN_ERROR_USERNAME:
            $err .= "Invalid Username.";
        break;

        case LOGIN_ERROR_ACTIVE:
            $err .= "User is inactive.";
        break;
    }
return $err;
于 2012-09-25T00:09:29.620 回答