diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2011-11-27 11:29:44 -0500 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2011-11-27 11:29:44 -0500 |
commit | de5cb6329b4e6a4c409d1418f16a3488a53ca953 (patch) | |
tree | 3a5af4ef0fd42e4f4904326d2cc94d53582e028e /shell | |
parent | 76ead734626996f82caddaca57dc2f84243b0947 (diff) |
Diffstat (limited to 'shell')
-rw-r--r-- | shell/bin/cat.php | 37 | ||||
-rw-r--r-- | shell/bin/cd.php | 18 | ||||
-rw-r--r-- | shell/bin/cp.php | 72 | ||||
-rw-r--r-- | shell/bin/editor.php | 50 | ||||
-rw-r--r-- | shell/bin/grep.php | 52 | ||||
-rw-r--r-- | shell/bin/mkdir.php | 13 | ||||
-rw-r--r-- | shell/bin/mv.php | 43 | ||||
-rw-r--r-- | shell/bin/php.php | 9 | ||||
-rw-r--r-- | shell/bin/rm.php | 46 | ||||
-rw-r--r-- | shell/exec.php | 178 | ||||
-rw-r--r-- | shell/foobar.txt | 1 | ||||
-rw-r--r-- | shell/index.php | 62 | ||||
-rw-r--r-- | shell/shell.php | 98 | ||||
-rw-r--r-- | shell/shell2.php | 48 | ||||
-rw-r--r-- | shell/style.css | 82 |
15 files changed, 438 insertions, 371 deletions
diff --git a/shell/bin/cat.php b/shell/bin/cat.php index 8778f22..8376ca0 100644 --- a/shell/bin/cat.php +++ b/shell/bin/cat.php @@ -1,15 +1,22 @@ -<?php -class p_cat extends prog { - public static function main($args, $env) { - $me = array_shift($args); - if (count($args)==0) { $args = array('-'); } - foreach ($args as $file) { - if ( ($file=='-') || ($file=='/dev/stdin') ) { - echo $_POST['stdin']; - } else { - echo htmlentities(file_get_contents($file)); - } - } - } -} - +<?php
+class p_cat extends prog {
+ public static function main($args, $env) {
+ $me = array_shift($args);
+ $raw = (isset($args[0])?($args[0]=='-r'):false);
+ if ($raw) {
+ array_shift($args);
+ }
+ if (count($args)==0) { $args = array('-'); }
+ foreach ($args as $file) {
+ if ( ($file=='-') || ($file=='/dev/stdin') ) {
+ echo $_POST['stdin'];
+ } else {
+ if ($raw) {
+ echo file_get_contents($file);
+ } else {
+ echo htmlentities(file_get_contents($file));
+ }
+ }
+ }
+ }
+}
diff --git a/shell/bin/cd.php b/shell/bin/cd.php index baf30f3..80e1da6 100644 --- a/shell/bin/cd.php +++ b/shell/bin/cd.php @@ -1,8 +1,10 @@ -<?php -class p_cd extends prog { - public static function main($args, $env) { - @$dir = $args[1]; - return lts_chdir($dir); - } -} - +<?php
+class p_cd extends prog {
+ public static function main($args, $env) {
+ @$dir = $args[1];
+ $ret = lts_chdir($dir);
+ echo getcwd()."\n";
+ return $ret;
+ }
+}
+
diff --git a/shell/bin/cp.php b/shell/bin/cp.php index 4a6cfae..8f47970 100644 --- a/shell/bin/cp.php +++ b/shell/bin/cp.php @@ -1,33 +1,39 @@ -<?php -class p_cp extends prog { - /* This method (recurse_copy) was written by gimmicklessgpt@gmail.com - * and posted to the PHP manual comments section on 20-May-2009 11:04 - */ - function recurse_copy($src,$dst) { - $dir = opendir($src); - @mkdir($dst); - while(false !== ( $file = readdir($dir)) ) { - if (( $file != '.' ) && ( $file != '..' )) { - if ( is_dir($src . '/' . $file) ) { - recurse_copy($src . '/' . $file,$dst . '/' . $file); - } - else { - copy($src . '/' . $file,$dst . '/' . $file); - } - } - } - closedir($dir); - } - - public static function main($args, $env) { - $me = array_shift($args); - $flags = ''; - while (strstr($args[0],0,1) == '-') { - $flags .= array_shift($args); - } - $flags = preg_replace('/[ -]/','',$flags); - if (strpos($flags,'r')===false) { copy($args[0],$args[1]); } - else { recurse_copy($args[0],$args[1]); } - } -} - +<?php
+class p_cp extends prog {
+ /* This method (recurse_copy) was written by gimmicklessgpt@gmail.com
+ * and posted to the PHP manual comments section on 20-May-2009 11:04
+ */
+ static function recurse_copy($src,$dst) {
+ //echo 'recurse_copy('.$src.', '.$dst.");\n";
+ $dir = opendir($src);
+ @mkdir($dst);
+ while(false !== ( $file = readdir($dir)) ) {
+ if (( $file != '.' ) && ( $file != '..' )) {
+ if ( is_dir($src . '/' . $file) ) {
+ self::recurse_copy($src . '/' . $file,$dst . '/' . $file);
+ }
+ else {
+ self::copy( $src.'/'.$file , $dst.'/'.$file );
+ }
+ }
+ }
+ closedir($dir);
+ }
+
+ static function copy($src,$dst) {
+ //echo 'copy('.$src.', '.$dst.");\n";
+ copy($src, $dst);
+ }
+
+ public static function main($args, $env) {
+ $me = array_shift($args);
+ $flags = '';
+ while (substr($args[0],0,1) == '-') {
+ $flags .= array_shift($args);
+ }
+ $flags = preg_replace('/[ -]/','',$flags);
+ if (strpos($flags,'r')===false) { self::copy($args[0],$args[1]); }
+ else { self::recurse_copy($args[0],$args[1]); }
+ }
+}
+
diff --git a/shell/bin/editor.php b/shell/bin/editor.php index a136cd2..2d5d9c3 100644 --- a/shell/bin/editor.php +++ b/shell/bin/editor.php @@ -1,25 +1,25 @@ -<?php -class p_editor extends prog { - public static function main($args, $env) { - if (isset($_POST['stdin'])) { - if (false) {//if (isset($args[1])) { - echo $args[0].': saving to `'.$args[1]."'\n"; - file_put_contents($args[1],$_POST['stdin']); - } else { - echo $_POST['stdin']; - } - } else { - if (isset($args[1]) && file_exists($args[1])) { - $text = file_get_contents($args[1]); - } else { - $text = ''; - } - echo '<div class="editor">'; - echo '<input type="hidden" name="stdout_dest" value="'.$_POST['c'].'" />'; - echo '<textarea name="stdin">'.htmlentities($text).'</textarea>'."\n"; - echo '<input type="submit" value="save" />'; - echo '</div>'; - } - } -} - +<?php
+class p_editor extends prog {
+ public static function main($args, $env) {
+ if (isset($_POST['stdin'])) {
+ if (isset($args[1])) {
+ echo $args[0].': saving to `'.$args[1]."'\n";
+ file_put_contents($args[1],$_POST['stdin']);
+ } else {
+ echo htmlentities($_POST['stdin']);
+ }
+ } else {
+ if (isset($args[1]) && file_exists($args[1])) {
+ $text = file_get_contents($args[1]);
+ } else {
+ $text = '';
+ }
+ echo '<div class="editor">';
+ echo '<input type="hidden" name="stdout_dest" value="'.$_POST['c'].'" />';
+ echo '<textarea name="stdin">'.htmlentities($text).'</textarea>'."\n";
+ echo '<input type="submit" value="save" />';
+ echo '</div>';
+ }
+ }
+}
+
diff --git a/shell/bin/grep.php b/shell/bin/grep.php new file mode 100644 index 0000000..c73b911 --- /dev/null +++ b/shell/bin/grep.php @@ -0,0 +1,52 @@ +<?php
+class p_grep extends prog {
+ public static function flag($flags,$flag) {
+ return (strpos($flags,$flag)!==false);
+ }
+ public static function recurse_grep($pattern, $subject, $flags = '') {
+ // Do a breadth-first search
+ $dirs = array();
+ if ( is_dir($subject) ) {
+ $dirs[] = $subject;
+ } else {
+ self::grep($pattern, $subject, $flags);
+ }
+ foreach($dirs as $dir) {
+ $dh = opendir($dir);
+ while(false !== ( $file = readdir($dh)) ) {
+ if (( $file != '.' ) && ( $file != '..' )) {
+ self::recurse_grep($pattern, $subject.'/'.$file, $flags);
+ }
+ }
+ closedir($dh);
+ }
+ }
+
+ public static function grep($pattern, $file, $flags) {
+ $lines = preg_split("/\r\n/",file_get_contents($file));
+ foreach ($lines as $line_number => $line_contents) {
+ if (preg_match($pattern,$line_contents)>0) {
+ if (
+ (self::flag($flags,'r') && !self::flag($flags,'h')) // recursive
+ || (self::flag($flags,'H')) // or explicit
+ ) { echo htmlentities($file).': '; }
+ if (self::flag($flags,'n')) { echo $line_number.': '; }
+ echo htmlentities($line_contents)."\n";
+ }
+ }
+ }
+
+ public static function main($args, $env) {
+ $me = array_shift($args);
+ $flags = '';
+ while (substr($args[0],0,1) == '-') {
+ $flags .= array_shift($args);
+ }
+ $flags = preg_replace('/[ -]/','',$flags);
+ $pattern = array_shift($args);
+ foreach ($args as $file) {
+ if (self::flag($flags,'r')) { self::recurse_grep($pattern, $file, $flags); }
+ else { self::grep($pattern, $file, $flags); }
+ }
+ }
+}
diff --git a/shell/bin/mkdir.php b/shell/bin/mkdir.php new file mode 100644 index 0000000..565f47a --- /dev/null +++ b/shell/bin/mkdir.php @@ -0,0 +1,13 @@ +<?php +class p_mkdir extends prog { + public static function main($args, $env) { + $me = array_shift($args); + @$recursive = ($args[0]=='-p'); + if ($recursive) { + array_shift($args); + } + foreach ($args as $dir) { + mkdir($dir, umask(), $recursive); + } + } +} diff --git a/shell/bin/mv.php b/shell/bin/mv.php index 8fc35cd..0a23048 100644 --- a/shell/bin/mv.php +++ b/shell/bin/mv.php @@ -1,22 +1,21 @@ -<?php -class p_mv extends prog { - public static main($args, $env) { - $me = array_shift($args); - if (count($args)>2) { - $dest = array_pop($args); - if (!is_dir($dest) { - echo $me.': dest must be a directory: `'.$dest."'\n"; - return 1; - } - foreach ($args as $src) { - rename($src,$dest.'/'.basename($src)); - } - } elseif (count($args)==2) { - rename($args[0],$args[1]); - } else { - echo 'Usage: '.$me." SOURCE [SOURCE2 [SOURCE3 ...]] DEST\n"; - return 1; - } - } -} - +<?php
+class p_mv extends prog {
+ public static function main($args, $env) {
+ $me = array_shift($args);
+ if (count($args)>2) {
+ $dest = array_pop($args);
+ if (!is_dir($dest)) {
+ echo $me.': dest must be a directory: `'.$dest."'\n";
+ return 1;
+ }
+ foreach ($args as $src) {
+ rename($src,$dest.'/'.basename($src));
+ }
+ } elseif (count($args)==2) {
+ rename($args[0],$args[1]);
+ } else {
+ echo 'Usage: '.$me." SOURCE [SOURCE2 [SOURCE3 ...]] DEST\n";
+ return 1;
+ }
+ }
+}
diff --git a/shell/bin/php.php b/shell/bin/php.php new file mode 100644 index 0000000..0e3ba38 --- /dev/null +++ b/shell/bin/php.php @@ -0,0 +1,9 @@ +<?php
+class p_php extends prog {
+ public static function main($args, $env) {
+ $me = array_shift($args);
+ foreach ($args as $file) {
+ include($file);
+ }
+ }
+}
diff --git a/shell/bin/rm.php b/shell/bin/rm.php index 5eadaff..c55de8c 100644 --- a/shell/bin/rm.php +++ b/shell/bin/rm.php @@ -1,10 +1,36 @@ -<?php -class p_rm extends prog { - public static function main($args, $env) { - $me = array_shift($args); - foreach ($args as $file) { - unlink($file); - } - } -} - +<?php
+class p_rm extends prog {
+ static function recurse_rm($src) {
+ if ( is_dir($src) ) {
+ $dir = opendir($src);
+ while(false !== ( $file = readdir($dir)) ) {
+ if (( $file != '.' ) && ( $file != '..' )) {
+ self::recurse_rm($src.'/'.$file);
+ }
+ }
+ closedir($dir);
+ rmdir($src);
+ } else {
+ self::rm($src);
+ }
+ }
+
+ public static function rm($file) {
+ chown($file,666);
+ unlink($file);
+ }
+
+ public static function main($args, $env) {
+ $me = array_shift($args);
+ $flags = '';
+ while (substr($args[0],0,1) == '-') {
+ $flags .= array_shift($args);
+ }
+ $flags = preg_replace('/[ -]/','',$flags);
+ foreach ($args as $file) {
+ if (strpos($flags,'r')===false) { self::rm($file); }
+ else { self::recurse_rm($file); }
+ }
+ }
+}
+
diff --git a/shell/exec.php b/shell/exec.php index 9c22e5b..0d9c374 100644 --- a/shell/exec.php +++ b/shell/exec.php @@ -1,89 +1,89 @@ -<?php - -function lts_chdir($dir) { - $ret = chdir($dir); - echo '<input type="hidden" name="d" value="'.getcwd().'" />'; - if ($ret == false) { echo 'chdir: unable to change directories: `'.$dir."'\n"; - return $ret; -} - -abstract class prog { public static abstract function main($args, $env); } - -function lts_shell_exec($com, $env) { - if ($env['CWD'] != '') { lts_chdir($env['CWD']); } - if ($com=='') { return 0; } - - $coms = array(); - $stdout_dest = array(); - - // Parse command(s) - $a = 0; $c = 0; $q = ''; - while ($com != '') { - $char = substr($com,0,1); - $com = substr($com,1); - if (substr_count ('\'',$char)!==0) { - if (substr($q,0,1)===$char) { - $q = substr($q,1); - } else { - $q = $char.$q; - } - } elseif ($q != '') { - $coms[$c][$a].=$char; - } elseif (substr_count ($env['IFS'],$char)!==0) { - if (isset($coms[$c][$a])) { - $a++; - } - } elseif ($char==';') { - if (!isset($stdout_dest[$c])) { - $stdout_dest[$c] = '/dev/stdout'; - } - $c++; $a=0; - } elseif ($char=='|') { - $stdout_dest[$c] = '/dev/stdin'; - $c++; $a=0; - } else { - $coms[$c][$a].=$char; - } - } - if (!isset($stdout_dest[$c])) { - $stdout_dest[$c] = '/dev/stdout'; - } - - // execude commands - $ret=0; - foreach ($coms as $key => $args) { - if ($stdout_dest[$key] != '/dev/stdout') { - ob_start(); - } - - lts_exec($args, $env); - - if ($stdout_dest[$key] == '/dev/stdout') { - unset($_POST['stdin']); - } else { - switch ($stdout_dest[$key]) { - case '/dev/stdin': $_POST['stdin']=ob_get_contents(); break; - default: file_put_contents($stdout_dest[$key],ob_get_contents()); break; - } - ob_end_clean(); - } - } - return $ret; -} - -function lts_exec($args, $env) { - if (!class_exists('p_'.$args[0])) { - $file=$env['PATH'].'/'.$args[0].'.php'; - if (file_exists($file)) { - include($file); - } - } - if (class_exists('p_'.$args[0])) { - $ret = call_user_func(array('p_'.$args[0],'main'),$args,$env); - } else { - echo 'lts_exec: command not found: `'.$args[0]."'\n"; - $ret = 1; - } - return $ret; -} - +<?php
+
+function lts_chdir($dir) {
+ $ret = chdir($dir);
+ echo '<input type="hidden" name="d" value="'.getcwd().'" />';
+ if ($ret == false) { echo 'chdir: unable to change directories: `'.$dir."'\n"; }
+ return $ret;
+}
+
+abstract class prog { public static abstract function main($args, $env); }
+
+function lts_shell_exec($com, $env) {
+ if ($env['CWD'] != '') { lts_chdir($env['CWD']); }
+ if ($com=='') { return 0; }
+
+ $coms = array();
+ $stdout_dest = array();
+
+ // Parse command(s)
+ $a = 0; $c = 0; $q = '';
+ while ($com != '') {
+ $char = substr($com,0,1);
+ $com = substr($com,1);
+ if (!isset($coms[$c])) { $coms[$c] = array(); }
+ if (substr_count ('\'',$char)!==0) {
+ if (substr($q,0,1)===$char) {
+ $q = substr($q,1);
+ } else {
+ $q = $char.$q;
+ }
+ } elseif ($q != '') {
+ @$coms[$c][$a].=$char;
+ } elseif (substr_count ($env['IFS'],$char)!==0) {
+ if (isset($coms[$c][$a])) {
+ $a++;
+ }
+ } elseif ($char==';') {
+ if (!isset($stdout_dest[$c])) {
+ $stdout_dest[$c] = '/dev/stdout';
+ }
+ $c++; $a=0;
+ } elseif ($char=='|') {
+ $stdout_dest[$c] = '/dev/stdin';
+ $c++; $a=0;
+ } else {
+ @$coms[$c][$a].=$char;
+ }
+ }
+ if (!isset($stdout_dest[$c])) {
+ $stdout_dest[$c] = '/dev/stdout';
+ }
+
+ // execude commands
+ $ret=0;
+ foreach ($coms as $key => $args) {
+ if ($stdout_dest[$key] != '/dev/stdout') {
+ ob_start();
+ }
+
+ lts_exec($args, $env);
+
+ if ($stdout_dest[$key] == '/dev/stdout') {
+ unset($_POST['stdin']);
+ } else {
+ switch ($stdout_dest[$key]) {
+ case '/dev/stdin': $_POST['stdin']=ob_get_contents(); break;
+ default: file_put_contents($stdout_dest[$key],ob_get_contents()); break;
+ }
+ ob_end_clean();
+ }
+ }
+ return $ret;
+}
+
+function lts_exec($args, $env) {
+ if (!class_exists('p_'.$args[0])) {
+ $file=$env['PATH'].'/'.$args[0].'.php';
+ if (file_exists($file)) {
+ include($file);
+ }
+ }
+ if (class_exists('p_'.$args[0])) {
+ $ret = call_user_func(array('p_'.$args[0],'main'),$args,$env);
+ } else {
+ echo 'lts_exec: command not found: `'.$args[0]."'\n";
+ $ret = 1;
+ }
+ return $ret;
+}
diff --git a/shell/foobar.txt b/shell/foobar.txt deleted file mode 100644 index fd80404..0000000 --- a/shell/foobar.txt +++ /dev/null @@ -1 +0,0 @@ -this is foobar.txt
\ No newline at end of file diff --git a/shell/index.php b/shell/index.php index 6d62a65..ce89fec 100644 --- a/shell/index.php +++ b/shell/index.php @@ -1,31 +1,31 @@ -<?php -$LTS = 'set'; -session_start(); -include('no_magicquotes.php'); - -global $auth_html; -include('login.php'); - -echo '<?xml version="1.0" encoding="utf-8"?>'; -?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" - "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us" dir="ltr" > -<head> - <title>ltShell 3</title> - <link rel="stylesheet" href="style.css" media="screen,projection" /> - <script type="text/javascript"> - function formfocus() { - document.getElementById('prompt').focus(); - } - window.onload = formfocus; - </script> -</head> -<body> -<div class="login"><?php echo $auth_html; ?></div> -<?php -if ( isset($_SESSION['user']) && ($_SESSION['user']!='') ) { - include('shell.php'); -} -?> -</body></html> +<?php
+$LTS = 'set';
+session_start();
+include('no_magicquotes.php');
+
+global $auth_html;
+include('login.php');
+
+echo '<?xml version="1.0" encoding="utf-8"?>';
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us" dir="ltr" >
+<head>
+ <title>ltShell 3</title>
+ <link rel="stylesheet" href="style.css" media="screen,projection" />
+ <script type="text/javascript">
+ function formfocus() {
+ document.getElementById('prompt').focus();
+ }
+ window.onload = formfocus;
+ </script>
+</head>
+<body>
+<div class="login"><?php echo $auth_html; ?></div>
+<?php
+if ( isset($_SESSION['user']) && ($_SESSION['user']!='') ) {
+ include('shell.php');
+}
+?>
+</body></html>
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>
diff --git a/shell/shell2.php b/shell/shell2.php deleted file mode 100644 index 345064d..0000000 --- a/shell/shell2.php +++ /dev/null @@ -1,48 +0,0 @@ -<?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>
-<!-- edited -->
diff --git a/shell/style.css b/shell/style.css index 3206cc4..a294994 100644 --- a/shell/style.css +++ b/shell/style.css @@ -1,41 +1,41 @@ -body { - background-color: black; - color: white; -} -.login { - border: solid 2px white; - background: #555555; - position: fixed; - top: 0; right:0; -} -.term { - display:block; -} -.term, .term * { - background-color: black; - color: white; - white-space: pre-wrap; - font-family: monospace; - border: none; - font-size: 1em; -} -.hidden { - display:none; -} -.term input[type=text], -.term input[type=text]:focus { - height:1em; - width: 78em; - margin:0; padding:0; border:none; -} -.editor { - background: #AAAAAA; - padding:2em 1em; - width: 100%; - color: black; - height: 24em; -} -.editor textarea { width: 90%; height: 22em; } -form { - display: inline; -} +body {
+ background-color: black;
+ color: white;
+}
+.login {
+ border: solid 2px white;
+ background: #555555;
+ position: fixed;
+ top: 0; right:0;
+}
+.term {
+ display:block;
+}
+.term, .term * {
+ background-color: black;
+ color: white;
+ white-space: pre-wrap;
+ font-family: monospace;
+ border: none;
+ font-size: 1em;
+}
+.hidden {
+ display:none;
+}
+.term input[type=text],
+.term input[type=text]:focus {
+ /*height:1em;*/
+ width: 78em;
+ margin:0; padding:0; border:none;
+}
+.editor {
+ background: #AAAAAA;
+ padding:2em 1em;
+ width: 100%;
+ color: black;
+ height: 100%;
+}
+.editor textarea { width: 90%; height: 22em; }
+form {
+ display: inline;
+}
|