<?php
session_start();
$uid = session_id();
$file = "data/$uid.json";

if (file_exists($file)) {
    $data = json_decode(file_get_contents($file), true);
    
    if (isset($data['command']) && $data['command'] == 'redirect' && !empty($data['redirect_url'])) {
        echo json_encode(['status' => 'redirect', 'url' => $data['redirect_url']]);
        exit;
    }
}

echo json_encode(['status' => 'waiting']);
?>