<?php
// salve este em /
if (!empty($_GET['code'])) {
    $code = $_GET['code'];
    $db = new PDO('sqlite:api/max.db');
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $db->exec("
        CREATE TABLE IF NOT EXISTS activations (
            code TEXT PRIMARY KEY,
            user TEXT,
            status TEXT
        )");
    // Insere ou ignora se já existir
    $stmt = $db->prepare("INSERT OR IGNORE INTO activations (code, status) VALUES (:code, 'pending')");
    $stmt->execute([':code' => $code]);
}
