I'm trying to make a captcha popup on the screen when you fail to enter your password wrong too many times but not sure how to go about it. I've found quite a few pages about this but they all involve using a template and none of those pages explain what I have to put into my form.
Here's what I got so far.
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.";
}
}
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;