Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
class PHP_Shell_Extensions_LoadScript implements PHP_Shell_Extension {
4
    public function register() {
5
        $cmd = PHP_Shell_Commands::getInstance();
6
 
7
        $cmd->registerCommand('#^r #', $this, 'cmdLoadScript', 'r <filename>',
8
            'load a php-script and execute each line');
9
 
10
    }
11
 
12
    public function cmdLoadScript($l) {
13
        $l = substr($l, 2);
14
 
15
        if (file_exists($l)) {
16
            $content = file($l);
17
 
18
            $source = array();
19
 
20
            foreach ($content as $line) {
21
                $line = chop($line);
22
 
23
                if (preg_match('#^<\?php#', $line)) continue;
24
 
25
                $source[] = $line;
26
            }
27
 
28
            return $source;
29
        }
30
        return "";
31
    }
32
}