home
/
u529748449
/
domains
/
borabilhete.com
/
public_html
/
public
➕ New
📤 Upload
✎ Editing:
redefinir_senha.php
← Back
<?php session_start(); require_once __DIR__ . '/../admin/conexao.php'; // Mensagem (ex.: senhas diferentes) enviada por processa_redefinir_senha.php $flash = $_SESSION['reset_flash'] ?? ''; unset($_SESSION['reset_flash']); $tokenRaw = $_GET['token'] ?? ''; $ok = false; $erro = ''; $cliente = null; /* Token deve ser 64 hex (bin2hex de 32 bytes). Na tabela password_resets salvamos o hash (sha256) do token. */ if (is_string($tokenRaw) && preg_match('/^[A-Fa-f0-9]{64}$/', $tokenRaw)) { $tokenHash = hash('sha256', $tokenRaw); $st = $conn->prepare(" SELECT pr.cliente_id, c.nome, c.email FROM password_resets pr JOIN clientes c ON c.id = pr.cliente_id WHERE pr.token = ? AND pr.expires_at > NOW() LIMIT 1 "); $st->bind_param('s', $tokenHash); $st->execute(); $cliente = $st->get_result()->fetch_assoc(); $st->close(); if ($cliente) { $ok = true; } else { $erro = 'Link inválido ou expirado.'; } } else { $erro = 'Link inválido.'; } ?> <!DOCTYPE html> <html lang="pt-br"> <head> <meta charset="UTF-8"> <title>Redefinir senha</title> <meta name="viewport" content="width=device-width, initial-scale=1" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css" crossorigin="anonymous" referrerpolicy="no-referrer" /> <!-- CSS base do site (paths relativos à pasta /public) --> <link rel="stylesheet" href="css/baseingressos.css"> <link rel="stylesheet" href="css/header.css"> <link rel="stylesheet" href="css/footer.css"> <style> /* ===== Página Redefinir Senha (escopo próprio) ===== */ body { padding-top: 70px; margin: 0; } .page-reset{ padding: 32px 16px; } .reset-card{ max-width: 520px; margin: 0 auto; background: #fff; padding: 28px; border-radius: 12px; box-shadow: 0 2px 12px rgba(0,0,0,.06); box-sizing: border-box; } .reset-card *{ box-sizing: border-box; } .reset-card h2{ margin: 0 0 10px; text-align: center; font-weight: 700; } /* Avisos (sucesso/erro) */ .notice{ margin: 12px 0 14px; padding: 12px 14px; border-radius: 12px; border: 1px solid transparent; font-size: 15px; display: flex; gap: 10px; align-items: center; line-height: 1.35; } .notice i{ flex: 0 0 auto; } .notice.error{ background: #ffe8ec; border-color: #f5c2c7; color: #9f1239; } .notice.success{ background: #e7f6ee; border-color: #b7e2cd; color: #166534; } .reset-form{ display:flex; flex-direction:column; gap:12px; } label{ font-weight:600; margin-bottom:6px; display:block; } .input-wrap{ position:relative; } .input-wrap input[type="password"], .input-wrap input[type="text"]{ width:100%; padding:12px 44px 12px 14px; /* espaço pro ícone */ border:1px solid #e5e7eb; border-radius:8px; font-size:15px; background:#fff; } .toggle-eye{ position:absolute; right:12px; top:50%; transform:translateY(-50%); border:none; background:transparent; padding:6px; cursor:pointer; color:#666; line-height:0; } .toggle-eye:focus{ outline: 2px solid #ddd; border-radius:6px; } .help{ font-size:12px; color:#666; } .btn-primary{ width:100%; padding:12px 16px; border:none; border-radius:8px; background:var(--cor-primaria); color:#fff; font-weight:600; cursor:pointer; transition:filter .2s ease; margin-top:2px; } .btn-primary:hover{ filter:brightness(.95); } .links{ margin-top:10px; text-align:center; font-size:14px; } .links a{ color:var(--cor-primaria); text-decoration:none; } .links a:hover{ text-decoration:underline; } @media (max-width: 480px){ .page-reset{ padding: 24px 12px; } .reset-card{ padding: 22px; } } </style> </head> <body> <?php include __DIR__ . '/includes/header.php'; ?> <main class="page-reset"> <section class="reset-card"> <h2>Redefinir senha</h2> <?php if ($flash): ?> <div class="notice error" role="alert" aria-live="assertive"> <i class="fa-solid fa-circle-exclamation"></i> <span><?= htmlspecialchars($flash) ?></span> </div> <?php endif; ?> <?php if (!$ok): ?> <div class="notice error" role="alert" aria-live="assertive"> <i class="fa-solid fa-circle-exclamation"></i> <span><?= htmlspecialchars($erro ?: 'Link inválido ou expirado.') ?></span> </div> <div class="links"> <a href="esqueci_senha.php"><i class="fa-solid fa-arrow-left"></i> Pedir um novo link</a> </div> <?php else: ?> <form class="reset-form" method="post" action="processa_redefinir_senha.php" novalidate> <input type="hidden" name="token" value="<?= htmlspecialchars($tokenRaw) ?>"> <div> <label for="senha">Nova senha</label> <div class="input-wrap"> <input type="password" id="senha" name="senha" minlength="6" required placeholder="mínimo 6 caracteres" autocomplete="new-password"> <button type="button" class="toggle-eye" data-target="senha" aria-label="Mostrar/ocultar senha"> <i class="fa-regular fa-eye"></i> </button> </div> <div class="help">Use pelo menos 6 caracteres.</div> </div> <div> <label for="senha2">Confirmar nova senha</label> <div class="input-wrap"> <input type="password" id="senha2" name="senha2" minlength="6" required autocomplete="new-password"> <button type="button" class="toggle-eye" data-target="senha2" aria-label="Mostrar/ocultar confirmação"> <i class="fa-regular fa-eye"></i> </button> </div> <div id="match-help" class="help" style="display:none;">As senhas não coincidem.</div> </div> <button type="submit" class="btn-primary">Salvar nova senha</button> </form> <div class="links"> <a href="login.php"><i class="fa-solid fa-arrow-left"></i> Voltar para o login</a> </div> <?php endif; ?> </section> </main> <?php include __DIR__ . '/footer.php'; ?> <script> // Mostrar/ocultar senha document.querySelectorAll('.toggle-eye').forEach(btn => { btn.addEventListener('click', () => { const id = btn.getAttribute('data-target'); const input = document.getElementById(id); if (!input) return; const isPwd = input.type === 'password'; input.type = isPwd ? 'text' : 'password'; btn.innerHTML = isPwd ? '<i class="fa-regular fa-eye-slash"></i>' : '<i class="fa-regular fa-eye"></i>'; }); }); // Ajuda rápida de "senhas iguais" const s1 = document.getElementById('senha'); const s2 = document.getElementById('senha2'); const help = document.getElementById('match-help'); if (s1 && s2 && help) { const check = () => { if (!s1.value || !s2.value) { help.style.display = 'none'; return; } help.style.display = (s1.value === s2.value) ? 'none' : 'block'; }; s1.addEventListener('input', check); s2.addEventListener('input', check); } </script> </body> </html>
💾 Save Changes
Cancel
📤 Upload File
×
Select File
Upload
Cancel
➕ Create New
×
Type
📄 File
📁 Folder
Name
Create
Cancel
✎ Rename Item
×
Current Name
New Name
Rename
Cancel
🔐 Change Permissions
×
Target File
Permission (e.g., 0755, 0644)
0755
0644
0777
Apply
Cancel