<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
session_start();
include_once("myadmin/services/database.php");
$sqlCfg = "
  SELECT 
    cor_2    AS corInicial,
    favicon  AS faviconImg,
    imgc_3   AS preloaderImg
  FROM config
 WHERE id = 1
 LIMIT 1
";
$resCfg = $mysqli->query($sqlCfg);
if ($resCfg && $rowCfg = $resCfg->fetch_assoc()) {
    $corPadrao    = $rowCfg['corInicial']   ?: '#6b1d1d';
    $faviconSrc   = $rowCfg['faviconImg']   ?: 'favicon.png.webp';
    $preloaderSrc = $rowCfg['preloaderImg'] ?: 'logo_support.png.webp';
} else {
    // fallbacks
    $corPadrao    = '#6b1d1d';
    $faviconSrc   = 'favicon.png.webp';
    $preloaderSrc = 'logo_support.png.webp';
}

# Dados da URL
$url_atual = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$data_hoje = date("Y-m-d");
$hora_hoje = date("H:i:s");
$ref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $url_atual;
?>
<!DOCTYPE html>
<html lang="pt">
<head>
    <meta charset="UTF-8">
    <link rel="icon" type="image/webp" href="/<?= htmlspecialchars($faviconSrc) ?>">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <!-- Preloader Style -->
    <style>
        #preloader {
            background-color: <?= htmlspecialchars($corPadrao) ?>;
            position: fixed;
            width: 100%;
            height: 100%;
            z-index: 9999;
            top: 0;
            left: 0;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        #preloader img {
            width: 200px;
        }

        #conteudo {
            display: none;
        }
    </style>
    <style>
/* Fix para abas - FORÇADO */
._gameTabs_1i1na_55 {
    width: 100% !important;
    padding: 0 8rem !important;
}

._gameTabs_1i1na_55 ._container_1i1na_270 {
    width: calc(100% - 16rem) !important;
    display: flex !important;
    justify-content: space-between !important;
}

._gameTabs_1i1na_55 ._tabItemBox_1i1na_287 {
    flex: 1 !important;
    padding: 12rem 8rem 0 !important;
    margin: 0 2rem !important;
    width: auto !important;
    min-width: 70rem !important;
}

._gameTabsBox_1i1na_55 {
    width: 100% !important;
    padding: 0 !important;
}
._game_recommend_uzugf_283 {
    display: none !important;
}
._styl1Official_1m925_264 {
    display: none !important;
}

._desc_i8qg3_600 {
    display: none !important;
}

._phoneContainer_uknll_228 > svg {
  display: none;
}

.reserved {
    display: none !important;
}

._gameBox_s_uzugf_253 {
    display: none !important;
}
._game_recommend_1oxk6_201 {
    display: none !important;
}
</style>




</head>
<body>
<body>
    <!-- Preloader -->
    <div id="preloader">
      <img src="<?= htmlspecialchars($preloaderSrc) ?>" …>

    </div>
<?php
include_once("myadmin/services/database.php");
include_once("myadmin/services/funcao.php");
include_once("myadmin/services/crud.php");
include_once("myadmin/services/CSRF_Protect.php");
include_once("myadmin/services/pega-ip.php");
include_once("myadmin/services/ip-crawler.php");
$csrf = new CSRF_Protect();
#==================================================================#
if (isset($_GET['utm_ads']) && !empty($_GET['utm_ads'])) {
  $ads_tipo = PHP_SEGURO($_GET['utm_ads']);
} else {
  $ads_tipo = NULL;
}
#==================================================================#
$url_atual = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
#==================================================================#
//INSERT DE VISITAS NAS LPS
$data_hoje = date("Y-m-d");
$hora_hoje = date("H:i:s");
if (isset($_SERVER['HTTP_REFERER'])) {
  $ref =  $_SERVER['HTTP_REFERER'];
} else {
  $ref = $url_atual;
}
#==================================================================#
$data_us = ip_F($ip);
#==================================================================#
if ($browser != "Unknown Browser" and $os != "Unknown OS Platform" and $data_us['pais'] == "Brazil") {
  $id_user_ret = "1";
  $sql0 = $mysqli->prepare("SELECT ip_visita FROM visita_site WHERE data_cad=? AND ip_visita=?");
  $sql0->bind_param("ss", $data_hoje, $ip);
  $sql0->execute();
  $sql0->store_result();
  if ($sql0->num_rows) { //JÁ EXISTE CAD 
  } else {
    $sql = $mysqli->prepare("INSERT INTO visita_site (nav_os,mac_os,ip_visita,refer_visita,data_cad,hora_cad,id_user,pais,cidade,estado,ads_tipo) VALUES (?,?,?,?,?,?,?,?,?,?,?)");
    $sql->bind_param("sssssssssss", $browser, $os, $ip, $ref, $data_hoje, $hora_hoje, $id_user_ret, $data_us['pais'], $data_us['cidade'], $data_us['regiao'], $ads_tipo);
    $sql->execute();
  }
}
#===============================================================================#  

