<?php
require_once __DIR__ . "/../intgrtn/vendor/autoload.php";
$lpType = '';
$lpTypeParam = !empty($_GET["intgrtn_lpType"]) ? $_GET["intgrtn_lpType"] : null;
$availableLpType = array("1step");

if (in_array($lpTypeParam, $availableLpType)) {
    $lpType = $lpTypeParam;
}
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="en" ng-app="app" ng-cloak>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Home | The News Spy</title>
    <link rel="stylesheet" href="css/slick.css">
    <link rel="stylesheet" href="//malihu.github.io/custom-scrollbar/jquery.mCustomScrollbar.min.css"/>
    <link rel="stylesheet" href="css/main.min.css">
    <link rel="shortcut icon" href="images/favicon/favicon.ico" type="image/x-icon">
    <link rel="apple-touch-icon" sizes="180x180" href="images/favicon/apple-touch-icon.png">
    <link rel="icon" type="image/png" sizes="32x32" href="images/favicon/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="16x16" href="images/favicon/favicon-16x16.png">
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/fancybox/3.3.5/jquery.fancybox.min.css"/>
    <link href="https://vjs.zencdn.net/7.6.0/video-js.css" rel="stylesheet">
    <link rel="stylesheet" href="css/index.css">
    <meta name="theme-color" content="#00b5a4]">
    <meta name="msapplication-navbutton-color" content="#00b5a4">
    <meta name="apple-mobile-web-app-status-bar-style" content="#00b5a4">
    <link href="css/intgrtn.css?v=<?php echo time(); ?>" rel="stylesheet" type="text/css"/>

    <!-- BEGIN intgrtn -->
    <script>
        window.intgrtnInit = function () {
            var path = "/";
            if (window.location.pathname.split("/")[1]) {
                path = "/" + window.location.pathname.split("/")[1] + "/";
            }
            window.intgrtn.setOptions({
                cookies: {
                    path: path
                },
            });
        };
        (function (d) {
            if (window.intgrtn) {
                return;
            }
            var s = d.createElement("script");
            var date = new Date();
            s.src = "<?php echo $trackingUrl ?>/api/v2/integration/app.js?v=2" + date.getFullYear().toString() + date.getMonth().toString() + date.getDay().toString() + date.getHours().toString();
            d.getElementsByTagName("head")[0].appendChild(s);
        }(document));
    </script>
    <!-- END intgrtn -->
    <script src="js/jquery-1.11.2.min.js"></script>
    <script src='https://vjs.zencdn.net/7.6.0/video.js'></script>
    <script type="text/javascript" src="js/angular.js"></script>
    <script type="text/javascript" src="js/angular-messages.js"></script>
    <script type="text/javascript"
            src="js/app/app.js?v=<?php echo filemtime(__DIR__ . '/../js/app/app.js'); ?>"></script>
    <script type="text/javascript"
            src="js/app/SubscribeController.js?v=<?php echo filemtime(__DIR__ . '/../js/app/SubscribeController.js'); ?>"></script>
