本文整理汇总了PHP中CLISetup::log方法的典型用法代码示例。如果您正苦于以下问题:PHP CLISetup::log方法的具体用法?PHP CLISetup::log怎么用?PHP CLISetup::log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CLISetup
的用法示例。
在下文中一共展示了CLISetup::log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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;
}
示例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: 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);
}
示例12: 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;
}
示例13: account
function account()
{
$fields = array('name' => ['Username', false], 'pass1' => ['Enter Password', true], 'pass2' => ['Confirm Password', true]);
if (CLISetup::readInput($fields)) {
CLISetup::log();
if (!User::isValidName($fields['name'], $e)) {
CLISetup::log(Lang::account($e == 1 ? 'errNameLength' : 'errNameChars'), CLISetup::LOG_ERROR);
} else {
if (!User::isValidPass($fields['pass1'], $e)) {
CLISetup::log(Lang::account($e == 1 ? 'errPassLength' : 'errPassChars'), CLISetup::LOG_ERROR);
} else {
if ($fields['pass1'] != $fields['pass2']) {
CLISetup::log(Lang::account('passMismatch'), CLISetup::LOG_ERROR);
} else {
if ($_ = DB::Aowow()->SelectCell('SELECT 1 FROM ?_account WHERE user = ? AND (status <> ?d OR (status = ?d AND statusTimer > UNIX_TIMESTAMP()))', $fields['name'], ACC_STATUS_NEW, ACC_STATUS_NEW)) {
CLISetup::log(Lang::account('nameInUse'), CLISetup::LOG_ERROR);
} else {
// write to db
$ok = DB::Aowow()->query('REPLACE INTO ?_account (user, passHash, displayName, joindate, email, allowExpire, userGroups, userPerms) VALUES (?, ?, ?, UNIX_TIMESTAMP(), ?, 0, ?d, 1)', $fields['name'], User::hashCrypt($fields['pass1']), Util::ucFirst($fields['name']), CFG_CONTACT_EMAIL, U_GROUP_ADMIN);
if ($ok) {
$newId = DB::Aowow()->selectCell('SELECT id FROM ?_account WHERE user = ?', $fields['name']);
Util::gainSiteReputation($newId, SITEREP_ACTION_REGISTER);
CLISetup::log("account " . $fields['name'] . " created successfully", CLISetup::LOG_OK);
} else {
// something went wrong
CLISetup::log(Lang::main('intError'), CLISetup::LOG_ERROR);
}
}
}
}
}
} else {
CLISetup::log();
CLISetup::log("account creation aborted", CLISetup::LOG_WARN);
}
}
示例14: currencies
function currencies(array $ids = [])
{
if (!$ids) {
DB::Aowow()->query('REPLACE INTO ?_currencies (id, category, itemId) SELECT Id, category, itemId FROM dbc_currencytypes');
}
$moneyItems = DB::Aowow()->selectCol('SELECT id AS ARRAY_KEY, itemId FROM dbc_currencytypes{ WHERE id IN (?a)}', $ids ?: DBSIMPLE_SKIP);
// apply names
$moneyNames = DB::World()->select('SELECT it.entry AS ARRAY_KEY, name AS name_loc0, name_loc2, name_loc3, name_loc6, name_loc8 FROM item_template it LEFT JOIN locales_item li ON li.entry = it.entry WHERE it.entry IN (?a)', $moneyItems);
foreach ($moneyItems as $cId => $itemId) {
if (!empty($moneyNames[$itemId])) {
$strings = $moneyNames[$itemId];
} else {
CLISetup::log('item #' . $itemId . ' required by currency #' . $cId . ' not in item_template', CLISetup::LOG_WARN);
$strings = ['name_loc0' => 'Item #' . $itemId . ' not in DB', 'iconId' => -1240, 'cuFlags' => CUSTOM_EXCLUDE_FOR_LISTVIEW, 'category' => 3];
}
DB::Aowow()->query('UPDATE ?_currencies SET ?a WHERE itemId = ?d', $strings, $itemId);
}
// apply icons
$displayIds = DB::World()->selectCol('SELECT entry AS ARRAY_KEY, displayid FROM item_template WHERE entry IN (?a)', $moneyItems);
foreach ($displayIds as $itemId => $iconId) {
DB::Aowow()->query('UPDATE ?_currencies SET iconId = ?d WHERE itemId = ?d', -$iconId, $itemId);
}
return true;
}
示例15: objects
function objects(array $ids = [])
{
$baseQuery = '
SELECT
go.entry,
`type`,
IF(`type` = 2, -2, -- quests 1
IF(`type` = 8 AND Data0 IN (1, 2, 3, 4, 1552), -6, -- tools
IF(`type` = 3 AND IFNULL(gqi.ItemId, 0) <> 0, -2, -- quests 2
IF(`type` IN (3, 9, 25), `type`, 0)))), -- regular chests, books, pools
0 AS event, -- linked worldevent
displayId,
go.name,
gtl2.`name` AS name_loc2,
gtl3.`name` AS name_loc3,
gtl6.`name` AS name_loc6,
gtl8.`name` AS name_loc8,
faction,
flags,
0 AS cuFlags, -- custom Flags
IF(`type` IN (3, 25), Data1, 0), -- lootId
IF(`type` IN (2, 3, 6, 10, 13, 24, 26), Data0, IF(`type` IN (0, 1), Data1, 0)), -- lockId
0 AS reqSkill, -- reqSkill
IF(`type` = 9, Data0, IF(`type` = 10, Data7, 0)), -- pageTextId
IF(`type` = 1, Data3, -- linkedTrapIds
IF(`type` = 3, Data7,
IF(`type` = 10, Data12,
IF(`type` = 8, Data2, 0)))),
IF(`type` = 5, Data5, -- reqQuest
IF(`type` = 3, Data8,
IF(`type` = 10, Data1,
IF(`type` = 8, Data4, 0)))),
IF(`type` = 8, Data0, 0), -- spellFocusId
IF(`type` = 10, Data10, -- onUseSpell
IF(`type` IN (18, 24), Data1,
IF(`type` = 26, Data2,
IF(`type` = 22, Data0, 0)))),
IF(`type` = 18, Data4, 0), -- onSuccessSpell
IF(`type` = 18, Data2, IF(`type` = 24, Data3, 0)), -- auraSpell
IF(`type` = 30, Data2, IF(`type` = 24, Data4, IF(`type` = 6, Data3, 0))), -- triggeredSpell
IF(`type` = 29, CONCAT_WS(" ", Data14, Data15, Data16, Data17, Data0), -- miscInfo: capturePoint
IF(`type` = 3, CONCAT_WS(" ", Data4, Data5, Data2), -- miscInfo: loot v
IF(`type` = 25, CONCAT_WS(" ", Data2, Data3, 0),
IF(`type` = 23, CONCAT_WS(" ", Data0, Data1, Data2), "")))), -- miscInfo: meetingStone
IF(ScriptName <> "", ScriptName, AIName)
FROM
gameobject_template go
LEFT JOIN
gameobject_template_locale gtl2 ON go.entry = gtl2.entry AND gtl2.`locale` = "frFR"
LEFT JOIN
gameobject_template_locale gtl3 ON go.entry = gtl3.entry AND gtl3.`locale` = "deDE"
LEFT JOIN
gameobject_template_locale gtl6 ON go.entry = gtl6.entry AND gtl6.`locale` = "esES"
LEFT JOIN
gameobject_template_locale gtl8 ON go.entry = gtl8.entry AND gtl8.`locale` = "ruRU"
LEFT JOIN
gameobject_questitem gqi ON gqi.GameObjectEntry = go.entry
{
WHERE
go.entry IN (?a)
}
GROUP BY
go.entry
LIMIT
?d, ?d';
$updateQuery = '
UPDATE
?_objects o
LEFT JOIN
dbc_lock l ON l.id = IF(o.`type` = 3, lockId, null)
SET
typeCat = IF(`type` = 3 AND (l.properties1 = 1 OR l.properties2 = 1), -5, -- footlocker
IF(`type` = 3 AND (l.properties1 = 2), -3, -- herb
IF(`type` = 3 AND (l.properties1 = 3), -4, typeCat))), -- ore
reqSkill = IF(`type` = 3 AND l.properties1 IN (1, 2, 3), IF(l.reqSkill1 > 1, l.reqSkill1, 1),
IF(`type` = 3 AND l.properties2 = 1, IF(l.reqSkill2 > 1, l.reqSkill2, 1), 0))
{
WHERE
o.id IN (?a)
}';
$offset = 0;
while ($objects = DB::World()->select($baseQuery, $ids ?: DBSIMPLE_SKIP, $offset, SqlGen::$stepSize)) {
CLISetup::log(' * sets ' . ($offset + 1) . ' - ' . ($offset + count($objects)));
$offset += SqlGen::$stepSize;
foreach ($objects as $o) {
DB::Aowow()->query('REPLACE INTO ?_objects VALUES (?a)', array_values($o));
}
}
// apply typeCat and reqSkill depending on locks
DB::Aowow()->query($updateQuery, $ids ?: DBSIMPLE_SKIP);
return true;
}