<?php
require_once dirname(__DIR__) . '/config.php';

header('Content-Type: application/json');

$user_id = $_SESSION['user_id'] ?? 0;
$version = $_POST['version'] ?? '';

if ($user_id <= 0 || empty($version)) {
    echo json_encode(['success' => false]);
    exit;
}

// 检查是否已记录
$exists = $db->fetchOne("SELECT id FROM user_version_reminders WHERE user_id = $user_id AND version = '$version'");
if (!$exists) {
    $db->query("INSERT INTO user_version_reminders (user_id, version) VALUES ($user_id, '$version')");
}

echo json_encode(['success' => true]);
?>