summaryrefslogtreecommitdiff
path: root/shell/shell.php
diff options
context:
space:
mode:
Diffstat (limited to 'shell/shell.php')
-rw-r--r--shell/shell.php98
1 files changed, 50 insertions, 48 deletions
diff --git a/shell/shell.php b/shell/shell.php
index 499441d..9fd10e6 100644
--- a/shell/shell.php
+++ b/shell/shell.php
@@ -1,48 +1,50 @@
-<?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>
-
+<?php
+if (!isset($LTS)) { die('shell.php may not be accessed directly.'); }
+error_reporting(E_ALL);
+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']);
+}
+
+// Display terminal
+?>
+<div class="term"><?php
+ echo '<form action="'.$_SERVER['PHP_SELF'].'#prompt" method="post">';
+
+ // Figure out what needs to be displayed on the terminal
+ if (!isset($_POST['c'])) { $_POST['c'] = ''; }
+ ob_start();
+ if ($_POST['c'] == 'clear') {
+ lts_chdir('.');
+ } else {
+ if (isset($_POST['stdout'])) { echo htmlentities($_POST['stdout']); }
+ echo $_POST['c']."\n";
+
+ lts_shell_exec($_POST['c'],$env);
+
+ echo '$ ';
+ }
+ $term = ob_get_contents();
+ ob_end_flush();
+
+ // prompt
+ 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>