Source for file php_shell.php
Documentation is available at php_shell.php
* @copyright (c) 2005 John Peterson
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
require_once("php_shell/shell.php");
* Instead of printing the NOTICE or WARNING from php we wan't the turn non-FATAL
* messages into exceptions and handle them in our own way.
* you can set your own error-handler by createing a function named
* @param integer $errno Error-Number
* @param string $errstr Error-Message
* @param string $errfile Filename where the error was raised
* @param interger $errline Line-Number in the File
* @param mixed $errctx ...
## ... what is this errno again ?
if ($errno == 2048) return;
throw new Exception(sprintf("%s:%d\r\n%s", $errfile, $errline, $errstr));
>> use '?' to open the inline help
$__shell->hasReadline() ? ', with readline() support' : '');
print $__shell->getColour("default");
while($__shell->input()) {
if ($__shell->parse() == 0) {
## we have a full command, execute it
* If a class doesn't exist try to load it by guessing the filename
* class PHP_Shell should be located in PHP/Shell.php.
* you can set your own autoloader by defining __autoload() before including
* @param string $classname name of the class
$__shell_retval = eval ($__shell->getCode());
if (isset ($__shell_retval)) {
print $__shell->getColour("value");
__shell_print_var($__shell_retval, $__shell->getVerbose());
## cleanup the variable namespace
} catch (Exception $__shell_exception) {
print $__shell->getColour("exception");
print $__shell_exception->getMessage();
## cleanup the variable namespace
unset ($__shell_exception);
print $__shell->getColour("default");
print $__shell->getColour("reset");
|