<?php

include 'function/connect.php';
session_start();


/* =========================
   HELPER FUNCTION
========================= */
function fetchOne($koneksi, $sql){
    $q = mysqli_query($koneksi, $sql);
    return $q ? mysqli_fetch_assoc($q) : [];
}

$whatsapp    = $contact['no_whatsapp'] ?? '';
$id_livechat = $contact['id_livechat'] ?? '';

$urlweb     = $web['url']        ?? '';
$logo       = $web['logo']       ?? '';
$title      = $web['title']      ?? '';
$deskripsi  = $web['deskripsi']  ?? '';
$keyword    = $web['keyword']    ?? '';

?>

<!DOCTYPE html>
<html lang="id">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title><?= $title; ?></title>
  <meta name="description" content="<?= $deskripsi; ?>">
  <meta name="robots" content="index, follow">
  <meta name="keywords" content="<?= $keyword; ?>">
  <link rel="canonical" href="<?= $urlweb; ?>">
  <meta name="theme-color" content="#151515">
  <meta name="msapplication-TileColor" content="#151515">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta property="og:title" content="<?= $title; ?>">
  <meta property="og:description" content="<?= $deskripsi; ?>">
  <meta property="og:type" content="website">
  <meta property="og:url" content="<?= $urlweb; ?>">
  <meta property="og:image" content="<?= $urlweb; ?>/assets/img/<?= $logo; ?>">
  <meta name="twitter:card" content="summary_large_image">
  <meta name="twitter:title" content="<?= $title; ?>">
  <meta name="twitter:description" content="<?= $deskripsi; ?>">
  <meta name="twitter:image" content="<?= $urlweb; ?>/assets/img/<?= $logo; ?>">
  <link rel="icon" href="<?= $urlweb; ?>/assets/img/koi_ico_notext.png">
  <link rel="preload" as="font" href="themes/default/font/font-awesome/webfonts/fa-solid-900.woff2" type="font/woff2" crossorigin>
</head>
<body>

<script>
/* =========================
   AUTO REDIRECT MOBILE
========================= */
setTimeout(() => {
    const isMobile = /Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i
        .test(navigator.userAgent);

    const params = new URLSearchParams(window.location.search);
    const reff   = params.get('reff');

    if (isMobile) {
        window.location.href = reff
            ? `main/index.php?page=daftar&reff=${encodeURIComponent(reff)}`
            : `main/index.php`;
    } else {
        window.location.href = `main/error_page/alert_desktop.php`;
    }
}, 100);
</script>

</body>
</html>