<?php
/**
 *  Copyright (C) 2021  Double Bastion LLC
 *
 *  This file is part of Roundpin, which is licensed under the
 *  GNU Affero General Public License Version 3.0. The license terms
 *  are detailed in the "LICENSE.txt" file located in the root directory.
 */

define('RESTRICTED', TRUE);

include 'install-signup-check.php';

if ($installcheck == true) {

 session_start();

 if ($_SESSION['instcompleteaccess'] == "instaccess") {


         $currentdomain = $_SERVER['HTTP_HOST'];

         $messagetouser = '<h4 style="text-align: center;">Roundpin has been successfully installed !</h4><div style="font-size:17px";>You can use the
                           administrator username and password that you have just set up to login to Roundpin here:
                           <p><a href="https://'.$currentdomain.'/roundpin-login.php" target="_blank"><font style="color: #0082c9">
                           https://'.$currentdomain.'/roundpin-login.php</font></a></p><br>
                           If you want to run the installation process again, edit the <font style="font-family: Courier;
                           font-weight: bold;">install-signup-check.php</font> file and change
                           <br><br><font style="font-family: Courier; font-weight: bold;">$installcheck = false;</font><br>to<br>
                           <font style="font-family: Courier; font-weight: bold;">$installcheck = true;</font><br><br></div>';

         // Change $installcheck from 'true' to 'false'
         $setupflcontent = file('install-signup-check.php');

         foreach ($setupflcontent as $flkey => $flvalue) {
               if (strpos($flvalue, "\$installcheck") !== false) {
                   $replacestr = str_replace("true", "false", $flvalue);
                   $setupflcontent[$flkey] = $replacestr;
               break;
               }
         }

         $finalfilecontent = implode("", $setupflcontent);
         file_put_contents('install-signup-check.php', $finalfilecontent);

         $_SESSION['instcompleteaccess'] = "denyinstaccess";

?>

<html>

<head>
  <title>Roundpin Setup</title>

  <link rel="stylesheet" href="css/setup.min.css">

</head>

<body>

  <div id="mainarea">

    <img class="logosetuppage" src="images/login-logo.svg" />

    <h3 style="text-align:center;">Roundpin Setup</h3><br>

    <img class="setupStage" src="images/roundpin-setup-stages-3.svg" />

    <?php echo $messagetouser; ?>

  </div>

</body>

</html>

<?php
 }
}

?>
