blob: 567c93da55dfc5aaed39104aa01e0333368bdbb9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
<?php
// src/view/LoginBuilder.php
declare(strict_types=1);
use App\Entity\Node;
class LoginBuilder extends AbstractBuilder
{
public function __construct(Node $node)
{
// déjà connecté?
if($_SESSION['admin'])
{
header('Location: ' . new URL);
die;
}
$viewFile = self::VIEWS_PATH . $node->getName() . '.php';
$captcha = new Captcha;
$_SESSION['captcha'] = $captcha->getSolution(); // enregistrement de la réponse du captcha pour vérification
//$this->html .= $header;
$error_messages = [
'error_non_valid_captcha' => 'Erreur au test anti-robot, veuillez saisir un nombre entier.',
'captcha_server_error' => 'captcha_server_error',
'bad_solution_captcha' => 'Erreur au test anti-robot, veuillez réessayer.',
'bad_login_or_password' => 'Mauvais identifiant ou mot de passe, veuillez réessayer.', // ne pas indiquer où est l'erreur
'forbidden_characters' => 'Caractères interdits: espaces, tabulations, sauts CR/LF.'
];
$link_form = new URL(['action' => 'connection']);
isset($_GET['from']) ? $link_form->addParams(['from' => $_GET['from']]) : '';
isset($_GET['id']) ? $link_form->addParams(['id' => $_GET['id']]) : '';
$link_exit = new URL;
isset($_GET['from']) ? $link_exit->addParams(['page' => $_GET['from'] ]) : '';
isset($_GET['id']) ? $link_exit->addParams(['id' => $_GET['id']]) : '';
$error = isset($_GET['error']) ? $error_messages[$_GET['error']] : '';
ob_start();
require $viewFile;
$this->html = ob_get_clean(); // nouveau contenu
//$this->html .= <p class='connexionP' style='color: red;'>Ce site utilise un cookie « obligatoire » lorsque vous êtes connecté ainsi que sur cette page.<br>Il sera supprimé à votre déconnexion ou dès que vous aurez quitté le site.</p>;
//$this->html .= $footer;
}
}
|