Core/Config

* convert configuration from list of constants to object
 * fixes config changes not applying on cli whithout closing and reopening again
 * config variables are no longer embedded in localization text
This commit is contained in:
Sarjuuk
2024-05-28 15:41:44 +02:00
parent 454e09cc78
commit f77d676a19
94 changed files with 1094 additions and 922 deletions

File diff suppressed because one or more lines are too long

View File

@@ -126,12 +126,12 @@ class CLISetup
// restrict actual locales
foreach (self::$locales as $idx => $str)
if (!defined('CFG_LOCALES') || CFG_LOCALES & (1 << $idx))
if (!($l = Cfg::get('LOCALES')) || ($l & (1 << $idx)))
self::$localeIds[] = $idx;
// get site status
if (DB::isConnected(DB_AOWOW))
self::$lock = (int)DB::Aowow()->selectCell('SELECT `value` FROM ?_config WHERE `key` = "maintenance"');
self::$lock = (int)Cfg::get('MAINTENANCE');
else
self::$lock = self::LOCK_ON;
}
@@ -200,7 +200,7 @@ class CLISetup
public static function siteLock(int $mode = self::LOCK_RESTORE) : void
{
if (DB::isConnected(DB_AOWOW))
DB::Aowow()->query('UPDATE ?_config SET `value` = ?d WHERE `key` = "maintenance"', (int)!!($mode == self::LOCK_RESTORE ? self::$lock : $mode));
Cfg::set('MAINTENANCE', $mode == self::LOCK_RESTORE ? self::$lock : $mode);
}

View File

@@ -49,7 +49,7 @@ function account() : void
$fields['name'],
User::hashCrypt($fields['pass1']),
Util::ucFirst($fields['name']),
CFG_CONTACT_EMAIL,
Cfg::get('CONTACT_EMAIL'),
U_GROUP_ADMIN
);
if ($ok)

View File

@@ -27,8 +27,8 @@ function setup() : void
$upd = [[], []]; // ref to pass commands from 'update' to 'sync'
$steps = array(
// clisetup, params, test function, introText, errorText
['dbconfig', [null], 'testDB', 'Please enter your database credentials.', 'could not establish connection to:'],
['siteconfig', [null], 'testSelf', 'SITE_HOST and STATIC_HOST '.CLI::bold('must').' be set. Also enable FORCE_SSL if needed. You may also want to change other variables such as NAME, NAME_SHORT or LOCALES.', 'could not access:'],
['dbconfig', [null, null], 'testDB', 'Please enter your database credentials.', 'could not establish connection to:'],
['siteconfig', [null, null], 'testSelf', 'SITE_HOST and STATIC_HOST '.CLI::bold('must').' be set. Also enable FORCE_SSL if needed. You may also want to change other variables such as NAME, NAME_SHORT or LOCALES.', 'could not access:'],
// sql- and build- stuff here
['SqlGen::generate', 'areatrigger', null, null, null],
['SqlGen::generate', 'achievementcriteria', null, null, null],
@@ -103,7 +103,7 @@ function setup() : void
// apply sql-updates from repository
['update', &$upd, null, null, null],
['sync', &$upd, null, null, null],
['account', [null], 'testAcc', 'Please create your admin account.', 'There is no user with administrator privileges in the DB.']
['account', [null, null], 'testAcc', 'Please create your admin account.', 'There is no user with administrator privileges in the DB.']
);
@@ -174,11 +174,10 @@ function setup() : void
return false;
}
$res = DB::Aowow()->selectCol('SELECT `key` AS ARRAY_KEY, value FROM ?_config WHERE `key` IN ("site_host", "static_host", "force_ssl")');
$prot = $res['force_ssl'] ? 'https://' : 'http://';
$prot = Cfg::get('FORCE_SSL') ? 'https://' : 'http://';
$cases = array(
'site_host' => [$prot, $res['site_host'], '/README.md'],
'static_host' => [$prot, $res['static_host'], '/css/aowow.css']
'site_host' => [$prot, Cfg::get('SITE_HOST'), '/README.md'],
'static_host' => [$prot, Cfg::get('STATIC_HOST'), '/css/aowow.css']
);
foreach ($cases as $conf => [$protocol, $host, $testFile])
@@ -195,8 +194,8 @@ function setup() : void
$error[] = ' * '.$protocol.$host.$testFile.' ['.$resp.']';
else
{
DB::Aowow()->query('UPDATE ?_config SET `value` = ? WHERE `key` = ?', $host, $conf);
DB::Aowow()->query('UPDATE ?_config SET `value` = ?d WHERE `key` = "force_ssl"', intVal($protocol == 'https://'));
Cfg::set($conf, $host);
Cfg::set('FORCE_SSL', $protocol == 'https://');
}
CLI::write();
@@ -290,7 +289,7 @@ function setup() : void
CLI::write($step[3]);
$inp = ['x' => ['Press any key to continue', true]];
if (!CLI::read($inp, true)) // we don't actually care about the input
if (!CLI::read($inp, true)) // we don't actually care about the input
return;
}
@@ -301,7 +300,7 @@ function setup() : void
else
{
$args = &$step[1]; // see: https://github.com/php/php-src/issues/14202
$res = $step[0]($args);
$res = $step[0]($args[0], $args[1]);
}
// check script result

View File

