<?php
if (session_status() !== PHP_SESSION_ACTIVE) {
    session_start();
}
date_default_timezone_set("Asia/Jakarta");

$call = mysqli_connect('localhost', 'noxp_asgapi', 'noxp_asgapi', 'noxp_asgapi');
if(!$call){
    die("Error: ".mysqli_connect_error());
}

require_once __DIR__ . '/agent_identity.php';

function str_acak($n) {
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $randomString = '';
    
    for ($i = 0; $i < $n; $i++) {
        $index = rand(0, strlen($characters) - 1);
        $randomString .= $characters[$index];
    }
    
    return $randomString;
}
function hide_token(string $string, string $chars = '*', int $length = 6, int $init = 3): string {
    $getString  = $string;  // String yang akan disensor.
    $getChars   = $chars;   // Karakter yang akan digunakan.
    $getLength  = $length;  // Panjang karakter sensor.
    $getInit    = $init;    // Jumlah default karakter sensor.
    return substr_replace($getString, str_repeat($getChars, (strlen($getString) - $getLength)), $getInit, (strlen($getString) - $getLength));
}
?>
