To do this functionality, I use Ajax and javascript.
I call a php program which do the login to verify user/password.
I want to use ajaxRequest.status to control the result of login in javascript.
In all the cases (good password/wrong password) the Php Code send me ajaxRequest.status=200
Firebug show me the wrong result.
The error is in the following php program :
Code: Select all
<?php
define('IN_PHPBB', true);
// Include files
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require($phpbb_root_path . 'common.' . $phpEx);
//Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('');
$username = $_GET['name'];
$password = $_GET['pwd'];
$display_string = "";
if(isset($username) && isset($password)) {
$display_string .= "username ".$username."</br>";
$display_string .= "password ".$password."</br>";
$result = $auth->login($username, $password, false, 1, 0);
$display_string .= "status ".$result['status']."</br>";
if ($result['status'] == LOGIN_SUCCESS) {
//Le username et mot de passe sont ok
$display_string .= "Username et mot de passe ok "."</br>";
//affichage du resultat recupéré par la page appelante
echo $display_string;
//par défaut 200 si tout ce passe bien
http_response_code(200);
} elseif ($result['status'] == LOGIN_ERROR_ATTEMPTS) {
//Le username et mot de passe ne correspondent pas
$display_string .= "Vous avez dépassé le maximum autorisé de tentatives de connexion, connectez vous au forum avant l'adhésion "."</br>";
//affichage du resultat recupéré par la page appelante
echo $display_string;
//temps d'attente de 7 secondes pour éviter les pirates
sleep (7);
//en cas d'erreur non trouvé on sort en erreur 204 - 204 No Content
http_response_code(206);
} else {
//Le username et mot de passe ne correspondent pas
$display_string .= "Username et mot de passe invalide "."</br>";
//affichage du resultat recupéré par la page appelante
echo $display_string;
//temps d'attente de 7 secondes pour éviter les pirates
sleep (7);
//en cas d'erreur non trouvé on sort en erreur 204 - 204 No Content
http_response_code(204);
}
} else {
//Le username et mot de passe ne correspondent pas
$display_string .= "Username ou mot de passe non rempli "."</br>";
//affichage du resultat recupéré par la page appelante
echo $display_string;
//temps d'attente de 7 secondes pour éviter les pirates
sleep (7);
//en cas d'erreur non trouvé on sort en erreur 204 - 204 No Content
http_response_code(204);
}
?>
If I log http_response_code() the good value is logged (204/206)
but when i received the status, firebug always give me 200.
I have try to simplfy my code to identify the problem,
This code send me 200
Code: Select all
<?php
define('IN_PHPBB', true);
// Include files
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require($phpbb_root_path . 'common.' . $phpEx);
//Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('');
http_response_code(204);
$display_string .= "http_response_code ".http_response_code()."</br>";
echo $display_string;
return;
?>
Code: Select all
<?php
define('IN_PHPBB', true);
// Include files
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require($phpbb_root_path . 'common.' . $phpEx);
http_response_code(204);
$display_string .= "http_response_code ".http_response_code()."</br>";
echo $display_string;
return;
?>
Code: Select all
//Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('');
François