<?php
session_start();

include 'parameters.php';

date_default_timezone_set("Asia/Jerusalem");

require __DIR__ . '/vendor/autoload.php';

$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . "/../");
$dotenv->load();


$phone = $_SESSION["phone"];
$mac = $_SESSION["mac"];
$apmac = $_SESSION["apmac"];
$site = $_SESSION["site"];
$country_code = $_SESSION['country_code'];

$curl = curl_init();
  curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://'.$_SERVER['HOST_URL'].'/api/customer/bots',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS => array('site' => $site,'mac' => $mac,'apmac' => $apmac,'phone' => $phone),
    CURLOPT_HTTPHEADER => array(
      'Accept: application/json'
    ),
  ));
  $response = curl_exec($curl);
  curl_close($curl);

  $curl = curl_init();
  curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://'.$_SERVER['HOST_URL'].'/api/master/sendMessage',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS => array('phone_number' => $phone,'country_code' => $country_code, 'message' => 'Unblock link : https://'.$_SERVER['HOST_URL'].'/block-removal.php'),
    CURLOPT_HTTPHEADER => array(
      'Accept: application/json'
    ),
  ));
  $response = curl_exec($curl);
  curl_close($curl);

?>
<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <title><?php echo htmlspecialchars($business_name); ?> Free WiFi</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <link rel="stylesheet" href="bulma.min.css"/>
    <script defer src="vendor\fortawesome\font-awesome\js\all.js"></script>
    <link rel="icon" type="image/png" href="favicomatic\favicon-32x32.png" sizes="32x32"/>
    <link rel="icon" type="image/png" href="favicomatic\favicon-16x16.png" sizes="16x16"/>
    <link rel="stylesheet" href="style.css"/>
</head>

<body>
<div class="page">
    <figure id="antibot_error" class="image">
        <img src="multi-mac.png">
    </figure>
    <div class="centered_text">
        <a href="policy.pdf">
            <img src="policy-button.png">
        </a>
    </div>
    <figure id="antibot_error" class="image">
        <img src="footer.png">
    </figure>
</div>
</body>
</html>