Esempio n. 1
0
                fclose($io[1]);
                fclose($io[2]);
                proc_close($p);
            } else {
                $stdout = shell_exec($_REQUEST['command']);
                $_SESSION['output'] .= htmlspecialchars($stdout, ENT_COMPAT, 'UTF-8');
            }
        }
    }
}
// end phpTerm
/*##########################################################
## The main thing starts here
## All output ist XHTML
##########################################################*/
$terminal = new phpTerm();
$terminal->logout(@$_GET['logout']);
if (!$terminal->checkPassword($passwd)) {
    header('WWW-Authenticate: Basic realm="PHP-Terminal"');
    header('HTTP/1.0 401 Unauthorized');
} else {
    $terminal->initVars();
    $terminal->buildCommandHistory();
    $terminal->buildJavaHistory();
    if (!isset($_SESSION['prompt'])) {
        $terminal->formatPrompt();
    }
    $terminal->outputHandle($aliases);
    if (isset($_GET['color'])) {
        $_SESSION['color'] = $_GET['color'];
    }
Esempio n. 2
0
            $p = proc_open(@$_REQUEST['command'], array(1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $io);
            /* Read output sent to stdout. */
            while (!feof($io[1])) {
                $_SESSION['output'] .= htmlspecialchars(fgets($io[1]), ENT_COMPAT, 'UTF-8');
            }
            /* Read output sent to stderr. */
            while (!feof($io[2])) {
                $_SESSION['output'] .= htmlspecialchars(fgets($io[2]), ENT_COMPAT, 'UTF-8');
            }
            fclose($io[1]);
            fclose($io[2]);
            proc_close($p);
        }
    }
}
$terminal = new phpTerm();
if (isset($_REQUEST['command']) && $_REQUEST['command'] == "logout") {
    $terminal->logout();
}
if (!$terminal->checkPassword($passwd)) {
    header('WWW-Authenticate: Basic realm="Terminal"');
    header('HTTP/1.0 401 Unauthorized');
} else {
    $terminal->initVars();
    $terminal->buildCommandHistory();
    $terminal->buildJavaHistory();
    if (!isset($_SESSION['prompt'])) {
        $terminal->formatPrompt();
    }
    $terminal->outputHandle($aliases);
    ?>