<?php
declare(strict_types=1);

require_once __DIR__ . "/../../includes/db.php";
require_once __DIR__ . "/../../includes/session_staff.php";

function h($s): string { return htmlspecialchars((string)$s, ENT_QUOTES, "UTF-8"); }

function json_input(): array {
  $raw = file_get_contents("php://input");
  $data = json_decode($raw, true);
  return is_array($data) ? $data : [];
}

function json_out(array $arr, int $code=200): void {
  http_response_code($code);
  header("Content-Type: application/json; charset=utf-8");
  echo json_encode($arr, JSON_UNESCAPED_UNICODE);
  exit;
}
