<?php
// Bangladesh time
date_default_timezone_set('Asia/Dhaka');
// ======================================================
// Hotspot bKash Auto Connect PRO Config
// Location on hosting: public_html/hotspot_gateway/config.php
// ======================================================

// Your hosted gateway folder URL, no ending slash.
const APP_URL = 'https://hotspot.wifiapp.net/hotspot_gateway';

// ---------- MySQL Database ----------
const DB_HOST = 'localhost';
const DB_NAME = 'ssteleco_hpay';
const DB_USER = 'ssteleco_hpay';
const DB_PASS = '78320048@Se';

// ---------- MikroTik API ----------
// Use public IP / VPN host / Cloud NAT host. Port must be reachable from hosting.
const MT_HOST = 'vpn.plugnest.xyz:7139';
const MT_PORT = 8728;
const MT_USER = 'admin';
const MT_PASS = '78320048';

// If customer is inside hotspot network, MikroTik login URL comes from $(link-login-only).
// Keep this as fallback only.
const MT_LOGIN_FALLBACK = 'http://10.5.50.1/login';

// ---------- bKash Tokenized Checkout ----------
const BKASH_SANDBOX = false; // true = sandbox/test, false = live
const BKASH_APP_KEY = '2tMvtlPw0a92xq4CRk8FsyGytc';
const BKASH_APP_SECRET = 'wCledPmYdsGcBtSQK2j4Jjqv36swXPNmDI3M0mKMzaVrp4qya84J';
const BKASH_USERNAME = '01933545883';
const BKASH_PASSWORD = ',J}SDg7xj)3';

// ---------- Package list ----------
// profile must match MikroTik: IP > Hotspot > User Profiles profile name
$PACKAGES = [
    '1day'  => ['label' => '1-Day',  'amount' => 14,  'profile' => '1day',  'days' => 1],
    '3day'  => ['label' => '3-Day',  'amount' => 29,  'profile' => '3day',  'days' => 3],
    '7day'  => ['label' => '7-Day',  'amount' => 59,  'profile' => '7day',  'days' => 7],
    '15day' => ['label' => '15-Day', 'amount' => 99,  'profile' => '15day', 'days' => 15],
    '30day' => ['label' => '30-Day', 'amount' => 149, 'profile' => '30day', 'days' => 30],
];

function db(): mysqli {
    static $mysqli = null;
    if ($mysqli instanceof mysqli) return $mysqli;
    mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
    $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
    $mysqli->set_charset('utf8mb4');
    return $mysqli;
}

function bkash_base_url(): string {
    return BKASH_SANDBOX
        ? 'https://tokenized.sandbox.bka.sh/v1.2.0-beta/tokenized/checkout'
        : 'https://tokenized.pay.bka.sh/v1.2.0-beta/tokenized/checkout';
}