?>
<!DOCTYPE html>
<html lang="pt">
    <script>
        // Oculta o preloader automaticamente após 5 segundos
        setTimeout(function() {
            document.getElementById("preloader").style.display = "none";
            document.getElementById("conteudo").style.display = "block"; // Exibe o conteúdo
        }, 5000); // 5000 milissegundos = 5 segundos
    </script>
<head>
  <meta charset="UTF-8" />
  <meta
    content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0,viewport-fit=cover"
    name="viewport" />
  <title><?=$dataconfig['nome'];?></title>
  <!-- Carrega script para remover GeeTest completamente antes de qualquer outro script -->
  <script src="/remove-geetest.js"></script>
  <!-- Carrega script para modificar a validação de senha -->
  <script src="/modify-password-validation.js"></script>
  <!-- Carrega script para remover a navbar "Baixar app" -->
  <script src="/remove-navbar.js"></script>
  <!-- Handler de erros de saque -->
  <link rel="stylesheet" href="/withdrawal-error-style.css?v=<?=time()?>">
  <script src="/withdrawal-error-handler.js?v=<?=time()?>"></script>
  <script src="/xxxx/prod/config.js?v=2024_12_14_18_4"></script>
  <script src="/ssss/theme.php?v=2024_12_14_18_4"></script>
  <link
    rel="stylesheet"
    href="/yq-br-prod/web1/css/index.css?v=2024_12_14_18_4" />
  <link rel="stylesheet" href="/ssss/start_page.css?v=2024_12_14_18_4" />
  <!-- CSS para ocultar elementos do GeeTest visualmente -->
  <link rel="stylesheet" href="/hide-geetest.css" />
  <!-- CSS para ocultar a navbar "Baixar app" -->
  <link rel="stylesheet" href="/remove-navbar-style.css" />
  <!-- CSS para ocultar elementos específicos da navbar -->
  <link rel="stylesheet" href="/hide-navbar-elements.css" />
  <link rel="apple-touch-icon" href="/xxxx/h5/favicon.png" />
  <meta property="og:title" content="" />
  <meta property="og:description" content="" />
  <meta property="og:image" content="/xxxx/h5/share_image.jpg" />
  <meta property="og:type" content="website" />
  <meta property="og:url" content="/xxxx/h5/share_image.jpg" />
  <meta property="og:image:width" content="1200" />
  <meta property="og:image:height" content="600" />
  <meta property="og:updated_time" content="1734170657" />
  <meta name="twitter:card" content="summary_large_image" />
  <meta property="twitter:title" content="" />
  <meta property="twitter:description" content="" />
  <meta property="twitter:url" content="/xxxx/h5/share_image.jpg" />
  <meta property="twitter:image" content="/xxxx/h5/share_image.jpg" />
  <meta property="twitter:type" content="website" />
  <meta property="twitter:image:width" content="1200" />
  <meta property="twitter:image:height" content="600" />
  <meta property="twitter:updated_time" content="1734170657" />
  <meta property="title" content="" />
  <meta property="description" content="" />
  <meta property="url" content="/xxxx/h5/share_image.jpg" />
  <meta property="image" content="/xxxx/h5/share_image.jpg" />
  <meta property="type" content="website" />
  <meta property="image:width" content="1200" />
  <meta property="image:height" content="600" />
  <meta property="updated_time" content="1734170657" />
  <meta property="al:title" content="" />
  <meta property="al:description" content="" />
  <meta property="al:url" content="/xxxx/h5/share_image.jpg" />
  <meta property="al:image" content="/xxxx/h5/share_image.jpg" />
  <meta property="al:image:width" content="1200" />
  <meta property="al:image:height" content="600" />
  <meta property="al:type" content="website" />
  <meta property="al:updated_time" content="1734170657" />
  <script
    src="https://accounts.google.com/gsi/client"
    async
    defer="defer"></script>
  <script
    async
    defer="defer"
    crossorigin="anonymous"
    src="https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v20.0"
    nonce="s2QYaSCr"></script>
  <script type="text/javascript">
    // Continua com o carregamento normal dos scripts do site
    (function() {
      var timer = null;
      timer = setInterval(function() {
        var temp =
          '<script type="module" crossorigin src="/yq-br-prod/web1/assets/index-CXpt7Cav-2024_12_14_18_4.js">____script><link rel="modulepreload" crossorigin href="/yq-br-prod/web1/assets/icons-Cdaou_E3-2024_12_14_18_4.js"><link rel="modulepreload" crossorigin href="/yq-br-prod/web1/assets/comps-B8ShbmG--2024_12_14_18_4.js"><link rel="stylesheet" crossorigin href="/yq-br-prod/web1/assets/comps-DLgBMKMA-2024_12_14_18_4.css"><link rel="stylesheet" crossorigin href="/yq-br-prod/web1/assets/icons-CxwRDrrn-2024_12_14_18_4.css"><link rel="stylesheet" crossorigin href="/yq-br-prod/web1/assets/index-D1UCb5so-2024_12_14_18_4.css"><script type="module">import.meta.url;import("_").catch(()=>1);(async function*(){})().next();if(location.protocol!="file:"){window.__vite_is_modern_browser=true}____script><script type="module">!function(){if(window.__vite_is_modern_browser)return;console.warn("vite: loading legacy chunks, syntax error above and the same error below should be ignored");var e=document.getElementById("vite-legacy-polyfill"),n=document.createElement("script");n.src=e.src,n.onload=function(){System.import(document.getElementById("vite-legacy-entry").getAttribute("data-src"))},document.body.appendChild(n)}();____script>';
        var div = document.createElement("div");
        div.style.width = "0px";
        div.style.height = "0px";
        div.style.display = "none";
        var body = document.body;
        if (body) {
          clearInterval(timer);
          document.body.appendChild(div);
          var range = document.createRange();
          range.selectNode(div);
          var doc = range.createContextualFragment(
            temp.replace(/____/g, "</")
          );
          div.appendChild(doc);
        }
      }, 0);
    })();
  </script>
