summaryrefslogtreecommitdiff
path: root/shell/exec.php
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2011-11-27 11:22:36 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2011-11-27 11:22:36 -0500
commit3d6790614bb0dc776e02a95835e5c274263d1d1a (patch)
treeaad032777fccb7fbdc80551a6f89f4bb4845a510 /shell/exec.php
parent66c84cedfb411ad6ca0508d9f45d6d33c8ad474d (diff)
This zip file was identified as ltshell-3.zip
Diffstat (limited to 'shell/exec.php')
-rw-r--r--shell/exec.php58
1 files changed, 58 insertions, 0 deletions
diff --git a/shell/exec.php b/shell/exec.php
new file mode 100644
index 0000000..f3dc8d1
--- /dev/null
+++ b/shell/exec.php
@@ -0,0 +1,58 @@
+<?php
+
+function php_chdir($dir) {
+ $ret = chdir($dir);
+ echo '<input type="hidden" name="d" value="'.getcwd().'" />';
+ return $ret;
+}
+
+function php_exec($com, $cwd='') {
+ if ($cwd != '') { php_chdir($cwd); }
+ if ($com=='') { return 0; }
+
+ $root = dirname(__FILE__);
+
+ $ifs=' ';
+ $path = $root.'/bin';
+
+ $env = array('IFS' => $ifs, 'PATH' => $path);
+
+ $coms = array();
+ $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 ($ifs,$char)!==0) {
+ if (isset($coms[$c][$a])) {
+ $a++;
+ }
+ } elseif (substr_count (';',$char)!==0) {
+ $c++;
+ } else {
+ $coms[$c][$a].=$char;
+ }
+ }
+
+ $ret=0;
+ foreach ($coms as $args) {
+ $file=$path.'/'.$args[0].'.php';
+ if (file_exists($file)) {
+ include($file);
+ $ret = main($args,$env);
+ } else {
+ echo 'sh: command not found: `'.$args[0]."'\n";
+ $ret = 1;
+ }
+ }
+ return $ret;
+}