@@ -13,7 +13,6 @@ if (!CLI)
function siteconfig() : void
{
$reqKeys = ['site_host', 'static_host'];
$updScripts = [];
if (!DB::isConnected(DB_AOWOW))
@@ -24,195 +23,124 @@ function siteconfig() : void
return;
}
$onChange = function($key, $val) use (&$updScripts)
function toOptList(string $options, $curVal, bool $bitmask = false) : string
{
$fn = null;
switch ($key)
$result = '';
foreach (explode(', ', $options) as $opt)
{
case 'battlegroup':
array_push($updScripts, 'realms', 'realmMenu');
break;
case 'name_short':
array_push($updScripts, 'searchboxBody', 'demo', 'searchplugin');
break;
case 'site_host':
array_push($updScripts, 'searchplugin', 'demo', 'power', 'searchboxBody');
break;
case 'static_host':
array_push($updScripts, 'searchplugin', 'power', 'searchboxBody', 'searchboxScript');
break;
case 'contact_email':
array_push($updScripts, 'markup');
break;
case 'locales':
array_push($updScripts, 'locales');
CLI::write(' * remember to rebuild all static files for the language you just added.', CLI::LOG_INFO);
CLI::write(' * you can speed this up by supplying the regionCode to the setup: '.CLI::bold('--locales=<regionCodes,> -f'));
break;
case 'profiler_enable':
array_push($updScripts, 'realms', 'realmMenu');
$fn = function($x) {
if (!$x)
return true;
[$val, $name] = explode(':', $opt);
$equal = $bitmask ? ($curVal & (1 << $val)) : $curVal == $val;
$ok = Profiler::queueStart($msg);
if ($msg)
CLI::write($msg, CLI::LOG_ERROR);
return $ok;
};
break;
case 'acc_auth_mode':
$fn = function($x) {
if ($x == 1 && !extension_loaded('gmp'))
{
CLI::write('PHP extension GMP is required to use TrinityCore as auth source, but it is currently not enabled.', CLI::LOG_ERROR);
return false;
}
return true;
};
break;
default: // nothing to do, everything is fine
return true;
$result .= '['.($equal ? 'x' : ' ').']'.$name.' ';
}
return $fn ? $fn($val) : true;
};
return substr($result, 0, -1);
}
function formatValue($value, $flags, $opts) : string
{
if ($flags & Cfg::FLAG_TYPE_BOOL)
return '[bool] '.($value ? '<Enabled>' : '<Disabled>');
if ($flags & Cfg::FLAG_OPT_LIST)
return '[opt] '.toOptList($opts, $value, false);
if ($flags & Cfg::FLAG_BITMASK)
return '[mask] '.toOptList($opts, $value, true);
if ($flags & Cfg::FLAG_TYPE_FLOAT)
return '[float] '.floatVal($value);
if ($flags & Cfg::FLAG_TYPE_INT)
return '[int] '.intVal($value);
// if ($flags & Cfg::FLAG_TYPE_STRING)
if ($value === '')
return '[str] '.(($flags & Cfg::FLAG_REQUIRED) ? CLI::red('<empty>') : CLI::grey('<empty>'));
else
return '[str] "'.$value.'"';
}
while (true)
{
CLI::write('select a numerical index to use the corresponding entry');
CLI::write('select a numerical index or name to use the corresponding entry');
CLI::write();
$sumNum = 0;
$cfgList = [];
$hasEmpty = false;
$mainBuff = [];
$miscBuff = []; // catg 'misc' should come last
$listBuff = [];
foreach (Util::$configCats as $idx => $cat)
foreach (Cfg::$categories as $idx => $cat)
{
if ($idx)
$mainBuff[] = '===== '.$cat.' =====';
else
$miscBuff[] = '===== '.$cat.' =====';
$listBuff[] = '===== '.$cat.' =====';
$results = DB::Aowow()->select('SELECT *, (flags & ?d) AS php FROM ?_config WHERE `cat` = ?d ORDER BY `key` ASC', CON_FLAG_PHP, $idx);
foreach ($results as $num => $data)
foreach (Cfg::forCategory($idx) as $key => [$value, $flags, $catg, $default, $comment])
{
if (!($data['flags'] & CON_FLAG_PHP) && $data['value'] === '' && in_array($data['key'], $reqKeys))
$isPhp = $flags & Cfg::FLAG_PHP;
if ($value === '' && ($flags & Cfg::FLAG_REQUIRED))
$hasEmpty = true;
$cfgList[$sumNum + $num] = $data;
$cfgList[$sumNum] = strtolower($key);
$php = $data['flags'] & CON_FLAG_PHP;
$buff = "[".CLI::bold($sumNum + $num)."] ".(($sumNum + $num) > 9 ? '' : ' ').($php ? ' PHP ' : ' AOWOW ');
$buff .= str_pad($php ? strtolower($data['key']) : strtoupper($data['key']), 35);
if ($data['value'] === '')
$buff .= in_array($data['key'], $reqKeys) ? CLI::red('<empty>') : '<empty>';
else
{
$info = explode(' - ', $data['comment']);
$row = '['.CLI::bold($sumNum).'] '.(($sumNum) > 9 ? '' : ' ').($isPhp ? ' PHP ' : ' AOWOW ');
$row .= str_pad($isPhp ? strtolower($key) : strtoupper($key), 35);
if ($data['flags'] & CON_FLAG_TYPE_BOOL)
$buff .= '[bool] '.($data['value'] ? '<Enabled>' : '<Disabled>');
else if ($data['flags'] & CON_FLAG_OPT_LIST && !empty($info[2]))
{
$buff .= "[opt] ";
foreach (explode(', ', $info[2]) as $option)
{
$opt = explode(':', $option);
$buff .= '['.($data['value'] == $opt[0] ? 'x' : ' ').']'.$opt[1].' ';
}
}
else if ($data['flags'] & CON_FLAG_BITMASK && !empty($info[2]))
{
$buff .= "[mask] ";
foreach (explode(', ', $info[2]) as $option)
{
$opt = explode(':', $option);
$buff .= '['.($data['value'] & (1 << $opt[0]) ? 'x' : ' ').']'.$opt[1].' ';
}
}
else if ($data['flags'] & CON_FLAG_TYPE_STRING)
$buff .= "[str] ".$data['value'];
else if ($data['flags'] & CON_FLAG_TYPE_FLOAT)
$buff .= "[float] ".floatVal($data['value']);
else /* if ($data['flags'] & CON_FLAG_TYPE_INT) */
$buff .= "[int] ".intVal($data['value']);
}
if ($idx)
$mainBuff[] = $buff;
else
$miscBuff[] = $buff;
$opts = explode(' - ', $comment);
$row .= formatValue($value, $flags, $opts[1] ?? '');
$listBuff[] = $row;
$sumNum++;
}
$sumNum += count($results);
}
foreach ($mainBuff as $b)
foreach ($listBuff as $b)
CLI::write($b);
foreach ($miscBuff as $b)
CLI::write($b);
CLI::write(str_pad("[".CLI::bold($sumNum)."]", 21)."add another php configuration");
CLI::write(str_pad('['.CLI::bold($sumNum).']', 21).'add another php configuration');
CLI::write();
if ($hasEmpty)
{
CLI::write("please configure the required empty settings", CLI::LOG_WARN);
CLI::write('please configure the required empty settings', CLI::LOG_WARN);
CLI::write();
}
$inp = ['idx' => ['', false, '/\d/']];
$inp = ['idx' => ['', false, Cfg::PATTERN_CONF_KEY]];
if (CLI::read($inp) && $inp && $inp['idx'] !== '')
{
$inp['idx'] = intVal($inp['idx']);
$idx = array_search(strtolower($inp['idx']), $cfgList);
if ($idx === false)
$idx = intVal($inp['idx']);
// add new php setting
if ($inp['idx'] == $sumNum)
if ($idx == $sumNum)
{
CLI::write("Adding additional php configuration.");
CLI::write('Adding additional php configuration.');
CLI::write();
while (true)
{
$setting = array(
'key' => ['option name', false, '/[\w_\.\-]/i'],
'key' => ['option name', false, Cfg::PATTERN_CONF_KEY],
'val' => ['value', ]
);
if (CLI::read($setting) && $setting)
{
$key = strtolower($setting['key']);
if (ini_get($key) === false || ini_set($key, $setting['val']) === false)
{
CLI::write("this configuration option cannot be set", CLI::LOG_ERROR);
sleep(1);
}
else if (DB::Aowow()->selectCell('SELECT 1 FROM ?_config WHERE `flags` & ?d AND `key` = ?', CON_FLAG_PHP, $key))
{
CLI::write("this configuration option is already in use", CLI::LOG_ERROR);
sleep(1);
}
if ($err = Cfg::add($key, $setting['val']))
CLI::write($err, CLI::LOG_ERROR);
else
{
DB::Aowow()->query('INSERT IGNORE INTO ?_config (`key`, `value`, `cat`, `flags`) VALUES (?, ?, 0, ?d)', $key, $setting['val'], CON_FLAG_TYPE_STRING | CON_FLAG_PHP);
CLI::write("new php configuration added", CLI::LOG_OK);
sleep(1);
}
CLI::write('new php configuration added', CLI::LOG_OK);
sleep(1);
CLI::write();
break;
}
else
{
CLI::write("edit canceled! returning to list...", CLI::LOG_INFO);
CLI::write('edit canceled! returning to list...', CLI::LOG_INFO);
CLI::write();
sleep(1);
break;
@@ -220,58 +148,30 @@ function siteconfig() : void
}
}
// edit existing setting
else if ($inp['idx'] >= 0 && $inp['idx'] < $sumNum)
else if ($idx >= 0 && $idx < $sumNum)
{
$conf = $cfgList[$inp['idx']];
$info = explode(' - ', $conf['comment']);
$key = strtolower($conf['key']);
[$value, $flags, , $default, $comment] = Cfg::get($cfgList[$idx], false, true);
$key = $cfgList[$idx];
$info = explode(' - ', $comment);
$buff = '';
$buff .= $conf['flags'] & CON_FLAG_PHP ? " PHP: " : "AOWOW: ";
$buff .= $conf['flags'] & CON_FLAG_PHP ? $key : strtoupper('cfg_'.$conf['key']);
$buff .= $flags & Cfg::FLAG_PHP ? 'PHP: ' : 'AOWOW: ';
$buff .= $flags & Cfg::FLAG_PHP ? $key : 'Cfg::'.strtoupper($key);
if (!empty($info[1]))
$buff .= " - ".$info[1];
if (!empty($info[0]))
$buff .= ' - '.$info[0];
CLI::write($buff);
CLI::write();
$buff = "VALUE: ";
if ($conf['flags'] & CON_FLAG_TYPE_BOOL)
$buff .= $conf['value'] ? '<Enabled>' : '<Disabled>';
else if ($conf['flags'] & CON_FLAG_OPT_LIST && !empty($info[2]))
{
foreach (explode(', ', $info[2]) as $option)
{
$opt = explode(':', $option);
$buff .= '['.($conf['value'] == $opt[0] ? 'x' : ' ').'] '.$opt[1].' ';
}
}
else if ($conf['flags'] & CON_FLAG_BITMASK && !empty($info[2]))
{
foreach (explode(', ', $info[2]) as $option)
{
$opt = explode(':', $option);
$buff .= '['.($conf['value'] & (1 << $opt[0]) ? 'x' : ' ').'] '.$opt[1].' ';
}
}
else if ($conf['flags'] & CON_FLAG_TYPE_STRING)
$buff .= $conf['value'];
else if ($conf['flags'] & CON_FLAG_TYPE_FLOAT)
$buff .= floatVal($conf['value']);
else /* if ($conf['flags'] & CON_FLAG_TYPE_INT) */
$buff .= intVal($conf['value']);
CLI::write($buff);
CLI::write('VALUE: '.formatValue($value, $flags, $info[1] ?? ''));
CLI::write();
CLI::write("[".CLI::bold('E')."]dit");
CLI::write('['.CLI::bold('E').']dit');
if (!($conf['flags'] & CON_FLAG_PERSISTENT))
CLI::write("[".CLI::bold('D')."]elete");
if (!($flags & Cfg::FLAG_PERSISTENT))
CLI::write('['.CLI::bold('D').']elete');
if (strstr($info[0], 'default:'))
CLI::write("[".CLI::bold('R')."]estore Default - ".trim(explode('default:', $info[0])[1]));
if ($default)
CLI::write('['.CLI::bold('R').']estore Default - '.$default);
CLI::write();
@@ -287,48 +187,34 @@ function siteconfig() : void
$single = false;
$value = ['idx' => ['Select new value', false, &$pattern]];
if ($conf['flags'] & CON_FLAG_OPT_LIST)
if ($flags & Cfg::FLAG_OPT_LIST)
{
$_valid = [];
foreach (explode(', ', $info[2]) as $option)
foreach (explode(', ', $info[1]) as $option)
{
$opt = explode(':', $option);
$_valid[] = $opt[0];
CLI::write('['.CLI::bold($opt[0]).'] '.$opt[1]);
[$val, $name] = explode(':', $option);
CLI::write('['.CLI::bold($val).'] '.$name);
}
$single = true;
$pattern = '/\d/';
$validate = function ($v) use($_valid) { return in_array($v, $_valid); };
}
else if ($conf['flags'] & CON_FLAG_BITMASK)
else if ($flags & Cfg::FLAG_BITMASK)
{
CLI::write('Bitmask: sum fields to select multiple options');
$_valid = 0x0;
foreach (explode(', ', $info[2]) as $option)
foreach (explode(', ', $info[1]) as $option)
{
$opt = explode(':', $option);
$_valid |= (1 << $opt[0]);
CLI::write('['.CLI::bold(1 << $opt[0]).']'.str_pad('', 4-strlen(1 << $opt[0])).$opt[1]);
[$val, $name] = explode(':', $option);
CLI::write('['.CLI::bold(1 << $val).']'.str_pad('', 6 - strlen(1 << $val)).$name);
}
$pattern = '/\d+/';
$validate = function ($v) use($_valid) { $v = ($v ?: 0) & $_valid; return $v; };
}
else if ($conf['flags'] & CON_FLAG_TYPE_BOOL)
else if ($flags & Cfg::FLAG_TYPE_BOOL)
{
CLI::write('['.CLI::bold(0).'] Disabled');
CLI::write('['.CLI::bold(1).'] Enabled');
$single = true;
$pattern = '/[01]/';
$validate = function ($v) { return true; };
}
else if ($conf['flags'] & CON_FLAG_TYPE_INT)
$validate = function ($v) { return preg_match('/^-?\d+$/i', $v); };
else if ($conf['flags'] & CON_FLAG_TYPE_FLOAT)
$validate = function ($v) { return preg_match('/^-?\d*(,|.)?\d+$/i', $v); };
else // string
$validate = function ($v) { return true; };
while (true)
{
@@ -338,33 +224,23 @@ function siteconfig() : void
CLI::write();
$inp = $use['idx'] ?? '';
if (!$validate($inp))
if ($err = Cfg::set($key, $inp, $updScripts))
{
CLI::write("value not in range", CLI::LOG_ERROR);
CLI::write($err, CLI::LOG_ERROR);
sleep(1);
continue;
}
else
{
$oldVal = DB::Aowow()->selectCell('SELECT `value` FROM ?_config WHERE `key` = ?', $key);
DB::Aowow()->query('UPDATE ?_config SET `value` = ? WHERE `key` = ?', $inp, $key);
// postChange returned false => reset value
if (!$onChange($key, $inp))
{
DB::Aowow()->query('UPDATE ?_config SET `value` = ? WHERE `key` = ?', $oldVal, $key);
sleep(1);
break;
}
CLI::write("setting updated", CLI::LOG_OK);
CLI::write('setting updated', CLI::LOG_OK);
sleep(1);
break 3;
}
}
else
{
CLI::write("edit canceled! returning to selection...", CLI::LOG_INFO);
CLI::write('edit canceled! returning to selection...', CLI::LOG_INFO);
sleep(1);
break;
}
@@ -372,29 +248,26 @@ function siteconfig() : void
break 2;
case 'R': // restore default
if (!strstr($info[0], 'default:'))
if (!$default)
continue 2;
// @eval .. some dafault values are supplied as bitmask or the likes
$val = trim(explode('default:', $info[0])[1]);
if (!($conf['flags'] & CON_FLAG_TYPE_STRING))
$val = @eval('return ('.$val.');');
if (DB::Aowow()->query('UPDATE ?_config SET `value` = ? WHERE `key` = ?', $val, $key))
{
CLI::write("default value restored", CLI::LOG_OK);
$onChange($key, $val);
sleep(1);
}
if ($err = Cfg::reset($key, $updScripts))
CLI::write($err, CLI::LOG_ERROR);
else
CLI::write('default value restored', CLI::LOG_OK);
sleep(1);
break 2;
case 'D': // delete config pair
if ($conf['flags'] & CON_FLAG_PERSISTENT)
if ($flags & Cfg::FLAG_PERSISTENT)
continue 2;
if (DB::Aowow()->query('DELETE FROM ?_config WHERE `key` = ? AND (`flags` & ?d) = 0', $key, CON_FLAG_PERSISTENT))
{
CLI::write("php setting deleted ['".$conf['key']."': '".$conf['value']."']", CLI::LOG_OK);
sleep(1);
}
if ($err = Cfg::delete($key))
CLI::write($err, CLI::LOG_ERROR);
else
CLI::write("php setting deleted ['".$key."': '".$value."']", CLI::LOG_OK);
sleep(1);
break 2;
}
}
@@ -440,9 +313,6 @@ function siteconfig() : void
$updScripts = [];
}
}
// actually load set constants
loadConfig(true);
}
?>

