blob: 499441db085f3b4d6cdef9fe2d4dbd157cd0833a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
<?php if (!isset($LTS)) { die(); }
include('exec.php');
// Set up environment
$ltshell_dir = dirname(__FILE__);
$env['PATH'] = $ltshell_dir.'/bin';
$env['IFS'] = " \t\n";
if (isset($_POST['d'])) { chdir($_POST['d']); }
$env['CWD'] = getcwd();
// Check for an incomplete command
if (isset($_POST['stdout_dest'])) {
$_POST['c'] = $_POST['stdout_dest'];
unset($_POST['stdout_dest']);
}
// Figure out what needs to be displayed on the terminal
ob_start();
if ($_POST['c'] == 'clear') {
lts_chdir('.');
} else {
echo htmlentities($_POST['stdout']);
echo $_POST['c']."\n";
lts_shell_exec($_POST['c'],$env);
echo '$ ';
}
$term = ob_get_contents();
ob_end_clean();
// Display it
?>
<div class="term"><?php
echo '<form action="'.$_SERVER['PHP_SELF'].'#prompt" method="post">';
echo $term;
echo '<input id="prompt" type="text" name="c" />';
echo '<textarea name="stdout" class="hidden" readonly="readonly">';
// this PCRE is so that only markup from the current
// command ends up on the terminal; the rest gets
// stripped out
echo preg_replace('/<[^>]*>/','',$term);
echo '</textarea>';
echo '</form>';
?></div>
</form>
|