<?php
session_start();
require(realpath(__DIR__ . '/../../../services/Model.php'));

$obj = new Model();

header('Content-Type: application/json');

$input = json_decode(file_get_contents("php://input"), true);

$mikrotikId = $input['mikrotik_id'] ?? null;
$secretName  = $input['secret_name'] ?? null;

if (!$mikrotikId || !$secretName) {
    echo json_encode([
        'status' => false,
        'error' => 'missing params'
    ]);
    exit;
}

// ONLY THIS CALL (your heavy function)
$result = $obj->showSingleResellerSecret($mikrotikId, $secretName);

$isDisabled = !empty($result['disabled']) ? (bool)$result['disabled'] : false;

echo json_encode([
    'status' => true,
    'disabled' => $result['disabled']
]);