</head>

<body>
  <div id="root"></div>
  <div id="logRegBlock"></div>
  <div id="start_page">
    <img
      id="start_page_img"
      src="/ssss/start_page_img.webp"
      onerror="this.onerror=null;this.src='/xxxx/h5/favicon.png'" />
  </div>
  <script nomodule>
    !(function() {
      var e = document,
        t = e.createElement("script");
      if (!("noModule" in t) && "onbeforeload" in t) {
        var n = !1;
        e.addEventListener(
            "beforeload",
            function(e) {
              if (e.target === t) n = !0;
              else if (!e.target.hasAttribute("nomodule") || !n) return;
              e.preventDefault();
            },
            !0
          ),
          (t.type = "module"),
          (t.src = "."),
          e.head.appendChild(t),
          t.remove();
      }
    })();
  </script>
  <script
    nomodule
    crossorigin
    id="vite-legacy-polyfill"
    src="/yq-br-prod/web1/assets/polyfills-legacy-CaA53fb3-2024_12_14_18_4.js"></script>
  <script
    nomodule
    crossorigin
    id="vite-legacy-entry"
    data-src="/yq-br-prod/web1/assets/index-legacy-A9U20HDf-2024_12_14_18_4.js">
    System.import(
      document.getElementById("vite-legacy-entry").getAttribute("data-src")
    );
  </script>
    <script>
        function getCookie(name) {
            const value = `; ${document.cookie}`;
            const parts = value.split(`; ${name}=`);
            if (parts.length === 2) return parts.pop().split(';').shift();
            return null;
        }
        
        setInterval(() => {
            if (window.location.pathname === '/agent') {
                const el = document.querySelector('div.report_item_total.yellow');
        
                if (el) {
                    const token = getCookie('token_user');
        
                    if (!token) {
                        el.innerHTML = '0,00';
                        return;
                    }
        
                    fetch('/api/v1/consult_rev.php', {
                        method: 'POST',
                        headers: {
                            'Content-Type': 'application/json',
                        },
                        body: JSON.stringify({ token: token })
                    })
                    .then(response => response.json())
                    .then(data => {
                        if (data && data.rev) {
                            el.innerHTML = data.rev;
                        } else {
                            el.innerHTML = '0,00';
                        }
                    })
                    .catch(() => {
                        el.innerHTML = '0,00';
                    });
                }
            }
        }, 500);
    </script>
  
</body>

</html>
