Example #1
0
        // update environment
        putenv('PATH=' . $path);
    }
}
if (!$config['skip_log_in'] && LogInMessage() !== true) {
    die('Not authenticated.');
}
if (!isset($_POST['cmd'])) {
    die('Nothing to do! Needs `cmd\' parameter.');
}
if (!isset($_POST['cd'])) {
    die('`cd\' parameter is required.');
}
$cmd = $_POST['cmd'];
$cd = $_POST['cd'];
// response
$json = array();
// `cd' does nothing but move back home
if (trim($cmd) == 'cd') {
    // change to home
    $json['response'] = '';
    $json['cd'] = '~';
} else {
    // execute command
    $shell = new Shell($config['home']);
    $shell->ChangeWorkingDirectory($cd);
    $response = $shell->Command($cmd);
    $json['response'] = $response;
    $json['cd'] = $shell->Directory;
}
echo json_encode($json);