summaryrefslogtreecommitdiff
path: root/framework/3rdParty/PhpShell/PHP/Shell/Extensions/LoadScript.php
diff options
context:
space:
mode:
authorxue <>2006-09-23 01:51:57 +0000
committerxue <>2006-09-23 01:51:57 +0000
commita5467e842316daf6a8a4345740f05a9731167ce1 (patch)
tree0a982dd52df5c682fd2de8f9b22137471cee2dbe /framework/3rdParty/PhpShell/PHP/Shell/Extensions/LoadScript.php
parent9af56fd93ed071d86f14296cec618073f6c0941a (diff)
merge from 3.0 branch till 1435.
Diffstat (limited to 'framework/3rdParty/PhpShell/PHP/Shell/Extensions/LoadScript.php')
-rw-r--r--framework/3rdParty/PhpShell/PHP/Shell/Extensions/LoadScript.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/framework/3rdParty/PhpShell/PHP/Shell/Extensions/LoadScript.php b/framework/3rdParty/PhpShell/PHP/Shell/Extensions/LoadScript.php
new file mode 100644
index 00000000..a8c4697d
--- /dev/null
+++ b/framework/3rdParty/PhpShell/PHP/Shell/Extensions/LoadScript.php
@@ -0,0 +1,32 @@
+<?php
+
+class PHP_Shell_Extensions_LoadScript implements PHP_Shell_Extension {
+ public function register() {
+ $cmd = PHP_Shell_Commands::getInstance();
+
+ $cmd->registerCommand('#^r #', $this, 'cmdLoadScript', 'r <filename>',
+ 'load a php-script and execute each line');
+
+ }
+
+ public function cmdLoadScript($l) {
+ $l = substr($l, 2);
+
+ if (file_exists($l)) {
+ $content = file($l);
+
+ $source = array();
+
+ foreach ($content as $line) {
+ $line = chop($line);
+
+ if (preg_match('#^<\?php#', $line)) continue;
+
+ $source[] = $line;
+ }
+
+ return $source;
+ }
+ return "";
+ }
+}