usleep(50000); Console::status("app/models "); usleep(50000); Console::status("app/views "); usleep(50000); Console::status("res "); usleep(50000); Console::writeLn("Done "); Console::write("Copying files ... "); Console::writeLn("39 of 39"); Console::write("Checking configuration ... "); Console::writeLn("Ok"); Console::write("Do you want a htconf too? [y/N] "); $w = Console::readLn(); } function config() { Console::write("Reading configuration metadata ... "); Console::status('dbx '); sleep(1); Console::status('dbx.db '); sleep(1); Console::status('dbx.db.mysql '); sleep(1); Console::writeLn('done '); Console::writeLn("Parsing configuration file ... done"); Console::writeLn("Preparing options ... done"); } } actions::register(new BaseAction(), 'base', 'Base management functions', BaseAction::$commands);
$disablegroup = false; $rdo = "#ENDGROUP"; } elseif ($ingroup && $disablegroup) { $rdo = sprintf("#%-20s %s", $rd[0], join(' ', array_slice($rd, 1))); } else { if (preg_match('/[0-9]*\\.[0-9]*\\.[0-9]*\\.[0-9]*/', $rd[0])) { $rdo = sprintf("#%-19s %s", $rd[0], join(' ', array_slice($rd, 1))); } else { $rdo = sprintf("# %s", join(' ', $rd)); } } } else { $rd = explode(' ', trim($row)); $rdo = sprintf("%-20s %s", $rd[0], join(' ', array_slice($rd, 1))); } } $fout[] = $rdo; } $fsout = join("\n", $fout); file_put_contents('/etc/hosts', $fsout); } function addgroup($group = null) { if (!$group) { console::fatal("You need to specify the group to add!"); exit(1); } } } actions::register(new HostsAction(), 'hosts', 'Manage hosts file groups for local development', HostsAction::$actions);
<?php module("Install Application", array('author' => 'Christopher Vagnetoft <*****@*****.**>', 'version' => '1.0', 'updater' => null)); class ApplicationAction extends Action { private $extn; public static $commands = array('install' => array('arguments' => '', 'info' => 'Install application')); public function install() { actions::invoke('database', array('initialize')); actions::invoke('database', array('import')); if (config::has('installer.class')) { $ic = config::get('installer.class'); $c = new $ic(); $c->install(); } } } actions::register(new ApplicationAction(), 'application', 'Application Install', ApplicationAction::$commands);
console::writeLn(); } } } } function compile() { $this->openDatabase(); foreach ($this->db as $key => $val) { if (string::like('lang:*', $key)) { $out = ''; $keyparts = explode(':', $key); $lang = $keyparts[1]; $out = sprintf("<?php\n// Do not edit! Automatically generated by 'lepton strings'\n\n"); $out .= sprintf("intl::registerLanguage('%s',array(\n", $lang); foreach ($val as $src => $str) { $out .= sprintf(" '%s' => '%s'", str_replace('\'', '\\\'', $src), str_replace('\'', '\\\'', $str)); if ($str != end($val)) { $out .= ','; } $out .= "\n"; } $out .= sprintf("));"); console::writeLn(__astr("\\g{Generated:} %s"), $lang); file_put_contents(base::appPath() . 'languages/' . $lang . '.php', $out); } } } } actions::register(new StringsAction(), 'strings', 'Manages internationalization and translation of strings', StringsAction::$commands);
foreach ($sf as $val) { Console::write(' %-18s', $val); $cb++; if ($cb > 3 && $val != end($sf)) { Console::writeLn(); $cb = 0; } } Console::writeLn(); Console::writeLn(); } function extensions() { $cb = 0; Console::writeLn(__astr("\\b{Loaded extensions:}")); $ext = get_loaded_extensions(); sort($ext); foreach ($ext as $val) { Console::write(' %-18s', $val); $cb++; if ($cb > 3 && $val != end($ext)) { Console::writeLn(); $cb = 0; } } Console::writeLn(); Console::writeLn(); } } actions::register(new InfoAction(), 'info', 'Show various pieces of information', InfoAction::$commands);
$card = 0; $code = 1; } console::writeLn(PppAuthentication::getCode($key, $code, 4)); break; case 'getlotto': $key = PppAuthentication::generateRandomSequenceKey(); $code = rand(0, 65535); console::writeLn(PppAuthentication::getLotto($key, $code)); break; case 'tostring': if (count($args) > 0) { console::writeLn(PppAuthentication::cardIndexToString($args[0])); } else { console::writeLn("Not enough parameters."); } break; case '': console::writeLn(__astr("ppp \\b{printcard} [\\u{card} [\\u{key}]] -- Print a specific card (with specific key)")); console::writeLn(__astr("ppp \\b{printcode} [\\u{card} \\u{code} [\\u{key}]] -- Print code from card")); console::writeLn(__astr("ppp \\b{genkey} [\\u{string}] -- Generate key (from string)")); console::writeLn(__astr("ppp \\b{getlotto} -- return lotto numbers")); console::writeLn(__astr("ppp \\b{tostring} \\u{code} -- return string representation of code index")); break; default: console::writeLn("Bad command."); } } } actions::register(new UserAction(), 'user', 'Add, remove and manage users', UserAction::$commands);
$conn->exec(sprintf("CREATE DATABASE %s;", $dbc['database'])); } catch (Exception $e) { console::writeLn("Not successful, does the database already exist?"); } } console::writeLn("Creating user..."); $conn->exec(sprintf("GRANT ALL ON %s.* TO %s@localhost IDENTIFIED BY '%s';", $dbc['database'], $dbc['username'], $dbc['password'])); $conn->exec("USE " . $dbc['database']); } else { console::writeLn("No password specified, ignoring database and user creation."); $conn = new DatabaseConnection(); } console::writeLn(__astr("\n\\b{Importing tables}")); $f = glob(base::basePath() . '/dist/sql/*.sql'); foreach ($f as $fn) { $fc = file_get_contents($fn); console::writeLn(" [sys] %s", basename($fn)); $conn->exec($fc); } $f = glob(base::appPath() . '/sql/*.sql'); foreach ($f as $fn) { $fc = file_get_contents($fn); console::writeLn(" [app] %s", basename($fn)); $conn->exec($fc); } console::writeLn("All done."); } } actions::register(new DatabaseAction(), 'database', 'Manage the databases', DatabaseAction::$commands); actions::register(new DatabaseAction(), 'db', 'Manage the databases', DatabaseAction::$commands);
Lepton Framework is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the software; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ module("CLI System Information", array('author' => 'Christopher Vagnetoft <*****@*****.**>', 'version' => '1.0', 'updater' => null)); class ForexAction extends Action { private $extn; public static $commands = array('update' => array('arguments' => '', 'info' => 'Update the forex tables'), 'convert' => array('arguments' => '\\g{amount} \\g{from} \\g{to}', 'info' => 'Convert the amount from one currency to another')); public function update() { using('lepton.web.forex'); $cc = new CurrencyExchange(); console::writeLn("Updating symbols..."); $cc->update(); } public function convert($fv, $fc, $tc) { using('lepton.web.forex'); $cc = new CurrencyExchange(); $tv = $cc->convert($fv, $fc, $tc); console::writeLn("%0.2f %s = %0.2f %s", $fv, $fc, $tv, $tc); } } actions::register(new ForexAction(), 'forex', 'FOReign EXchange - Currency conversion', ForexAction::$commands);
along with the software; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ module("CLI Package management", array('author' => 'Christopher Vagnetoft <*****@*****.**>', 'version' => '1.0', 'updater' => null)); class PackageAction extends Action { private $extn; public static $commands = array('install' => array('arguments' => '[\\u{packagefile.l2p}|\\u{packagename}|\\u{...}]', 'info' => 'Install a package from the web or a local file'), 'remove' => array('arguments' => '[\\u{packagename}]', 'info' => 'Remove an installed package'), 'check' => array('arguments' => '', 'info' => 'List installed packages'), 'update' => array('arguments' => '', 'info' => 'Update package list'), 'upgrade' => array('arguments' => '', 'info' => 'Upgrade all installed packages'), 'search' => array('arguments' => '[\\u{querystring}]', 'info' => 'Search for a package.')); public function install($packages = null) { using('lepton.utils.l2package'); $pm = new L2PackageManager(); $pkg = new L2Package($pkgname); $pm->installPackage($pkg); } public function remove($package = null) { using('lepton.utils.l2package'); $pm = new L2PackageManager(); $pkg = new L2Package($pkgname); $pm->removePackage($pkg); } public function check() { using('lepton.utils.l2package'); $pm = new L2PackageManager(); $pm->listPackages(); } } actions::register(new PackageAction(), 'package', 'Package manager', PackageAction::$commands);