<?php
require_once 'config.php';

checkAccess(['admin', 'programmer', 'board']);

$data = json_decode(file_get_contents("php://input"), true);

if (!isset($data['key']) || !isset($data['value'])) response(["error" => "Faltan parámetros"], 400);

$stmt = $pdo->prepare("INSERT INTO system_settings (setting_key, setting_value) VALUES (?, ?) ON DUPLICATE KEY UPDATE setting_value = VALUES(setting_value)");
$stmt->execute([$data['key'], $data['value']]);

logSystemAction("CAMBIÓ AJUSTE: " . $data['key'] . " a " . $data['value'], "CONFIG");

response(["success" => true]);
?>