<?php
require_once __DIR__ . '/../auth.php';
require_once __DIR__ . '/../helpers.php';
require_once __DIR__ . '/../mikrotik_lib.php';

require_login();
if(function_exists('require_perm')) require_perm('can_settings');

header('Content-Type: application/json; charset=utf-8');

try {
  $list = mt_list_interfaces($conn);
  echo json_encode(['ok'=>true,'interfaces'=>$list], JSON_UNESCAPED_UNICODE);
} catch (Throwable $e) {
  echo json_encode(['ok'=>false,'error'=>$e->getMessage()], JSON_UNESCAPED_UNICODE);
}