View File

@@ -60,14 +60,6 @@ class FileGen
'static/wowsounds/'
);
private static $txtConstants = array(
'CFG_NAME' => '',
'CFG_NAME_SHORT' => '',
'CFG_CONTACT_EMAIL' => '',
'HOST_URL' => '',
'STATIC_URL' => ''
);
public static function init(int $mode = self::MODE_NORMAL, array $updScripts = []) : bool
{
self::$defaultExecTime = ini_get('max_execution_time');
@@ -186,14 +178,10 @@ class FileGen
{
[$file, $destPath, $deps] = self::$tplFiles[$key];
foreach (self::$txtConstants as $n => &$c)
if (!$c && defined($n))
$c = constant($n);
if ($content = file_get_contents(self::$tplPath.$file.'.in'))
{
// replace constants
$content = strtr($content, self::$txtConstants);
$content = Cfg::applyToString($content);
// check for required auxiliary DBC files
foreach ($reqDBC as $req)

View File

@@ -83,7 +83,7 @@ if (!CLI)
$enchIds = array_column($enchantSpells, 'effect1MiscValue');
$enchantments = new EnchantmentList(array(['id', $enchIds], CFG_SQL_LIMIT_NONE));
$enchantments = new EnchantmentList(array(['id', $enchIds], Cfg::get('SQL_LIMIT_NONE')));
if ($enchantments->error)
{
CLI::write('Required table ?_itemenchantment seems to be empty! Leaving enchants()...', CLI::LOG_ERROR);
@@ -91,7 +91,7 @@ if (!CLI)
return false;
}
$castItems = new ItemList(array(['spellId1', array_keys($enchantSpells)], ['src.typeId', null, '!'], CFG_SQL_LIMIT_NONE));
$castItems = new ItemList(array(['spellId1', array_keys($enchantSpells)], ['src.typeId', null, '!'], Cfg::get('SQL_LIMIT_NONE')));
foreach (CLISetup::$localeIds as $lId)
{

View File

@@ -53,7 +53,7 @@ if (!CLI)
foreach ($gems as $pop)
$enchIds[] = $pop['enchId'];
$enchantments = new EnchantmentList(array(['id', $enchIds], CFG_SQL_LIMIT_NONE));
$enchantments = new EnchantmentList(array(['id', $enchIds], Cfg::get('SQL_LIMIT_NONE')));
if ($enchantments->error)
{
CLI::write('Required table ?_itemenchantment seems to be empty! Leaving gems()...', CLI::LOG_ERROR);

View File

@@ -48,7 +48,7 @@ if (!CLI)
if (!CLISetup::writeDir('datasets/'.$dir))
$success = false;
$glyphSpells = new SpellList(array(['s.id', array_keys($glyphList)], CFG_SQL_LIMIT_NONE));
$glyphSpells = new SpellList(array(['s.id', array_keys($glyphList)], Cfg::get('SQL_LIMIT_NONE')));
foreach (CLISetup::$localeIds as $lId)
{

View File

@@ -69,9 +69,9 @@ if (!CLI)
$mods = DB::Aowow()->selectCol('SELECT idx - 1 AS ARRAY_KEY, ratio FROM dbc_gtoctclasscombatratingscalar WHERE idx IN (?a)', $offsets);
foreach ($data as $itemMod => &$val)
$val = CFG_DEBUG ? $base[$val].' / '.$mods[$val] : $base[$val] / $mods[$val];
$val = Cfg::get('DEBUG') ? $base[$val].' / '.$mods[$val] : $base[$val] / $mods[$val];
if (!CFG_DEBUG)
if (!Cfg::get('DEBUG'))
return Util::toJSON($data);
$buff = [];
@@ -97,7 +97,7 @@ if (!CLI)
foreach ($data as &$d)
$d = array_values($d); // strip indizes
return CFG_DEBUG ? debugify($data) : Util::toJSON($data);
return Cfg::get('DEBUG') ? debugify($data) : Util::toJSON($data);
}
function itemScalingSD()
@@ -109,7 +109,6 @@ if (!CLI)
array_splice($row, 0, 1);
}
return CFG_DEBUG ? debugify($data) : Util::toJSON($data);
return Cfg::get('DEBUG') ? debugify($data) : Util::toJSON($data);
}
?>

View File

@@ -63,7 +63,7 @@ if (!CLI)
$questorder = [];
$questtotal = [];
$condition = [
CFG_SQL_LIMIT_NONE,
Cfg::get('SQL_LIMIT_NONE'),
'AND',
[['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW | CUSTOM_UNAVAILABLE | CUSTOM_DISABLED, '&'], 0],
[['flags', QUEST_FLAG_DAILY | QUEST_FLAG_WEEKLY | QUEST_FLAG_REPEATABLE | QUEST_FLAG_AUTO_REWARDED, '&'], 0],
@@ -151,7 +151,7 @@ if (!CLI)
{
$success = true;
$condition = array(
CFG_SQL_LIMIT_NONE,
Cfg::get('SQL_LIMIT_NONE'),
[['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0],
);
$titlez = new TitleList($condition);
@@ -193,7 +193,7 @@ if (!CLI)
{
$success = true;
$condition = array(
CFG_SQL_LIMIT_NONE,
Cfg::get('SQL_LIMIT_NONE'),
[['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0],
['typeCat', -5],
['castTime', 0, '!']
@@ -253,7 +253,7 @@ if (!CLI)
{
$success = true;
$condition = array(
CFG_SQL_LIMIT_NONE,
Cfg::get('SQL_LIMIT_NONE'),
[['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0],
['typeCat', -6]
);
@@ -297,7 +297,7 @@ if (!CLI)
{
$success = true;
$condition = array( // todo (med): exclude non-gaining reputation-header
CFG_SQL_LIMIT_NONE,
Cfg::get('SQL_LIMIT_NONE'),
[['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0]
);
$factionz = new FactionList($condition);
@@ -331,7 +331,7 @@ if (!CLI)
$skills = array_merge(SKILLS_TRADE_PRIMARY, [[185, 129, 356]]);
$success = true;
$baseCnd = array(
CFG_SQL_LIMIT_NONE,
Cfg::get('SQL_LIMIT_NONE'),
[['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0],
['effect1Id', [6, 45, 57, 127, 33, 158, 99, 28, 95], '!'], // aura, tradeSkill, Tracking, Prospecting, Decipher, Milling, Disenchant, Summon (Engineering), Skinning
['effect2Id', [118, 60], '!'], // not the skill itself
@@ -397,7 +397,7 @@ if (!CLI)
{
$success = true;
$condition = array(
CFG_SQL_LIMIT_NONE,
Cfg::get('SQL_LIMIT_NONE'),
[['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0],
[['flags', 1, '&'], 0], // no statistics
);

View File

@@ -42,8 +42,8 @@ if (!CLI)
$set = 0x0;
$menu = [
// skip usage of battlegroup
// ['us', Lang::profiler('regions', 'us'), null,[[Profiler::urlize(CFG_BATTLEGROUP), CFG_BATTLEGROUP, null, &$subUS]]],
// ['eu', Lang::profiler('regions', 'eu'), null,[[Profiler::urlize(CFG_BATTLEGROUP), CFG_BATTLEGROUP, null, &$subEU]]]
// ['us', Lang::profiler('regions', 'us'), null,[[Profiler::urlize(Cfg::get('BATTLEGROUP')), Cfg::get('BATTLEGROUP'), null, &$subUS]]],
// ['eu', Lang::profiler('regions', 'eu'), null,[[Profiler::urlize(Cfg::get('BATTLEGROUP')), Cfg::get('BATTLEGROUP'), null, &$subEU]]]
];
foreach (Util::$regions as $idx => $n)

View File

@@ -33,7 +33,7 @@ if (!CLI)
CLI::write(' - realms: Auth-DB not set up .. static data g_realms will be empty', CLI::LOG_WARN);
// else
// foreach ($realms as &$r)
// $r['battlegroup'] = CFG_BATTLEGROUP;
// $r['battlegroup'] = Cfg::get('BATTLEGROUP');
// remove access column
array_walk($realms, function (&$x) { unset($x['access']); });

View File

@@ -31,7 +31,7 @@ if (!CLI)
function talentCalc()
{
$success = true;
$spellMods = (new SpellList(array(['typeCat', -2], CFG_SQL_LIMIT_NONE)))->getProfilerMods();
$spellMods = (new SpellList(array(['typeCat', -2], Cfg::get('SQL_LIMIT_NONE'))))->getProfilerMods();
$buildTree = function ($class) use (&$petFamIcons, &$tSpells, $spellMods)
{
@@ -171,7 +171,7 @@ if (!CLI)
$success = false;
$tSpellIds = DB::Aowow()->selectCol('SELECT rank1 FROM dbc_talent UNION SELECT rank2 FROM dbc_talent UNION SELECT rank3 FROM dbc_talent UNION SELECT rank4 FROM dbc_talent UNION SELECT rank5 FROM dbc_talent');
$tSpells = new SpellList(array(['s.id', $tSpellIds], CFG_SQL_LIMIT_NONE));
$tSpells = new SpellList(array(['s.id', $tSpellIds], Cfg::get('SQL_LIMIT_NONE')));
foreach (CLISetup::$localeIds as $lId)
{

View File

@@ -153,7 +153,7 @@ SqlGen::register(new class extends SetupScript
}
if ($spells)
$spellStats = (new SpellList(array(['id', $spells], CFG_SQL_LIMIT_NONE)))->getStatGain();
$spellStats = (new SpellList(array(['id', $spells], Cfg::get('SQL_LIMIT_NONE'))))->getStatGain();
$result = [];
foreach ($enchants as $eId => $e)

View File

@@ -241,7 +241,7 @@ SqlGen::register(new class extends SetupScript
$descText = [];
foreach (Util::mask2bits(CFG_LOCALES) as $loc)
foreach (Util::mask2bits(Cfg::get('LOCALES')) as $loc)
{
User::useLocale($loc);

View File

@@ -0,0 +1,72 @@
ALTER TABLE aowow_config
MODIFY COLUMN `cat` tinyint unsigned NOT NULL DEFAULT 0,
MODIFY COLUMN `flags` smallint unsigned NOT NULL DEFAULT 0,
ADD COLUMN `default` varchar(255) DEFAULT NULL AFTER `value`;
INSERT IGNORE INTO aowow_config VALUES
('rep_req_border_unco', 5000, 5000, 5, 129, 'required reputation for uncommon quality avatar border'),
('rep_req_border_rare', 10000, 10000, 5, 129, 'required reputation for rare quality avatar border'),
('rep_req_border_epic', 15000, 15000, 5, 129, 'required reputation for epic quality avatar border'),
('rep_req_border_lege', 25000, 25000, 5, 129, 'required reputation for legendary quality avatar border');
UPDATE aowow_config SET `default` = 'UTF-8' WHERE `key` = 'default_charset';
UPDATE aowow_config SET `comment` = 'website title' WHERE `key` = 'name';
UPDATE aowow_config SET `comment` = 'feed title' WHERE `key` = 'name_short';
UPDATE aowow_config SET `comment` = 'another halfbaked javascript thing..' WHERE `key` = 'board_url';
UPDATE aowow_config SET `comment` = 'displayed sender for auth-mails, ect' WHERE `key` = 'contact_email';
UPDATE aowow_config SET `comment` = 'pretend, we belong to a battlegroup to satisfy profiler-related javascripts' WHERE `key` = 'battlegroup';
UPDATE aowow_config SET `comment` = 'points js to executable files', `flags` = `flags` | 768 WHERE `key` = 'site_host';
UPDATE aowow_config SET `comment` = 'points js to images & scripts', `flags` = `flags` | 768 WHERE `key` = 'static_host';
UPDATE aowow_config SET `comment` = 'some derelict code, probably unused' WHERE `key` = 'serialize_precision';
UPDATE aowow_config SET `comment` = 'enter your GA-user here to track site stats' WHERE `key` = 'analytics_user';
UPDATE aowow_config SET `comment` = 'if auth mode is not self; link to external account creation' WHERE `key` = 'acc_ext_create_url';
UPDATE aowow_config SET `comment` = 'if auth mode is not self; link to external account recovery' WHERE `key` = 'acc_ext_recover_url';
UPDATE aowow_config SET `comment` = 'php sessions are saved here. Leave empty to use php default directory.' WHERE `key` = 'session_cache_dir';
UPDATE aowow_config SET `comment` = 'max results for search', `default` = '500' WHERE `key` = 'sql_limit_search';
UPDATE aowow_config SET `comment` = 'max results for listviews', `default` = '300' WHERE `key` = 'sql_limit_default';
UPDATE aowow_config SET `comment` = 'max results for suggestions', `default` = '10' WHERE `key` = 'sql_limit_quicksearch';
UPDATE aowow_config SET `comment` = 'unlimited results (i wouldn\'t change that mate)', `default` = '0' WHERE `key` = 'sql_limit_none';
UPDATE aowow_config SET `comment` = 'time to live for RSS (in seconds)', `default` = '60' WHERE `key` = 'ttl_rss';
UPDATE aowow_config SET `comment` = 'disable cache, enable error_reporting - 0:None, 1:Error, 2:Warning, 3:Info', `default` = '0', `flags` = 145 WHERE `key` = 'debug';
UPDATE aowow_config SET `comment` = 'display brb gnomes and block access for non-staff', `default` = '0' WHERE `key` = 'maintenance';
UPDATE aowow_config SET `comment` = 'vote limit per day', `default` = '50' WHERE `key` = 'user_max_votes';
UPDATE aowow_config SET `comment` = 'enforce SSL, if auto-detect fails', `default` = '0' WHERE `key` = 'force_ssl';
UPDATE aowow_config SET `comment` = 'allowed locales - 0:English, 2:French, 3:German, 4:Chinese, 6:Spanish, 8:Russian', `default` = '0x15D' WHERE `key` = 'locales';
UPDATE aowow_config SET `comment` = 'minimum dimensions of uploaded screenshots in px (yes, it\'s square)', `default` = '200' WHERE `key` = 'screenshot_min_size';
UPDATE aowow_config SET `comment` = 'time to keep cache in seconds', `default` = '60 * 60 * 7' WHERE `key` = 'cache_decay';
UPDATE aowow_config SET `comment` = 'set cache method - 0:filecache, 1:memcached', `default` = '1' WHERE `key` = 'cache_mode';
UPDATE aowow_config SET `comment` = 'generated pages are saved here (requires CACHE_MODE: filecache)', `default` = 'cache/template' WHERE `key` = 'cache_dir';
UPDATE aowow_config SET `comment` = 'how long an account is closed after exceeding FAILED_AUTH_COUNT (in seconds)', `default` = '15 * 60' WHERE `key` = 'acc_failed_auth_block';
UPDATE aowow_config SET `comment` = 'how often invalid passwords are tolerated', `default` = '5' WHERE `key` = 'acc_failed_auth_count';
UPDATE aowow_config SET `comment` = 'allow/disallow account creation (requires AUTH_MODE: aowow)', `default` = '1' WHERE `key` = 'acc_allow_register';
UPDATE aowow_config SET `comment` = 'source to auth against - 0:AoWoW, 1:TC auth-table, 2:External script (config/extAuth.php)', `default` = '0', `flags`= `flags`| 256 WHERE `key` = 'acc_auth_mode';
UPDATE aowow_config SET `comment` = 'time in wich an unconfirmed account cannot be overwritten by new registrations', `default` = '604800' WHERE `key` = 'acc_create_save_decay';
UPDATE aowow_config SET `comment` = 'time to recover your account and new recovery requests are blocked', `default` = '300' WHERE `key` = 'acc_recovery_decay';
UPDATE aowow_config SET `comment` = 'non-permanent session times out in time() + X', `default` = '60 * 60' WHERE `key` = 'session_timeout_delay';
UPDATE aowow_config SET `comment` = 'lifetime of session data', `default` = '7 * 24 * 60 * 60' WHERE `key` = 'session.gc_maxlifetime';
UPDATE aowow_config SET `comment` = 'probability to remove session data on garbage collection', `default` = '0' WHERE `key` = 'session.gc_probability';
UPDATE aowow_config SET `comment` = 'probability to remove session data on garbage collection', `default` = '100' WHERE `key` = 'session.gc_divisor';
UPDATE aowow_config SET `comment` = 'required reputation to upvote comments', `default` = '125' WHERE `key` = 'rep_req_upvote';
UPDATE aowow_config SET `comment` = 'required reputation to downvote comments', `default` = '250' WHERE `key` = 'rep_req_downvote';
UPDATE aowow_config SET `comment` = 'required reputation to write a comment', `default` = '75' WHERE `key` = 'rep_req_comment';
UPDATE aowow_config SET `comment` = 'required reputation to write a reply', `default` = '75' WHERE `key` = 'rep_req_reply';
UPDATE aowow_config SET `comment` = 'required reputation for double vote effect', `default` = '2500' WHERE `key` = 'rep_req_supervote';
UPDATE aowow_config SET `comment` = 'gains more votes past this threshold', `default` = '2000' WHERE `key` = 'rep_req_votemore_base';
UPDATE aowow_config SET `comment` = 'activated an account', `default` = '100' WHERE `key` = 'rep_reward_register';
UPDATE aowow_config SET `comment` = 'comment received upvote', `default` = '5' WHERE `key` = 'rep_reward_upvoted';
UPDATE aowow_config SET `comment` = 'comment received downvote', `default` = '0' WHERE `key` = 'rep_reward_downvoted';
UPDATE aowow_config SET `comment` = 'filed an accepted report', `default` = '10' WHERE `key` = 'rep_reward_good_report';
UPDATE aowow_config SET `comment` = 'filed a rejected report', `default` = '0' WHERE `key` = 'rep_reward_bad_report';
UPDATE aowow_config SET `comment` = 'daily visit', `default` = '5' WHERE `key` = 'rep_reward_dailyvisit';
UPDATE aowow_config SET `comment` = 'moderator imposed a warning', `default` = '-50' WHERE `key` = 'rep_reward_user_warned';
UPDATE aowow_config SET `comment` = 'created a comment (not a reply)', `default` = '1' WHERE `key` = 'rep_reward_comment';
UPDATE aowow_config SET `comment` = 'required reputation for premium status through reputation', `default` = '25000' WHERE `key` = 'rep_req_premium';
UPDATE aowow_config SET `comment` = 'suggested / uploaded video / screenshot was approved', `default` = '10' WHERE `key` = 'rep_reward_upload';
UPDATE aowow_config SET `comment` = 'submitted an approved article/guide', `default` = '100' WHERE `key` = 'rep_reward_article';
UPDATE aowow_config SET `comment` = 'moderator revoked rights', `default` = '-200' WHERE `key` = 'rep_reward_user_suspended';
UPDATE aowow_config SET `comment` = 'required reputation per additional vote past threshold', `default` = '250' WHERE `key` = 'rep_req_votemore_add';
UPDATE aowow_config SET `comment` = 'parsing spell.dbc is quite intense', `default` = '1500M' WHERE `key` = 'memory_limit';
UPDATE aowow_config SET `comment` = 'enable/disable profiler feature', `default` = '0', `flags`= `flags`| 256 WHERE `key` = 'profiler_enable';
UPDATE aowow_config SET `comment` = 'min. delay between queue cycles (in ms)', `default` = '3000' WHERE `key` = 'profiler_queue_delay';
UPDATE aowow_config SET `comment` = 'how often the javascript asks for for updates, when queued (in ms)', `default` = '5000' WHERE `key` = 'profiler_resync_ping';
UPDATE aowow_config SET `comment` = 'how often a character can be refreshed (in sec)', `default` = '1 * 60 * 60' WHERE `key` = 'profiler_resync_delay';