Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
$f = <<<EOF
4
PHP-Shell - Version %s%s
5
(c) 2006, Jan Kneschke <jan@kneschke.de>
6
 
7
>> use '?' to open the inline help
8
 
9
EOF;
10
 
11
printf($f,
12
    $__shell->getVersion(),
13
    $__shell->hasReadline() ? ', with readline() support' : '');
14
unset($f);
15
 
16
print $__shell_exts->colour->getColour("default");
17
while($__shell->input()) {
18
    if ($__shell_exts->autoload->isAutoloadEnabled() && !function_exists('__autoload')) {
19
        /**
20
        * default autoloader
21
        *
22
        * If a class doesn't exist try to load it by guessing the filename
23
        * class PHP_Shell should be located in PHP/Shell.php.
24
        *
25
        * you can set your own autoloader by defining __autoload() before including
26
        * this file
27
        *
28
        * @param string $classname name of the class
29
        */
30
 
31
        function __autoload($classname) {
32
            global $__shell_exts;
33
 
34
            if ($__shell_exts->autoload_debug->isAutoloadDebug()) {
35
                print str_repeat(".", $__shell_exts->autoload_debug->incAutoloadDepth())." -> autoloading $classname".PHP_EOL;
36
            }
37
            include_once str_replace('_', '/', $classname).'.php';
38
            if ($__shell_exts->autoload_debug->isAutoloadDebug()) {
39
                print str_repeat(".", $__shell_exts->autoload_debug->decAutoloadDepth())." <- autoloading $classname".PHP_EOL;
40
            }
41
        }
42
    }
43
 
44
    try {
45
        $__shell_exts->exectime->startParseTime();
46
        if ($__shell->parse() == 0) {
47
            ## we have a full command, execute it
48
 
49
            $__shell_exts->exectime->startExecTime();
50
 
51
            $__shell_retval = eval($__shell->getCode());
52
            if (isset($__shell_retval)) {
53
                print $__shell_exts->colour->getColour("value");
54
 
55
                if (function_exists("__shell_print_var")) {
56
                    __shell_print_var($__shell,$__shell_retval, $__shell_exts->verboseprint->isVerbose());
57
                } else {
58
                    var_export($__shell_retval);
59
                }
60
            }
61
            ## cleanup the variable namespace
62
            unset($__shell_retval);
63
            $__shell->resetCode();
64
        }
65
    } catch(Exception $__shell_exception) {
66
        print $__shell_exts->colour->getColour("exception");
67
        printf('%s (code: %d) got thrown'.PHP_EOL, get_class($__shell_exception), $__shell_exception->getCode());
68
        print $__shell_exception;
69
 
70
        $__shell->resetCode();
71
 
72
        ## cleanup the variable namespace
73
        unset($__shell_exception);
74
    }
75
    print $__shell_exts->colour->getColour("default");
76
    $__shell_exts->exectime->stopTime();
77
    if ($__shell_exts->exectime->isShow()) {
78
        printf(" (parse: %.4fs, exec: %.4fs)",
79
            $__shell_exts->exectime->getParseTime(),
80
            $__shell_exts->exectime->getExecTime()
81
        );
82
    }
83
}
84
 
85
print $__shell_exts->colour->getColour("reset");
86