<?php

/**
 * @copyright 2024 Double Bastion LLC <www.doublebastion.com>
 *
 * @author Double Bastion LLC
 *
 * @license GNU AGPL version 3 or any later version
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

define('RESTRICTED', TRUE);

include 'install-signup-check.php';

if ($installcheck == true) {

 session_start();

 if ($_SESSION['instcompleteaccesspnl'] == "instaccesspnl") {

         $currentdomain = $_SERVER['HTTP_HOST'];

         $messagetouser = '<h4 style="text-align: center;">RED SCARF Suite Panel 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 RED SCARF Suite Panel here:
                           <p><a href="https://'.$currentdomain.'/panel-login.php" target="_blank"><font style="color: #0082c9">
                           https://'.$currentdomain.'/panel-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['instcompleteaccesspnl'] = "denyinstaccesspnl";

?>

<html>

<head>
  <title>RED SCARF Suite Panel Setup</title>

  <link rel="stylesheet" href="assets/css/setup-style.css">

</head>

<body>

  <div id="mainarea">

    <img class="logosetuppage" src="images/red-scarf-suite-panel_logo_about.svg" />

    <h3 style="text-align:center;">RED SCARF Suite Panel Setup</h3><br>

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

    <?php echo $messagetouser; ?>

  </div>

</body>

</html>

<?php

 }
}

?>