Example #1
0
function use_shell()
{
    while (1) {
        echo "[Shell]~\$: ";
        $cmd = stripslashes(trim(fgets(STDIN)));
        if (preg_match('/^(exit|--exit|quit|--quit)$/i', $cmd)) {
            die("\nExited\n");
        }
        print exec_cmd($cmd);
    }
}
Example #2
0
if ($argc > 1) {
    if (!defined('RUN_MODE')) {
        define('RUN_MODE', 'CLI');
    }
    exec_cmd($argv[1], array_slice($argv, 2, count($argv) - 1));
} else {
    if (!defined('RUN_MODE')) {
        define('RUN_MODE', 'INTERACTIVE');
    }
    Output::write(Template::render('introduction.tpl.php'), false, true, 2);
    print_ticker();
    do {
        do {
            $q = fgets(STDIN);
        } while (trim($q) == '');
        exec_cmd($q);
    } while (true);
}
/*-------------------------------------------------
 * DISPATCHER
 *-------------------------------------------------*/
function exec_cmd($q, $params = NULL)
{
    $match = false;
    foreach (Titanium::function_patterns() as $regex => $funct) {
        if (preg_match($regex, $q, $matches) > 0) {
            if (file_exists('functions/' . $funct . '.php')) {
                require_once 'functions/' . $funct . '.php';
                $match = true;
                call_user_func(str_replace('.', '_', $funct), $q, $matches, $params);
                print_ticker();
Example #3
0
        }
        $OUT = '';
        $LINE = $isXML || $isRELAT ? "\n" : '';
        foreach (scandir($file) as $f) {
            if (preg_match('/\\.html?$/i', $f)) {
                $OUT .= exec_cmd($cmd, "{$file}{$f}", $isRELAT) . $LINE;
            }
        }
        // for if
        $file = '';
    }
    // if
}
// if
if ($file) {
    $OUT = exec_cmd($cmd, $file, $isRELAT);
}
print_byTPL($OUT, $isRELAT, $isXML);
if ($isRELAT) {
    print "\n\nTOTAL GERAL: {$NTOTAL}\n";
}
/////////
function print_byTPL($OUT, $isRELAT, $isXML, $tag = 'html')
{
    global $cmd;
    global $io_options;
    if ($isXML) {
        if ($cmd == 'xml') {
            print XML_HEADER1 . "\n<{$tag}>{$OUT}\n</{$tag}>\n";
        } else {
            print XML_HEADER1 . $OUT;
Example #4
0
        }
        $OUT = '';
        $LINE = $isXML || $isRELAT ? "\n" : '';
        foreach (scandir($file) as $f) {
            if (preg_match('/\\.html?$/i', $f)) {
                $OUT .= preg_replace('|</?html>|', '', exec_cmd($cmd, "{$file}{$f}", $isRELAT, $isMultiSec)) . $LINE;
            }
        }
        $OUT = "\n<html>\n{$OUT}\n</html>";
        $file = '';
    }
    // if
}
// if
if ($file) {
    $OUT = exec_cmd($cmd, $file, $isRELAT, $isMultiSec);
}
print_byTPL($OUT, $isRELAT, $isXML);
if ($isRELAT) {
    print "\n\nTOTAL GERAL: {$NTOTAL}\n";
}
/////////
function print_byTPL($OUT, $isRELAT, $isXML, $tag = 'html')
{
    global $cmd;
    global $io_options;
    if ($isXML) {
        if ($cmd == 'xml') {
            print XML_HEADER1 . "\n<{$tag}>{$OUT}\n</{$tag}>\n";
        } else {
            print XML_HEADER1 . $OUT;