Version stable, aprelic, connexion CFRS et autres corrections
This commit is contained in:
1 parent
865de8a976
commit
e9d0010451
62 files changed
+17483
-7256
No files matched your search
+60
-60
@@ -1,34 +1,33 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
require_once __DIR__ . '/../includes/bootstrap_global.php';
|
||||
declare (strict_types = 1);
|
||||
require_once __DIR__ . '/../includes/bootstrap_global.php';
|
||||
|
||||
$message = '';
|
||||
$message = '';
|
||||
$messageType = '';
|
||||
|
||||
if (($_SERVER['REQUEST_METHOD'] ?? '') === 'POST') {
|
||||
if (($_SERVER['REQUEST_METHOD'] ?? '') === 'POST') {
|
||||
$email = trim($_POST['email'] ?? '');
|
||||
|
||||
// Email valide + pas d’injection d’en-têtes
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL) || preg_match('/[\r\n]/', $email)) {
|
||||
$message = $translations['err_email_non_valide'] ?? 'Email invalide.';
|
||||
// On garde le contrôle de format, mais message neutre côté utilisateur
|
||||
if (! filter_var($email, FILTER_VALIDATE_EMAIL) || preg_match('/[\r\n]/', $email)) {
|
||||
$message = $translations['mdp_oublie_message_neutre'] ?? 'Si un compte existe pour cette adresse, un code a été envoyé.';
|
||||
$messageType = 'success';
|
||||
} else {
|
||||
// Vérifier si le compte existe
|
||||
$stmt = $pdo->prepare("SELECT id FROM compte WHERE email = :email LIMIT 1");
|
||||
$stmt->execute(['email' => $email]);
|
||||
$compte = $stmt->fetch();
|
||||
|
||||
if ($compte) {
|
||||
// Génère un code à 6 chiffres
|
||||
$code = random_int(100000, 999999);
|
||||
|
||||
// Enregistre en session (TTL 10 minutes)
|
||||
$_SESSION['reset_email'] = $email;
|
||||
$_SESSION['reset_code'] = $code;
|
||||
$_SESSION['reset_time'] = time();
|
||||
$_SESSION['reset_ttl'] = 600; // 10 min
|
||||
$_SESSION['reset_email'] = $email;
|
||||
$_SESSION['reset_code'] = (string) $code;
|
||||
$_SESSION['reset_time'] = time();
|
||||
$_SESSION['reset_ttl'] = 600;
|
||||
$_SESSION['reset_attempts'] = 0;
|
||||
|
||||
// Prépare l'e-mail
|
||||
$sujet = $translations['mail_sujet_code'];
|
||||
$codeHtml = htmlspecialchars((string)$code, ENT_QUOTES, 'UTF-8');
|
||||
$sujet = $translations['mail_sujet_code'] ?? 'Code de réinitialisation';
|
||||
$codeHtml = htmlspecialchars((string) $code, ENT_QUOTES, 'UTF-8');
|
||||
|
||||
$html = "<!DOCTYPE html>
|
||||
<html lang='fr'>
|
||||
@@ -44,66 +43,62 @@ if (($_SERVER['REQUEST_METHOD'] ?? '') === 'POST') {
|
||||
</head>
|
||||
<body>
|
||||
<div class='mail-container'>
|
||||
<div class='title'>".$translations['mail_bonjour']."</div>
|
||||
<p>".$translations['mail_phrase_code']."</p>
|
||||
<div class='code'>".$codeHtml."</div>
|
||||
<p>".$translations['mail_phrase_validite']."</p>
|
||||
<div class='footer'>".$translations['mail_signature']."</div>
|
||||
<div class='title'>" . htmlspecialchars($translations['mail_bonjour'] ?? 'Bonjour', ENT_QUOTES, 'UTF-8') . "</div>
|
||||
<p>" . htmlspecialchars($translations['mail_phrase_code'] ?? 'Voici votre code de réinitialisation :', ENT_QUOTES, 'UTF-8') . "</p>
|
||||
<div class='code'>" . $codeHtml . "</div>
|
||||
<p>" . htmlspecialchars($translations['mail_phrase_validite'] ?? 'Ce code est valable pendant un temps limité.', ENT_QUOTES, 'UTF-8') . "</p>
|
||||
<div class='footer'>" . htmlspecialchars($translations['mail_signature'] ?? 'USLUGI.FR', ENT_QUOTES, 'UTF-8') . "</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>";
|
||||
|
||||
$text = strip_tags(
|
||||
$translations['mail_bonjour']."\n\n".
|
||||
$translations['mail_phrase_code']."\n".
|
||||
$code."\n".
|
||||
$translations['mail_phrase_validite']."\n\n".
|
||||
$translations['mail_signature']
|
||||
($translations['mail_bonjour'] ?? 'Bonjour') . "\n\n" .
|
||||
($translations['mail_phrase_code'] ?? 'Voici votre code de réinitialisation :') . "\n" .
|
||||
$code . "\n" .
|
||||
($translations['mail_phrase_validite'] ?? 'Ce code est valable pendant un temps limité.') . "\n\n" .
|
||||
($translations['mail_signature'] ?? 'USLUGI.FR')
|
||||
);
|
||||
|
||||
// Envoi via PHPMailer helper
|
||||
list($ok, $err) = uslugi_mail($email, $sujet, $html, $text);
|
||||
if (!$ok) {
|
||||
|
||||
if (! $ok) {
|
||||
error_log("Reset code mail NOT sent to $email : $err");
|
||||
// On reste silencieux pour l’utilisateur
|
||||
// on reste neutre côté utilisateur
|
||||
}
|
||||
|
||||
// On peut rediriger seulement si le compte existe
|
||||
header("Location: verifier_code.php");
|
||||
exit;
|
||||
} else {
|
||||
// Ton message existant si l'email est inconnu
|
||||
$message = $translations['erreur_email_inconnu'];
|
||||
}
|
||||
|
||||
// Email inconnu → message neutre, pas de détail
|
||||
$message = $translations['mdp_oublie_message_neutre'] ?? 'Si un compte existe pour cette adresse, un code a été envoyé.';
|
||||
$messageType = 'success';
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title><?= $translations['mdp_oublie_title'] ?></title>
|
||||
<title><?php echo htmlspecialchars($translations['mdp_oublie_title'] ?? 'Mot de passe oublié', ENT_QUOTES, 'UTF-8') ?></title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="<?= asset('/includes/site_style.css') ?>">
|
||||
<link rel="stylesheet" href="<?= asset('/includes/custom_style.css') ?>"> <!-- ta home -->
|
||||
|
||||
<link rel="stylesheet" href="<?= asset('/includes/mobil_style.css') ?>">
|
||||
<link rel="stylesheet" href="<?php echo asset('/includes/site_style.css') ?>">
|
||||
<link rel="stylesheet" href="<?php echo asset('/includes/custom_style.css') ?>">
|
||||
<link rel="stylesheet" href="<?php echo asset('/includes/mobil_style.css') ?>">
|
||||
<?php include_once __DIR__ . '/includes/tracking.php'; ?>
|
||||
</head>
|
||||
<body>
|
||||
<header class="site-header">
|
||||
<div class="container">
|
||||
<div class="header-left">
|
||||
<div class="brand">
|
||||
<a href="/index.php"><img src="/public/uploads/img/logo_u.png"
|
||||
alt="uslugi.fr"
|
||||
class="logo-mobile"></a>
|
||||
|
||||
<a href="/index.php"><img src="/public/uploads/img/logo.png"
|
||||
alt="uslugi.fr"
|
||||
class="logo-desktop"></a>
|
||||
</div>
|
||||
<div class="lang-switch">
|
||||
<div class="brand">
|
||||
<a href="/index.php"><img src="/public/uploads/img/logo_u.png" alt="uslugi.fr" class="logo-mobile"></a>
|
||||
<a href="/index.php"><img src="/public/uploads/img/logo.png" alt="uslugi.fr" class="logo-desktop"></a>
|
||||
</div>
|
||||
<div class="lang-switch">
|
||||
<?php require __DIR__ . '/includes/menu_langue.php'; ?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -113,37 +108,42 @@ if (($_SERVER['REQUEST_METHOD'] ?? '') === 'POST') {
|
||||
type="button" data-bs-toggle="dropdown" data-bs-auto-close="true"
|
||||
aria-expanded="false" aria-label="Помощь">?</button>
|
||||
<ul class="dropdown-menu dropdown-menu-end shadow help-menu menu-panel">
|
||||
<li><a href="/how-it-work.php"><?= $translations['kak_rabotaet'] ?></a></a></li>
|
||||
<li><a href="/about.php"><?= $translations['pro_nas'] ?></a></li>
|
||||
<li><a href="/faq.php"><?= $translations['faq'] ?></a></li>
|
||||
<li><a href="/contact.php"><?= $translations['nam_pisat'] ?></a></li>
|
||||
<li><a href="/how-it-work.php"><?php echo $translations['kak_rabotaet'] ?></a></li>
|
||||
<li><a href="/about.php"><?php echo $translations['pro_nas'] ?></a></li>
|
||||
<li><a href="/faq.php"><?php echo $translations['faq'] ?></a></li>
|
||||
<li><a href="/contact.php"><?php echo $translations['nam_pisat'] ?></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="main">
|
||||
<div class="card shadow-sm p-4" style="min-width:380px; max-width:520px; margin:40px auto;">
|
||||
<h3 class="mb-4 text-center"><?= $translations['mdp_oublie_h3'] ?></h3>
|
||||
<h3 class="mb-4 text-center"><?php echo htmlspecialchars($translations['mdp_oublie_h3'] ?? 'Mot de passe oublié', ENT_QUOTES, 'UTF-8') ?></h3>
|
||||
|
||||
<?php if (!empty($message)): ?>
|
||||
<div class="alert alert-danger py-2"><?= htmlspecialchars($message, ENT_QUOTES, 'UTF-8') ?></div>
|
||||
<?php if (! empty($message)): ?>
|
||||
<div class="alert alert-<?php echo $messageType === 'success' ? 'success' : 'danger' ?> py-2">
|
||||
<?php echo htmlspecialchars($message, ENT_QUOTES, 'UTF-8') ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="POST" novalidate>
|
||||
<div class="mb-3">
|
||||
<input type="email" name="email" class="form-control" placeholder="<?= $translations['placeholder_email'] ?>" required>
|
||||
<input type="email" name="email" class="form-control"
|
||||
placeholder="<?php echo htmlspecialchars($translations['placeholder_email'] ?? 'Email', ENT_QUOTES, 'UTF-8') ?>"
|
||||
required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary w-100"><?= $translations['btn_envoyer_code'] ?></button>
|
||||
<button type="submit" class="btn btn-primary w-100">
|
||||
<?php echo htmlspecialchars($translations['btn_envoyer_code'] ?? 'Envoyer le code', ENT_QUOTES, 'UTF-8') ?>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="site-footer">
|
||||
<div class="container">
|
||||
<p><?= $translations['copyr'] ?></p>
|
||||
<p><?php echo $translations['copyr'] ?></p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
Reference in new issue
Block a user