<?php
require_once __DIR__ . '/db/config.php';

if (isset($_GET['type'])) {
    $type = $_GET['type'];
    try {
        $db = db();
        $stmt = $db->prepare("INSERT INTO click_logs (event_type) VALUES (:type)");
        $stmt->execute(['type' => $type]);
    } catch (Exception $e) {
        error_log("Click tracking error: " . $e->getMessage());
    }
}

if (isset($_GET['redirect'])) {
    header("Location: " . $_GET['redirect']);
    exit;
}
