<?php
require_once __DIR__ . "/../Febe.php";
$febe = new Febe;
$febe->setCurrentSubFolderLanguageCookie();
function getTrackingUrl(): string
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://server.4markets.net/api/v2/offers/tracking-domain");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        "Referer: https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'],
    ]);
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
    $response = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

    if ($httpCode != 200) {
        return "";
    }
    if (empty($response)) {
        return "";
    }

    $responseTrackingDomainJson = json_decode($response);

    if (empty($responseTrackingDomainJson)) {
        return "";
    }

    return $responseTrackingDomainJson->details->endpoint;
}

$trackingUrl = getTrackingUrl();
?>
<!DOCTYPE html>
<html data-intgrtn-language="location">

<meta http-equiv="content-type" content="text/html;charset=UTF-8"/>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title><?php echo $title;?></title>
    <base href="<?= $febe->getHref(); ?>">

    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link rel="icon" type="image/x-icon" href="img/fico.png">
    <script data-cfasync="false" src="js/jquery.min.js"></script>
    <link href="https://fonts.googleapis.com/css2?family=Lato&amp;family=Montserrat:wght@300;400;500;600;700&amp;family=Oswald:wght@600;700&amp;display=swap"
          rel="stylesheet">
    <link rel="stylesheet" href="css/calculator.css">
    <link rel="stylesheet" href="css/style.css">
    <link href="css/footer-top-level.css" rel="stylesheet" rel="preload" as="style">
    <style>
        .gc-footer__container {
            max-width: 1110px;
        }

        input[type=checkbox] {
            display: inline-block !important;
        }

        label.checkbox {
            margin-left: 10px
        }
    </style>

    <link rel="stylesheet" href="css/intgrtn.css">
