本文整理汇总了PHP中CLISetup类的典型用法代码示例。如果您正苦于以下问题:PHP CLISetup类的具体用法?PHP CLISetup怎么用?PHP CLISetup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CLISetup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sql
function sql($syncMe = null)
{
require_once 'setup/tools/sqlGen.class.php';
SqlGen::init($syncMe !== null ? SqlGen::MODE_UPDATE : SqlGen::MODE_NORMAL, $syncMe ?: []);
$done = [];
if (SqlGen::$subScripts) {
$allOk = true;
// start file generation
CLISetup::log('begin generation of ' . implode(', ', SqlGen::$subScripts));
CLISetup::log();
foreach (SqlGen::$subScripts as $tbl) {
$syncIds = [];
// todo: fetch what exactly must be regenerated
$ok = SqlGen::generate($tbl, $syncIds);
if (!$ok) {
$allOk = false;
} else {
$done[] = $tbl;
}
CLISetup::log(' - subscript \'' . $tbl . '\' returned ' . ($ok ? 'sucessfully' : 'with errors'), $ok ? CLISetup::LOG_OK : CLISetup::LOG_ERROR);
set_time_limit(SqlGen::$defaultExecTime);
// reset to default for the next script
}
// end
CLISetup::log();
if ($allOk) {
CLISetup::log('successfully finished sql generation', CLISetup::LOG_OK);
} else {
CLISetup::log('finished sql generation with errors', CLISetup::LOG_ERROR);
}
} else {
CLISetup::log('no valid script names supplied', CLISetup::LOG_ERROR);
}
return $done;
}
示例2: realmMenu
function realmMenu()
{
$subEU = [];
$subUS = [];
$set = 0x0;
$menu = [['us', 'US & Oceanic', null, [[Util::urlize(CFG_BATTLEGROUP), CFG_BATTLEGROUP, null, &$subUS]]], ['eu', 'Europe', null, [[Util::urlize(CFG_BATTLEGROUP), CFG_BATTLEGROUP, null, &$subEU]]]];
foreach (Util::getRealms() as $row) {
if ($row['region'] == 'eu') {
$set |= 0x1;
$subEU[] = [Util::urlize($row['name']), $row['name']];
} else {
if ($row['region'] == 'us') {
$set |= 0x2;
$subUS[] = [Util::urlize($row['name']), $row['name']];
}
}
}
if (!$set) {
CLISetup::log(' - realmMenu: Auth-DB not set up .. menu will be empty', CLISetup::LOG_WARN);
}
if (!($set & 0x1)) {
array_pop($menu);
}
if (!($set & 0x2)) {
array_shift($menu);
}
return Util::toJSON($menu);
}
示例3: realmMenu
function realmMenu()
{
$subEU = [];
$subUS = [];
$set = 0x0;
$menu = [['us', 'US & Oceanic', null, [[Util::urlize(CFG_BATTLEGROUP), CFG_BATTLEGROUP, null, &$subEU]]], ['eu', 'Europe', null, [[Util::urlize(CFG_BATTLEGROUP), CFG_BATTLEGROUP, null, &$subUS]]]];
if (DB::isConnectable(DB_AUTH)) {
$rows = DB::Auth()->select('SELECT name, IF(timezone IN (8, 9, 10, 11, 12), "eu", "us") AS region FROM realmlist WHERE allowedSecurityLevel = 0 AND gamebuild = ?d', WOW_VERSION);
foreach ($rows as $row) {
if ($row['region'] == 'eu') {
$set |= 0x1;
$subEU[] = [Util::urlize($row['name']), $row['name']];
} else {
if ($row['region'] == 'us') {
$set |= 0x2;
$subUS[] = [Util::urlize($row['name']), $row['name']];
}
}
}
} else {
CLISetup::log(' - realmMenu: Auth-DB not set up .. menu will be empty', CLISetup::LOG_WARN);
}
if (!($set & 0x1)) {
array_shift($menu);
}
if (!($set & 0x2)) {
array_pop($menu);
}
return Util::toJSON($menu);
}
示例4: build
function build()
{
require_once 'setup/tools/fileGen.class.php';
FileGen::init();
if (FileGen::$subScripts) {
$allOk = true;
// start file generation
CLISetup::log('begin generation of ' . implode(', ', FileGen::$subScripts));
CLISetup::log();
// files with template
foreach (FileGen::$tplFiles as $name => list($file, $destPath, $deps)) {
$reqDBC = [];
if (!in_array($name, FileGen::$subScripts)) {
continue;
}
if (!file_exists(FileGen::$tplPath . $file . '.in')) {
CLISetup::log(sprintf(ERR_MISSING_FILE, FileGen::$tplPath . $file . '.in'), CLISetup::LOG_ERROR);
$allOk = false;
continue;
}
if (!CLISetup::writeDir($destPath)) {
continue;
}
$syncIds = [];
// todo: fetch what exactly must be regenerated
$ok = FileGen::generate($name, $syncIds);
if (!$ok) {
$allOk = false;
}
CLISetup::log(' - subscript \'' . $file . '\' returned ' . ($ok ? 'sucessfully' : 'with errors'), $ok ? CLISetup::LOG_OK : CLISetup::LOG_ERROR);
set_time_limit(FileGen::$defaultExecTime);
// reset to default for the next script
}
// files without template
foreach (FileGen::$datasets as $file => $deps) {
if (!in_array($file, FileGen::$subScripts)) {
continue;
}
$syncIds = [];
// todo: fetch what exactly must be regenerated
$ok = FileGen::generate($file, $syncIds);
if (!$ok) {
$allOk = false;
}
CLISetup::log(' - subscript \'' . $file . '\' returned ' . ($ok ? 'sucessfully' : 'with errors'), $ok ? CLISetup::LOG_OK : CLISetup::LOG_ERROR);
set_time_limit(FileGen::$defaultExecTime);
// reset to default for the next script
}
// end
CLISetup::log();
if ($allOk) {
CLISetup::log('successfully finished file generation', CLISetup::LOG_OK);
} else {
CLISetup::log('finished file generation with errors', CLISetup::LOG_ERROR);
}
} else {
CLISetup::log('no valid script names supplied', CLISetup::LOG_ERROR);
}
}
示例5: finish
function finish()
{
if (!getopt('d', ['delete'])) {
// generated with TEMPORARY keyword. Manual deletion is not needed
CLISetup::log('generated dbc_* - tables kept available', CLISetup::LOG_INFO);
}
die("\n");
}
示例6: realms
function realms()
{
$realms = [];
if (DB::isConnectable(DB_AUTH)) {
$realms = DB::Auth()->select('SELECT id AS ARRAY_KEY, name, ? AS battlegroup, IF(timezone IN (8, 9, 10, 11, 12), "eu", "us") AS region FROM realmlist WHERE allowedSecurityLevel = 0 AND gamebuild = ?d', CFG_BATTLEGROUP, WOW_VERSION);
} else {
CLISetup::log(' - realms: Auth-DB not set up .. static data g_realms will be empty', CLISetup::LOG_WARN);
}
$toFile = "var g_realms = " . Util::toJSON($realms) . ";";
$file = 'datasets/realms';
return CLISetup::writeFile($file, $toFile);
}
示例7: gems
function gems()
{
// sketchy, but should work
// Id < 36'000 || ilevel < 70 ? BC : WOTLK
$gems = DB::Aowow()->Select('SELECT i.id AS itemId,
i.name_loc0, i.name_loc2, i.name_loc3, i.name_loc4, i.name_loc6, i.name_loc8,
IF (i.id < 36000 OR i.itemLevel < 70, 1 , 2) AS expansion,
i.quality,
ic.iconString AS icon,
i.gemEnchantmentId AS enchId,
i.gemColorMask AS colors
FROM ?_items i
JOIN ?_icons ic ON ic.id = -i.displayId
WHERE i.gemEnchantmentId <> 0
ORDER BY i.id DESC');
$success = true;
// check directory-structure
foreach (Util::$localeStrings as $dir) {
if (!CLISetup::writeDir('datasets/' . $dir)) {
$success = false;
}
}
$enchIds = [];
foreach ($gems as $pop) {
$enchIds[] = $pop['enchId'];
}
$enchantments = new EnchantmentList(array(['id', $enchIds], CFG_SQL_LIMIT_NONE));
if ($enchantments->error) {
CLISetup::log('Required table ?_itemenchantment seems to be empty! Leaving gems()...', CLISetup::LOG_ERROR);
CLISetup::log();
return false;
}
foreach (CLISetup::$localeIds as $lId) {
set_time_limit(5);
User::useLocale($lId);
Lang::load(Util::$localeStrings[$lId]);
$gemsOut = [];
foreach ($gems as $pop) {
if (!$enchantments->getEntry($pop['enchId'])) {
CLISetup::log(' * could not find enchantment #' . $pop['enchId'] . ' referenced by item #' . $gem['itemId'], CLISetup::LOG_WARN);
continue;
}
$gemsOut[$pop['itemId']] = array('name' => Util::localizedString($pop, 'name'), 'quality' => $pop['quality'], 'icon' => strToLower($pop['icon']), 'enchantment' => $enchantments->getField('name', true), 'jsonequip' => $enchantments->getStatGain(), 'colors' => $pop['colors'], 'expansion' => $pop['expansion']);
}
$toFile = "var g_gems = " . Util::toJSON($gemsOut) . ";";
$file = 'datasets/' . User::$localeString . '/gems';
if (!CLISetup::writeFile($file, $toFile)) {
$success = false;
}
}
return $success;
}
示例8: realms
function realms()
{
$realms = Util::getRealms();
if (!$realms) {
CLISetup::log(' - realms: Auth-DB not set up .. static data g_realms will be empty', CLISetup::LOG_WARN);
} else {
foreach ($realms as &$r) {
$r['battlegroup'] = CFG_BATTLEGROUP;
}
}
$toFile = "var g_realms = " . Util::toJSON($realms) . ";";
$file = 'datasets/realms';
return CLISetup::writeFile($file, $toFile);
}
示例9: finish
function finish()
{
if (!getopt('d', ['delete'])) {
// generated with TEMPORARY keyword. Manual deletion is not needed
CLISetup::log('generated dbc_* - tables kept available', CLISetup::LOG_INFO);
}
// send "i'm in use @" - ping
$u = !empty($_SERVER['USER']) ? $_SERVER['USER'] : 'NULL';
$s = !empty($_SERVER['SSH_CONNECTION']) ? explode(' ', $_SERVER['SSH_CONNECTION'])[2] : 'NULL';
if ($h = @fopen('http://aowow.meedns.com/ref?u=' . $u . '&s=' . $s, 'r')) {
fclose($h);
}
die("\n");
}
示例10: update
function update()
{
list($date, $part) = array_values(DB::Aowow()->selectRow('SELECT `date`, `part` FROM ?_dbversion'));
CLISetup::log('checking sql updates');
$nFiles = 0;
foreach (glob('setup/updates/*.sql') as $file) {
$pi = pathinfo($file);
list($fDate, $fPart) = explode('_', $pi['filename']);
if ($date && $fDate < $date) {
continue;
} else {
if ($part && $date && $fDate == $date && $fPart <= $part) {
continue;
}
}
$nFiles++;
$updQuery = '';
$nQuerys = 0;
foreach (file($file) as $line) {
// skip comments
if (substr($line, 0, 2) == '--' || $line == '') {
continue;
}
$updQuery .= $line;
// semicolon at the end -> end of query
if (substr(trim($line), -1, 1) == ';') {
if (DB::Aowow()->query($updQuery)) {
$nQuerys++;
}
$updQuery = '';
}
}
DB::Aowow()->query('UPDATE ?_dbversion SET `date`= ?d, `part` = ?d', $fDate, $fPart);
CLISetup::log(' -> ' . date('d.m.Y', $fDate) . ' #' . $fPart . ': ' . $nQuerys . ' queries applied', CLISetup::LOG_OK);
}
CLISetup::log($nFiles ? 'applied ' . $nFiles . ' update(s)' : 'db is already up to date', CLISetup::LOG_OK);
// fetch sql/build after applying updates, as they may contain sync-prompts
list($sql, $build) = array_values(DB::Aowow()->selectRow('SELECT `sql`, `build` FROM ?_dbversion'));
sleep(1);
$sql = trim($sql) ? array_unique(explode(' ', trim($sql))) : [];
$build = trim($build) ? array_unique(explode(' ', trim($build))) : [];
if ($sql) {
CLISetup::log('The following table(s) require syncing: ' . implode(', ', $sql));
}
if ($build) {
CLISetup::log('The following file(s) require syncing: ' . implode(', ', $build));
}
return [$sql, $build];
}
示例11: glyphs
function glyphs()
{
$success = true;
$glyphList = DB::Aowow()->Select('SELECT i.id AS itemId,
i.*,
IF (g.typeFlags & 0x1, 2, 1) AS type,
i.subclass AS classs,
i.requiredLevel AS level,
s1.Id AS glyphSpell,
ic.iconString AS icon,
s1.skillLine1 AS skillId,
s2.Id AS glyphEffect,
s2.Id AS ARRAY_KEY
FROM ?_items i
JOIN ?_spell s1 ON s1.Id = i.spellid1
JOIN ?_glyphproperties g ON g.Id = s1.effect1MiscValue
JOIN ?_spell s2 ON s2.Id = g.spellId
JOIN ?_icons ic ON ic.Id = s1.iconIdAlt
WHERE i.classBak = 16');
// check directory-structure
foreach (Util::$localeStrings as $dir) {
if (!CLISetup::writeDir('datasets/' . $dir)) {
$success = false;
}
}
$glyphSpells = new SpellList(array(['s.id', array_keys($glyphList)], CFG_SQL_LIMIT_NONE));
foreach (CLISetup::$localeIds as $lId) {
set_time_limit(30);
User::useLocale($lId);
Lang::load(Util::$localeStrings[$lId]);
$glyphsOut = [];
foreach ($glyphSpells->iterate() as $__) {
$pop = $glyphList[$glyphSpells->id];
if (!$pop['glyphEffect']) {
continue;
}
if ($glyphSpells->getField('effect1Id') != 6 && $glyphSpells->getField('effect2Id') != 6 && $glyphSpells->getField('effect3Id') != 6) {
continue;
}
$glyphsOut[$pop['itemId']] = array('name' => Util::localizedString($pop, 'name'), 'description' => $glyphSpells->parseText()[0], 'icon' => $pop['icon'], 'type' => $pop['type'], 'classs' => $pop['classs'], 'skill' => $pop['skillId'], 'level' => $pop['level']);
}
$toFile = "var g_glyphs = " . Util::toJSON($glyphsOut) . ";";
$file = 'datasets/' . User::$localeString . '/glyphs';
if (!CLISetup::writeFile($file, $toFile)) {
$success = false;
}
}
return $success;
}
示例12: pets
function pets()
{
$success = true;
$locations = [];
$petList = DB::Aowow()->Select('SELECT cr. id,
cr.name_loc0, cr.name_loc2, cr.name_loc3, cr.name_loc6, cr.name_loc8,
cr.minLevel,
cr.maxLevel,
ft.A,
ft.H,
cr.rank AS classification,
cr.family,
cr.displayId1 AS displayId,
cr.textureString AS skin,
LOWER(SUBSTRING_INDEX(cf.iconString, "\\\\", -1)) AS icon,
cf.petTalentType AS type
FROM ?_creature cr
JOIN ?_factiontemplate ft ON ft.Id = cr.faction
JOIN dbc_creaturefamily cf ON cf.id = cr.family
WHERE cr.typeFlags & 0x1 AND (cr.cuFlags & 0x2) = 0
ORDER BY cr.id ASC');
// check directory-structure
foreach (Util::$localeStrings as $dir) {
if (!CLISetup::writeDir('datasets/' . $dir)) {
$success = false;
}
}
foreach (CLISetup::$localeIds as $lId) {
User::useLocale($lId);
Lang::load(Util::$localeStrings[$lId]);
$petsOut = [];
foreach ($petList as $pet) {
// get locations
// again: caching will save you time and nerves
if (!isset($locations[$pet['id']])) {
$locations[$pet['id']] = DB::Aowow()->SelectCol('SELECT DISTINCT areaId FROM ?_spawns WHERE type = ?d AND typeId = ?d', TYPE_NPC, $pet['id']);
}
$petsOut[$pet['id']] = array('id' => $pet['id'], 'name' => Util::localizedString($pet, 'name'), 'minlevel' => $pet['minLevel'], 'maxlevel' => $pet['maxLevel'], 'location' => $locations[$pet['id']], 'react' => [$pet['A'], $pet['H']], 'classification' => $pet['classification'], 'family' => $pet['family'], 'displayId' => $pet['displayId'], 'skin' => $pet['skin'], 'icon' => $pet['icon'], 'type' => $pet['type']);
}
$toFile = "var g_pets = " . Util::toJSON($petsOut) . ";";
$file = 'datasets/' . User::$localeString . '/pets';
if (!CLISetup::writeFile($file, $toFile)) {
$success = false;
}
}
return $success;
}
示例13: gems
function gems()
{
// sketchy, but should work
// Id < 36'000 || ilevel < 70 ? BC : WOTLK
$gems = DB::Aowow()->Select('SELECT i.id AS itemId,
i.name_loc0, i.name_loc2, i.name_loc3, i.name_loc6, i.name_loc8,
IF (i.id < 36000 OR i.itemLevel < 70, 1 , 2) AS expansion,
i.quality,
ic.iconString AS icon,
i.gemEnchantmentId AS enchId,
i.gemColorMask AS colors
FROM ?_items i
JOIN ?_icons ic ON ic.id = -i.displayId
WHERE i.gemEnchantmentId <> 0
ORDER BY i.id DESC');
$success = true;
// check directory-structure
foreach (Util::$localeStrings as $dir) {
if (!CLISetup::writeDir('datasets/' . $dir)) {
$success = false;
}
}
$enchIds = [];
foreach ($gems as $pop) {
$enchIds[] = $pop['enchId'];
}
$enchMisc = [];
$enchJSON = Util::parseItemEnchantment($enchIds, false, $enchMisc);
foreach (CLISetup::$localeIds as $lId) {
set_time_limit(5);
User::useLocale($lId);
Lang::load(Util::$localeStrings[$lId]);
$gemsOut = [];
foreach ($gems as $pop) {
$gemsOut[$pop['itemId']] = array('name' => Util::localizedString($pop, 'name'), 'quality' => $pop['quality'], 'icon' => strToLower($pop['icon']), 'enchantment' => Util::localizedString(@$enchMisc[$pop['enchId']]['text'] ?: [], 'text'), 'jsonequip' => @$enchJSON[$pop['enchId']] ?: [], 'colors' => $pop['colors'], 'expansion' => $pop['expansion']);
}
$toFile = "var g_gems = " . Util::toJSON($gemsOut) . ";";
$file = 'datasets/' . User::$localeString . '/gems';
if (!CLISetup::writeFile($file, $toFile)) {
$success = false;
}
}
return $success;
}
示例14: update
function update()
{
$createQuery = "\r\n CREATE TABLE `aowow_dbversion` (\r\n `date` INT(10) UNSIGNED NOT NULL DEFAULT '0',\r\n `part` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0'\r\n ) ENGINE=MyISAM";
$date = $part = 0;
if (!DB::Aowow()->selectCell('SHOW TABLES LIKE "%dbversion"')) {
DB::Aowow()->query($createQuery);
DB::Aowow()->query('INSERT INTO ?_dbversion VALUES (0, 0)');
} else {
list($date, $part) = array_values(DB::Aowow()->selectRow('SELECT `date`, `part` FROM ?_dbversion'));
}
CLISetup::log('checking sql updates');
$nFiles = 0;
foreach (glob('setup/updates/*.sql') as $file) {
$pi = pathinfo($file);
list($fDate, $fPart) = explode('_', $pi['filename']);
if ($date && $fDate < $date) {
continue;
} else {
if ($part && $date && $fDate == $date && $fPart <= $part) {
continue;
}
}
$nFiles++;
$updQuery = '';
$nQuerys = 0;
foreach (file($file) as $line) {
// skip comments
if (substr($line, 0, 2) == '--' || $line == '') {
continue;
}
$updQuery .= $line;
// semicolon at the end -> end of query
if (substr(trim($line), -1, 1) == ';') {
if (DB::Aowow()->query($updQuery)) {
$nQuerys++;
}
$updQuery = '';
}
}
DB::Aowow()->query('UPDATE ?_dbversion SET `date`= ?d, `part` = ?d', $fDate, $fPart);
CLISetup::log(' -> ' . date('d.m.Y', $fDate) . ' #' . $fPart . ': ' . $nQuerys . ' queries applied', CLISetup::LOG_OK);
}
CLISetup::log($nFiles ? 'applied ' . $nFiles . ' update(s)' : 'db is already up to date', CLISetup::LOG_OK);
}
示例15: weightPresets
function weightPresets()
{
// check directory-structure
if (!CLISetup::writeDir('datasets/')) {
return false;
}
$wtPresets = [];
$scales = DB::Aowow()->select('SELECT id, name, icon, class FROM ?_account_weightscales WHERE userId = 0 ORDER BY class, id ASC');
foreach ($scales as $s) {
$weights = DB::Aowow()->selectCol('SELECT field AS ARRAY_KEY, val FROM ?_account_weightscale_data WHERE id = ?d', $s['id']);
if (!$weights) {
CLISetup::log('WeightScale \'' . CLISetup::bold($s['name']) . '\' has no data set. Skipping...', CLISetup::LOG_WARN);
continue;
}
$wtPresets[$s['class']]['pve'][$s['name']] = array_merge(['__icon' => $s['icon']], $weights);
}
$toFile = "var wt_presets = " . Util::toJSON($wtPresets) . ";";
$file = 'datasets/weight-presets';
if (!CLISetup::writeFile($file, $toFile)) {
return false;
}
return true;
}