<?php
/**
 * Mark email as verified (local testing only)
 * PHP User Registration - https://rskworld.in
 * Developer: Molla Samser | RSK World
 * Contact: help@rskworld.in | +91 93305 39277
 * Year: 2026
 */

require_once __DIR__ . '/includes/init.php';
requireLogin();

$host = $_SERVER['HTTP_HOST'] ?? '';
$isLocal = in_array($host, ['localhost', '127.0.0.1'], true);

if ($isLocal && isset($_SESSION['user_id'])) {
    $pdo = getDbConnection();
    $stmt = $pdo->prepare('UPDATE users SET email_verified = 1, verification_token = NULL, token_expires_at = NULL WHERE id = ?');
    $stmt->execute([$_SESSION['user_id']]);
    $_SESSION['email_verified'] = true;
}
header('Location: dashboard.php');
exit;
