<?php
$baseHref = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
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 lang="pl">
<meta http-equiv="content-type" content="text/html;charset=UTF-8"/>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <base href="<?= $baseHref; ?>">

    <style class="vjs-styles-defaults">
        .video-js {
            width: 300px;
            height: 150px;
        }

        .vjs-fluid {
            padding-top: 56.25%
        }
    </style>
    <style class="vjs-styles-dimensions">
        .vjs_video_3-dimensions {
            width: 640px;
            height: 360px;
        }

        .vjs_video_3-dimensions.vjs-fluid {
            padding-top: 56.25%;
        }
    </style>
    <link rel="shortcut icon" href="css/FDZKFQZT0KPM.png">
    <link href="https://fonts.googleapis.com/css2?family=Open+Sans+Condensed:wght@700&amp;family=Open+Sans:wght@300;400;700&amp;display=swap" rel="stylesheet">
    <title>Crypto Bank</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.css">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="css/UJGVAYYBS9FG.css" rel="stylesheet">
    <link rel="stylesheet" href="css/HXDYMEF162WV.css">
    <link rel="stylesheet" href="css/WIRY4IYBJST4.css">
    <link rel="stylesheet" href="css/NUJ616A12MST.css">
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/intgrtn.css">

    <script src="js/jquery-1.11.3.min.js"></script>
    <script src="js/bootstrap.min.js"></script>

    <script>
        function proverka(numer) {
            numer.value = numer.value.replace(/[^\d]/g, '');
        };

        function proverkaChar(chars) {
            chars.value = chars.value.replace(/[^A-Za-zА-Яа-я -]/, '');
        };
    </script>
    <style>
        .wrapper .fs-header .fsh-bottom, .wrapper .fs-header .fsh-top {
            font-size: 20px;
        }
    </style>