summaryrefslogtreecommitdiff
path: root/framework/Vendor/PhpShell/PHP/Shell/Extensions/LoadScript.php
diff options
context:
space:
mode:
authorFabio Bas <ctrlaltca@gmail.com>2015-02-05 11:45:26 +0100
committerFabio Bas <ctrlaltca@gmail.com>2015-02-05 11:45:26 +0100
commit6dae236ec5528522de472637f9d70a98158b9a5d (patch)
tree0392bc0afb1f09921810d8b313b1f22b2f360106 /framework/Vendor/PhpShell/PHP/Shell/Extensions/LoadScript.php
parent81efaa0c6acdcd2e36081fed21ad5eac11fad3bc (diff)
Renamed 3rdparty directory to vendor
Php namespaces can’t begin with a number
Diffstat (limited to 'framework/Vendor/PhpShell/PHP/Shell/Extensions/LoadScript.php')
-rw-r--r--framework/Vendor/PhpShell/PHP/Shell/Extensions/LoadScript.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/framework/Vendor/PhpShell/PHP/Shell/Extensions/LoadScript.php b/framework/Vendor/PhpShell/PHP/Shell/Extensions/LoadScript.php
new file mode 100644
index 00000000..a8c4697d
--- /dev/null
+++ b/framework/Vendor/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 "";
+ }
+}