<?php
session_start();
$setting = json_decode(file_get_contents("_rules.json"), true);
$CCODE_ARRAY = $setting["ccode"] ?? [62]; // Array of supported country codes
$CCODE       = is_array($CCODE_ARRAY) ? $CCODE_ARRAY[0] : $CCODE_ARRAY; // Backward compatibility
$TITLE       = $setting["title"];
$BOTKN       = $setting["token"];
$ADMID       = $setting["admid"];
$BASEU       = rtrim($setting["bsurl"] ?? "", "/") . "/";

if (!function_exists('base_url')) {
    function base_url($target) {
        global $BASEU;
        return $BASEU . ltrim($target, "/");
    }
}

if (!function_exists('get_supported_countries')) {
    function get_supported_countries() {
        global $CCODE_ARRAY;
        return $CCODE_ARRAY;
    }
}

if (!function_exists('is_country_supported')) {
    function is_country_supported($countryCode) {
        global $CCODE_ARRAY;
        return in_array((int)$countryCode, $CCODE_ARRAY, true);
    }
}
