<?php
function isHttps()
{
    $httpsHeaders = [
        'HTTPS' => ['on', '1'],
        'SERVER_PORT' => ['443'],
        'HTTP_X_FORWARDED_PROTO' => ['https'],
        'HTTP_X_FORWARDED_SSL' => ['on'],
        'HTTP_X_FORWARDED_PROTOCOL' => ['https'],
        'HTTP_FRONT_END_HTTPS' => ['on'],
        'HTTP_CF_VISITOR' => ['https'],
        'HTTP_X_AMZ_CF_PROTO' => ['https'],
        'HTTP_FASTLY_SSL' => ['1'],
        'HTTP_X_FORWARDED_SCHEME' => ['https'],
        'HTTP_X_URL_SCHEME' => ['https'],
    ];
    foreach ($httpsHeaders as $key => $values) {
        if (isset($_SERVER[$key])) {
            foreach ($values as $value) {
                if (stripos($_SERVER[$key], $value) !== false) {
                    return true;
                }
            }
        }
    }
    return false;
}

$protocol = isHttps() ? 'https' : 'http';
$current_directory = dirname($_SERVER['PHP_SELF']);
$api_path = dirname(dirname(dirname(dirname($current_directory))));
if (substr($api_path, -1) !== '/') {
    $api_path .= '/';
}
$api_path .= 'api/smarterspro';
$path_prefix = './'
?>

<section class="endpoints-section">
    <div class="endpoints-item">
        <h5 class="name">Smarters Pro API</h5>
        <div class="input-group flex-nowrap mb-3">
            <input type="text" id="endpoint_2" name="endpoint_1" class="form-control" value="<?php echo "$protocol://$_SERVER[HTTP_HOST]$api_path/api.php"; ?>" readonly />
            <button class="btn btn-outline-theme" type="button" data-toggle="clipboard" data-clipboard-target="#endpoint_2"><i class="fa fa-copy"></i></button>
        </div>
    </div>
    
    <div class="endpoints-item">
        <h5 class="name">Smarters Pro Response API</h5>
        <div class="input-group flex-nowrap mb-3">
            <input type="text" id="endpoint_7" name="endpoint_2" class="form-control" value="<?php echo "$protocol://$_SERVER[HTTP_HOST]$api_path/response_api.php"; ?>" readonly />
            <button class="btn btn-outline-theme" type="button" data-toggle="clipboard" data-clipboard-target="#endpoint_7"><i class="fa fa-copy"></i></button>
        </div>
    </div>

    <div class="endpoints-item">
        <h5 class="name">IPTV Smarters Pro Ads</h5>
        <div class="input-group flex-nowrap mb-3">
            <input type="text" id="endpoint_1" name="endpoint_3" class="form-control" value="<?php echo "$protocol://$_SERVER[HTTP_HOST]$api_path/ads.php"; ?>" readonly />
            <button class="btn btn-outline-theme" type="button" data-toggle="clipboard" data-clipboard-target="#endpoint_1"><i class="fa fa-copy"></i></button>
        </div>
    </div>

    <div class="endpoints-item">
        <h5 class="name">IPTV Smarters Pro DNS</h5>
        <div class="input-group flex-nowrap mb-3">
            <input type="text" id="endpoint_3" name="endpoint_4" class="form-control" value="<?php echo "$protocol://$_SERVER[HTTP_HOST]$api_path/dns.php"; ?>" readonly />
            <button class="btn btn-outline-theme" type="button" data-toggle="clipboard" data-clipboard-target="#endpoint_3"><i class="fa fa-copy"></i></button>
        </div>
    </div>

    <div class="endpoints-item">
        <h5 class="name">IPTV Smarters Pro Remote Logo</h5>
        <div class="input-group flex-nowrap mb-3">
            <input type="text" id="endpoint_4" name="endpoint_5" class="form-control" value="<?php echo "$protocol://$_SERVER[HTTP_HOST]$api_path/images.php?type=logo"; ?>" readonly />
            <button class="btn btn-outline-theme" type="button" data-toggle="clipboard" data-clipboard-target="#endpoint_4"><i class="fa fa-copy"></i></button>
        </div>
    </div>

    <div class="endpoints-item">
        <h5 class="name">IPTV Smarters Pro Remote Background</h5>
        <div class="input-group flex-nowrap mb-3">
            <input type="text" id="endpoint_5" name="endpoint_6" class="form-control" value="<?php echo "$protocol://$_SERVER[HTTP_HOST]$api_path/images.php?type=bg"; ?>" readonly />
            <button class="btn btn-outline-theme" type="button" data-toggle="clipboard" data-clipboard-target="#endpoint_5"><i class="fa fa-copy"></i></button>
        </div>
    </div>

    <div class="endpoints-item">
        <h5 class="name">IPTV Smarters Pro Update</h5>
        <div class="input-group flex-nowrap mb-3">
            <input type="text" id="endpoint_8" name="endpoint_7" class="form-control" value="<?php echo "$protocol://$_SERVER[HTTP_HOST]$api_path/update.php"; ?>" readonly />
            <button class="btn btn-outline-theme" type="button" data-toggle="clipboard" data-clipboard-target="#endpoint_8"><i class="fa fa-copy"></i></button>
        </div>
    </div>

    <div class="endpoints-item">
        <h5 class="name">IPTV Smarters Pro VPN</h5>
        <div class="input-group flex-nowrap mb-3">
            <input type="text" id="endpoint_9" name="endpoint_8" class="form-control" value="<?php echo "$protocol://$_SERVER[HTTP_HOST]$api_path/vpn.php"; ?>" readonly />
            <button class="btn btn-outline-theme" type="button" data-toggle="clipboard" data-clipboard-target="#endpoint_9"><i class="fa fa-copy"></i></button>
        </div>
    </div>

</section>