diff options
| author | polo <ordipolo@gmx.fr> | 2026-10-23 00:47:32 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2026-10-23 00:47:32 +0200 |
| commit | f27cca08ff786ceff1870147f6d6bad14d71117f (patch) | |
| tree | d36597a72025313d6faf4ed228755fa267ebe2f6 /src/View/UserEditBuilder.php | |
| parent | c7309f900ef05bd5cb313110ec159b761af394ec (diff) | |
| download | cms-f27cca08ff786ceff1870147f6d6bad14d71117f.tar.gz cms-f27cca08ff786ceff1870147f6d6bad14d71117f.tar.bz2 cms-f27cca08ff786ceff1870147f6d6bad14d71117f.zip | |
dossiers avec majuscule, namespace pour toutes les classes, autoload psr-4, UserDataService::createZip déplacé dans Backup
Diffstat (limited to 'src/View/UserEditBuilder.php')
| -rw-r--r-- | src/View/UserEditBuilder.php | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/View/UserEditBuilder.php b/src/View/UserEditBuilder.php new file mode 100644 index 0000000..4a9fd90 --- /dev/null +++ b/src/View/UserEditBuilder.php | |||
| @@ -0,0 +1,64 @@ | |||
| 1 | <?php | ||
| 2 | // src/View/UserEditBuilder.php | ||
| 3 | // | ||
| 4 | // fonctionne avec UserController | ||
| 5 | |||
| 6 | declare(strict_types=1); | ||
| 7 | |||
| 8 | namespace App\View; | ||
| 9 | |||
| 10 | use App\Entity\Node; | ||
| 11 | use App\Service\URL; | ||
| 12 | use App\Service\Captcha; | ||
| 13 | |||
| 14 | class UserEditBuilder extends AbstractBuilder | ||
| 15 | { | ||
| 16 | public function __construct(Node $node){ | ||
| 17 | // pour éviter les arnaques | ||
| 18 | if(!IS_ADMIN){ | ||
| 19 | header('Location: ' . new URL); | ||
| 20 | die; | ||
| 21 | } | ||
| 22 | |||
| 23 | $viewFile = self::VIEWS_PATH . $node->getName() . '.php'; | ||
| 24 | |||
| 25 | $error_messages = [ | ||
| 26 | 'error_non_valid_captcha' => 'Erreur au test anti-robot, veuillez saisir un nombre entier.', | ||
| 27 | 'captcha_server_error' => 'captcha_server_error', | ||
| 28 | |||
| 29 | 'bad_login_or_password' => 'Mauvais identifiant ou mot de passe, veuillez réessayer.', // ne pas indiquer où est l'erreur | ||
| 30 | 'bad_solution_captcha' => 'Erreur au test anti-robot, veuillez réessayer.', | ||
| 31 | 'forbidden_characters' => 'Caractères interdits: espaces, tabulations, sauts CR/LF.', | ||
| 32 | 'same_username_as_before' => 'Nouveau nom identique au précédent.', | ||
| 33 | 'same_password_as_before' => 'Nouveau mot de passe identique au précédent.' | ||
| 34 | ]; | ||
| 35 | |||
| 36 | $error_username = isset($_GET['error_username']) ? $error_messages[$_GET['error_username']] : ''; | ||
| 37 | $success_username = (isset($_GET['success_username']) && $_GET['success_username']) ? 'Identifiant modifié avec succès.' : ''; | ||
| 38 | $error_password = isset($_GET['error_password']) ? $error_messages[$_GET['error_password']] : ''; | ||
| 39 | $success_password = (isset($_GET['success_password']) && $_GET['success_password']) ? 'Mot de passe modifié avec succès.' : ''; | ||
| 40 | |||
| 41 | $captcha = new Captcha; | ||
| 42 | $_SESSION['captcha'] = $captcha->getSolution(); // enregistrement de la réponse du captcha pour vérification | ||
| 43 | |||
| 44 | $link_user_form = new URL(['action' => 'update_username']); | ||
| 45 | isset($_GET['from']) ? $link_user_form->addParams(['from' => $_GET['from']]) : ''; | ||
| 46 | isset($_GET['id']) ? $link_user_form->addParams(['id' => $_GET['id']]) : ''; | ||
| 47 | |||
| 48 | $link_password_form = new URL(['action' => 'update_password']); | ||
| 49 | isset($_GET['from']) ? $link_password_form->addParams(['from' => $_GET['from']]) : ''; | ||
| 50 | isset($_GET['id']) ? $link_password_form->addParams(['id' => $_GET['id']]) : ''; | ||
| 51 | |||
| 52 | $link_exit = new URL; | ||
| 53 | isset($_GET['from']) ? $link_exit->addParams(['page' => $_GET['from'] ]) : ''; | ||
| 54 | isset($_GET['id']) ? $link_exit->addParams(['id' => $_GET['id']]) : ''; | ||
| 55 | |||
| 56 | $link_logout = new URL(['action' => 'deconnection']); | ||
| 57 | isset($_GET['from']) ? $link_logout->addParams(['from' => $_GET['from'] ]) : ''; | ||
| 58 | isset($_GET['id']) ? $link_logout->addParams(['id' => $_GET['id']]) : ''; | ||
| 59 | |||
| 60 | ob_start(); | ||
| 61 | require $viewFile; | ||
| 62 | $this->html = ob_get_clean(); // nouveau contenu | ||
| 63 | } | ||
| 64 | } \ No newline at end of file | ||
