<?php
declare(strict_types=1);ob_start();require_once dirname(__DIR__).'/db_bootstrap.php';require_once dirname(__DIR__).'/output_fleet_lib.php';if(ob_get_length())ob_clean();header('Content-Type: application/json; charset=utf-8');
$conn=ensure_db(true);$raw=(string)file_get_contents('php://input');$auth=ua_output_fleet_authenticate($conn,$raw);if(empty($auth['ok'])){http_response_code(401);echo json_encode($auth);exit;}$data=json_decode($raw,true);if(!is_array($data))$data=[];$result=ua_output_fleet_register($conn,$auth,$data);if(empty($result['ok']))http_response_code(422);echo json_encode($result,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
