Example #1
0
function _make($v, $arg)
{
    echo '  make: ' . $v;
    if (isset($arg[0])) {
        $arg[0] = str_replace('\\', '/', $arg[0]);
    }
    if (strtolower($v) == 'controller') {
        if (!isset($arg[0])) {
            return "\n\n  ERROR: indique o NOME do arquivo!\n";
        }
        return createFile($arg[0], 'controller');
    } elseif (strtolower($v) == 'model') {
        if (!isset($arg[0])) {
            return "\n\n  ERROR: indique o NOME do arquivo!\n";
        }
        return createFile($arg[0], 'model');
    } elseif (strtolower($v) == 'lib') {
        if (!isset($arg[0])) {
            return "\n\n  ERROR: indique o NOME do arquivo!\n";
        }
        return createFile($arg[0], 'lib');
    } elseif (strtolower($v) == 'html') {
        if (!isset($arg[0])) {
            return "\n\n  ERROR: indique o NOME do arquivo!\n";
        }
        $name = strtolower($arg[0]);
        if (file_exists(APP_PATH . 'html/' . $name . '.html')) {
            return "\n\n  WARNNING: this file already exists!\n  " . APP_PATH . 'html/' . $name . ".html\n\n";
        }
        if (!checkAndOrCreateDir(dirname(APP_PATH . 'html/' . $name . '.html'), true)) {
            return "\n\n  WARNNING: access denied in directory '" . dirname(APP_PATH . 'html/' . $name . '.html') . "'\n\n";
        }
        $ctrl = file_get_contents(CONFIG_PATH . 'templates/html.tpl');
        $ctrl = str_replace('%name%', ucfirst($name), $ctrl);
        file_put_contents(APP_PATH . 'html/' . $name . '.html', $ctrl);
        return "\n\n  HTML file '" . APP_PATH . 'html/' . $name . '.html' . "' criado com sucesso!\n\n";
    } else {
        return "\n\n  ----- ERROR: Command 'make:{$v}' not found!\n" . _help();
    }
}
Example #2
0
                    if ($line != '') {
                        $pass[] = $line;
                    }
                }
            }
            break;
    }
}
if (!count($target)) {
    _help(1);
}
if (!count($user)) {
    _help(2);
}
if (!count($pass)) {
    _help(3);
}
// preparar lista de alvos para incluir porta
foreach ($target as $k => $tg) {
    $ip = $tg;
    $port = 0;
    $p = strpos($tg, ':');
    if ($p !== false) {
        $a = explode(':', $tg);
        list($ip, $port) = explode(':', $tg);
        $port = (int) $port;
    }
    if (!$port) {
        $port = 22;
    }
    $target[$k] = array($ip, $port);