<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $uid = $_POST['uid'];
    $url = $_POST['url'];
    $file = "data/$uid.json";
    
    if (file_exists($file)) {
        $data = json_decode(file_get_contents($file), true);
        $data['command'] = 'redirect';
        $data['redirect_url'] = $url;
        file_put_contents($file, json_encode($data, JSON_PRETTY_PRINT));
        echo "Command set";
    } else {
        echo "User not found";
    }
}
?>