<?php
declare(strict_types=1);

// Static order gate because the dangerous race entry stays disabled.
$source = (string)file_get_contents(__DIR__ . '/race_execute.disabled.php');
$intent = strpos($source, "'phase' => 'fixture_intent'");
$menuInsert = strpos($source, "' (UUID,PUBLIC_TOKEN,STORE_ID,STATUS,IS_DELETE,DISPLAY_MODE,'");
$bindInsert = strpos($source, "' (MENU_ID,CODE_HASH,EXPIRES_AT,USED_AT,STATUS,STORE_ID,'");
$cases = [
    'hard_disabled' => strpos($source, 'const RACE_OWNED_WRITE_REVIEWED = false;') !== false,
    'intent_before_menu_insert' => $intent !== false && $menuInsert !== false
        && $intent < $menuInsert,
    'intent_before_bind_insert' => $intent !== false && $bindInsert !== false
        && $intent < $bindInsert,
    'worker_start_generation' => strpos($source, 'raceReadProcStat($pid)') !== false
        && strpos($source, "['worker_start_ticks'][\$side]") !== false,
    'worker_command_root_router' => strpos($source, "'/public'") !== false
        && strpos($source, 'race_router.disabled.php') !== false,
];
if (in_array(false, $cases, true)) {
    echo json_encode(['status' => 'offline_source_fail', 'cases' => $cases]), PHP_EOL;
    exit(1);
}
echo json_encode(['status' => 'offline_source_pass', 'cases' => $cases,
    'http' => false, 'dml' => false]), PHP_EOL;
