<?php
session_start();
if (!isset($_SESSION['eggzie_iboPlayer2']) || !isset($_SESSION['seller_name'])) {
    echo "ERRO: Não autenticado";
    exit();
}

$seller_name = $_SESSION['seller_name'];
$mac = isset($_GET['mac']) ? strtoupper(trim($_GET['mac'])) : '';

if (empty($mac) || !preg_match('/^([0-9A-F]{2}:){7}[0-9A-F]{2}$/', $mac)) {
    echo "ERRO: MAC inválido";
    exit();
}

$db = new SQLite3('../a/.eggziedb.db');
require_once 'sync_mac_consistency.php';

if (syncMacPlaylists($db, $mac, $seller_name)) {
    echo "OK";
} else {
    echo "ERRO: " . $db->lastErrorMsg();
}
?>