add user confirmation
This commit is contained in:
@@ -29,6 +29,45 @@ if (isset($_GET['toggle_active']) && is_numeric($_GET['toggle_active'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Gestione re-invio email verifica
|
||||
if (isset($_GET['resend_verification']) && is_numeric($_GET['resend_verification'])) {
|
||||
$user_id = (int)$_GET['resend_verification'];
|
||||
|
||||
try {
|
||||
$pdo = get_db_connection();
|
||||
$stmt = $pdo->prepare("SELECT id, email, first_name, email_verified FROM users WHERE id = ?");
|
||||
$stmt->execute([$user_id]);
|
||||
$user = $stmt->fetch();
|
||||
|
||||
if ($user && !$user['email_verified']) {
|
||||
// Genera nuovo token
|
||||
$email_token = bin2hex(random_bytes(32));
|
||||
$token_expires = date('Y-m-d H:i:s', strtotime('+24 hours'));
|
||||
|
||||
$stmt = $pdo->prepare("UPDATE users SET email_token = ?, email_token_expires = ? WHERE id = ?");
|
||||
$stmt->execute([$email_token, $token_expires, $user_id]);
|
||||
|
||||
// Invia email
|
||||
$verify_url = SITE_URL . "/verify_email.php?token=" . $email_token;
|
||||
$subject = "Conferma il tuo account su " . SITE_NAME;
|
||||
$body = "<p>Ciao <strong>" . htmlspecialchars($user['first_name']) . "</strong>,</p>
|
||||
<p>Un amministratore ha inviato nuovamente il link di verifica per il tuo account.</p>
|
||||
<p><a href='" . $verify_url . "' style='display: inline-block; padding: 12px 30px; background: #667eea; color: white; text-decoration: none; border-radius: 5px;'>Conferma Email</a></p>
|
||||
<p>Questo link è valido per 24 ore.</p>";
|
||||
|
||||
send_email($user['email'], $subject, $body);
|
||||
set_flash_message('success', 'Email di verifica inviata a ' . htmlspecialchars($user['email']));
|
||||
} else {
|
||||
set_flash_message('error', 'Utente già verificato o non trovato');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
set_flash_message('error', 'Errore durante l\'invio dell\'email');
|
||||
}
|
||||
|
||||
header('Location: users.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Ottieni tutti gli utenti non admin
|
||||
$pdo = get_db_connection();
|
||||
$stmt = $pdo->query("
|
||||
@@ -102,6 +141,7 @@ $users = $stmt->fetchAll();
|
||||
<tr>
|
||||
<th>Nome</th>
|
||||
<th>Email</th>
|
||||
<th>Stato Email</th>
|
||||
<th>Registrato il</th>
|
||||
<th>Ultimo Accesso</th>
|
||||
<th>Acquisti</th>
|
||||
@@ -116,7 +156,16 @@ $users = $stmt->fetchAll();
|
||||
<td>
|
||||
<strong><?php echo htmlspecialchars($user['first_name'] . ' ' . $user['last_name']); ?></strong>
|
||||
</td>
|
||||
<td><?php echo htmlspecialchars($user['email']); ?></td>
|
||||
<td>
|
||||
<?php echo htmlspecialchars($user['email']); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if ($user['email_verified']): ?>
|
||||
<span class="text-success">✓ Verificata</span>
|
||||
<?php else: ?>
|
||||
<span class="text-warning">⚠️ Non verificata</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><?php echo format_date($user['created_at']); ?></td>
|
||||
<td>
|
||||
<?php
|
||||
@@ -137,6 +186,14 @@ $users = $stmt->fetchAll();
|
||||
class="btn btn-small <?php echo $user['is_active'] ? 'btn-danger' : 'btn-success'; ?>">
|
||||
<?php echo $user['is_active'] ? 'Blocca' : 'Sblocca'; ?>
|
||||
</a>
|
||||
<?php if (!$user['email_verified']): ?>
|
||||
<a href="users.php?resend_verification=<?php echo $user['id']; ?>"
|
||||
class="btn btn-small btn-secondary"
|
||||
style="margin-left: 5px;"
|
||||
onclick="return confirm('Inviare nuovamente l\'email di verifica?');">
|
||||
📧 Re-Invia
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
||||
Reference in New Issue
Block a user