| 1 |
lars |
1 |
<?php
|
|
|
2 |
@ob_end_clean();
|
|
|
3 |
error_reporting(E_ALL);
|
|
|
4 |
set_time_limit(0);
|
|
|
5 |
|
|
|
6 |
/**
|
|
|
7 |
* the wrapper around the PHP_Shell class
|
|
|
8 |
*
|
|
|
9 |
* - load extensions
|
|
|
10 |
* - set default error-handler
|
|
|
11 |
* - add exec-hooks for the extensions
|
|
|
12 |
*
|
|
|
13 |
* To keep the namespace clashing between shell and your program
|
|
|
14 |
* as small as possible all public variables and functions from
|
|
|
15 |
* the shell are prefixed with __shell:
|
|
|
16 |
*
|
|
|
17 |
* - $__shell is the object of the shell
|
|
|
18 |
* can be read, this is the shell object itself, don't touch it
|
|
|
19 |
* - $__shell_retval is the return value of the eval() before
|
|
|
20 |
* it is printed
|
|
|
21 |
* can't be read, but overwrites existing vars with this name
|
|
|
22 |
* - $__shell_exception is the catched Exception on Warnings, Notices, ..
|
|
|
23 |
* can't be read, but overwrites existing vars with this name
|
|
|
24 |
*/
|
|
|
25 |
|
|
|
26 |
//try loading it from PEAR
|
|
|
27 |
@require_once('PHP/Shell.php');
|
|
|
28 |
if(class_exists('PHP_Shell', false))
|
|
|
29 |
{
|
|
|
30 |
require_once "PHP/Shell/Extensions/Autoload.php";
|
|
|
31 |
require_once "PHP/Shell/Extensions/AutoloadDebug.php";
|
|
|
32 |
require_once "PHP/Shell/Extensions/Colour.php";
|
|
|
33 |
require_once "PHP/Shell/Extensions/ExecutionTime.php";
|
|
|
34 |
require_once "PHP/Shell/Extensions/InlineHelp.php";
|
|
|
35 |
require_once "PHP/Shell/Extensions/VerbosePrint.php";
|
|
|
36 |
require_once "PHP/Shell/Extensions/LoadScript.php";
|
|
|
37 |
}
|
|
|
38 |
else
|
|
|
39 |
{
|
|
|
40 |
require_once(dirname(__FILE__)."/PHP/Shell.php");
|
|
|
41 |
require_once(dirname(__FILE__)."/PHP/Shell/Extensions/Autoload.php");
|
|
|
42 |
require_once(dirname(__FILE__)."/PHP/Shell/Extensions/AutoloadDebug.php");
|
|
|
43 |
require_once(dirname(__FILE__)."/PHP/Shell/Extensions/Colour.php");
|
|
|
44 |
require_once(dirname(__FILE__)."/PHP/Shell/Extensions/ExecutionTime.php");
|
|
|
45 |
require_once(dirname(__FILE__)."/PHP/Shell/Extensions/InlineHelp.php");
|
|
|
46 |
require_once(dirname(__FILE__)."/PHP/Shell/Extensions/VerbosePrint.php");
|
|
|
47 |
require_once(dirname(__FILE__)."/PHP/Shell/Extensions/LoadScript.php");
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
/**
|
|
|
51 |
* default error-handler
|
|
|
52 |
*
|
|
|
53 |
* Instead of printing the NOTICE or WARNING from php we wan't the turn non-FATAL
|
|
|
54 |
* messages into exceptions and handle them in our own way.
|
|
|
55 |
*
|
|
|
56 |
* you can set your own error-handler by createing a function named
|
|
|
57 |
* __shell_error_handler
|
|
|
58 |
*
|
|
|
59 |
* @param integer $errno Error-Number
|
|
|
60 |
* @param string $errstr Error-Message
|
|
|
61 |
* @param string $errfile Filename where the error was raised
|
|
|
62 |
* @param interger $errline Line-Number in the File
|
|
|
63 |
* @param mixed $errctx ...
|
|
|
64 |
*/
|
|
|
65 |
function __shell_default_error_handler($errno, $errstr, $errfile, $errline, $errctx) {
|
|
|
66 |
## ... what is this errno again ?
|
|
|
67 |
if ($errno == 2048) return;
|
|
|
68 |
|
|
|
69 |
throw new Exception(sprintf("%s:%d\r\n%s", $errfile, $errline, $errstr));
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
//set_error_handler("__shell_default_error_handler");
|
|
|
73 |
|
|
|
74 |
$__shell = new PHP_Shell();
|
|
|
75 |
$__shell_exts = PHP_Shell_Extensions::getInstance();
|
|
|
76 |
$__shell_exts->registerExtensions(array(
|
|
|
77 |
"options" => PHP_Shell_Options::getInstance(), /* the :set command */
|
|
|
78 |
|
|
|
79 |
"autoload" => new PHP_Shell_Extensions_Autoload(),
|
|
|
80 |
"autoload_debug" => new PHP_Shell_Extensions_AutoloadDebug(),
|
|
|
81 |
"colour" => new PHP_Shell_Extensions_Colour(),
|
|
|
82 |
"exectime" => new PHP_Shell_Extensions_ExecutionTime(),
|
|
|
83 |
"inlinehelp" => new PHP_Shell_Extensions_InlineHelp(),
|
|
|
84 |
"verboseprint" => new PHP_Shell_Extensions_VerbosePrint()
|
|
|
85 |
// "loadscript" => new PHP_Shell_Extensions_LoadScript()
|
|
|
86 |
));
|
|
|
87 |
|
|
|
88 |
?>
|