From f77d676a19380d38ea161229f19a5680c092fad9 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Tue, 28 May 2024 15:41:44 +0200 Subject: [PATCH] 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 --- includes/ajaxHandler/admin.class.php | 112 +------ includes/ajaxHandler/data.class.php | 4 +- includes/ajaxHandler/profile.class.php | 10 +- includes/basetype.class.php | 4 +- includes/community.class.php | 26 +- includes/config.class.php | 387 +++++++++++++++++++++++ includes/database.class.php | 2 +- includes/defines.php | 10 - includes/kernel.php | 138 ++++---- includes/loot.class.php | 7 +- includes/profiler.class.php | 6 +- includes/types/arenateam.class.php | 8 +- includes/types/guide.class.php | 4 +- includes/types/guild.class.php | 6 +- includes/types/item.class.php | 6 +- includes/types/profile.class.php | 8 +- includes/types/sound.class.php | 2 +- includes/types/spell.class.php | 2 +- includes/user.class.php | 41 +-- includes/utilities.php | 140 ++++---- localization/lang.class.php | 2 + localization/locale_dede.php | 18 +- localization/locale_enus.php | 18 +- localization/locale_eses.php | 18 +- localization/locale_frfr.php | 18 +- localization/locale_ruru.php | 18 +- localization/locale_zhcn.php | 18 +- pages/account.php | 52 +-- pages/achievements.php | 4 +- pages/admin.php | 83 ++--- pages/areatriggers.php | 4 +- pages/arenateam.php | 2 +- pages/arenateams.php | 8 +- pages/class.php | 6 +- pages/emotes.php | 2 +- pages/enchantment.php | 2 +- pages/enchantments.php | 4 +- pages/faction.php | 8 +- pages/genericPage.class.php | 45 +-- pages/guide.php | 2 +- pages/guild.php | 4 +- pages/guilds.php | 8 +- pages/home.php | 4 +- pages/item.php | 6 +- pages/items.php | 4 +- pages/itemsets.php | 4 +- pages/more.php | 46 ++- pages/npcs.php | 4 +- pages/object.php | 4 +- pages/objects.php | 4 +- pages/pet.php | 2 +- pages/profile.php | 2 +- pages/profiler.php | 2 +- pages/profiles.php | 8 +- pages/quests.php | 4 +- pages/screenshot.php | 13 +- pages/search.php | 15 +- pages/skill.php | 16 +- pages/sound.php | 2 +- pages/sounds.php | 4 +- pages/spell.php | 4 +- pages/spells.php | 4 +- pages/user.php | 8 +- pages/utility.php | 32 +- pages/zone.php | 6 +- pages/zones.php | 2 +- prQueue | 8 +- setup/db_structure.sql | 9 +- setup/tools/CLISetup.class.php | 6 +- setup/tools/clisetup/account.func.php | 2 +- setup/tools/clisetup/setup.func.php | 21 +- setup/tools/clisetup/siteconfig.func.php | 338 ++++++-------------- setup/tools/fileGen.class.php | 14 +- setup/tools/filegen/enchants.func.php | 4 +- setup/tools/filegen/gems.func.php | 2 +- setup/tools/filegen/glyphs.func.php | 2 +- setup/tools/filegen/itemScaling.func.php | 9 +- setup/tools/filegen/profiler.func.php | 14 +- setup/tools/filegen/realmMenu.func.php | 4 +- setup/tools/filegen/realms.func.php | 2 +- setup/tools/filegen/talentCalc.func.php | 4 +- setup/tools/sqlgen/item_stats.func.php | 2 +- setup/tools/sqlgen/itemset.func.php | 2 +- setup/updates/1717076299_01.sql | 72 +++++ template/bricks/footer.tpl.php | 2 +- template/bricks/head.tpl.php | 12 +- template/localized/ssReminder_0.tpl.php | 2 +- template/localized/ssReminder_3.tpl.php | 2 +- template/localized/ssReminder_4.tpl.php | 2 +- template/pages/acc-signIn.tpl.php | 2 +- template/pages/guide-edit.tpl.php | 4 +- template/pages/maintenance.tpl.php | 4 +- template/pages/privileges.tpl.php | 2 +- template/pages/spell.tpl.php | 2 +- 94 files changed, 1094 insertions(+), 922 deletions(-) create mode 100644 includes/config.class.php create mode 100644 setup/updates/1717076299_01.sql diff --git a/includes/ajaxHandler/admin.class.php b/includes/ajaxHandler/admin.class.php index 62a104a0..3632507e 100644 --- a/includes/ajaxHandler/admin.class.php +++ b/includes/ajaxHandler/admin.class.php @@ -324,20 +324,7 @@ class AjaxAdmin extends AjaxHandler $key = trim($this->_get['key']); $val = trim(urldecode($this->_get['val'])); - if ($key === null) - return 'empty option name given'; - - if (!strlen($key)) - return 'invalid chars in option name: [a-z 0-9 _ . -] are allowed'; - - if (ini_get($key) === false || ini_set($key, $val) === false) - return 'this configuration option cannot be set'; - - if (DB::Aowow()->selectCell('SELECT 1 FROM ?_config WHERE `flags` & ?d AND `key` = ?', CON_FLAG_PHP, $key)) - return 'this configuration option is already in use'; - - DB::Aowow()->query('INSERT IGNORE INTO ?_config (`key`, `value`, `cat`, `flags`) VALUES (?, ?, 0, ?d)', $key, $val, CON_FLAG_TYPE_STRING | CON_FLAG_PHP); - return ''; + return Cfg::add($key, $val); } protected function confRemove() : string @@ -345,39 +332,15 @@ class AjaxAdmin extends AjaxHandler if (!$this->reqGET('key')) return 'invalid configuration option given'; - if (DB::Aowow()->query('DELETE FROM ?_config WHERE `key` = ? AND (`flags` & ?d) = 0', $this->_get['key'], CON_FLAG_PERSISTENT)) - return ''; - else - return 'option name is either protected or was not found'; + return Cfg::delete($this->_get['key']); } protected function confUpdate() : string { $key = trim($this->_get['key']); $val = trim(urldecode($this->_get['val'])); - $msg = ''; - if (!strlen($key)) - return 'empty option name given'; - - $cfg = DB::Aowow()->selectRow('SELECT `flags`, `value` FROM ?_config WHERE `key` = ?', $key); - if (!$cfg) - return 'configuration option not found'; - - if (!($cfg['flags'] & CON_FLAG_TYPE_STRING) && !strlen($val)) - return 'empty value given'; - else if ($cfg['flags'] & CON_FLAG_TYPE_INT && !preg_match('/^-?\d+$/i', $val)) - return "value must be integer"; - else if ($cfg['flags'] & CON_FLAG_TYPE_FLOAT && !preg_match('/^-?\d*(,|.)?\d+$/i', $val)) - return "value must be float"; - else if ($cfg['flags'] & CON_FLAG_TYPE_BOOL && $val != '1') - $val = '0'; - - DB::Aowow()->query('UPDATE ?_config SET `value` = ? WHERE `key` = ?', $val, $key); - if (!$this->confOnChange($key, $val, $msg)) - DB::Aowow()->query('UPDATE ?_config SET `value` = ? WHERE `key` = ?', $cfg['value'], $key); - - return $msg; + return Cfg::set($key, $val); } protected function wtSave() : string @@ -563,7 +526,7 @@ class AjaxAdmin extends AjaxHandler protected static function checkKey(string $val) : string { // expecting string - if (preg_match('/[^a-z0-9_\.\-]/i', $val)) + if (preg_match(Cfg::PATTERN_INV_CONF_KEY, $val)) return ''; return strtolower($val); @@ -586,73 +549,6 @@ class AjaxAdmin extends AjaxHandler return ''; } - - - /**********/ - /* helper */ - /**********/ - - private static function confOnChange(string $key, string $val, string &$msg) : bool - { - $fn = $buildList = null; - - switch ($key) - { - case 'battlegroup': - $buildList = 'realms,realmMenu'; - break; - case 'name_short': - $buildList = 'searchboxBody,demo,searchplugin'; - break; - case 'site_host': - $buildList = 'searchplugin,demo,power,searchboxBody'; - break; - case 'static_host': - $buildList = 'searchplugin,power,searchboxBody,searchboxScript'; - break; - case 'contact_email': - $buildList = 'markup'; - break; - case 'locales': - $buildList = 'locales'; - $msg .= ' * remember to rebuild all static files for the language you just added.
'; - $msg .= ' * you can speed this up by supplying the regionCode to the setup:
--locales= -f
'; - break; - case 'profiler_enable': - $buildList = 'realms,realmMenu'; - $fn = function($x) use (&$msg) { - if (!$x) - return true; - - return Profiler::queueStart($msg); - }; - break; - case 'acc_auth_mode': - $fn = function($x) use (&$msg) { - if ($x == 1 && !extension_loaded('gmp')) - { - $msg .= 'PHP extension GMP is required to use TrinityCore as auth source, but is not currently enabled.
'; - return false; - } - - return true; - }; - break; - default: // nothing to do, everything is fine - return true; - } - - if ($buildList) - { - // we need to use exec as build() can only be run from CLI - exec('php aowow --build='.$buildList, $out); - foreach ($out as $o) - if (strstr($o, 'ERR')) - $msg .= explode('0m]', $o)[1]."
\n"; - } - - return $fn ? $fn($val) : true; - } } ?> diff --git a/includes/ajaxHandler/data.class.php b/includes/ajaxHandler/data.class.php index 5b10fcba..49348489 100644 --- a/includes/ajaxHandler/data.class.php +++ b/includes/ajaxHandler/data.class.php @@ -86,7 +86,7 @@ class AjaxData extends AjaxHandler case 'item-scaling': case 'realms': case 'statistics': - if (!Util::loadStaticFile($set, $result) && CFG_DEBUG) + if (!Util::loadStaticFile($set, $result) && Cfg::get('DEBUG')) $result .= "alert('could not fetch static data: ".$set."');"; $result .= "\n\n"; @@ -102,7 +102,7 @@ class AjaxData extends AjaxHandler case 'enchants': case 'itemsets': case 'pets': - if (!Util::loadStaticFile($set, $result, true) && CFG_DEBUG) + if (!Util::loadStaticFile($set, $result, true) && Cfg::get('DEBUG')) $result .= "alert('could not fetch static data: ".$set." for locale: ".User::$localeString."');"; $result .= "\n\n"; diff --git a/includes/ajaxHandler/profile.class.php b/includes/ajaxHandler/profile.class.php index 453c09ea..02f32142 100644 --- a/includes/ajaxHandler/profile.class.php +++ b/includes/ajaxHandler/profile.class.php @@ -48,7 +48,7 @@ class AjaxProfile extends AjaxHandler if (!$this->params) return; - if (!CFG_PROFILER_ENABLE) + if (!Cfg::get('PROFILER_ENABLE')) return; switch ($this->params[0]) @@ -563,7 +563,7 @@ class AjaxProfile extends AjaxHandler if ($pBase['realm']) { $profile['region'] = [$rData['region'], Lang::profiler('regions', $rData['region'])]; - $profile['battlegroup'] = [Profiler::urlize(CFG_BATTLEGROUP), CFG_BATTLEGROUP]; + $profile['battlegroup'] = [Profiler::urlize(Cfg::get('BATTLEGROUP')), Cfg::get('BATTLEGROUP')]; $profile['realm'] = [Profiler::urlize($rData['name'], true), $rData['name']]; } @@ -616,7 +616,7 @@ class AjaxProfile extends AjaxHandler $profile['titles'] = $data; break; case Type::QUEST: - $qList = new QuestList(array(['id', array_keys($data)], CFG_SQL_LIMIT_NONE)); + $qList = new QuestList(array(['id', array_keys($data)], Cfg::get('SQL_LIMIT_NONE'))); $qResult = []; foreach ($qList->iterate() as $id => $__) $qResult[$id] = [$qList->getField('cat1'), $qList->getField('cat2')]; @@ -691,7 +691,7 @@ class AjaxProfile extends AjaxHandler if ($items = DB::Aowow()->select('SELECT * FROM ?_profiler_items WHERE id = ?d', $pBase['id'])) { - $itemz = new ItemList(array(['id', array_column($items, 'item')], CFG_SQL_LIMIT_NONE)); + $itemz = new ItemList(array(['id', array_column($items, 'item')], Cfg::get('SQL_LIMIT_NONE'))); if (!$itemz->error) { $data = $itemz->getListviewData(ITEMINFO_JSON | ITEMINFO_SUBITEMS); @@ -720,7 +720,7 @@ class AjaxProfile extends AjaxHandler // if ($au = $char->getField('auras')) // { - // $auraz = new SpellList(array(['id', $char->getField('auras')], CFG_SQL_LIMIT_NONE)); + // $auraz = new SpellList(array(['id', $char->getField('auras')], Cfg::get('SQL_LIMIT_NONE'))); // $dataz = $auraz->getListviewData(); // $modz = $auraz->getProfilerMods(); diff --git a/includes/basetype.class.php b/includes/basetype.class.php index 7e4ced75..9ce6bfaf 100644 --- a/includes/basetype.class.php +++ b/includes/basetype.class.php @@ -59,7 +59,7 @@ abstract class BaseType { $where = []; $linking = ' AND '; - $limit = CFG_SQL_LIMIT_DEFAULT; + $limit = Cfg::get('SQL_LIMIT_DEFAULT'); if (!$this->queryBase || $conditions === null) return; @@ -875,7 +875,7 @@ trait sourceHelper $buff[$_curTpl['moreType']][] = $_curTpl['moreTypeId']; foreach ($buff as $type => $ids) - $this->sourceMore[$type] = Type::newList($type, [CFG_SQL_LIMIT_NONE, ['id', $ids]]); + $this->sourceMore[$type] = Type::newList($type, [Cfg::get('SQL_LIMIT_NONE'), ['id', $ids]]); } $s = array_keys($this->sources[$this->id]); diff --git a/includes/community.class.php b/includes/community.class.php index 26f9f6c5..0b8c2261 100644 --- a/includes/community.class.php +++ b/includes/community.class.php @@ -116,7 +116,7 @@ class CommunityContent if (!$_) continue; - $obj = Type::newList($type, [CFG_SQL_LIMIT_NONE, ['id', $_]]); + $obj = Type::newList($type, [Cfg::get('SQL_LIMIT_NONE'), ['id', $_]]); if (!$obj) continue; @@ -154,7 +154,7 @@ class CommunityContent CC_FLAG_DELETED, User::$id, User::isInGroup(U_GROUP_COMMENTS_MODERATOR), - CFG_SQL_LIMIT_DEFAULT + Cfg::get('SQL_LIMIT_DEFAULT') ); foreach ($comments as $c) @@ -320,7 +320,7 @@ class CommunityContent if (!$ids) continue; - $obj = Type::newList($t, [CFG_SQL_LIMIT_NONE, ['id', $ids]]); + $obj = Type::newList($t, [Cfg::get('SQL_LIMIT_NONE'), ['id', $ids]]); if (!$obj || $obj->error) continue; @@ -410,13 +410,13 @@ class CommunityContent { $videos = DB::Aowow()->selectPage($nFound, self::$viQuery, CC_FLAG_STICKY, - $typeOrUser < 0 ? -$typeOrUser : DBSIMPLE_SKIP, - $typeOrUser > 0 ? $typeOrUser : DBSIMPLE_SKIP, - $typeOrUser > 0 ? $typeId : DBSIMPLE_SKIP, + $typeOrUser < 0 ? -$typeOrUser : DBSIMPLE_SKIP, + $typeOrUser > 0 ? $typeOrUser : DBSIMPLE_SKIP, + $typeOrUser > 0 ? $typeId : DBSIMPLE_SKIP, CC_FLAG_APPROVED, CC_FLAG_DELETED, - !$typeOrUser ? 'date' : DBSIMPLE_SKIP, - !$typeOrUser ? CFG_SQL_LIMIT_SEARCH : DBSIMPLE_SKIP + !$typeOrUser ? 'date' : DBSIMPLE_SKIP, + !$typeOrUser ? Cfg::get('SQL_LIMIT_SEARCH') : DBSIMPLE_SKIP ); if ($typeOrUser <= 0) // not for search by type/typeId @@ -455,13 +455,13 @@ class CommunityContent { $screenshots = DB::Aowow()->selectPage($nFound, self::$ssQuery, CC_FLAG_STICKY, - $typeOrUser < 0 ? -$typeOrUser : DBSIMPLE_SKIP, - $typeOrUser > 0 ? $typeOrUser : DBSIMPLE_SKIP, - $typeOrUser > 0 ? $typeId : DBSIMPLE_SKIP, + $typeOrUser < 0 ? -$typeOrUser : DBSIMPLE_SKIP, + $typeOrUser > 0 ? $typeOrUser : DBSIMPLE_SKIP, + $typeOrUser > 0 ? $typeId : DBSIMPLE_SKIP, CC_FLAG_APPROVED, CC_FLAG_DELETED, - !$typeOrUser ? 'date' : DBSIMPLE_SKIP, - !$typeOrUser ? CFG_SQL_LIMIT_SEARCH : DBSIMPLE_SKIP + !$typeOrUser ? 'date' : DBSIMPLE_SKIP, + !$typeOrUser ? Cfg::get('SQL_LIMIT_SEARCH') : DBSIMPLE_SKIP ); if ($typeOrUser <= 0) // not for search by type/typeId diff --git a/includes/config.class.php b/includes/config.class.php new file mode 100644 index 00000000..2b30c75d --- /dev/null +++ b/includes/config.class.php @@ -0,0 +1,387 @@ + 'Site', 'Caching', 'Account', 'Session', 'Site Reputation', 'Google Analytics', 'Profiler', 0 => 'Other' + ); + + private const IDX_VALUE = 0; + private const IDX_FLAGS = 1; + private const IDX_CATEGORY = 2; + private const IDX_DEFAULT = 3; + private const IDX_COMMENT = 4; + + private static $store = []; // name => [value, flags, cat, default, comment] + + private static $rebuildScripts = array( + // 'rep_req_border_unco' => ['global'], // currently not a template or buildScript + // 'rep_req_border_rare' => ['global'], + // 'rep_req_border_epic' => ['global'], + // 'rep_req_border_lege' => ['global'], + 'profiler_enable' => ['realms', 'realmMenu'], + 'battlegroup' => ['realms', 'realmMenu'], + 'name_short' => ['searchplugin', 'searchboxBody', 'searchboxScript', 'demo'], + 'site_host' => ['searchplugin', 'searchboxBody', 'searchboxScript', 'demo', 'power'], + 'static_host' => ['searchplugin', 'searchboxBody', 'searchboxScript', 'power'], + 'contact_email' => ['markup'], + 'locales' => ['locales'] + ); + + public static function load() : void + { + if (!DB::isConnectable(DB_AOWOW)) + return; + + $sets = DB::Aowow()->select('SELECT `key` AS ARRAY_KEY, `value` AS "0", `flags` AS "1", `cat` AS "2", `default` AS "3", `comment` AS "4" FROM ?_config ORDER BY `key` ASC'); + foreach ($sets as $key => [$value, $flags, $catg, $default, $comment]) + { + $php = $flags & self::FLAG_PHP; + + if ($err = self::validate($value, $flags, $comment)) + { + trigger_error('Aowow config '.strtoupper($key).' failed validation and was skipped: '.$err, E_USER_ERROR); + continue; + } + + if ($flags & self::FLAG_INTERNAL) + { + trigger_error('Aowow config '.strtoupper($key).' is flagged as internaly generated and should not have been set in DB.', E_USER_ERROR); + continue; + } + + if ($flags & self::FLAG_ON_LOAD_FN) + { + if (!method_exists('Cfg', $key)) + trigger_error('Aowow config '.strtoupper($key).' flagged for onLoadFN handling, but no handler was set', E_USER_WARNING); + else + self::{$key}($value); + } + + if ($php) + ini_set(strtolower($key), $value); + + self::$store[strtolower($key)] = [$value, $flags, $catg, $default, $comment]; + } + } + + public static function add(string $key, /*int|string*/ $value) : string + { + if (!$key) + return 'empty option name given'; + + $key = strtolower($key); + + if (preg_match(self::PATTERN_INV_CONF_KEY, $key)) + return 'invalid chars in option name: [a-z 0-9 _ . -] are allowed'; + + if (isset(self::$store[$key])) + return 'this configuration option is already in use'; + + if ($errStr = self::validate($value)) + return $errStr; + + if (ini_get($key) === false || ini_set($key, $value) === false) + return 'this configuration option cannot be set'; + + $flags = self::FLAG_TYPE_STRING | self::FLAG_PHP; + if (!DB::Aowow()->query('INSERT IGNORE INTO ?_config (`key`, `value`, `cat`, `flags`) VALUES (?, ?, ?d, ?d)', $key, $value, self::CAT_MISCELLANEOUS, $flags)) + return 'internal error'; + + self::$store[$key] = [$value, $flags, self::CAT_MISCELLANEOUS, null, null]; + return ''; + } + + public static function delete(string $key) : string + { + $key = strtolower($key); + + if (!isset(self::$store[$key])) + return 'configuration option not found'; + + if (self::$store[$key][self::IDX_FLAGS] & self::FLAG_PERSISTENT) + return 'can\'t delete persistent options'; + + if (!(self::$store[$key][self::IDX_FLAGS] & self::FLAG_PHP)) + return 'can\'t delete non-php options'; + + if (self::$store[$key][self::IDX_FLAGS] & self::FLAG_INTERNAL) + return 'can\'t delete internal options'; + + if (!DB::Aowow()->query('DELETE FROM ?_config WHERE `key` = ? AND (`flags` & ?d) = 0 AND (`flags` & ?d) > 0', $key, self::FLAG_PERSISTENT, self::FLAG_PHP)) + return 'internal error'; + + unset(self::$store[$key]); + return ''; + } + + public static function get(string $key, bool $fromDB = false, bool $fullInfo = false) // : int|float|string + { + $key = strtolower($key); + + if (!isset(self::$store[$key])) + { + trigger_error('cfg not defined: '.$key, E_USER_ERROR); + return ''; + } + + if ($fromDB && $fullInfo) + return array_values(DB::Aowow()->selectRow('SELECT `value`, `flags`, `cat`, `default`, `comment` FROM ?_config WHERE `key` = ?', $key)); + if ($fromDB) + return DB::Aowow()->selectCell('SELECT `value` FROM ?_config WHERE `key` = ?', $key); + if ($fullInfo) + return self::$store[$key]; + + return self::$store[$key][self::IDX_VALUE]; + } + + public static function set(string $key, /*int|string*/ $value, ?array &$rebuildFiles = []) : string + { + $key = strtolower($key); + + if (!isset(self::$store[$key])) + return 'configuration option not found'; + + [$oldValue, $flags, , , $comment] = self::$store[$key]; + + if ($flags & self::FLAG_INTERNAL) + return 'can\'t set internal options directly'; + + if ($err = self::validate($value, $flags, $comment)) + return $err; + + if ($flags & self::FLAG_REQUIRED && !strlen($value)) + return 'empty value given for required config'; + + DB::Aowow()->query('UPDATE ?_config SET `value` = ? WHERE `key` = ?', $value, $key); + + self::$store[$key][self::IDX_VALUE] = $value; + + // validate change + if ($flags & self::FLAG_ON_SET_FN) + { + $errMsg = ''; + if (!method_exists('Cfg', $key)) + $errMsg = 'required onSetFN validator not set'; + else + self::{$key}($value, $errMsg); + + if ($errMsg) + { + // rollback change + DB::Aowow()->query('UPDATE ?_config SET `value` = ? WHERE `key` = ?', $oldValue, $key); + self::$store[$key][self::IDX_VALUE] = $oldValue; + + // trigger_error($errMsg) ? + return $errMsg; + } + } + + if ($flags & self::FLAG_ON_LOAD_FN) + { + if (!method_exists('Cfg', $key)) + return 'Aowow config '.strtoupper($key).' flagged for onLoadFN handling, but no handler was set'; + else + self::{$key}($value); + } + + // trigger setup build + return self::handleFileBuild($key, $rebuildFiles); + } + + public static function reset(string $key, ?array &$rebuildFiles = []) : string + { + $key = strtolower($key); + + if (!isset(self::$store[$key])) + return 'configuration option not found'; + + [, $flags, , $default, ] = self::$store[$key]; + if ($flags & self::FLAG_INTERNAL) + return 'can\'t set internal options directly'; + + if (!$default) + return 'config option has no default value'; + + // @eval .. some dafault values are supplied as bitmask or the likes + if (!($flags & Cfg::FLAG_TYPE_STRING)) + $default = @eval('return ('.$default.');'); + + DB::Aowow()->query('UPDATE ?_config SET `value` = ? WHERE `key` = ?', $default, $key); + self::$store[$key][self::IDX_VALUE] = $default; + + // trigger setup build + return self::handleFileBuild($key, $rebuildFiles); + } + + public static function forCategory(int $category) : Generator + { + foreach (self::$store as $k => [, $flags, $catg, , ]) + if ($catg == $category && !($flags & self::FLAG_INTERNAL)) + yield $k => self::$store[$k]; + } + + public static function applyToString(string $string) : string + { + return preg_replace_callback( + ['/CFG_([A-Z_]+)/', '/((HOST|STATIC)_URL)/'], + function ($m) { + if (!isset(self::$store[strtolower($m[1])])) + return $m[1]; + + [$val, $flags, , , ] = self::$store[strtolower($m[1])]; + return $flags & (self::FLAG_TYPE_FLOAT | self::FLAG_TYPE_INT) ? Lang::nf($val) : $val; + }, + $string + ); + } + + + /************/ + /* internal */ + /************/ + + private static function validate(&$value, int $flags = self::FLAG_TYPE_STRING | self::FLAG_PHP, string $comment = ' - ') : string + { + $value = preg_replace(self::PATTERN_INVALID_CHARS, '', $value); + + if (!($flags & (self::FLAG_TYPE_BOOL | self::FLAG_TYPE_FLOAT | self::FLAG_TYPE_INT | self::FLAG_TYPE_STRING))) + return 'no type set for value'; + + if ($flags & self::FLAG_TYPE_INT && !Util::checkNumeric($value, NUM_CAST_INT)) + return 'value must be integer'; + + if ($flags & self::FLAG_TYPE_FLOAT && !Util::checkNumeric($value, NUM_CAST_FLOAT)) + return 'value must be float'; + + if ($flags & self::FLAG_OPT_LIST) + { + $info = explode(' - ', $comment)[1]; + foreach (explode(', ', $info) as $option) + if (explode(':', $option)[0] == $value) + return ''; + + return 'value not in range'; + } + + if ($flags & self::FLAG_BITMASK) + { + $mask = 0x0; + $info = explode(' - ', $comment)[1]; + foreach (explode(', ', $info) as $option) + $mask |= (1 << explode(':', $option)[0]); + + if (!($value &= $mask)) + return 'value not in range'; + } + + if ($flags & self::FLAG_TYPE_BOOL) + $value = (bool)$value; + + return ''; + } + + private static function handleFileBuild(string $key, array &$rebuildFiles) : string + { + if (!isset(self::$rebuildScripts[$key])) + return ''; + + $msg = ''; + + if (CLI) + { + $rebuildFiles = array_merge($rebuildFiles, self::$rebuildScripts[$key]); + return ''; + } + + // not in CLI mode and build() can only be run from CLI. .. todo: other options..? + exec('php aowow --build='.implode(',', self::$rebuildScripts[$key]), $out); + foreach ($out as $o) + if (strstr($o, 'ERR')) + $msg .= explode('0m]', $o)[1]."
\n"; + + return $msg; + } + + private static function acc_auth_mode(/*int|string*/ $value, ?string $msg = '') : bool + { + if ($value == 1 && !extension_loaded('gmp')) + { + $msg .= 'PHP extension GMP is required to use TrinityCore as auth source, but is not currently enabled.'; + return false; + } + + return true; + } + + private static function profiler_enable(/*int|string*/ $value, ?string $msg = '') : bool + { + if ($value != 1) + return true; + + return Profiler::queueStart($msg); + } + + private static function static_host(/*int|string*/ $value, ?string $msg = '') : bool + { + self::$store['static_url'] = array( // points js to images & scripts + (self::useSSL() ? 'https://' : 'http://').$value, + self::FLAG_PERSISTENT | self::FLAG_TYPE_STRING | self::FLAG_INTERNAL, + self::CAT_SITE, + null, // no default value + null, // no comment/info + ); + + return true; + } + + private static function site_host(/*int|string*/ $value, ?string $msg = '') : bool + { + self::$store['host_url'] = array( // points js to executable files + (self::useSSL() ? 'https://' : 'http://').$value, + self::FLAG_PERSISTENT | self::FLAG_TYPE_STRING | self::FLAG_INTERNAL, + self::CAT_SITE, + null, // no default value + null, // no comment/info + ); + + return true; + } + + private static function useSSL() : bool + { + return (($_SERVER['HTTPS'] ?? 'off') != 'off') || (self::$store['force_ssl'][self::IDX_VALUE] ?? 0); + } +} + +?> diff --git a/includes/database.class.php b/includes/database.class.php index 3910c6ef..7ecda53b 100644 --- a/includes/database.class.php +++ b/includes/database.class.php @@ -79,7 +79,7 @@ class DB // make number sensible again $data['code'] = abs($data['code']); - if (defined('CFG_DEBUG') && CFG_DEBUG) + if (Cfg::get('DEBUG') >= CLI::LOG_INFO) { echo "\nDB ERROR\n"; foreach ($data as $k => $v) diff --git a/includes/defines.php b/includes/defines.php index 8377b1b2..1efd4a55 100644 --- a/includes/defines.php +++ b/includes/defines.php @@ -98,16 +98,6 @@ define('SITEREP_ACTION_ARTICLE', 16); // Guide approved (a define('SITEREP_ACTION_USER_WARNED', 17); // Moderator Warning define('SITEREP_ACTION_USER_SUSPENDED', 18); // Moderator Suspension -// config flags -define('CON_FLAG_TYPE_INT', 0x01); // validate with intVal() -define('CON_FLAG_TYPE_FLOAT', 0x02); // validate with floatVal() -define('CON_FLAG_TYPE_BOOL', 0x04); // 0 || 1 -define('CON_FLAG_TYPE_STRING', 0x08); // -define('CON_FLAG_OPT_LIST', 0x10); // single option -define('CON_FLAG_BITMASK', 0x20); // multiple options -define('CON_FLAG_PHP', 0x40); // applied with ini_set() [restrictions apply!] -define('CON_FLAG_PERSISTENT', 0x80); // can not be deleted - // Auth Result define('AUTH_OK', 0); define('AUTH_WRONGUSER', 1); diff --git a/includes/kernel.php b/includes/kernel.php index 359cc5cc..c4a18365 100644 --- a/includes/kernel.php +++ b/includes/kernel.php @@ -22,15 +22,10 @@ if ($error) die(CLI ? strip_tags($error) : $error); -if (file_exists('config/config.php')) - require_once 'config/config.php'; -else - $AoWoWconf = []; - - require_once 'includes/defines.php'; require_once 'includes/libs/DbSimple/Generic.php'; // Libraray: http://en.dklab.ru/lib/DbSimple (using variant: https://github.com/ivan1986/DbSimple/tree/master) require_once 'includes/utilities.php'; // helper functions +require_once 'includes/config.class.php'; // Config holder require_once 'includes/game.php'; // game related data & functions require_once 'includes/profiler.class.php'; require_once 'includes/user.class.php'; @@ -93,36 +88,59 @@ set_error_handler(function($errNo, $errStr, $errFile, $errLine) if (strstr($errStr, 'mysqli_connect') && $errNo == E_WARNING) return true; - $errName = 'unknown error'; // errors not in this list can not be handled by set_error_handler (as per documentation) or are ignored - $uGroup = U_GROUP_EMPLOYEE; + $errName = 'unknown error'; // errors not in this list can not be handled by set_error_handler (as per documentation) or are ignored + $uGroup = U_GROUP_EMPLOYEE; + $logLevel = CLI::LOG_BLANK; if ($errNo == E_WARNING) // 0x0002 - $errName = 'E_WARNING'; + { + $errName = 'E_WARNING'; + $logLevel = CLI::LOG_WARN; + } else if ($errNo == E_PARSE) // 0x0004 - $errName = 'E_PARSE'; + { + $errName = 'E_PARSE'; + $logLevel = CLI::LOG_ERROR; + } else if ($errNo == E_NOTICE) // 0x0008 - $errName = 'E_NOTICE'; + { + $errName = 'E_NOTICE'; + $logLevel = CLI::LOG_INFO; + } else if ($errNo == E_USER_ERROR) // 0x0100 - $errName = 'E_USER_ERROR'; + { + $errName = 'E_USER_ERROR'; + $logLevel = CLI::LOG_ERROR; + } else if ($errNo == E_USER_WARNING) // 0x0200 - $errName = 'E_USER_WARNING'; + { + $errName = 'E_USER_WARNING'; + $logLevel = CLI::LOG_WARN; + } else if ($errNo == E_USER_NOTICE) // 0x0400 { - $errName = 'E_USER_NOTICE'; - $uGroup = U_GROUP_STAFF; + $errName = 'E_USER_NOTICE'; + $uGroup = U_GROUP_STAFF; + $logLevel = CLI::LOG_INFO; } else if ($errNo == E_RECOVERABLE_ERROR) // 0x1000 - $errName = 'E_RECOVERABLE_ERROR'; - - Util::addNote($uGroup, $errName.' - '.$errStr.' @ '.$errFile. ':'.$errLine); - if (CLI) - CLI::write($errName.' - '.$errStr.' @ '.$errFile. ':'.$errLine, $errNo & (E_WARNING | E_USER_WARNING | E_NOTICE | E_USER_NOTICE) ? CLI::LOG_WARN : CLI::LOG_ERROR); + { + $errName = 'E_RECOVERABLE_ERROR'; + $logLevel = CLI::LOG_ERROR; + } if (DB::isConnected(DB_AOWOW)) DB::Aowow()->query('INSERT INTO ?_errors (`date`, `version`, `phpError`, `file`, `line`, `query`, `userGroups`, `message`) VALUES (UNIX_TIMESTAMP(), ?d, ?d, ?, ?d, ?, ?d, ?) ON DUPLICATE KEY UPDATE `date` = UNIX_TIMESTAMP()', AOWOW_REVISION, $errNo, $errFile, $errLine, CLI ? 'CLI' : ($_SERVER['QUERY_STRING'] ?? ''), User::$groups, $errStr ); + if (Cfg::get('DEBUG') >= $logLevel) + { + Util::addNote($uGroup, $errName.' - '.$errStr.' @ '.$errFile. ':'.$errLine); + if (CLI) + CLI::write($errName.' - '.$errStr.' @ '.$errFile. ':'.$errLine, $errNo & (E_WARNING | E_USER_WARNING | E_NOTICE | E_USER_NOTICE) ? CLI::LOG_WARN : CLI::LOG_ERROR); + } + return true; }, E_AOWOW); @@ -161,6 +179,11 @@ register_shutdown_function(function() }); // Setup DB-Wrapper +if (file_exists('config/config.php')) + require_once 'config/config.php'; +else + $AoWoWconf = []; + if (!empty($AoWoWconf['aowow']['db'])) DB::load(DB_AOWOW, $AoWoWconf['aowow']); @@ -175,80 +198,29 @@ if (!empty($AoWoWconf['characters'])) if (!empty($charDBInfo)) DB::load(DB_CHARACTERS . $realm, $charDBInfo); - -// load config to constants -function loadConfig(bool $noPHP = false) : void -{ - $sets = DB::isConnected(DB_AOWOW) ? DB::Aowow()->select('SELECT `key` AS ARRAY_KEY, `value`, `flags` FROM ?_config') : []; - foreach ($sets as $k => $v) - { - $php = $v['flags'] & CON_FLAG_PHP; - if ($php && $noPHP) - continue; - - // this should not have been possible - if (!strlen($v['value']) && !($v['flags'] & CON_FLAG_TYPE_STRING) && !$php) - { - trigger_error('Aowow config value CFG_'.strtoupper($k).' is empty - config will not be used!', E_USER_ERROR); - continue; - } - - if ($v['flags'] & CON_FLAG_TYPE_INT) - $val = intVal($v['value']); - else if ($v['flags'] & CON_FLAG_TYPE_FLOAT) - $val = floatVal($v['value']); - else if ($v['flags'] & CON_FLAG_TYPE_BOOL) - $val = (bool)$v['value']; - else if ($v['flags'] & CON_FLAG_TYPE_STRING) - $val = preg_replace("/[\p{C}]/ui", '', $v['value']); - else if ($php) - { - trigger_error('PHP config value '.strtolower($k).' has no type set - config will not be used!', E_USER_ERROR); - continue; - } - else // if (!$php) - { - trigger_error('Aowow config value CFG_'.strtoupper($k).' has no type set - value forced to 0!', E_USER_ERROR); - $val = 0; - } - - if ($php) - ini_set(strtolower($k), $val); - else if (!defined('CFG_'.strtoupper($k))) - define('CFG_'.strtoupper($k), $val); - } - - $required = ['CFG_SCREENSHOT_MIN_SIZE', 'CFG_CONTACT_EMAIL', 'CFG_NAME', 'CFG_NAME_SHORT', 'CFG_FORCE_SSL', 'CFG_DEBUG']; - foreach ($required as $r) - if (!defined($r)) - define($r, ''); -} -loadConfig(); +$AoWoWconf = null; // empty auths -$secure = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || (!empty($AoWoWconf['aowow']) && CFG_FORCE_SSL); -if (defined('CFG_STATIC_HOST')) // points js to images & scripts - define('STATIC_URL', ($secure ? 'https://' : 'http://').CFG_STATIC_HOST); - -if (defined('CFG_SITE_HOST')) // points js to executable files - define('HOST_URL', ($secure ? 'https://' : 'http://').CFG_SITE_HOST); +// load config from DB +Cfg::load(); // handle non-fatal errors and notices -error_reporting(CFG_DEBUG ? E_AOWOW : 0); +error_reporting(Cfg::get('DEBUG') ? E_AOWOW : 0); if (!CLI) { // not displaying the brb gnomes as static_host is missing, but eh... - if (!DB::isConnected(DB_AOWOW) || !DB::isConnected(DB_WORLD) || !defined('HOST_URL') || !defined('STATIC_URL')) + if (!DB::isConnected(DB_AOWOW) || !DB::isConnected(DB_WORLD) || !Cfg::get('HOST_URL') || !Cfg::get('STATIC_URL')) (new GenericPage())->maintenance(); // Setup Session - if (CFG_SESSION_CACHE_DIR && Util::writeDir(CFG_SESSION_CACHE_DIR)) - session_save_path(getcwd().'/'.CFG_SESSION_CACHE_DIR); + $cacheDir = Cfg::get('SESSION_CACHE_DIR'); + if ($cacheDir && Util::writeDir($cacheDir)) + session_save_path(getcwd().'/'.$cacheDir); - session_set_cookie_params(15 * YEAR, '/', '', $secure, true); + session_set_cookie_params(15 * YEAR, '/', '', (($_SERVER['HTTPS'] ?? 'off') != 'off') || Cfg::get('FORCE_SSL'), true); session_cache_limiter('private'); if (!session_start()) { @@ -260,7 +232,7 @@ if (!CLI) User::save(); // save user-variables in session // set up some logging (~10 queries will execute before we init the user and load the config) - if (CFG_DEBUG && User::isInGroup(U_GROUP_DEV | U_GROUP_ADMIN)) + if (Cfg::get('DEBUG') >= CLI::LOG_INFO && User::isInGroup(U_GROUP_DEV | U_GROUP_ADMIN)) { DB::Aowow()->setLogger(['DB', 'profiler']); DB::World()->setLogger(['DB', 'profiler']); @@ -278,7 +250,7 @@ if (!CLI) if (isset($_GET['locale'])) { $loc = intVal($_GET['locale']); - if ($loc <= MAX_LOCALES && $loc >= 0 && (CFG_LOCALES & (1 << $loc))) + if ($loc <= MAX_LOCALES && $loc >= 0 && (Cfg::get('LOCALES') & (1 << $loc))) User::useLocale($loc); } @@ -293,6 +265,4 @@ if (!CLI) else if (DB::isConnected(DB_AOWOW)) Lang::load(LOCALE_EN); -$AoWoWconf = null; // empty auths - ?> diff --git a/includes/loot.class.php b/includes/loot.class.php index 3a04a3f8..4dad436d 100644 --- a/includes/loot.class.php +++ b/includes/loot.class.php @@ -283,7 +283,7 @@ class Loot if (!$struct) return false; - $items = new ItemList(array(['i.id', $struct[1]], CFG_SQL_LIMIT_NONE)); + $items = new ItemList(array(['i.id', $struct[1]], Cfg::get('SQL_LIMIT_NONE'))); $this->jsGlobals = $items->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED); $foo = $items->getListviewData(); @@ -386,13 +386,16 @@ class Loot return true; } - public function getByItem(int $entry, int $maxResults = CFG_SQL_LIMIT_DEFAULT, array $lootTableList = []) : bool + public function getByItem(int $entry, int $maxResults = -1, array $lootTableList = []) : bool { $this->entry = intVal($entry); if (!$this->entry) return false; + if ($maxResults < 0) + $maxResults = Cfg::get('SQL_LIMIT_DEFAULT'); + // [fileName, tabData, tabName, tabId, extraCols, hiddenCols, visibleCols] $tabsFinal = array( [Type::ITEM, [], '$LANG.tab_containedin', 'contained-in-item', [], [], []], diff --git a/includes/profiler.class.php b/includes/profiler.class.php index 168c37a2..ec1163c5 100644 --- a/includes/profiler.class.php +++ b/includes/profiler.class.php @@ -243,7 +243,7 @@ class Profiler // not on already scheduled - recalc time and set status to PR_QUEUE_STATUS_WAITING if ($rData['status'] != PR_QUEUE_STATUS_WAITING) { - $newTime = CFG_DEBUG ? time() : max($rData['time'] + CFG_PROFILER_RESYNC_DELAY, time()); + $newTime = Cfg::get('DEBUG') ? time() : max($rData['time'] + Cfg::get('PROFILER_RESYNC_DELAY'), time()); DB::Aowow()->query('UPDATE ?_profiler_sync SET requestTime = ?d, status = ?d, errorCode = 0 WHERE realm = ?d AND realmGUID = ?d AND `type` = ?d AND typeId = ?d', $newTime, PR_QUEUE_STATUS_WAITING, $realmId, $guid, $type, $localId); } } @@ -287,7 +287,7 @@ class Profiler public static function resyncStatus($type, array $subjectGUIDs) { - $response = [CFG_PROFILER_ENABLE ? 2 : 0]; // in theory you could have multiple queues; used as divisor for: (15 / x) + 2 + $response = [Cfg::get('PROFILER_ENABLE') ? 2 : 0]; // in theory you could have multiple queues; used as divisor for: (15 / x) + 2 if (!$subjectGUIDs) $response[] = [PR_QUEUE_STATUS_ENDED, 0, 0, PR_QUEUE_ERROR_CHAR]; else @@ -306,7 +306,7 @@ class Profiler else $response[] = array( $subjectStatus[$guid]['status'], - $subjectStatus[$guid]['status'] != PR_QUEUE_STATUS_READY ? CFG_PROFILER_RESYNC_PING : 0, + $subjectStatus[$guid]['status'] != PR_QUEUE_STATUS_READY ? Cfg::get('PROFILER_RESYNC_PING') : 0, array_search($type.':'.$guid, $queue) + 1, 0, 1 // nResycTries - unsure about this one diff --git a/includes/types/arenateam.class.php b/includes/types/arenateam.class.php index 12379952..bc38abb4 100644 --- a/includes/types/arenateam.class.php +++ b/includes/types/arenateam.class.php @@ -152,7 +152,7 @@ class RemoteArenaTeamList extends ArenaTeamList foreach ($this->iterate() as $guid => &$curTpl) { // battlegroup - $curTpl['battlegroup'] = CFG_BATTLEGROUP; + $curTpl['battlegroup'] = Cfg::get('BATTLEGROUP'); // realm, rank $r = explode(':', $guid); @@ -208,7 +208,7 @@ class RemoteArenaTeamList extends ArenaTeamList ); // equalize subject distribution across realms - $limit = CFG_SQL_LIMIT_DEFAULT; + $limit = Cfg::get('SQL_LIMIT_DEFAULT'); foreach ($conditions as $c) if (is_int($c)) $limit = $c; @@ -244,7 +244,7 @@ class RemoteArenaTeamList extends ArenaTeamList foreach ($teams as $team) $gladiators = array_merge($gladiators, array_keys($team)); - $profiles[$realmId] = new RemoteProfileList(array(['c.guid', $gladiators], CFG_SQL_LIMIT_NONE), ['sv' => $realmId]); + $profiles[$realmId] = new RemoteProfileList(array(['c.guid', $gladiators], Cfg::get('SQL_LIMIT_NONE')), ['sv' => $realmId]); if (!$profiles[$realmId]->error) $profiles[$realmId]->initializeLocalEntries(); @@ -346,7 +346,7 @@ class LocalArenaTeamList extends ArenaTeamList } // battlegroup - $curTpl['battlegroup'] = CFG_BATTLEGROUP; + $curTpl['battlegroup'] = Cfg::get('BATTLEGROUP'); $curTpl['members'] = $members[$id]; } diff --git a/includes/types/guide.class.php b/includes/types/guide.class.php index a174b092..5f98d13b 100644 --- a/includes/types/guide.class.php +++ b/includes/types/guide.class.php @@ -146,13 +146,13 @@ class GuideList extends BaseType if ($c = $this->getField('classId')) { $n = Lang::game('cl', $c); - $specStr .= '  –  %s'; + $specStr .= '  –  %s'; if (($s = $this->getField('specId')) > -1) { $i = Game::$specIconStrings[$c][$s]; $n = ''; - $specStr .= ''.Lang::game('classSpecs', $c, $s).''; + $specStr .= ''.Lang::game('classSpecs', $c, $s).''; } $specStr = sprintf($specStr, $n); diff --git a/includes/types/guild.class.php b/includes/types/guild.class.php index dccde5c5..5f65f5a7 100644 --- a/includes/types/guild.class.php +++ b/includes/types/guild.class.php @@ -182,7 +182,7 @@ class RemoteGuildList extends GuildList foreach ($this->iterate() as $guid => &$curTpl) { // battlegroup - $curTpl['battlegroup'] = CFG_BATTLEGROUP; + $curTpl['battlegroup'] = Cfg::get('BATTLEGROUP'); $r = explode(':', $guid)[0]; if (!empty($realms[$r])) @@ -213,7 +213,7 @@ class RemoteGuildList extends GuildList $distrib[$curTpl['realm']]++; } - $limit = CFG_SQL_LIMIT_DEFAULT; + $limit = Cfg::get('SQL_LIMIT_DEFAULT'); foreach ($conditions as $c) if (is_int($c)) $limit = $c; @@ -292,7 +292,7 @@ class LocalGuildList extends GuildList } // battlegroup - $curTpl['battlegroup'] = CFG_BATTLEGROUP; + $curTpl['battlegroup'] = Cfg::get('BATTLEGROUP'); } } diff --git a/includes/types/item.class.php b/includes/types/item.class.php index 3ff750d8..052991dd 100644 --- a/includes/types/item.class.php +++ b/includes/types/item.class.php @@ -834,7 +834,7 @@ class ItemList extends BaseType $pop = array_pop($enhance['g']); $col = $pop ? 1 : 0; $hasMatch &= $pop ? (($gems[$pop]['colorMask'] & (1 << $colorId)) ? 1 : 0) : 0; - $icon = $pop ? sprintf(Util::$bgImagePath['tiny'], STATIC_URL, strtolower($gems[$pop]['iconString'])) : null; + $icon = $pop ? sprintf('style="background-image: url(%s/images/wow/icons/tiny/%s.gif)"', Cfg::get('STATIC_URL'), strtolower($gems[$pop]['iconString'])) : null; $text = $pop ? Util::localizedString($gems[$pop], 'name') : Lang::item('socket', $colorId); if ($interactive) @@ -848,7 +848,7 @@ class ItemList extends BaseType { $pop = array_pop($enhance['g']); $col = $pop ? 1 : 0; - $icon = $pop ? sprintf(Util::$bgImagePath['tiny'], STATIC_URL, strtolower($gems[$pop]['iconString'])) : null; + $icon = $pop ? sprintf('style="background-image: url(%s/images/wow/icons/tiny/%s.gif)"', Cfg::get('STATIC_URL'), strtolower($gems[$pop]['iconString'])) : null; $text = $pop ? Util::localizedString($gems[$pop], 'name') : Lang::item('socket', -1); if ($interactive) @@ -1580,7 +1580,7 @@ class ItemList extends BaseType array_column($randEnchants, 'enchantId5') )); - $enchants = new EnchantmentList(array(['id', $enchIds], CFG_SQL_LIMIT_NONE)); + $enchants = new EnchantmentList(array(['id', $enchIds], Cfg::get('SQL_LIMIT_NONE'))); foreach ($enchants->iterate() as $eId => $_) { $this->rndEnchIds[$eId] = array( diff --git a/includes/types/profile.class.php b/includes/types/profile.class.php index 5507ca00..2ef83cb6 100644 --- a/includes/types/profile.class.php +++ b/includes/types/profile.class.php @@ -531,7 +531,7 @@ class RemoteProfileList extends ProfileList $talentSpells = []; $talentLookup = []; $distrib = null; - $limit = CFG_SQL_LIMIT_DEFAULT; + $limit = Cfg::get('SQL_LIMIT_DEFAULT'); foreach ($conditions as $c) if (is_int($c)) @@ -541,7 +541,7 @@ class RemoteProfileList extends ProfileList foreach ($this->iterate() as $guid => &$curTpl) { // battlegroup - $curTpl['battlegroup'] = CFG_BATTLEGROUP; + $curTpl['battlegroup'] = Cfg::get('BATTLEGROUP'); // realm [$r, $g] = explode(':', $guid); @@ -575,7 +575,7 @@ class RemoteProfileList extends ProfileList $curTpl['activespec'] = $curTpl['activeTalentGroup']; // equalize distribution - if ($limit != CFG_SQL_LIMIT_NONE) + if ($limit != Cfg::get('SQL_LIMIT_NONE')) { if (empty($distrib[$curTpl['realm']])) $distrib[$curTpl['realm']] = 1; @@ -753,7 +753,7 @@ class LocalProfileList extends ProfileList } // battlegroup - $curTpl['battlegroup'] = CFG_BATTLEGROUP; + $curTpl['battlegroup'] = Cfg::get('BATTLEGROUP'); } } diff --git a/includes/types/sound.class.php b/includes/types/sound.class.php index af690d74..df532a70 100644 --- a/includes/types/sound.class.php +++ b/includes/types/sound.class.php @@ -53,7 +53,7 @@ class SoundList extends BaseType // enum to string $data['type'] = self::$fileTypes[$data['type']]; // get real url - $data['url'] = STATIC_URL . '/wowsounds/' . $data['id']; + $data['url'] = Cfg::get('STATIC_URL') . '/wowsounds/' . $data['id']; // v push v $this->fileBuffer[$id] = $data; } diff --git a/includes/types/spell.class.php b/includes/types/spell.class.php index 20764c20..493846ae 100644 --- a/includes/types/spell.class.php +++ b/includes/types/spell.class.php @@ -178,7 +178,7 @@ class SpellList extends BaseType } if ($foo) - $this->relItems = new ItemList(array(['i.id', array_unique($foo)], CFG_SQL_LIMIT_NONE)); + $this->relItems = new ItemList(array(['i.id', array_unique($foo)], Cfg::get('SQL_LIMIT_NONE'))); } // use if you JUST need the name diff --git a/includes/user.class.php b/includes/user.class.php index 5cd1a711..1909e0e6 100644 --- a/includes/user.class.php +++ b/includes/user.class.php @@ -41,7 +41,7 @@ class User // check IP bans if ($ipBan = DB::Aowow()->selectRow('SELECT count, unbanDate FROM ?_account_bannedips WHERE ip = ? AND type = 0', self::$ip)) { - if ($ipBan['count'] > CFG_ACC_FAILED_AUTH_COUNT && $ipBan['unbanDate'] > time()) + if ($ipBan['count'] > Cfg::get('ACC_FAILED_AUTH_COUNT') && $ipBan['unbanDate'] > time()) return false; else if ($ipBan['unbanDate'] <= time()) DB::Aowow()->query('DELETE FROM ?_account_bannedips WHERE ip = ?', self::$ip); @@ -193,11 +193,12 @@ class User } // check; pick first viable if failed - if (CFG_LOCALES && !(CFG_LOCALES & (1 << $loc))) + $allowedLoc = Cfg::get('LOCALES'); + if ($allowedLoc && !($allowedLoc & (1 << $loc))) { foreach (Util::$localeStrings as $idx => $__) { - if (CFG_LOCALES & (1 << $idx)) + if ($allowedLoc & (1 << $idx)) { $loc = $idx; break; @@ -236,7 +237,7 @@ class User $user = 0; $hash = ''; - switch (CFG_ACC_AUTH_MODE) + switch (Cfg::get('ACC_AUTH_MODE')) { case AUTH_MODE_SELF: { @@ -246,11 +247,11 @@ class User // handle login try limitation $ip = DB::Aowow()->selectRow('SELECT ip, count, unbanDate FROM ?_account_bannedips WHERE type = 0 AND ip = ?', self::$ip); if (!$ip || $ip['unbanDate'] < time()) // no entry exists or time expired; set count to 1 - DB::Aowow()->query('REPLACE INTO ?_account_bannedips (ip, type, count, unbanDate) VALUES (?, 0, 1, UNIX_TIMESTAMP() + ?d)', self::$ip, CFG_ACC_FAILED_AUTH_BLOCK); + DB::Aowow()->query('REPLACE INTO ?_account_bannedips (ip, type, count, unbanDate) VALUES (?, 0, 1, UNIX_TIMESTAMP() + ?d)', self::$ip, Cfg::get('ACC_FAILED_AUTH_BLOCK')); else // entry already exists; increment count - DB::Aowow()->query('UPDATE ?_account_bannedips SET count = count + 1, unbanDate = UNIX_TIMESTAMP() + ?d WHERE ip = ?', CFG_ACC_FAILED_AUTH_BLOCK, self::$ip); + DB::Aowow()->query('UPDATE ?_account_bannedips SET count = count + 1, unbanDate = UNIX_TIMESTAMP() + ?d WHERE ip = ?', Cfg::get('ACC_FAILED_AUTH_BLOCK'), self::$ip); - if ($ip && $ip['count'] >= CFG_ACC_FAILED_AUTH_COUNT && $ip['unbanDate'] >= time()) + if ($ip && $ip['count'] >= Cfg::get('ACC_FAILED_AUTH_COUNT') && $ip['unbanDate'] >= time()) return AUTH_IPBANNED; $query = DB::Aowow()->SelectRow(' @@ -406,12 +407,12 @@ class User // different auth modes require different usernames $min = 0; // external case $max = 0; - if (CFG_ACC_AUTH_MODE == AUTH_MODE_SELF) + if (Cfg::get('ACC_AUTH_MODE') == AUTH_MODE_SELF) { $min = 4; $max = 16; } - else if (CFG_ACC_AUTH_MODE == AUTH_MODE_REALM) + else if (Cfg::get('ACC_AUTH_MODE') == AUTH_MODE_REALM) { $min = 3; $max = 32; @@ -430,7 +431,7 @@ class User $errCode = 0; // only enforce for own passwords - if (mb_strlen($pass) < 6 && CFG_ACC_AUTH_MODE == AUTH_MODE_SELF) + if (mb_strlen($pass) < 6 && Cfg::get('ACC_AUTH_MODE') == AUTH_MODE_SELF) $errCode = 1; // else if (preg_match('/[^\w\d!"#\$%]/', $pass)) // such things exist..? :o // $errCode = 2; @@ -443,7 +444,7 @@ class User $_SESSION['user'] = self::$id; $_SESSION['hash'] = self::$passHash; $_SESSION['locale'] = self::$localeId; - $_SESSION['timeout'] = self::$expires ? time() + CFG_SESSION_TIMEOUT_DELAY : 0; + $_SESSION['timeout'] = self::$expires ? time() + Cfg::get('SESSION_TIMEOUT_DELAY') : 0; // $_SESSION['dataKey'] does not depend on user login status and is set in User::init() } @@ -475,7 +476,7 @@ class User if (!self::$id || self::$banStatus & (ACC_BAN_COMMENT | ACC_BAN_PERM | ACC_BAN_TEMP)) return false; - return self::$perms || self::$reputation >= CFG_REP_REQ_COMMENT; + return self::$perms || self::$reputation >= Cfg::get('REP_REQ_COMMENT'); } public static function canReply() @@ -483,7 +484,7 @@ class User if (!self::$id || self::$banStatus & (ACC_BAN_COMMENT | ACC_BAN_PERM | ACC_BAN_TEMP)) return false; - return self::$perms || self::$reputation >= CFG_REP_REQ_REPLY; + return self::$perms || self::$reputation >= Cfg::get('REP_REQ_REPLY'); } public static function canUpvote() @@ -491,7 +492,7 @@ class User if (!self::$id || self::$banStatus & (ACC_BAN_COMMENT | ACC_BAN_PERM | ACC_BAN_TEMP)) return false; - return self::$perms || (self::$reputation >= CFG_REP_REQ_UPVOTE && self::$dailyVotes > 0); + return self::$perms || (self::$reputation >= Cfg::get('REP_REQ_UPVOTE') && self::$dailyVotes > 0); } public static function canDownvote() @@ -499,7 +500,7 @@ class User if (!self::$id || self::$banStatus & (ACC_BAN_RATE | ACC_BAN_PERM | ACC_BAN_TEMP)) return false; - return self::$perms || (self::$reputation >= CFG_REP_REQ_DOWNVOTE && self::$dailyVotes > 0); + return self::$perms || (self::$reputation >= Cfg::get('REP_REQ_DOWNVOTE') && self::$dailyVotes > 0); } public static function canSupervote() @@ -507,7 +508,7 @@ class User if (!self::$id || self::$banStatus & (ACC_BAN_RATE | ACC_BAN_PERM | ACC_BAN_TEMP)) return false; - return self::$reputation >= CFG_REP_REQ_SUPERVOTE; + return self::$reputation >= Cfg::get('REP_REQ_SUPERVOTE'); } public static function canUploadScreenshot() @@ -536,7 +537,7 @@ class User public static function isPremium() { - return self::isInGroup(U_GROUP_PREMIUM) || self::$reputation >= CFG_REP_REQ_PREMIUM; + return self::isInGroup(U_GROUP_PREMIUM) || self::$reputation >= Cfg::get('REP_REQ_PREMIUM'); } /**************/ @@ -559,7 +560,7 @@ class User if (!self::$id || self::$banStatus & (ACC_BAN_PERM | ACC_BAN_TEMP)) return 0; - return CFG_USER_MAX_VOTES + (self::$reputation >= CFG_REP_REQ_VOTEMORE_BASE ? 1 + intVal((self::$reputation - CFG_REP_REQ_VOTEMORE_BASE) / CFG_REP_REQ_VOTEMORE_ADD) : 0); + return Cfg::get('USER_MAX_VOTES') + (self::$reputation >= Cfg::get('REP_REQ_VOTEMORE_BASE') ? 1 + intVal((self::$reputation - Cfg::get('REP_REQ_VOTEMORE_BASE')) / Cfg::get('REP_REQ_VOTEMORE_ADD')) : 0); } public static function getReputation() @@ -585,8 +586,8 @@ class User $gUser['canDownvote'] = self::canDownvote(); $gUser['canPostReplies'] = self::canReply(); $gUser['superCommentVotes'] = self::canSupervote(); - $gUser['downvoteRep'] = CFG_REP_REQ_DOWNVOTE; - $gUser['upvoteRep'] = CFG_REP_REQ_UPVOTE; + $gUser['downvoteRep'] = Cfg::get('REP_REQ_DOWNVOTE'); + $gUser['upvoteRep'] = Cfg::get('REP_REQ_UPVOTE'); $gUser['characters'] = self::getCharacters(); $gUser['excludegroups'] = self::$excludeGroups; $gUser['settings'] = (new StdClass); // profiler requires this to be set; has property premiumborder (NYI) diff --git a/includes/utilities.php b/includes/utilities.php index 6b29d2fe..c855ed91 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -132,19 +132,19 @@ trait TrRequestData abstract class CLI { - const CHR_BELL = 7; - const CHR_BACK = 8; - const CHR_TAB = 9; - const CHR_LF = 10; - const CHR_CR = 13; - const CHR_ESC = 27; - const CHR_BACKSPACE = 127; + private const CHR_BELL = 7; + private const CHR_BACK = 8; + private const CHR_TAB = 9; + private const CHR_LF = 10; + private const CHR_CR = 13; + private const CHR_ESC = 27; + private const CHR_BACKSPACE = 127; - const LOG_BLANK = 0; - const LOG_OK = 1; - const LOG_WARN = 2; - const LOG_ERROR = 3; - const LOG_INFO = 4; + public const LOG_BLANK = 0; + public const LOG_ERROR = 1; + public const LOG_WARN = 2; + public const LOG_INFO = 3; + public const LOG_OK = 4; private static $logHandle = null; private static $hasReadline = null; @@ -216,6 +216,11 @@ abstract class CLI } } + public static function grey(string $str) : string + { + return CLI_HAS_E ? "\e[90m".$str."\e[0m" : $str; + } + public static function red(string $str) : string { return CLI_HAS_E ? "\e[31m".$str."\e[0m" : $str; @@ -536,17 +541,6 @@ abstract class Util null, 'bc', 'wotlk', 'cata', 'mop' ); - public static $bgImagePath = array ( - 'tiny' => 'style="background-image: url(%s/images/wow/icons/tiny/%s.gif)"', - 'small' => 'style="background-image: url(%s/images/wow/icons/small/%s.jpg)"', - 'medium' => 'style="background-image: url(%s/images/wow/icons/medium/%s.jpg)"', - 'large' => 'style="background-image: url(%s/images/wow/icons/large/%s.jpg)"', - ); - - public static $configCats = array( // don't mind the ordering ... please? - 1 => 'Site', 'Caching', 'Account', 'Session', 'Site Reputation', 'Google Analytics', 'Profiler', 0 => 'Other' - ); - public static $tcEncoding = '0zMcmVokRsaqbdrfwihuGINALpTjnyxtgevElBCDFHJKOPQSUWXYZ123456789'; private static $notes = []; @@ -737,7 +731,7 @@ abstract class Util // html may contain 'Pictures' and FlavorImages and "stuff" $text = preg_replace_callback( '/src="([^"]+)"/i', - function ($m) { return 'src="'.STATIC_URL.'/images/wow/'.strtr($m[1], ['\\' => '/']).'.png"'; }, + function ($m) { return sprintf('src="%s/images/wow/%s.png"', Cfg::get('STATIC_URL'), strtr($m[1], ['\\' => '/'])); }, strtr($text, $pairs) ); } @@ -848,8 +842,8 @@ abstract class Util return strtr($data, array( ' '' => 'scr"+"ipt>', - 'HOST_URL' => HOST_URL, - 'STATIC_URL' => STATIC_URL + 'HOST_URL' => Cfg::get('HOST_URL'), + 'STATIC_URL' => Cfg::get('STATIC_URL') )); } @@ -955,43 +949,59 @@ abstract class Util return mb_strtolower($str); } - // note: valid integer > 32bit are returned as float + // doesn't handle scientific notation .. why would you input 3e3 for 3000..? public static function checkNumeric(&$data, $typeCast = NUM_ANY) { if ($data === null) return false; - else if (!is_array($data)) + + if (is_array($data)) { - $rawData = $data; // do not transform strings - - $data = trim($data); - if (preg_match('/^-?\d*,\d+$/', $data)) - $data = strtr($data, ',', '.'); - - if (is_numeric($data)) - { - $data += 0; // becomes float or int - - if ((is_float($data) && $typeCast == NUM_REQ_INT) || - (is_int($data) && $typeCast == NUM_REQ_FLOAT)) - return false; - - if (is_float($data) && $typeCast == NUM_CAST_INT) - $data = intval($data); - - if (is_int($data) && $typeCast == NUM_CAST_FLOAT) - $data = floatval($data); - - return true; - } - - $data = $rawData; - return false; + array_walk($data, function(&$x) use($typeCast) { self::checkNumeric($x, $typeCast); }); + return false; // always false for passed arrays } - array_walk($data, function(&$x) use($typeCast) { self::checkNumeric($x, $typeCast); }); + // already in required state + if ((is_float($data) && $typeCast == NUM_REQ_FLOAT) || + (is_int($data) && $typeCast == NUM_REQ_INT)) + return true; - return false; // always false for passed arrays + // irreconcilable state + if ((!is_int($data) && $typeCast == NUM_REQ_INT) || + (!is_float($data) && $typeCast == NUM_REQ_FLOAT)) + return false; + + $number = $data; // do not transform strings, store state + $nMatches = 0; + + $number = trim($number); + $number = preg_replace('/^(-?\d*)[.,](\d+)$/', '$1.$2', $number, -1, $nMatches); + + // is float string + if ($nMatches) + { + if ($typeCast == NUM_CAST_INT) + $data = intVal($number); + else if ($typeCast == NUM_CAST_FLOAT) + $data = floatVal($number); + + return true; + } + + // is int string (is_numeric can only handle strings in base 10) + if (is_numeric($number) || preg_match('/0[xb]?\d+/', $number)) + { + $number = intVal($number, 0); // 'base 0' auto-detects base + if ($typeCast == NUM_CAST_INT) + $data = $number; + else if ($typeCast == NUM_CAST_FLOAT) + $data = floatVal($number); + + return true; + } + + // is string string + return false; } public static function arraySumByKey(array &$ref, array ...$adds) : void @@ -1090,18 +1100,18 @@ abstract class Util switch ($action) { case SITEREP_ACTION_REGISTER: - $x['amount'] = CFG_REP_REWARD_REGISTER; + $x['amount'] = Cfg::get('REP_REWARD_REGISTER'); break; case SITEREP_ACTION_DAILYVISIT: $x['sourceA'] = time(); - $x['amount'] = CFG_REP_REWARD_DAILYVISIT; + $x['amount'] = Cfg::get('REP_REWARD_DAILYVISIT'); break; case SITEREP_ACTION_COMMENT: if (empty($miscData['id'])) return false; $x['sourceA'] = $miscData['id']; // commentId - $x['amount'] = CFG_REP_REWARD_COMMENT; + $x['amount'] = Cfg::get('REP_REWARD_COMMENT'); break; case SITEREP_ACTION_UPVOTED: case SITEREP_ACTION_DOWNVOTED: @@ -1118,7 +1128,7 @@ abstract class Util $x['sourceA'] = $miscData['id']; // commentId $x['sourceB'] = $miscData['voterId']; - $x['amount'] = $action == SITEREP_ACTION_UPVOTED ? CFG_REP_REWARD_UPVOTED : CFG_REP_REWARD_DOWNVOTED; + $x['amount'] = $action == SITEREP_ACTION_UPVOTED ? Cfg::get('REP_REWARD_UPVOTED') : Cfg::get('REP_REWARD_DOWNVOTED'); break; case SITEREP_ACTION_UPLOAD: if (empty($miscData['id']) || empty($miscData['what'])) @@ -1126,7 +1136,7 @@ abstract class Util $x['sourceA'] = $miscData['id']; // screenshotId or videoId $x['sourceB'] = $miscData['what']; // screenshot:1 or video:NYD - $x['amount'] = CFG_REP_REWARD_UPLOAD; + $x['amount'] = Cfg::get('REP_REWARD_UPLOAD'); break; case SITEREP_ACTION_GOOD_REPORT: // NYI case SITEREP_ACTION_BAD_REPORT: @@ -1134,14 +1144,14 @@ abstract class Util return false; $x['sourceA'] = $miscData['id']; - $x['amount'] = $action == SITEREP_ACTION_GOOD_REPORT ? CFG_REP_REWARD_GOOD_REPORT : CFG_REP_REWARD_BAD_REPORT; + $x['amount'] = $action == SITEREP_ACTION_GOOD_REPORT ? Cfg::get('REP_REWARD_GOOD_REPORT') : Cfg::get('REP_REWARD_BAD_REPORT'); break; case SITEREP_ACTION_ARTICLE: if (empty($miscData['id'])) // guideId return false; $x['sourceA'] = $miscData['id']; - $x['amount'] = CFG_REP_REWARD_ARTICLE; + $x['amount'] = Cfg::get('REP_REWARD_ARTICLE'); break; case SITEREP_ACTION_USER_WARNED: // NYI case SITEREP_ACTION_USER_SUSPENDED: @@ -1149,7 +1159,7 @@ abstract class Util return false; $x['sourceA'] = $miscData['id']; - $x['amount'] = $action == SITEREP_ACTION_USER_WARNED ? CFG_REP_REWARD_USER_WARNED : CFG_REP_REWARD_USER_SUSPENDED; + $x['amount'] = $action == SITEREP_ACTION_USER_WARNED ? Cfg::get('REP_REWARD_USER_WARNED') : Cfg::get('REP_REWARD_USER_SUSPENDED'); break; } @@ -1318,7 +1328,7 @@ abstract class Util { $flags = $forceFlags ?: (JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE); - if (CFG_DEBUG && !$forceFlags) + if (Cfg::get('DEBUG') && !$forceFlags) $flags |= JSON_PRETTY_PRINT; $json = json_encode($data, $flags); @@ -1658,7 +1668,7 @@ abstract class Util return [(int)$deg, $desc]; } - static function mask2bits($bitmask, $offset = 0) + static function mask2bits(int $bitmask, int $offset = 0) : array { $bits = []; $i = 0; diff --git a/localization/lang.class.php b/localization/lang.class.php index 565e3ead..a935d771 100644 --- a/localization/lang.class.php +++ b/localization/lang.class.php @@ -599,6 +599,8 @@ class Lang if (!$var) // may be null or empty. Handled differently depending on context return $var; + $var = Cfg::applyToString($var); + if ($args) $var = vsprintf($var, $args); diff --git a/localization/locale_dede.php b/localization/locale_dede.php index 42934dd4..bc1ddd19 100644 --- a/localization/locale_dede.php +++ b/localization/locale_dede.php @@ -53,7 +53,7 @@ $lang = array( 'or' => " oder ", 'back' => "Zurück", 'reputationTip' => "Rufpunkte", - 'byUser' => 'Von %1$s ', + 'byUser' => 'Von %1$s ', 'help' => "Hilfe", 'status' => "Status", 'yes' => "Ja", @@ -270,7 +270,7 @@ $lang = array( ), 'error' => array( 'unkFormat' => "Unbekanntes Bildformat.", - 'tooSmall' => "Euer Screenshot ist viel zu klein. (< ".CFG_SCREENSHOT_MIN_SIZE."x".CFG_SCREENSHOT_MIN_SIZE.").", + 'tooSmall' => "Euer Screenshot ist viel zu klein. (< CFG_SCREENSHOT_MIN_SIZE x CFG_SCREENSHOT_MIN_SIZE).", 'selectSS' => "Wählt bitte den Screenshot aus, den Ihr hochladen möchtet.", 'notAllowed' => "Es ist euch nicht erlaubt einen Screenshot hochzuladen!", ) @@ -877,7 +877,7 @@ $lang = array( // form-text 'emailInvalid' => "Diese E-Mail-Adresse ist ungültig.", // message_emailnotvalid - 'emailNotFound' => "Die E-Mail-Adresse, die Ihr eingegeben habt, ist mit keinem Konto verbunden.

Falls Ihr die E-Mail-Adresse vergessen habt, mit der Ihr Euer Konto erstellt habt, kontaktiert Ihr bitte ".CFG_CONTACT_EMAIL." für Hilfestellung.", + 'emailNotFound' => "Die E-Mail-Adresse, die Ihr eingegeben habt, ist mit keinem Konto verbunden.

Falls Ihr die E-Mail-Adresse vergessen habt, mit der Ihr Euer Konto erstellt habt, kontaktiert Ihr bitte CFG_CONTACT_EMAIL für Hilfestellung.", 'createAccSent' => "Eine Nachricht wurde soeben an %s versandt. Folgt den Anweisungen um euer Konto zu erstellen.", 'recovUserSent' => "Eine Nachricht wurde soeben an %s versandt. Folgt den Anweisungen um euren Benutzernamen zu erhalten.", 'recovPassSent' => "Eine Nachricht wurde soeben an %s versandt. Folgt den Anweisungen um euer Kennwort zurückzusetzen.", @@ -914,9 +914,9 @@ $lang = array( 'posts' => "Forenbeiträge", // user mail 'tokenExpires' => "Das Token wird in %s verfallen.", - 'accConfirm' => ["Kontobestätigung", "Willkommen bei ".CFG_NAME_SHORT."!\r\n\r\nKlicke auf den Link um euren Account zu aktivieren.\r\n\r\n".HOST_URL."?account=signup&token=%s\r\n\r\nFalls Ihr diese Mail nicht angefordert habt kann sie einfach ignoriert werden."], - 'recoverUser' => ["Benutzernamenanfrage", "Folgt diesem Link um euch anzumelden.\r\n\r\n".HOST_URL."?account=signin&token=%s\r\n\r\nFalls Ihr diese Mail nicht angefordert habt kann sie einfach ignoriert werden."], - 'resetPass' => ["Kennwortreset", "Folgt diesem Link um euer Kennwort zurückzusetzen.\r\n\r\n".HOST_URL."?account=forgotpassword&token=%s\r\n\r\nFalls Ihr diese Mail nicht angefordert habt kann sie einfach ignoriert werden."] + 'accConfirm' => ["Kontobestätigung", "Willkommen bei CFG_NAME_SHORT!\r\n\r\nKlicke auf den Link um euren Account zu aktivieren.\r\n\r\nHOST_URL?account=signup&token=%s\r\n\r\nFalls Ihr diese Mail nicht angefordert habt kann sie einfach ignoriert werden."], + 'recoverUser' => ["Benutzernamenanfrage", "Folgt diesem Link um euch anzumelden.\r\n\r\nHOST_URL?account=signin&token=%s\r\n\r\nFalls Ihr diese Mail nicht angefordert habt kann sie einfach ignoriert werden."], + 'resetPass' => ["Kennwortreset", "Folgt diesem Link um euer Kennwort zurückzusetzen.\r\n\r\nHOST_URL?account=forgotpassword&token=%s\r\n\r\nFalls Ihr diese Mail nicht angefordert habt kann sie einfach ignoriert werden."] ), 'emote' => array( 'notFound' => "Dieses Emote existiert nicht.", @@ -1081,7 +1081,7 @@ $lang = array( 'slain' => "getötet", 'reqNumCrt' => "Benötigt", 'rfAvailable' => "Verfügbar auf Realm: ", - '_transfer' => 'Dieser Erfolg wird mit %s vertauscht, wenn Ihr zur %s wechselt.', + '_transfer' => 'Dieser Erfolg wird mit %s vertauscht, wenn Ihr zur %s wechselt.', 'cat' => array( 1 => "Statistiken", 21 => "Spieler gegen Spieler", 81 => "Heldentaten", 92 => "Allgemein", @@ -1477,7 +1477,7 @@ $lang = array( '_inSlot' => "im Platz", '_collapseAll' => "Alle einklappen", '_expandAll' => "Alle ausklappen", - '_transfer' => 'Dieser Zauber wird mit %s vertauscht, wenn Ihr zur %s wechselt.', + '_transfer' => 'Dieser Zauber wird mit %s vertauscht, wenn Ihr zur %s wechselt.', '_affected' => "Betroffene Zauber", '_seeMore' => "Mehr anzeigen", '_rankRange' => "Rang: %d - %d", @@ -1838,7 +1838,7 @@ $lang = array( 'tool' => "Werkzeug", 'cost' => "Preis", 'content' => "Inhalt", - '_transfer' => 'Dieser Gegenstand wird mit %s vertauscht, wenn Ihr zur %s wechselt.', + '_transfer' => 'Dieser Gegenstand wird mit %s vertauscht, wenn Ihr zur %s wechselt.', '_unavailable' => "Dieser Gegenstand ist nicht für Spieler verfügbar.", '_rndEnchants' => "Zufällige Verzauberungen", '_chance' => "(Chance von %s%%)", diff --git a/localization/locale_enus.php b/localization/locale_enus.php index 45891634..4db8dd5a 100644 --- a/localization/locale_enus.php +++ b/localization/locale_enus.php @@ -53,7 +53,7 @@ $lang = array( 'or' => " or ", 'back' => "Back", 'reputationTip' => "Reputation points", - 'byUser' => 'By %1$s ', // mind the \s + 'byUser' => 'By %1$s ', // mind the \s 'help' => "Help", 'status' => "Status", 'yes' => "Yes", @@ -270,7 +270,7 @@ $lang = array( ), 'error' => array( 'unkFormat' => "Unknown image format.", - 'tooSmall' => "Your screenshot is way too small. (< ".CFG_SCREENSHOT_MIN_SIZE."x".CFG_SCREENSHOT_MIN_SIZE.").", + 'tooSmall' => "Your screenshot is way too small. (< CFG_SCREENSHOT_MIN_SIZE x CFG_SCREENSHOT_MIN_SIZE).", 'selectSS' => "Please select the screenshot to upload.", 'notAllowed' => "You are not allowed to upload screenshots!", ) @@ -877,7 +877,7 @@ $lang = array( // form-text 'emailInvalid' => "That email address is not valid.", // message_emailnotvalid - 'emailNotFound' => "The email address you entered is not associated with any account.

If you forgot the email you registered your account with email ".CFG_CONTACT_EMAIL." for assistance.", + 'emailNotFound' => "The email address you entered is not associated with any account.

If you forgot the email you registered your account with email CFG_CONTACT_EMAIL for assistance.", 'createAccSent' => "An email was sent to %s. Simply follow the instructions to create your account.", 'recovUserSent' => "An email was sent to %s. Simply follow the instructions to recover your username.", 'recovPassSent' => "An email was sent to %s. Simply follow the instructions to reset your password.", @@ -914,9 +914,9 @@ $lang = array( 'posts' => "Forum posts", // user mail 'tokenExpires' => "This token expires in %s.", - 'accConfirm' => ["Account Confirmation", "Welcome to ".CFG_NAME_SHORT."!\r\n\r\nClick the Link below to activate your account.\r\n\r\n".HOST_URL."?account=signup&token=%s\r\n\r\nIf you did not request this mail simply ignore it."], - 'recoverUser' => ["User Recovery", "Follow this link to log in.\r\n\r\n".HOST_URL."?account=signin&token=%s\r\n\r\nIf you did not request this mail simply ignore it."], - 'resetPass' => ["Password Reset", "Follow this link to reset your password.\r\n\r\n".HOST_URL."?account=forgotpassword&token=%s\r\n\r\nIf you did not request this mail simply ignore it."] + 'accConfirm' => ["Account Confirmation", "Welcome to CFG_NAME_SHORT!\r\n\r\nClick the Link below to activate your account.\r\n\r\nHOST_URL?account=signup&token=%s\r\n\r\nIf you did not request this mail simply ignore it."], + 'recoverUser' => ["User Recovery", "Follow this link to log in.\r\n\r\nHOST_URL?account=signin&token=%s\r\n\r\nIf you did not request this mail simply ignore it."], + 'resetPass' => ["Password Reset", "Follow this link to reset your password.\r\n\r\nHOST_URL?account=forgotpassword&token=%s\r\n\r\nIf you did not request this mail simply ignore it."] ), 'emote' => array( 'notFound' => "This Emote doesn't exist.", @@ -1081,7 +1081,7 @@ $lang = array( 'slain' => "slain", 'reqNumCrt' => "Requires", 'rfAvailable' => "Available on realm: ", - '_transfer' => 'This achievement will be converted to %s if you transfer to %s.', + '_transfer' => 'This achievement will be converted to %s if you transfer to %s.', 'cat' => array( 1 => "Statistics", 21 => "Player vs. Player", 81 => "Feats of Strength", 92 => "General", @@ -1477,7 +1477,7 @@ $lang = array( '_inSlot' => "in slot", '_collapseAll' => "Collapse All", '_expandAll' => "Expand All", - '_transfer' => 'This spell will be converted to %s if you transfer to %s.', + '_transfer' => 'This spell will be converted to %s if you transfer to %s.', '_affected' => "Affected Spells", '_seeMore' => "See more", '_rankRange' => "Rank: %d - %d", @@ -1838,7 +1838,7 @@ $lang = array( 'tool' => "Tool", 'cost' => "Cost", // COSTS_LABEL 'content' => "Content", - '_transfer' => 'This item will be converted to %s if you transfer to %s.', + '_transfer' => 'This item will be converted to %s if you transfer to %s.', '_unavailable' => "This item is not available to players.", '_rndEnchants' => "Random Enchantments", '_chance' => "(%s%% chance)", diff --git a/localization/locale_eses.php b/localization/locale_eses.php index 0898e460..2fc08ac3 100644 --- a/localization/locale_eses.php +++ b/localization/locale_eses.php @@ -53,7 +53,7 @@ $lang = array( 'or' => " o ", 'back' => "Atrás", 'reputationTip' => "Puntos de reputación", - 'byUser' => 'Por %1$s ', + 'byUser' => 'Por %1$s ', 'help' => "Ayuda", 'status' => "Estado", 'yes' => "Sí", @@ -270,7 +270,7 @@ $lang = array( ), 'error' => array( 'unkFormat' => "Formato de imagen desconocido.", - 'tooSmall' => "Su captura de pantalla es muy pequeña. (< ".CFG_SCREENSHOT_MIN_SIZE."x".CFG_SCREENSHOT_MIN_SIZE.").", + 'tooSmall' => "Su captura de pantalla es muy pequeña. (< CFG_SCREENSHOT_MIN_SIZE x CFG_SCREENSHOT_MIN_SIZE).", 'selectSS' => "Por favor seleccione la captura de pantalla para subir.", 'notAllowed' => "¡No estás permitido para subir capturas de pantalla!", ) @@ -877,7 +877,7 @@ $lang = array( // form-text 'emailInvalid' => "Esa dirección de correo electrónico no es válida.", // message_emailnotvalid - 'emailNotFound' => "El correo electrónico que ingresaste no está asociado con ninguna cuenta.

Si olvistaste el correo electronico con el que registraste la cuenta, escribe a ".CFG_CONTACT_EMAIL." para asistencia.", + 'emailNotFound' => "El correo electrónico que ingresaste no está asociado con ninguna cuenta.

Si olvistaste el correo electronico con el que registraste la cuenta, escribe a CFG_CONTACT_EMAIL para asistencia.", 'createAccSent' => "Un correo fue enviado a %s. Siga las instrucciones para crear su cuenta.", 'recovUserSent' => "Un correo fue enviado a %s. Siga las instrucciones para recuperar su nombre de usuario.", 'recovPassSent' => "Un correo fue enviado a %s. Siga las instrucciones para reiniciar su contraseña.", @@ -914,9 +914,9 @@ $lang = array( 'posts' => "Mensajes en los foros", // user mail 'tokenExpires' => "Este token expira en %s", - 'accConfirm' => ["Confirmación de Cuenta", "Bienvenido a ".CFG_NAME_SHORT."!\r\n\r\nHaga click en el enlace siguiente para activar su cuenta.\r\n\r\n".HOST_URL."?account=signup&token=%s\r\n\r\nSi usted no solicitó este correo, por favor ignorelo."], - 'recoverUser' => ["Recuperacion de Usuario", "Siga a este enlace para ingresar.\r\n\r\n".HOST_URL."?account=signin&token=%s\r\n\r\nSi usted no solicitó este correo, por favor ignorelo."], - 'resetPass' => ["Reinicio de Contraseña", "Siga este enlace para reiniciar su contraseña.\r\n\r\n".HOST_URL."?account=forgotpassword&token=%s\r\n\r\nSi usted no solicitó este correo, por favor ignorelo."] + 'accConfirm' => ["Confirmación de Cuenta", "Bienvenido a CFG_NAME_SHORT!\r\n\r\nHaga click en el enlace siguiente para activar su cuenta.\r\n\r\nHOST_URL?account=signup&token=%s\r\n\r\nSi usted no solicitó este correo, por favor ignorelo."], + 'recoverUser' => ["Recuperacion de Usuario", "Siga a este enlace para ingresar.\r\n\r\nHOST_URL?account=signin&token=%s\r\n\r\nSi usted no solicitó este correo, por favor ignorelo."], + 'resetPass' => ["Reinicio de Contraseña", "Siga este enlace para reiniciar su contraseña.\r\n\r\nHOST_URL?account=forgotpassword&token=%s\r\n\r\nSi usted no solicitó este correo, por favor ignorelo."] ), 'emote' => array( 'notFound' => "Este emoticón no existe", @@ -1081,7 +1081,7 @@ $lang = array( 'slain' => "matado", 'reqNumCrt' => "Requiere", 'rfAvailable' => "Disponible en reino: ", - '_transfer' => 'Este logro será convertido a %s si lo transfieres a la %s.', + '_transfer' => 'Este logro será convertido a %s si lo transfieres a la %s.', 'cat' => array( 1 => "Estadísticas", 21 => "Jugador contra Jugador", 81 => "Proezas de fuerza", 92 => "General", @@ -1477,7 +1477,7 @@ $lang = array( '_inSlot' => "en la casilla", '_collapseAll' => "Contraer todo", '_expandAll' => "Expandier todo", - '_transfer' => 'Este hechizo será convertido a %s si lo transfieres a la %s.', + '_transfer' => 'Este hechizo será convertido a %s si lo transfieres a la %s.', '_affected' => "Hechizos affectados", '_seeMore' => "[See more]", '_rankRange' => "Rango: %d - %d", @@ -1838,7 +1838,7 @@ $lang = array( 'tool' => "Herramienta", 'cost' => "Coste", 'content' => "Contenido", - '_transfer' => 'Este objeto será convertido a %s si lo transfieres a la %s.', + '_transfer' => 'Este objeto será convertido a %s si lo transfieres a la %s.', '_unavailable' => "Este objeto no está disponible para los jugadores.", '_rndEnchants' => "Encantamientos aleatorios", '_chance' => "(probabilidad %s%%)", diff --git a/localization/locale_frfr.php b/localization/locale_frfr.php index ddd0870d..c1569001 100644 --- a/localization/locale_frfr.php +++ b/localization/locale_frfr.php @@ -53,7 +53,7 @@ $lang = array( 'or' => " ou ", 'back' => "Redro", 'reputationTip' => "Points de réputation", - 'byUser' => 'Par %1$s ', + 'byUser' => 'Par %1$s ', 'help' => "Aide", 'status' => "Statut", 'yes' => "Oui", @@ -270,7 +270,7 @@ $lang = array( ), 'error' => array( 'unkFormat' => "Format d'image inconnu.", - 'tooSmall' => "Votre capture est bien trop petite. (< ".CFG_SCREENSHOT_MIN_SIZE."x".CFG_SCREENSHOT_MIN_SIZE.").", + 'tooSmall' => "Votre capture est bien trop petite. (< CFG_SCREENSHOT_MIN_SIZE x CFG_SCREENSHOT_MIN_SIZE).", 'selectSS' => "Veuillez sélectionner la capture d'écran à envoyer.", 'notAllowed' => "Vous n'êtes pas autorisés à exporter des captures d'écran.", ) @@ -877,7 +877,7 @@ $lang = array( // form-text 'emailInvalid' => "Cette adresse courriel est invalide.", // message_emailnotvalid - 'emailNotFound' => "L'address email que vous avez entrée n'est pas associée à un compte.

Si vous avez oublié l'address email avec laquelle vous avez enregistré votre compte".CFG_CONTACT_EMAIL." pour obtenir de l'aide.", + 'emailNotFound' => "L'address email que vous avez entrée n'est pas associée à un compte.

Si vous avez oublié l'address email avec laquelle vous avez enregistré votre compteCFG_CONTACT_EMAIL pour obtenir de l'aide.", 'createAccSent' => "Un email a été envoyé à %s. Suivez les instructions pour créer votre compte.", 'recovUserSent' => "Un email a été envoyé à %s. Suivez les instructions pour récupérer votre nom d'utilisateur.", 'recovPassSent' => "Un email a été envoyé à %s. Suivez les instructions pour réinitialiser votre mot de passe.", @@ -914,9 +914,9 @@ $lang = array( 'posts' => "Messages sur le forum", // user mail 'tokenExpires' => "This token expires in %s.", - 'accConfirm' => ["Activation de compte", "Bienvenue sur ".CFG_NAME_SHORT."!\r\n\r\nCliquez sur le lien ci-dessous pour activer votre compte.\r\n\r\n".HOST_URL."?account=signup&token=%s\r\n\r\nSi vous n'avez pas demandé cet email, ignorez le."], - 'recoverUser' => ["Récupération d'utilisateur", "Suivez ce lien pour vous connecter.\r\n\r\n".HOST_URL."?account=signin&token=%s\r\n\r\nSi vous n'avez pas demandé cet email, ignorez le."], - 'resetPass' => ["Réinitialisation du mot de passe", "Suivez ce lien pour réinitialiser votre mot de passe.\r\n\r\n".HOST_URL."?account=forgotpassword&token=%s\r\n\r\nSi vous n'avez pas fait de demande de réinitialisation, ignorez cet email."] + 'accConfirm' => ["Activation de compte", "Bienvenue sur CFG_NAME_SHORT!\r\n\r\nCliquez sur le lien ci-dessous pour activer votre compte.\r\n\r\nHOST_URL?account=signup&token=%s\r\n\r\nSi vous n'avez pas demandé cet email, ignorez le."], + 'recoverUser' => ["Récupération d'utilisateur", "Suivez ce lien pour vous connecter.\r\n\r\nHOST_URL?account=signin&token=%s\r\n\r\nSi vous n'avez pas demandé cet email, ignorez le."], + 'resetPass' => ["Réinitialisation du mot de passe", "Suivez ce lien pour réinitialiser votre mot de passe.\r\n\r\nHOST_URL?account=forgotpassword&token=%s\r\n\r\nSi vous n'avez pas fait de demande de réinitialisation, ignorez cet email."] ), 'emote' => array( 'notFound' => "[This Emote doesn't exist.]", @@ -1081,7 +1081,7 @@ $lang = array( 'slain' => "tué", 'reqNumCrt' => "Nécessite", 'rfAvailable' => "Disponibles sur les royaumes : ", - '_transfer' => 'Cet haut fait sera converti en %s si vous transférez en %s.', + '_transfer' => 'Cet haut fait sera converti en %s si vous transférez en %s.', 'cat' => array( 1 => "Statistiques", 21 => "Joueur contre Joueur", 81 => "Tours de force", 92 => "Général", @@ -1477,7 +1477,7 @@ $lang = array( '_inSlot' => "dans l'emplacement", '_collapseAll' => "Replier Tout", '_expandAll' => "Déplier Tout", - '_transfer' => 'Cet sort sera converti en %s si vous transférez en %s.', + '_transfer' => 'Cet sort sera converti en %s si vous transférez en %s.', '_affected' => "Sorts affectés", '_seeMore' => "[See more]", '_rankRange' => "Rang : %d - %d", @@ -1838,7 +1838,7 @@ $lang = array( 'tool' => "Outil", 'cost' => "Coût", 'content' => "Contenu", - '_transfer' => 'Cet objet sera converti en %s si vous transférez en %s.', + '_transfer' => 'Cet objet sera converti en %s si vous transférez en %s.', '_unavailable' => "Cet objet n'est pas disponible pour les joueurs.", '_rndEnchants' => "Enchantements aléatoires", '_chance' => "(%s%% de chance)", diff --git a/localization/locale_ruru.php b/localization/locale_ruru.php index ee751244..8f3d2b1e 100644 --- a/localization/locale_ruru.php +++ b/localization/locale_ruru.php @@ -53,7 +53,7 @@ $lang = array( 'or' => " или ", 'back' => "Назад", 'reputationTip' => "Очки репутации", - 'byUser' => 'От %1s ', + 'byUser' => 'От %1s ', 'help' => "Справка", 'status' => "Статус", 'yes' => "Да", @@ -270,7 +270,7 @@ $lang = array( ), 'error' => array( 'unkFormat' => "неизвестный формат изображения.", - 'tooSmall' => "Изображение слишком маленькое. (< ".CFG_SCREENSHOT_MIN_SIZE."x".CFG_SCREENSHOT_MIN_SIZE.").", + 'tooSmall' => "Изображение слишком маленькое. (< CFG_SCREENSHOT_MIN_SIZE x CFG_SCREENSHOT_MIN_SIZE).", 'selectSS' => "Выберите изображение для загрузки.", 'notAllowed' => "[You are not allowed to upload screenshots!]", ) @@ -877,7 +877,7 @@ $lang = array( // form-text 'emailInvalid' => "Недопустимый адрес email.", // message_emailnotvalid - 'emailNotFound' => "The email address you entered is not associated with any account.

If you forgot the email you registered your account with email ".CFG_CONTACT_EMAIL." for assistance.", + 'emailNotFound' => "The email address you entered is not associated with any account.

If you forgot the email you registered your account with email CFG_CONTACT_EMAIL for assistance.", 'createAccSent' => "An email was sent to %s. Simply follow the instructions to create your account.", 'recovUserSent' => "An email was sent to %s. Simply follow the instructions to recover your username.", 'recovPassSent' => "An email was sent to %s. Simply follow the instructions to reset your password.", @@ -914,9 +914,9 @@ $lang = array( 'posts' => "Сообщений на форумах", // user mail 'tokenExpires' => "This token expires in %s.", - 'accConfirm' => ["Account Confirmation", "Welcome to ".CFG_NAME_SHORT."!\r\n\r\nClick the Link below to activate your account.\r\n\r\n".HOST_URL."?account=signup&token=%s\r\n\r\nIf you did not request this mail simply ignore it."], - 'recoverUser' => ["User Recovery", "Follow this link to log in.\r\n\r\n".HOST_URL."?account=signin&token=%s\r\n\r\nIf you did not request this mail simply ignore it."], - 'resetPass' => ["Password Reset", "Follow this link to reset your password.\r\n\r\n".HOST_URL."?account=forgotpassword&token=%s\r\n\r\nIf you did not request this mail simply ignore it."] + 'accConfirm' => ["Account Confirmation", "Welcome to CFG_NAME_SHORT!\r\n\r\nClick the Link below to activate your account.\r\n\r\nHOST_URL?account=signup&token=%s\r\n\r\nIf you did not request this mail simply ignore it."], + 'recoverUser' => ["User Recovery", "Follow this link to log in.\r\n\r\nHOST_URL?account=signin&token=%s\r\n\r\nIf you did not request this mail simply ignore it."], + 'resetPass' => ["Password Reset", "Follow this link to reset your password.\r\n\r\nHOST_URL?account=forgotpassword&token=%s\r\n\r\nIf you did not request this mail simply ignore it."] ), 'emote' => array( 'notFound' => "[This Emote doesn't exist.]", @@ -1081,7 +1081,7 @@ $lang = array( 'slain' => "убито", 'reqNumCrt' => "Требуется", 'rfAvailable' => "[Available on realm]: ", - '_transfer' => 'Этот предмет превратится в %s, если вы перейдете за %s.', + '_transfer' => 'Этот предмет превратится в %s, если вы перейдете за %s.', 'cat' => array( 1 => "Статистика", 21 => "PvP", 81 => "Великие подвиги", 92 => "Общее", @@ -1477,7 +1477,7 @@ $lang = array( '_inSlot' => "в слот", '_collapseAll' => "Свернуть все", '_expandAll' => "Развернуть все", - '_transfer' => 'Этот предмет превратится в %s, если вы перейдете за %s.', + '_transfer' => 'Этот предмет превратится в %s, если вы перейдете за %s.', '_affected' => "Влияет на заклинания", '_seeMore' => "[See more]", '_rankRange' => "Ранг: %d - %d", @@ -1838,7 +1838,7 @@ $lang = array( 'tool' => "Инструмент", 'cost' => "Цена", 'content' => "Материал", - '_transfer' => 'Этот предмет превратится в %s, если вы перейдете за %s.', + '_transfer' => 'Этот предмет превратится в %s, если вы перейдете за %s.', '_unavailable' => "Этот предмет не доступен игрокам.", '_rndEnchants' => "Случайные улучшения", '_chance' => "(шанс %s%%)", diff --git a/localization/locale_zhcn.php b/localization/locale_zhcn.php index 22c54e5f..e702f9b7 100644 --- a/localization/locale_zhcn.php +++ b/localization/locale_zhcn.php @@ -53,7 +53,7 @@ $lang = array( 'or' => "或", 'back' => "返回", 'reputationTip' => "声望点数", - 'byUser' => '由%1$s', + 'byUser' => '由%1$s', 'help' => "帮助", 'status' => "状态", 'yes' => "是", @@ -270,7 +270,7 @@ $lang = array( ), 'error' => array( 'unkFormat' => "未知图像格式。", - 'tooSmall' => "你的截图太小了。 (< ".CFG_SCREENSHOT_MIN_SIZE."x".CFG_SCREENSHOT_MIN_SIZE.").", + 'tooSmall' => "你的截图太小了。 (< CFG_SCREENSHOT_MIN_SIZE x CFG_SCREENSHOT_MIN_SIZE).", 'selectSS' => "请选择截图上传。", 'notAllowed' => "你不允许上传截图!", ) @@ -876,7 +876,7 @@ $lang = array( // form-text 'emailInvalid' => "该电子邮件地址无效。", // message_emailnotvalid - 'emailNotFound' => "你输入的电子邮件地址与任何帐户不关联。

如果您忘记了使用哪个电子邮件注册了您的帐户,请发送电子邮件至".CFG_CONTACT_EMAIL."寻求帮助。", + 'emailNotFound' => "你输入的电子邮件地址与任何帐户不关联。

如果您忘记了使用哪个电子邮件注册了您的帐户,请发送电子邮件至CFG_CONTACT_EMAIL寻求帮助。", 'createAccSent' => "电子邮件发送到%s。只需按照说明创建你的帐户。", 'recovUserSent' => "电子邮件发送到%s。只需按照说明恢复你的用户名。", 'recovPassSent' => "电子邮件发送到%s。只需按照说明重置你的密码。", @@ -913,9 +913,9 @@ $lang = array( 'posts' => "论坛帖子", // user mail 'tokenExpires' => "此令牌将在%s过期。", - 'accConfirm' => ["账户确认", "欢迎来到".CFG_NAME_SHORT."!\r\n\r\n点击下方链接以激活您的账户。\r\n\r\n".HOST_URL."?account=signup&token=%s\r\n\r\n如果您没有请求此邮件,请忽略它。"], - 'recoverUser' => ["用户恢复", "点击此链接登录\r\n\r\n".HOST_URL."?account=signin&token=%s\r\n\r\n如果您没有请求此邮件,请忽略它。"], - 'resetPass' => ["重置密码", "点击此链接以重置您的密码。\r\n\r\n".HOST_URL."?account=forgotpassword&token=%s\r\n\r\n如果您没有请求此邮件,请忽略它。"] + 'accConfirm' => ["账户确认", "欢迎来到CFG_NAME_SHORT!\r\n\r\n点击下方链接以激活您的账户。\r\n\r\nHOST_URL?account=signup&token=%s\r\n\r\n如果您没有请求此邮件,请忽略它。"], + 'recoverUser' => ["用户恢复", "点击此链接登录\r\n\r\nHOST_URL?account=signin&token=%s\r\n\r\n如果您没有请求此邮件,请忽略它。"], + 'resetPass' => ["重置密码", "点击此链接以重置您的密码。\r\n\r\nHOST_URL?account=forgotpassword&token=%s\r\n\r\n如果您没有请求此邮件,请忽略它。"] ), 'emote' => array( 'notFound' => "这个表情不存在。", @@ -1080,7 +1080,7 @@ $lang = array( 'slain' => "杀死", 'reqNumCrt' => "要求", 'rfAvailable' => "在服务器上可用:", - '_transfer' => '这个成就将被转换到%s,如果你转移到%s。', + '_transfer' => '这个成就将被转换到%s,如果你转移到%s。', 'cat' => array( 1 => "属性", 21 => "PvP", 81 => "光辉事迹", 92 => "综合", @@ -1476,7 +1476,7 @@ $lang = array( '_inSlot' => "在插槽中", '_collapseAll' => "折叠全部", '_expandAll' => "展开全部", - '_transfer' => '这个法术将被转换到%s,如果你转移到%s。', + '_transfer' => '这个法术将被转换到%s,如果你转移到%s。', '_affected' => "受影响法术", '_seeMore' => "[See more]", '_rankRange' => "排名: %d - %d", @@ -1837,7 +1837,7 @@ $lang = array( 'tool' => "工具", 'cost' => "花费", 'content' => "内容", - '_transfer' => '这个物品将被转换到%s,如果你转移到%s。', + '_transfer' => '这个物品将被转换到%s,如果你转移到%s。', '_unavailable' => "这个物品对玩家不可用。", '_rndEnchants' => "随机附魔", '_chance' => "(%s%%几率)", diff --git a/pages/account.php b/pages/account.php index 8e970709..6874792c 100644 --- a/pages/account.php +++ b/pages/account.php @@ -85,10 +85,10 @@ class AccountPage extends GenericPage switch ($this->category[0]) { case 'forgotpassword': - if (CFG_ACC_AUTH_MODE != AUTH_MODE_SELF) + if (Cfg::get('ACC_AUTH_MODE') != AUTH_MODE_SELF) { - if (CFG_ACC_EXT_RECOVER_URL) - header('Location: '.CFG_ACC_EXT_RECOVER_URL, true, 302); + if (Cfg::get('ACC_EXT_RECOVER_URL')) + header('Location: '.Cfg::get('ACC_EXT_RECOVER_URL'), true, 302); else $this->error(); } @@ -102,10 +102,10 @@ class AccountPage extends GenericPage $this->head = sprintf(Lang::account('recoverPass'), $nStep); break; case 'forgotusername': - if (CFG_ACC_AUTH_MODE != AUTH_MODE_SELF) + if (Cfg::get('ACC_AUTH_MODE') != AUTH_MODE_SELF) { - if (CFG_ACC_EXT_RECOVER_URL) - header('Location: '.CFG_ACC_EXT_RECOVER_URL, true, 302); + if (Cfg::get('ACC_EXT_RECOVER_URL')) + header('Location: '.Cfg::get('ACC_EXT_RECOVER_URL'), true, 302); else $this->error(); } @@ -145,13 +145,13 @@ class AccountPage extends GenericPage break; case 'signup': - if (!CFG_ACC_ALLOW_REGISTER) + if (!Cfg::get('ACC_ALLOW_REGISTER')) $this->error(); - if (CFG_ACC_AUTH_MODE != AUTH_MODE_SELF) + if (Cfg::get('ACC_AUTH_MODE') != AUTH_MODE_SELF) { - if (CFG_ACC_EXT_CREATE_URL) - header('Location: '.CFG_ACC_EXT_CREATE_URL, true, 302); + if (Cfg::get('ACC_EXT_CREATE_URL')) + header('Location: '.Cfg::get('ACC_EXT_CREATE_URL'), true, 302); else $this->error(); } @@ -172,7 +172,7 @@ class AccountPage extends GenericPage { $nStep = 2; DB::Aowow()->query('UPDATE ?_account SET status = ?d, statusTimer = 0, token = 0, userGroups = ?d WHERE token = ?', ACC_STATUS_OK, U_GROUP_NONE, $this->_get['token']); - DB::Aowow()->query('REPLACE INTO ?_account_bannedips (ip, type, count, unbanDate) VALUES (?, 1, ?d + 1, UNIX_TIMESTAMP() + ?d)', User::$ip, CFG_ACC_FAILED_AUTH_COUNT, CFG_ACC_FAILED_AUTH_BLOCK); + DB::Aowow()->query('REPLACE INTO ?_account_bannedips (ip, type, count, unbanDate) VALUES (?, 1, ?d + 1, UNIX_TIMESTAMP() + ?d)', User::$ip, Cfg::get('ACC_FAILED_AUTH_COUNT'), Cfg::get('ACC_FAILED_AUTH_BLOCK')); $this->text = sprintf(Lang::account('accActivated'), $this->_get['token']); } @@ -386,7 +386,7 @@ Markup.printHtml("description text here", "description-generic", { allow: Markup return Lang::account('wrongPass'); case AUTH_IPBANNED: User::destroy(); - return sprintf(Lang::account('loginExceeded'), Util::formatTime(CFG_ACC_FAILED_AUTH_BLOCK * 1000)); + return sprintf(Lang::account('loginExceeded'), Util::formatTime(Cfg::get('ACC_FAILED_AUTH_BLOCK') * 1000)); case AUTH_INTERNAL_ERR: User::destroy(); return Lang::main('intError'); @@ -418,10 +418,10 @@ Markup.printHtml("description text here", "description-generic", { allow: Markup // limit account creation $ip = DB::Aowow()->selectRow('SELECT ip, count, unbanDate FROM ?_account_bannedips WHERE type = 1 AND ip = ?', User::$ip); - if ($ip && $ip['count'] >= CFG_ACC_FAILED_AUTH_COUNT && $ip['unbanDate'] >= time()) + if ($ip && $ip['count'] >= Cfg::get('ACC_FAILED_AUTH_COUNT') && $ip['unbanDate'] >= time()) { - DB::Aowow()->query('UPDATE ?_account_bannedips SET count = count + 1, unbanDate = UNIX_TIMESTAMP() + ?d WHERE ip = ? AND type = 1', CFG_ACC_FAILED_AUTH_BLOCK, User::$ip); - return sprintf(Lang::account('signupExceeded'), Util::formatTime(CFG_ACC_FAILED_AUTH_BLOCK * 1000)); + DB::Aowow()->query('UPDATE ?_account_bannedips SET count = count + 1, unbanDate = UNIX_TIMESTAMP() + ?d WHERE ip = ? AND type = 1', Cfg::get('ACC_FAILED_AUTH_BLOCK'), User::$ip); + return sprintf(Lang::account('signupExceeded'), Util::formatTime(Cfg::get('ACC_FAILED_AUTH_BLOCK') * 1000)); } // username taken @@ -440,21 +440,21 @@ Markup.printHtml("description text here", "description-generic", { allow: Markup User::$localeId, U_GROUP_PENDING, ACC_STATUS_NEW, - CFG_ACC_CREATE_SAVE_DECAY, + Cfg::get('ACC_CREATE_SAVE_DECAY'), $token ); if (!$ok) return Lang::main('intError'); - else if ($_ = $this->sendMail(Lang::user('accConfirm', 0), sprintf(Lang::user('accConfirm', 1), $token), CFG_ACC_CREATE_SAVE_DECAY)) + else if ($_ = $this->sendMail(Lang::user('accConfirm', 0), sprintf(Lang::user('accConfirm', 1), $token), Cfg::get('ACC_CREATE_SAVE_DECAY'))) { if ($id = DB::Aowow()->selectCell('SELECT id FROM ?_account WHERE token = ?', $token)) Util::gainSiteReputation($id, SITEREP_ACTION_REGISTER); // success:: update ip-bans if (!$ip || $ip['unbanDate'] < time()) - DB::Aowow()->query('REPLACE INTO ?_account_bannedips (ip, type, count, unbanDate) VALUES (?, 1, 1, UNIX_TIMESTAMP() + ?d)', User::$ip, CFG_ACC_FAILED_AUTH_BLOCK); + DB::Aowow()->query('REPLACE INTO ?_account_bannedips (ip, type, count, unbanDate) VALUES (?, 1, 1, UNIX_TIMESTAMP() + ?d)', User::$ip, Cfg::get('ACC_FAILED_AUTH_BLOCK')); else - DB::Aowow()->query('UPDATE ?_account_bannedips SET count = count + 1, unbanDate = UNIX_TIMESTAMP() + ?d WHERE ip = ? AND type = 1', CFG_ACC_FAILED_AUTH_BLOCK, User::$ip); + DB::Aowow()->query('UPDATE ?_account_bannedips SET count = count + 1, unbanDate = UNIX_TIMESTAMP() + ?d WHERE ip = ? AND type = 1', Cfg::get('ACC_FAILED_AUTH_BLOCK'), User::$ip); return $_; } @@ -462,11 +462,11 @@ Markup.printHtml("description text here", "description-generic", { allow: Markup private function doRecoverPass() { - if ($_ = $this->initRecovery(ACC_STATUS_RECOVER_PASS, CFG_ACC_RECOVERY_DECAY, $token)) + if ($_ = $this->initRecovery(ACC_STATUS_RECOVER_PASS, Cfg::get('ACC_RECOVERY_DECAY'), $token)) return $_; // send recovery mail - return $this->sendMail(Lang::user('resetPass', 0), sprintf(Lang::user('resetPass', 1), $token), CFG_ACC_RECOVERY_DECAY); + return $this->sendMail(Lang::user('resetPass', 0), sprintf(Lang::user('resetPass', 1), $token), Cfg::get('ACC_RECOVERY_DECAY')); } private function doResetPass() @@ -494,11 +494,11 @@ Markup.printHtml("description text here", "description-generic", { allow: Markup private function doRecoverUser() { - if ($_ = $this->initRecovery(ACC_STATUS_RECOVER_USER, CFG_ACC_RECOVERY_DECAY, $token)) + if ($_ = $this->initRecovery(ACC_STATUS_RECOVER_USER, Cfg::get('ACC_RECOVERY_DECAY'), $token)) return $_; // send recovery mail - return $this->sendMail(Lang::user('recoverUser', 0), sprintf(Lang::user('recoverUser', 1), $token), CFG_ACC_RECOVERY_DECAY); + return $this->sendMail(Lang::user('recoverUser', 0), sprintf(Lang::user('recoverUser', 1), $token), Cfg::get('ACC_RECOVERY_DECAY')); } private function initRecovery($type, $delay, &$token) @@ -519,10 +519,10 @@ Markup.printHtml("description text here", "description-generic", { allow: Markup private function sendMail($subj, $msg, $delay = 300) { // send recovery mail - $subj = CFG_NAME_SHORT.Lang::main('colon') . $subj; + $subj = Cfg::get('NAME_SHORT').Lang::main('colon') . $subj; $msg .= "\r\n\r\n".sprintf(Lang::user('tokenExpires'), Util::formatTime($delay * 1000))."\r\n"; - $header = 'From: '.CFG_CONTACT_EMAIL . "\r\n" . - 'Reply-To: '.CFG_CONTACT_EMAIL . "\r\n" . + $header = 'From: '.Cfg::get('CONTACT_EMAIL') . "\r\n" . + 'Reply-To: '.Cfg::get('CONTACT_EMAIL') . "\r\n" . 'X-Mailer: PHP/' . phpversion(); if (!mail($this->_post['email'], $subj, $msg, $header)) diff --git a/pages/achievements.php b/pages/achievements.php index 51f4b404..f69e40e1 100644 --- a/pages/achievements.php +++ b/pages/achievements.php @@ -105,9 +105,9 @@ class AchievementsPage extends GenericPage $tabData['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)'; // create note if search limit was exceeded - if ($acvList->getMatches() > CFG_SQL_LIMIT_DEFAULT) + if ($acvList->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT')) { - $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_achievementsfound', $acvList->getMatches(), CFG_SQL_LIMIT_DEFAULT); + $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_achievementsfound', $acvList->getMatches(), Cfg::get('SQL_LIMIT_DEFAULT')); $tabData['_truncated'] = 1; } diff --git a/pages/admin.php b/pages/admin.php index de679dea..1638e1cd 100644 --- a/pages/admin.php +++ b/pages/admin.php @@ -115,42 +115,25 @@ class AdminPage extends GenericPage [SC_CSS_STRING, '.grid .status { position:absolute; right:5px; }'] ); - $head = ''; - $mainTab = []; - $miscTab = []; - foreach (Util::$configCats as $idx => $catName) + $head = ''; + foreach (Cfg::$categories as $idx => $catName) { - if ($rows = DB::Aowow()->select('SELECT * FROM ?_config WHERE cat = ?d ORDER BY `flags` DESC, `key` ASC', $idx)) - { - $buff = $head; - foreach ($rows as $r) - $buff .= $this->configAddRow($r); + $rows = ''; + foreach (Cfg::forCategory($idx) as $key => [$value, $flags, , $default, $comment]) + $rows .= $this->configAddRow($key, $value, $flags, $default, $comment); - if (!$idx) //cat: misc - $buff .= ''; + if ($idx == Cfg::CAT_MISCELLANEOUS) + $rows .= ''; - $buff .= '
KeyValueOptions
KeyValueOptions
new configuration
new configuration
'; + if (!$rows) + continue; - if ($idx) - $mainTab[$catName] = $buff; - else - $miscTab[$catName] = $buff; - } + $this->lvTabs[] = [null, array( + 'data' => '' . $head . $rows . '
', + 'name' => $catName, + 'id' => Profiler::urlize($catName) + )]; } - - foreach ($mainTab as $n => $t) - $this->lvTabs[] = [null, array( - 'data' => $t, - 'name' => $n, - 'id' => Profiler::urlize($n) - )]; - - foreach ($miscTab as $n => $t) - $this->lvTabs[] = [null, array( - 'data' => $t, - 'name' => $n, - 'id' => Profiler::urlize($n) - )]; } private function handlePhpInfo() : void @@ -320,55 +303,55 @@ class AdminPage extends GenericPage // } - private function configAddRow($r) + private function configAddRow($key, $value, $flags, $default, $comment) { $buff = ''; - $info = explode(' - ', $r['comment']); - $key = $r['flags'] & CON_FLAG_PHP ? strtolower($r['key']) : strtoupper($r['key']); + $info = explode(' - ', $comment); + $key = $flags & Cfg::FLAG_PHP ? strtolower($key) : strtoupper($key); // name - if (!empty($info[1])) - $buff .= ''.sprintf(Util::$dfnString, $info[1], $key).''; + if (!empty($info[0])) + $buff .= ''.sprintf(Util::$dfnString, $info[0], $key).''; else $buff .= ''.$key.''; // value - if ($r['flags'] & CON_FLAG_TYPE_BOOL) - $buff .= '
'; - else if ($r['flags'] & CON_FLAG_OPT_LIST && !empty($info[2])) + if ($flags & Cfg::FLAG_TYPE_BOOL) + $buff .= '
'; + else if ($flags & Cfg::FLAG_OPT_LIST && !empty($info[1])) { $buff .= ''; } - else if ($r['flags'] & CON_FLAG_BITMASK && !empty($info[2])) + else if ($flags & Cfg::FLAG_BITMASK && !empty($info[1])) { $buff .= '
'; - foreach (explode(', ', $info[2]) as $option) + foreach (explode(', ', $info[1]) as $option) { - $opt = explode(':', $option); - $buff .= ''; + [$idx, $name] = explode(':', $option); + $buff .= ''; } $buff .= '
'; } else - $buff .= ''; + $buff .= ''; // actions $buff .= ''; $buff .= ''; - if (strstr($info[0], 'default:')) - $buff .= '|'; + if (isset($default)) + $buff .= '|'; else $buff .= '|'; - if (!($r['flags'] & CON_FLAG_PERSISTENT)) + if (!($flags & Cfg::FLAG_PERSISTENT)) $buff .= '|'; $buff .= ''; diff --git a/pages/areatriggers.php b/pages/areatriggers.php index 40cfa556..6495668b 100644 --- a/pages/areatriggers.php +++ b/pages/areatriggers.php @@ -55,9 +55,9 @@ class AreaTriggersPage extends GenericPage $tabData['data'] = array_values($trigger->getListviewData()); // create note if search limit was exceeded; overwriting 'note' is intentional - if ($trigger->getMatches() > CFG_SQL_LIMIT_DEFAULT) + if ($trigger->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT')) { - $tabData['note'] = sprintf(Util::$tryFilteringEntityString, $trigger->getMatches(), '"'.Lang::game('areatriggers').'"', CFG_SQL_LIMIT_DEFAULT); + $tabData['note'] = sprintf(Util::$tryFilteringEntityString, $trigger->getMatches(), '"'.Lang::game('areatriggers').'"', Cfg::get('SQL_LIMIT_DEFAULT')); $tabData['_truncated'] = 1; } diff --git a/pages/arenateam.php b/pages/arenateam.php index da932243..ebb0f7eb 100644 --- a/pages/arenateam.php +++ b/pages/arenateam.php @@ -31,7 +31,7 @@ class ArenaTeamPage extends GenericPage { parent::__construct($pageCall, $pageParam); - if (!CFG_PROFILER_ENABLE) + if (!Cfg::get('PROFILER_ENABLE')) $this->error(); $params = array_map('urldecode', explode('.', $pageParam)); diff --git a/pages/arenateams.php b/pages/arenateams.php index 655afde5..9150f85b 100644 --- a/pages/arenateams.php +++ b/pages/arenateams.php @@ -33,7 +33,7 @@ class ArenaTeamsPage extends GenericPage { parent::__construct($pageCall, $pageParam); - if (!CFG_PROFILER_ENABLE) + if (!Cfg::get('PROFILER_ENABLE')) $this->error(); $this->getSubjectFromUrl($pageParam); @@ -58,7 +58,7 @@ class ArenaTeamsPage extends GenericPage protected function generateTitle() { if ($this->realm) - array_unshift($this->title, $this->realm,/* CFG_BATTLEGROUP,*/ Lang::profiler('regions', $this->region), Lang::profiler('arenaTeams')); + array_unshift($this->title, $this->realm,/* Cfg::get('BATTLEGROUP'),*/ Lang::profiler('regions', $this->region), Lang::profiler('arenaTeams')); else if ($this->region) array_unshift($this->title, Lang::profiler('regions', $this->region), Lang::profiler('arenaTeams')); else @@ -111,12 +111,12 @@ class ArenaTeamsPage extends GenericPage $tabData['data'] = array_values($teams->getListviewData()); // create note if search limit was exceeded - if ($this->filter['query'] && $teams->getMatches() > CFG_SQL_LIMIT_DEFAULT) + if ($this->filter['query'] && $teams->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT')) { $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_arenateamsfound2', $this->sumSubjects, $teams->getMatches()); $tabData['_truncated'] = 1; } - else if ($teams->getMatches() > CFG_SQL_LIMIT_DEFAULT) + else if ($teams->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT')) $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_arenateamsfound', $this->sumSubjects, 0); if ($this->filterObj->error) diff --git a/pages/class.php b/pages/class.php index 6cf02990..1006e057 100644 --- a/pages/class.php +++ b/pages/class.php @@ -99,7 +99,7 @@ class ClassPage extends GenericPage BUTTON_LINKS => ['type' => $this->type, 'typeId' => $this->typeId], BUTTON_WOWHEAD => true, BUTTON_TALENT => ['href' => '?talent#'.Util::$tcEncoding[$tcClassId[$this->typeId] * 3], 'pet' => false], - BUTTON_FORUM => false // todo (low): CFG_BOARD_URL + X + BUTTON_FORUM => false // todo (low): Cfg::get('BOARD_URL') + X ); @@ -127,7 +127,7 @@ class ClassPage extends GenericPage ['s.cuFlags', SPELL_CU_LAST_RANK, '&'], ['s.rankNo', 0] ], - CFG_SQL_LIMIT_NONE + Cfg::get('SQL_LIMIT_NONE') ); $genSpells = new SpellList($conditions); @@ -153,7 +153,7 @@ class ClassPage extends GenericPage ['requiredClass', $_mask, '&'], [['requiredClass', CLASS_MASK_ALL, '&'], CLASS_MASK_ALL, '!'], ['itemset', 0], // hmm, do or dont..? - CFG_SQL_LIMIT_NONE + Cfg::get('SQL_LIMIT_NONE') ); $items = new ItemList($conditions); diff --git a/pages/emotes.php b/pages/emotes.php index dc341ea2..38832085 100644 --- a/pages/emotes.php +++ b/pages/emotes.php @@ -25,7 +25,7 @@ class EmotesPage extends GenericPage protected function generateContent() { - $cnd = [CFG_SQL_LIMIT_NONE]; + $cnd = [Cfg::get('SQL_LIMIT_NONE')]; if (!User::isInGroup(U_GROUP_STAFF)) $cnd[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0]; diff --git a/pages/enchantment.php b/pages/enchantment.php index 07591cf8..652a7c73 100644 --- a/pages/enchantment.php +++ b/pages/enchantment.php @@ -285,7 +285,7 @@ class EnchantmentPage extends GenericPage foreach ($iet as $tplId => $data) $randIds[$ire[$data['ench']]['id'] > 0 ? $tplId : -$tplId] = $ire[$data['ench']]['id']; - $randItems = new ItemList(array(CFG_SQL_LIMIT_NONE, ['randomEnchant', array_keys($randIds)])); + $randItems = new ItemList(array(Cfg::get('SQL_LIMIT_NONE'), ['randomEnchant', array_keys($randIds)])); if (!$randItems->error) { $data = $randItems->getListviewData(); diff --git a/pages/enchantments.php b/pages/enchantments.php index e9ed6e7a..2f772610 100644 --- a/pages/enchantments.php +++ b/pages/enchantments.php @@ -72,9 +72,9 @@ class EnchantmentsPage extends GenericPage if ($xCols) $tabData['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)'; - if ($ench->getMatches() > CFG_SQL_LIMIT_DEFAULT) + if ($ench->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT')) { - $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_enchantmentsfound', $ench->getMatches(), CFG_SQL_LIMIT_DEFAULT); + $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_enchantmentsfound', $ench->getMatches(), Cfg::get('SQL_LIMIT_DEFAULT')); $tabData['_truncated'] = 1; } diff --git a/pages/faction.php b/pages/faction.php index faf2b008..8836ccf0 100644 --- a/pages/faction.php +++ b/pages/faction.php @@ -184,7 +184,7 @@ class FactionPage extends GenericPage 'sort' => ['standing', 'name'] ); - if ($items->getMatches() > CFG_SQL_LIMIT_DEFAULT) + if ($items->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT')) $tabData['note'] = sprintf(Util::$filterResultString, '?items&filter=cr=17;crs='.$this->typeId.';crv=0'); $this->lvTabs[] = [ItemList::$brickFile, $tabData, 'itemStandingCol']; @@ -217,7 +217,7 @@ class FactionPage extends GenericPage 'sort' => ['-reputation', 'name'] ); - if ($killCreatures->getMatches() > CFG_SQL_LIMIT_DEFAULT) + if ($killCreatures->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT')) $tabData['note'] = sprintf(Util::$filterResultString, '?npcs&filter=cr=42;crs='.$this->typeId.';crv=0'); $this->lvTabs[] = [CreatureList::$brickFile, $tabData, 'npcRepCol']; @@ -237,7 +237,7 @@ class FactionPage extends GenericPage 'name' => '$LANG.tab_members' ); - if ($members->getMatches() > CFG_SQL_LIMIT_DEFAULT) + if ($members->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT')) $tabData['note'] = sprintf(Util::$filterResultString, '?npcs&filter=cr=3;crs='.$this->typeId.';crv=0'); $this->lvTabs[] = [CreatureList::$brickFile, $tabData]; @@ -271,7 +271,7 @@ class FactionPage extends GenericPage 'extraCols' => '$_' ); - if ($quests->getMatches() > CFG_SQL_LIMIT_DEFAULT) + if ($quests->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT')) $tabData['note'] = sprintf(Util::$filterResultString, '?quests&filter=cr=1;crs='.$this->typeId.';crv=0'); $this->lvTabs[] = [QuestList::$brickFile, $tabData, 'questRepCol']; diff --git a/pages/genericPage.class.php b/pages/genericPage.class.php index 36f1f6d4..62222d70 100644 --- a/pages/genericPage.class.php +++ b/pages/genericPage.class.php @@ -126,8 +126,8 @@ trait TrProfiler $this->region = $cat[0]; - // if ($cat[1] == Profiler::urlize(CFG_BATTLEGROUP)) - // $this->battlegroup = CFG_BATTLEGROUP; + // if ($cat[1] == Profiler::urlize(Cfg::get('BATTLEGROUP'))) + // $this->battlegroup = Cfg::get('BATTLEGROUP'); if (isset($cat[1])) { foreach (Profiler::getRealms() as $rId => $r) @@ -173,7 +173,7 @@ trait TrProfiler if ($this->realm) $this->path[] = Profiler::urlize($this->realm, true); // else - // $this->path[] = Profiler::urlize(CFG_BATTLEGROUP); + // $this->path[] = Profiler::urlize(Cfg::get('BATTLEGROUP')); } } } @@ -193,7 +193,7 @@ class GenericPage protected $jsGlobals = []; protected $lvData = []; - protected $title = [CFG_NAME]; // for title-Element + protected $title = []; // for title-Element protected $name = ''; // for h1-Element protected $tabId = null; protected $gDataKey = false; // adds the dataKey to the user vars @@ -272,6 +272,8 @@ class GenericPage $this->initRequestData(); + $this->title[] = Cfg::get('NAME'); + if (!isset($this->contribute)) $this->contribute = CONTRIBUTE_NONE; @@ -279,8 +281,9 @@ class GenericPage if ($pageParam) $this->fullParams .= '='.$pageParam; - if (CFG_CACHE_DIR && Util::writeDir(CFG_CACHE_DIR)) - $this->cacheDir = mb_substr(CFG_CACHE_DIR, -1) != '/' ? CFG_CACHE_DIR.'/' : CFG_CACHE_DIR; + $cacheDir = Cfg::get('CACHE_DIR'); + if ($cacheDir && Util::writeDir($cacheDir)) + $this->cacheDir = mb_substr($cacheDir, -1) != '/' ? $cacheDir.'/' : $cacheDir; // force page refresh if (isset($_GET['refresh']) && User::isInGroup(U_GROUP_ADMIN | U_GROUP_BUREAU | U_GROUP_DEV)) @@ -337,9 +340,9 @@ class GenericPage $this->forwardToSignIn($_SERVER['QUERY_STRING'] ?? ''); } - if (CFG_MAINTENANCE && !User::isInGroup(U_GROUP_EMPLOYEE)) + if (Cfg::get('MAINTENANCE') && !User::isInGroup(U_GROUP_EMPLOYEE)) $this->maintenance(); - else if (CFG_MAINTENANCE && User::isInGroup(U_GROUP_EMPLOYEE)) + else if (Cfg::get('MAINTENANCE') && User::isInGroup(U_GROUP_EMPLOYEE)) Util::addNote(U_GROUP_EMPLOYEE, 'Maintenance mode enabled!'); // get errors from previous page from session and apply to template @@ -514,7 +517,7 @@ class GenericPage switch ($type) { case SC_JS_FILE: - $str = ($dynData ? HOST_URL : STATIC_URL).'/'.$str; + $str = ($dynData ? Cfg::get('HOST_URL') : Cfg::get('STATIC_URL')).'/'.$str; case SC_JS_STRING: if ($flags & SC_FLAG_PREFIX) array_unshift($this->js, [$type, $str]); @@ -522,7 +525,7 @@ class GenericPage $this->js[] = [$type, $str]; break; case SC_CSS_FILE: - $str = STATIC_URL.'/'.$str; + $str = Cfg::get('STATIC_URL').'/'.$str; case SC_CSS_STRING: if ($flags & SC_FLAG_PREFIX) array_unshift($this->css, [$type, $str]); @@ -609,7 +612,7 @@ class GenericPage 'mode' => 1, 'status' => 1, 'name' => 'internal error', - 'style' => 'color: #ff3333; font-weight: bold; font-size: 14px; padding-left: 40px; background-image: url('.STATIC_URL.'/images/announcements/warn-small.png); background-size: 15px 15px; background-position: 12px center; border: dashed 2px #C03030;', + 'style' => 'color: #ff3333; font-weight: bold; font-size: 14px; padding-left: 40px; background-image: url('.Cfg::get('STATIC_URL').'/images/announcements/warn-small.png); background-size: 15px 15px; background-position: 12px center; border: dashed 2px #C03030;', 'text' => '[span]'.implode("[br]", $_).'[/span]' ); } @@ -959,7 +962,7 @@ class GenericPage $this->initJSGlobal($type); - $obj = Type::newList($type, [CFG_SQL_LIMIT_NONE, ['id', array_unique($ids, SORT_NUMERIC)]]); + $obj = Type::newList($type, [Cfg::get('SQL_LIMIT_NONE'), ['id', array_unique($ids, SORT_NUMERIC)]]); if (!$obj) continue; @@ -981,7 +984,7 @@ class GenericPage if ($this->mode == CACHE_TYPE_NONE) return; - if (!CFG_CACHE_MODE || CFG_DEBUG) + if (!Cfg::get('CACHE_MODE') || Cfg::get('DEBUG')) return; $noCache = ['coError', 'ssError', 'viError']; @@ -1004,7 +1007,7 @@ class GenericPage else $cache = $saveString; - if (CFG_CACHE_MODE & CACHE_MODE_MEMCACHED) + if (Cfg::get('CACHE_MODE') & CACHE_MODE_MEMCACHED) { // on &refresh also clear related if ($this->skipCache == CACHE_MODE_MEMCACHED) @@ -1030,7 +1033,7 @@ class GenericPage $this->memcached()->set($cKey, $data); } - if (CFG_CACHE_MODE & CACHE_MODE_FILECACHE) + if (Cfg::get('CACHE_MODE') & CACHE_MODE_FILECACHE) { $data = time()." ".AOWOW_REVISION." ".($saveString ? '1' : '0')."\n"; $data .= gzcompress($saveString ? $cache : serialize($cache), 9); @@ -1062,27 +1065,27 @@ class GenericPage if ($this->mode == CACHE_TYPE_NONE) return false; - if (!CFG_CACHE_MODE || CFG_DEBUG) + if (!Cfg::get('CACHE_MODE') || Cfg::get('DEBUG')) return false; $cKey = $this->generateCacheKey(); $rev = $type = $cache = $data = null; - if ((CFG_CACHE_MODE & CACHE_MODE_MEMCACHED) && !($this->skipCache & CACHE_MODE_MEMCACHED)) + if ((Cfg::get('CACHE_MODE') & CACHE_MODE_MEMCACHED) && !($this->skipCache & CACHE_MODE_MEMCACHED)) { if ($cache = $this->memcached()->get($cKey)) { $type = $cache['isString']; $data = $cache['data']; - if ($cache['timestamp'] + CFG_CACHE_DECAY <= time() || $cache['revision'] != AOWOW_REVISION) + if ($cache['timestamp'] + Cfg::get('CACHE_DECAY') <= time() || $cache['revision'] != AOWOW_REVISION) $cache = null; else $this->cacheLoaded = [CACHE_MODE_MEMCACHED, $cache['timestamp']]; } } - if (!$cache && (CFG_CACHE_MODE & CACHE_MODE_FILECACHE) && !($this->skipCache & CACHE_MODE_FILECACHE)) + if (!$cache && (Cfg::get('CACHE_MODE') & CACHE_MODE_FILECACHE) && !($this->skipCache & CACHE_MODE_FILECACHE)) { if (!file_exists($this->cacheDir.$cKey)) return false; @@ -1098,7 +1101,7 @@ class GenericPage [$time, $rev, $type] = explode(' ', $cache[0]); - if ($time + CFG_CACHE_DECAY <= time() || $rev != AOWOW_REVISION) + if ($time + Cfg::get('CACHE_DECAY') <= time() || $rev != AOWOW_REVISION) $cache = null; else { @@ -1131,7 +1134,7 @@ class GenericPage private function memcached() : Memcached { - if (!$this->memcached && (CFG_CACHE_MODE & CACHE_MODE_MEMCACHED)) + if (!$this->memcached && (Cfg::get('CACHE_MODE') & CACHE_MODE_MEMCACHED)) { $this->memcached = new Memcached(); $this->memcached->addServer('localhost', 11211); diff --git a/pages/guide.php b/pages/guide.php index 50c885ef..887fd1c1 100644 --- a/pages/guide.php +++ b/pages/guide.php @@ -482,7 +482,7 @@ class GuidePage extends GenericPage return false; // req: valid data - if (!in_array($this->_post['category'], $this->validCats) || !(CFG_LOCALES & (1 << $this->_post['locale']))) + if (!in_array($this->_post['category'], $this->validCats) || !(Cfg::get('LOCALES') & (1 << $this->_post['locale']))) return false; // sanitize: spec / class diff --git a/pages/guild.php b/pages/guild.php index 42691f1c..53c82658 100644 --- a/pages/guild.php +++ b/pages/guild.php @@ -31,7 +31,7 @@ class GuildPage extends GenericPage { parent::__construct($pageCall, $pageParam); - if (!CFG_PROFILER_ENABLE) + if (!Cfg::get('PROFILER_ENABLE')) $this->error(); $params = array_map('urldecode', explode('.', $pageParam)); @@ -124,7 +124,7 @@ class GuildPage extends GenericPage /**************/ // tab: members - $member = new LocalProfileList(array(['p.guild', $this->subjectGUID], CFG_SQL_LIMIT_NONE)); + $member = new LocalProfileList(array(['p.guild', $this->subjectGUID], Cfg::get('SQL_LIMIT_NONE'))); if (!$member->error) { $this->lvTabs[] = [ProfileList::$brickFile, array( diff --git a/pages/guilds.php b/pages/guilds.php index 61c5d572..6c61e1c2 100644 --- a/pages/guilds.php +++ b/pages/guilds.php @@ -29,7 +29,7 @@ class GuildsPage extends GenericPage { parent::__construct($pageCall, $pageParam); - if (!CFG_PROFILER_ENABLE) + if (!Cfg::get('PROFILER_ENABLE')) $this->error(); $this->getSubjectFromUrl($pageParam); @@ -54,7 +54,7 @@ class GuildsPage extends GenericPage protected function generateTitle() { if ($this->realm) - array_unshift($this->title, $this->realm,/* CFG_BATTLEGROUP,*/ Lang::profiler('regions', $this->region), Lang::profiler('guilds')); + array_unshift($this->title, $this->realm,/* Cfg::get('BATTLEGROUP'),*/ Lang::profiler('regions', $this->region), Lang::profiler('guilds')); else if ($this->region) array_unshift($this->title, Lang::profiler('regions', $this->region), Lang::profiler('guilds')); else @@ -107,12 +107,12 @@ class GuildsPage extends GenericPage $tabData['data'] = array_values($guilds->getListviewData()); // create note if search limit was exceeded - if ($this->filter['query'] && $guilds->getMatches() > CFG_SQL_LIMIT_DEFAULT) + if ($this->filter['query'] && $guilds->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT')) { $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_guildsfound2', $this->sumSubjects, $guilds->getMatches()); $tabData['_truncated'] = 1; } - else if ($guilds->getMatches() > CFG_SQL_LIMIT_DEFAULT) + else if ($guilds->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT')) $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_guildsfound', $this->sumSubjects, 0); if ($this->filterObj->error) diff --git a/pages/home.php b/pages/home.php index e4e46564..bd209893 100644 --- a/pages/home.php +++ b/pages/home.php @@ -41,7 +41,7 @@ class HomePage extends GenericPage $this->extendGlobalData($_); if (empty($this->featuredBox['boxBG'])) - $this->featuredBox['boxBG'] = STATIC_URL.'/images/'.User::$localeString.'/mainpage-bg-news.jpg'; + $this->featuredBox['boxBG'] = Cfg::get('STATIC_URL').'/images/'.User::$localeString.'/mainpage-bg-news.jpg'; // load overlay links $this->featuredBox['overlays'] = DB::Aowow()->select('SELECT * FROM ?_home_featuredbox_overlay WHERE featureId = ?d', $this->featuredBox['id']); @@ -55,7 +55,7 @@ class HomePage extends GenericPage protected function generateTitle() { if ($_ = DB::Aowow()->selectCell('SELECT title FROM ?_home_titles WHERE active = 1 AND locale = ?d ORDER BY RAND() LIMIT 1', User::$localeId)) - $this->homeTitle = CFG_NAME.Lang::main('colon').$_; + $this->homeTitle = Cfg::get('NAME').Lang::main('colon').$_; } protected function generatePath() {} diff --git a/pages/item.php b/pages/item.php index b7b4cd6b..3f5a45c2 100644 --- a/pages/item.php +++ b/pages/item.php @@ -565,7 +565,7 @@ class ItemPage extends genericPage // tab: container can contain if ($this->subject->getField('slots') > 0) { - $contains = new ItemList(array(['bagFamily', $_bagFamily, '&'], ['slots', 1, '<'], CFG_SQL_LIMIT_NONE)); + $contains = new ItemList(array(['bagFamily', $_bagFamily, '&'], ['slots', 1, '<'], Cfg::get('SQL_LIMIT_NONE'))); if (!$contains->error) { $this->extendGlobalData($contains->getJSGlobals(GLOBALINFO_SELF)); @@ -586,7 +586,7 @@ class ItemPage extends genericPage // tab: can be contained in (except keys) else if ($_bagFamily != 0x0100) { - $contains = new ItemList(array(['bagFamily', $_bagFamily, '&'], ['slots', 0, '>'], CFG_SQL_LIMIT_NONE)); + $contains = new ItemList(array(['bagFamily', $_bagFamily, '&'], ['slots', 0, '>'], Cfg::get('SQL_LIMIT_NONE'))); if (!$contains->error) { $this->extendGlobalData($contains->getJSGlobals(GLOBALINFO_SELF)); @@ -1193,7 +1193,7 @@ class ItemPage extends genericPage } // link - $xml->addChild('link', HOST_URL.'?item='.$this->subject->id); + $xml->addChild('link', Cfg::get('HOST_URL').'?item='.$this->subject->id); } return $root->asXML(); diff --git a/pages/items.php b/pages/items.php index e4dcd2c8..67b8ef5d 100644 --- a/pages/items.php +++ b/pages/items.php @@ -231,7 +231,7 @@ class ItemsPage extends GenericPage $nameSource = []; $grouping = isset($this->filter['gb']) ? $this->filter['gb'] : null; $extraOpts = []; - $maxResults = CFG_SQL_LIMIT_DEFAULT; + $maxResults = Cfg::get('SQL_LIMIT_DEFAULT'); switch ($grouping) { @@ -409,7 +409,7 @@ class ItemsPage extends GenericPage } else if ($items->getMatches() > $maxResults) { - $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_itemsfound', $items->getMatches(), CFG_SQL_LIMIT_DEFAULT); + $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_itemsfound', $items->getMatches(), Cfg::get('SQL_LIMIT_DEFAULT')); $tabData['_truncated'] = 1; } diff --git a/pages/itemsets.php b/pages/itemsets.php index 8fb74742..71e34170 100644 --- a/pages/itemsets.php +++ b/pages/itemsets.php @@ -62,9 +62,9 @@ class ItemsetsPage extends GenericPage $tabData['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)'; // create note if search limit was exceeded - if ($itemsets->getMatches() > CFG_SQL_LIMIT_DEFAULT) + if ($itemsets->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT')) { - $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_itemsetsfound', $itemsets->getMatches(), CFG_SQL_LIMIT_DEFAULT); + $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_itemsetsfound', $itemsets->getMatches(), Cfg::get('SQL_LIMIT_DEFAULT')); $tabData['_truncated'] = 1; } diff --git a/pages/more.php b/pages/more.php index a3bb3c9f..61943f11 100644 --- a/pages/more.php +++ b/pages/more.php @@ -25,20 +25,20 @@ class MorePage extends GenericPage private $page = []; private $req2priv = array( - 1 => CFG_REP_REQ_COMMENT, // write comments - 2 => 0, // NYI post external links - 4 => 0, // NYI no captcha - 5 => CFG_REP_REQ_SUPERVOTE, // votes count for more - 9 => CFG_REP_REQ_VOTEMORE_BASE, // more votes per day - 10 => CFG_REP_REQ_UPVOTE, // can upvote - 11 => CFG_REP_REQ_DOWNVOTE, // can downvote - 12 => CFG_REP_REQ_REPLY, // can reply - 13 => 0, // avatar border [NYI: checked by js, avatars not in use] - 14 => 0, // avatar border [NYI: checked by js, avatars not in use] - 15 => 0, // avatar border [NYI: checked by js, avatars not in use] - 16 => 0, // avatar border [NYI: checked by js, avatars not in use] - 17 => CFG_REP_REQ_PREMIUM // premium status - ); + 1 => 'REP_REQ_COMMENT', // write comments + // 2 => 'REP_REQ_EXT_LINKS', // NYI post external links + // 4 => 'REP_REQ_NO_CAPTCHA', // NYI no captcha + 5 => 'REP_REQ_SUPERVOTE', // votes count for more + 9 => 'REP_REQ_VOTEMORE_BASE', // more votes per day + 10 => 'REP_REQ_UPVOTE', // can upvote + 11 => 'REP_REQ_DOWNVOTE', // can downvote + 12 => 'REP_REQ_REPLY', // can reply + 13 => 'REP_REQ_BORDER_UNCO', // uncommon avatar border [NYI: hardcoded in Icon.getPrivilegeBorder(), avatars not in use] + 14 => 'REP_REQ_BORDER_RARE', // rare avatar border [NYI: hardcoded in Icon.getPrivilegeBorder(), avatars not in use] + 15 => 'REP_REQ_BORDER_EPIC', // epic avatar border [NYI: hardcoded in Icon.getPrivilegeBorder(), avatars not in use] + 16 => 'REP_REQ_BORDER_LEGE', // legendary avatar border [NYI: hardcoded in Icon.getPrivilegeBorder(), avatars not in use] + 17 => 'REP_REQ_PREMIUM' // premium status + ); private $validPages = array( // [tabId, path[, subPaths]] 'whats-new' => [2, [2, 7]], @@ -49,7 +49,7 @@ class MorePage extends GenericPage 'searchplugins' => [2, [2, 8]], 'help' => [2, [2, 13], ['commenting-and-you', 'modelviewer', 'screenshots-tips-tricks', 'stat-weighting', 'talent-calculator', 'item-comparison', 'profiler', 'markup-guide']], 'reputation' => [1, [3, 10]], - 'privilege' => [1, [3, 10], [1, 2, 4, 5, 9, 10, 11, 12, 13, 14, 15, 16, 17]], + 'privilege' => [1, [3, 10], [1, /* 2, 4, */ 5, 9, 10, 11, 12, 13, 14, 15, 16, 17]], 'privileges' => [1, [3, 10, 0]], 'top-users' => [1, [3, 11]] ); @@ -90,7 +90,10 @@ class MorePage extends GenericPage else $this->error(); - // order by requirement ASC + // apply actual values and order by requirement ASC + foreach ($this->req2priv as &$var) + $var = Cfg::get($var); + asort($this->req2priv); } @@ -123,14 +126,7 @@ class MorePage extends GenericPage $this->page[0] != 'privilege') return; - $consts = get_defined_constants(true); - foreach ($consts['user'] as $k => $v) - { - if (strstr($k, 'CFG_REP_')) - $txt = str_replace($k, Lang::nf($v), $txt); - else if ($k == 'CFG_USER_MAX_VOTES' || $k == 'CFG_BOARD_URL') - $txt = str_replace($k, $v, $txt); - } + $txt = Cfg::applyToString($txt); } protected function generatePath() { } @@ -208,7 +204,7 @@ class MorePage extends GenericPage GROUP BY a.id ORDER BY reputation DESC LIMIT ?d - ', $t ?: DBSIMPLE_SKIP, CFG_SQL_LIMIT_SEARCH); + ', $t ?: DBSIMPLE_SKIP, Cfg::get('SQL_LIMIT_SEARCH')); $data = []; if ($res) diff --git a/pages/npcs.php b/pages/npcs.php index 095ff2b8..d170ca71 100644 --- a/pages/npcs.php +++ b/pages/npcs.php @@ -81,9 +81,9 @@ class NpcsPage extends GenericPage $tabData['hiddenCols'] = ['type']; // create note if search limit was exceeded - if ($npcs->getMatches() > CFG_SQL_LIMIT_DEFAULT) + if ($npcs->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT')) { - $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_npcsfound', $npcs->getMatches(), CFG_SQL_LIMIT_DEFAULT); + $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_npcsfound', $npcs->getMatches(), Cfg::get('SQL_LIMIT_DEFAULT')); $tabData['_truncated'] = 1; } diff --git a/pages/object.php b/pages/object.php index f38e1006..c08437cf 100644 --- a/pages/object.php +++ b/pages/object.php @@ -467,9 +467,9 @@ class ObjectPage extends GenericPage $this->extendGlobalData($focusSpells->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); // create note if search limit was exceeded - if ($focusSpells->getMatches() > CFG_SQL_LIMIT_DEFAULT) + if ($focusSpells->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT')) { - $tabData['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_spellsfound', $focusSpells->getMatches(), CFG_SQL_LIMIT_DEFAULT); + $tabData['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_spellsfound', $focusSpells->getMatches(), Cfg::get('SQL_LIMIT_DEFAULT')); $tabData['_truncated'] = 1; } diff --git a/pages/objects.php b/pages/objects.php index 4dab6eac..37a63870 100644 --- a/pages/objects.php +++ b/pages/objects.php @@ -63,9 +63,9 @@ class ObjectsPage extends GenericPage $tabData['visibleCols'] = ['skill']; // create note if search limit was exceeded - if ($objects->getMatches() > CFG_SQL_LIMIT_DEFAULT) + if ($objects->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT')) { - $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_objectsfound', $objects->getMatches(), CFG_SQL_LIMIT_DEFAULT); + $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_objectsfound', $objects->getMatches(), Cfg::get('SQL_LIMIT_DEFAULT')); $tabData['_truncated'] = 1; } diff --git a/pages/pet.php b/pages/pet.php index fbac9b9f..d3f67d39 100644 --- a/pages/pet.php +++ b/pages/pet.php @@ -114,7 +114,7 @@ class PetPage extends GenericPage if ($mask & (1 << ($i - 1))) $list[] = $i; - $food = new ItemList(array(['i.subClass', [5, 8]], ['i.FoodType', $list], CFG_SQL_LIMIT_NONE)); + $food = new ItemList(array(['i.subClass', [5, 8]], ['i.FoodType', $list], Cfg::get('SQL_LIMIT_NONE'))); $this->extendGlobalData($food->getJSGlobals()); $this->lvTabs[] = [ItemList::$brickFile, array( diff --git a/pages/profile.php b/pages/profile.php index f8065348..7ca0d5aa 100644 --- a/pages/profile.php +++ b/pages/profile.php @@ -44,7 +44,7 @@ class ProfilePage extends GenericPage { parent::__construct($pageCall, $pageParam); - if (!CFG_PROFILER_ENABLE) + if (!Cfg::get('PROFILER_ENABLE')) $this->error(); $params = array_map('urldecode', explode('.', $pageParam)); diff --git a/pages/profiler.php b/pages/profiler.php index f039244e..934234a8 100644 --- a/pages/profiler.php +++ b/pages/profiler.php @@ -20,7 +20,7 @@ class ProfilerPage extends GenericPage { parent::__construct($pageCall, $pageParam); - if (!CFG_PROFILER_ENABLE) + if (!Cfg::get('PROFILER_ENABLE')) $this->error(); } diff --git a/pages/profiles.php b/pages/profiles.php index 3c81fd87..47c8dec4 100644 --- a/pages/profiles.php +++ b/pages/profiles.php @@ -37,7 +37,7 @@ class ProfilesPage extends GenericPage parent::__construct($pageCall, $pageParam); - if (!CFG_PROFILER_ENABLE) + if (!Cfg::get('PROFILER_ENABLE')) $this->error(); $realms = []; @@ -62,7 +62,7 @@ class ProfilesPage extends GenericPage protected function generateTitle() { if ($this->realm) - array_unshift($this->title, $this->realm,/* CFG_BATTLEGROUP,*/ Lang::profiler('regions', $this->region), Lang::game('profiles')); + array_unshift($this->title, $this->realm,/* Cfg::get('BATTLEGROUP'),*/ Lang::profiler('regions', $this->region), Lang::game('profiles')); else if ($this->region) array_unshift($this->title, Lang::profiler('regions', $this->region), Lang::game('profiles')); else @@ -166,12 +166,12 @@ class ProfilesPage extends GenericPage $tabData['visibleCols'][] = 'guildrank'; // create note if search limit was exceeded - if ($this->filter['query'] && $profiles->getMatches() > CFG_SQL_LIMIT_DEFAULT) + if ($this->filter['query'] && $profiles->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT')) { $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_charactersfound2', $this->sumSubjects, $profiles->getMatches()); $tabData['_truncated'] = 1; } - else if ($profiles->getMatches() > CFG_SQL_LIMIT_DEFAULT) + else if ($profiles->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT')) $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_charactersfound', $this->sumSubjects, 0); if ($this->filterObj->useLocalList) diff --git a/pages/quests.php b/pages/quests.php index 3a1448de..f8068852 100644 --- a/pages/quests.php +++ b/pages/quests.php @@ -75,9 +75,9 @@ class QuestsPage extends GenericPage $tabData['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)'; // create note if search limit was exceeded - if ($quests->getMatches() > CFG_SQL_LIMIT_DEFAULT) + if ($quests->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT')) { - $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_questsfound', $quests->getMatches(), CFG_SQL_LIMIT_DEFAULT); + $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_questsfound', $quests->getMatches(), Cfg::get('SQL_LIMIT_DEFAULT')); $tabData['_truncated'] = 1; } else if (isset($this->category[1]) && $this->category[1] > 0) diff --git a/pages/screenshot.php b/pages/screenshot.php index fcff8f61..62773685 100644 --- a/pages/screenshot.php +++ b/pages/screenshot.php @@ -23,7 +23,7 @@ class ScreenshotPage extends GenericPage private $tmpPath = 'static/uploads/temp/'; private $pendingPath = 'static/uploads/screenshots/pending/'; private $destination = null; - private $minSize = CFG_SCREENSHOT_MIN_SIZE; + private $minSize = 200; private $command = ''; protected $validCats = ['add', 'crop', 'complete', 'thankyou']; @@ -43,11 +43,10 @@ class ScreenshotPage extends GenericPage $this->name = Lang::screenshot('submission'); $this->command = $pageParam; - if ($this->minSize <= 0) - { - trigger_error('config error: dimensions for uploaded screenshots equal or less than zero. Value forced to 200', E_USER_WARNING); - $this->minSize = 200; - } + if ($ms = Cfg::get('SCREENSHOT_MIN_SIZE')) + $this->minSize = abs($ms); + else + trigger_error('config error: Invalid value for minimum screenshot dimensions. Value forced to '.$this->minSize, E_USER_WARNING); // get screenshot destination // target delivered as screenshot=&.. (hash is optional) @@ -194,7 +193,7 @@ class ScreenshotPage extends GenericPage // r: x <= 488 && y <= 325 while x proportional to y // mincrop is optional and specifies the minimum resulting image size $this->cropper = [ - 'url' => STATIC_URL.'/uploads/temp/'.$this->ssName().'.jpg', + 'url' => Cfg::get('STATIC_URL').'/uploads/temp/'.$this->ssName().'.jpg', 'parent' => 'ss-container', 'oWidth' => $oSize[0], 'rWidth' => $rSize[0], diff --git a/pages/search.php b/pages/search.php index 24ba6e85..648e73b6 100644 --- a/pages/search.php +++ b/pages/search.php @@ -45,7 +45,7 @@ class SearchPage extends GenericPage 'opensearch' => ['filter' => FILTER_CALLBACK, 'options' => 'GenericPage::checkEmptySet'] ); - private $maxResults = CFG_SQL_LIMIT_SEARCH; + private $maxResults = 500; private $searchMask = 0x0; private $query = ''; // lookup private $included = []; @@ -84,6 +84,9 @@ class SearchPage extends GenericPage $this->statWeights = [$wt, $wtv]; } + if ($limit = Cfg::get('SQL_LIMIT_SEARCH')) + $this->maxResults = $limit; + // select search mode if ($this->_get['json']) { @@ -99,21 +102,21 @@ class SearchPage extends GenericPage } else if ($this->_get['opensearch']) { - $this->maxResults = CFG_SQL_LIMIT_QUICKSEARCH; + $this->maxResults = Cfg::get('SQL_LIMIT_QUICKSEARCH'); $this->searchMask |= SEARCH_TYPE_OPEN | SEARCH_MASK_OPEN; } else $this->searchMask |= SEARCH_TYPE_REGULAR | SEARCH_MASK_ALL; // handle maintenance status for js-cases - if (CFG_MAINTENANCE && !User::isInGroup(U_GROUP_EMPLOYEE) && !($this->searchMask & SEARCH_TYPE_REGULAR)) + if (Cfg::get('MAINTENANCE') && !User::isInGroup(U_GROUP_EMPLOYEE) && !($this->searchMask & SEARCH_TYPE_REGULAR)) $this->notFound(); // fill include, exclude and ignore $this->tokenizeQuery(); // invalid conditions: not enough characters to search OR no types to search - if ((CFG_MAINTENANCE && !User::isInGroup(U_GROUP_EMPLOYEE)) || + if ((Cfg::get('MAINTENANCE') && !User::isInGroup(U_GROUP_EMPLOYEE)) || (!$this->included && ($this->searchMask & (SEARCH_TYPE_OPEN | SEARCH_TYPE_REGULAR))) || (($this->searchMask & SEARCH_TYPE_JSON) && !$this->included && !$this->statWeights)) { @@ -303,7 +306,7 @@ class SearchPage extends GenericPage $hasQ = is_numeric($data['name'][0]) || $data['name'][0] == '@'; $result[1][] = ($hasQ ? mb_substr($data['name'], 1) : $data['name']).$osInfo[1]; - $result[3][] = HOST_URL.'/?'.Type::getFileString($osInfo[0]).'='.$data['id']; + $result[3][] = Cfg::get('HOST_URL').'/?'.Type::getFileString($osInfo[0]).'='.$data['id']; $extra = [$osInfo[0], $data['id']]; // type, typeId @@ -552,7 +555,7 @@ class SearchPage extends GenericPage if (($this->searchMask & SEARCH_TYPE_JSON) && ($this->searchMask & 0x20) && !empty($shared['pcsToSet'])) { - $cnd = [['i.id', array_keys($shared['pcsToSet'])], CFG_SQL_LIMIT_NONE]; + $cnd = [['i.id', array_keys($shared['pcsToSet'])], Cfg::get('SQL_LIMIT_NONE')]; $miscData = ['pcsToSet' => $shared['pcsToSet']]; } else if (($this->searchMask & SEARCH_TYPE_JSON) && ($this->searchMask & 0x40)) diff --git a/pages/skill.php b/pages/skill.php index 21c5e030..40d6f63d 100644 --- a/pages/skill.php +++ b/pages/skill.php @@ -82,7 +82,7 @@ class SkillPage extends GenericPage $condition = array( ['OR', ['s.reagent1', 0, '>'], ['s.reagent2', 0, '>'], ['s.reagent3', 0, '>'], ['s.reagent4', 0, '>'], ['s.reagent5', 0, '>'], ['s.reagent6', 0, '>'], ['s.reagent7', 0, '>'], ['s.reagent8', 0, '>']], ['OR', ['s.skillLine1', $this->typeId], ['AND', ['s.skillLine1', 0, '>'], ['s.skillLine2OrMask', $this->typeId]]], - CFG_SQL_LIMIT_NONE + Cfg::get('SQL_LIMIT_NONE') ); $recipes = new SpellList($condition); // also relevant for 3 @@ -104,7 +104,7 @@ class SkillPage extends GenericPage $conditions = array( ['requiredSkill', $this->typeId], ['class', ITEM_CLASS_RECIPE], - CFG_SQL_LIMIT_NONE + Cfg::get('SQL_LIMIT_NONE') ); $recipeItems = new ItemList($conditions); @@ -134,7 +134,7 @@ class SkillPage extends GenericPage if ($created) { - $created = new ItemList(array(['i.id', $created], CFG_SQL_LIMIT_NONE)); + $created = new ItemList(array(['i.id', $created], Cfg::get('SQL_LIMIT_NONE'))); if (!$created->error) { $this->extendGlobalData($created->getJSGlobals(GLOBALINFO_SELF)); @@ -156,7 +156,7 @@ class SkillPage extends GenericPage $conditions = array( ['requiredSkill', $this->typeId], ['class', ITEM_CLASS_RECIPE, '!'], - CFG_SQL_LIMIT_NONE + Cfg::get('SQL_LIMIT_NONE') ); $reqBy = new ItemList($conditions); @@ -179,7 +179,7 @@ class SkillPage extends GenericPage // tab: required by [itemset] $conditions = array( ['skillId', $this->typeId], - CFG_SQL_LIMIT_NONE + Cfg::get('SQL_LIMIT_NONE') ); $reqBy = new ItemsetList($conditions); @@ -201,7 +201,7 @@ class SkillPage extends GenericPage $condition = array( ['AND', ['s.reagent1', 0], ['s.reagent2', 0], ['s.reagent3', 0], ['s.reagent4', 0], ['s.reagent5', 0], ['s.reagent6', 0], ['s.reagent7', 0], ['s.reagent8', 0]], ['OR', ['s.skillLine1', $this->typeId], ['AND', ['s.skillLine1', 0, '>'], ['s.skillLine2OrMask', $this->typeId]]], - CFG_SQL_LIMIT_NONE + Cfg::get('SQL_LIMIT_NONE') ); foreach (Game::$skillLineMask as $line1 => $sets) @@ -266,7 +266,7 @@ class SkillPage extends GenericPage { $this->addScript([SC_JS_FILE, '?data=zones']); - $trainer = new CreatureList(array(CFG_SQL_LIMIT_NONE, ['ct.id', $list], ['s.guid', NULL, '!'], ['ct.npcflag', 0x10, '&'])); + $trainer = new CreatureList(array(Cfg::get('SQL_LIMIT_NONE'), ['ct.id', $list], ['s.guid', NULL, '!'], ['ct.npcflag', 0x10, '&'])); if (!$trainer->error) { @@ -302,7 +302,7 @@ class SkillPage extends GenericPage if ($sort) { - $quests = new QuestList(array(['zoneOrSort', -$sort], CFG_SQL_LIMIT_NONE)); + $quests = new QuestList(array(['zoneOrSort', -$sort], Cfg::get('SQL_LIMIT_NONE'))); if (!$quests->error) { $this->extendGlobalData($quests->getJSGlobals()); diff --git a/pages/sound.php b/pages/sound.php index c0c2d987..2c1dcbed 100644 --- a/pages/sound.php +++ b/pages/sound.php @@ -328,7 +328,7 @@ class SoundPage extends GenericPage if ($creatureIds || $displayIds) { $extra = []; - $cnds = [CFG_SQL_LIMIT_NONE, &$extra]; + $cnds = [Cfg::get('SQL_LIMIT_NONE'), &$extra]; if (!User::isInGroup(U_GROUP_STAFF)) $cnds[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0]; diff --git a/pages/sounds.php b/pages/sounds.php index 1d4e61c0..5d69b368 100644 --- a/pages/sounds.php +++ b/pages/sounds.php @@ -54,9 +54,9 @@ class SoundsPage extends GenericPage $tabData['data'] = array_values($sounds->getListviewData()); // create note if search limit was exceeded; overwriting 'note' is intentional - if ($sounds->getMatches() > CFG_SQL_LIMIT_DEFAULT) + if ($sounds->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT')) { - $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_soundsfound', $sounds->getMatches(), CFG_SQL_LIMIT_DEFAULT); + $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_soundsfound', $sounds->getMatches(), Cfg::get('SQL_LIMIT_DEFAULT')); $tabData['_truncated'] = 1; } diff --git a/pages/spell.php b/pages/spell.php index 6b8b50ba..78607b0a 100644 --- a/pages/spell.php +++ b/pages/spell.php @@ -286,7 +286,7 @@ class SpellPage extends GenericPage if ($_ = DB::Aowow()->selectCell('SELECT ic.name FROM ?_glyphproperties gp JOIN ?_icons ic ON gp.iconId = ic.id WHERE gp.spellId = ?d { OR gp.id = ?d }', $this->typeId, $glyphId ?: DBSIMPLE_SKIP)) if (file_exists('static/images/wow/Interface/Spellbook/'.$_.'.png')) - $infobox .= '[img src='.STATIC_URL.'/images/wow/Interface/Spellbook/'.$_.'.png border=0 float=center margin=15]'; + $infobox .= '[img src='.Cfg::get('STATIC_URL').'/images/wow/Interface/Spellbook/'.$_.'.png border=0 float=center margin=15]'; /****************/ @@ -1127,7 +1127,7 @@ class SpellPage extends GenericPage if ($list) { - $tbTrainer = new CreatureList(array(CFG_SQL_LIMIT_NONE, ['ct.id', $list], ['s.guid', null, '!'], ['ct.npcflag', 0x10, '&'])); + $tbTrainer = new CreatureList(array(Cfg::get('SQL_LIMIT_NONE'), ['ct.id', $list], ['s.guid', null, '!'], ['ct.npcflag', 0x10, '&'])); if (!$tbTrainer->error) { $this->extendGlobalData($tbTrainer->getJSGlobals()); diff --git a/pages/spells.php b/pages/spells.php index 36e56c25..92535283 100644 --- a/pages/spells.php +++ b/pages/spells.php @@ -436,9 +436,9 @@ class SpellsPage extends GenericPage } // create note if search limit was exceeded; overwriting 'note' is intentional - if ($spells->getMatches() > CFG_SQL_LIMIT_DEFAULT) + if ($spells->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT')) { - $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_spellsfound', $spells->getMatches(), CFG_SQL_LIMIT_DEFAULT); + $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_spellsfound', $spells->getMatches(), Cfg::get('SQL_LIMIT_DEFAULT')); $tabData['_truncated'] = 1; } diff --git a/pages/user.php b/pages/user.php index be38b3a6..28fb3147 100644 --- a/pages/user.php +++ b/pages/user.php @@ -161,7 +161,7 @@ class UserPage extends GenericPage '_totalCount' => $nFound ); - if ($nFound > CFG_SQL_LIMIT_DEFAULT) + if ($nFound > Cfg::get('SQL_LIMIT_DEFAULT')) { $tabData['name'] = '$LANG.tab_latestcomments'; $tabData['note'] = '$$WH.sprintf(LANG.lvnote_usercomments, '.$nFound.')'; @@ -180,7 +180,7 @@ class UserPage extends GenericPage '_totalCount' => $nFound ); - if ($nFound > CFG_SQL_LIMIT_DEFAULT) + if ($nFound > Cfg::get('SQL_LIMIT_DEFAULT')) { $tabData['name'] = '$LANG.tab_latestreplies'; $tabData['note'] = '$$WH.sprintf(LANG.lvnote_userreplies, '.$nFound.')'; @@ -197,7 +197,7 @@ class UserPage extends GenericPage '_totalCount' => $nFound ); - if ($nFound > CFG_SQL_LIMIT_DEFAULT) + if ($nFound > Cfg::get('SQL_LIMIT_DEFAULT')) { $tabData['name'] = '$LANG.tab_latestscreenshots'; $tabData['note'] = '$$WH.sprintf(LANG.lvnote_userscreenshots, '.$nFound.')'; @@ -214,7 +214,7 @@ class UserPage extends GenericPage '_totalCount' => $nFound ); - if ($nFound > CFG_SQL_LIMIT_DEFAULT) + if ($nFound > Cfg::get('SQL_LIMIT_DEFAULT')) { $tabData['name'] = '$LANG.tab_latestvideos'; $tabData['note'] = '$$WH.sprintf(LANG.lvnote_uservideos, '.$nFound.')'; diff --git a/pages/utility.php b/pages/utility.php index d1c486e0..0444fbd9 100644 --- a/pages/utility.php +++ b/pages/utility.php @@ -87,10 +87,10 @@ class UtilityPage extends GenericPage // todo (low): preview should be html-formated $this->feedData[] = array( 'title' => [true, [], Lang::typeName($d['type']).Lang::main('colon').htmlentities($d['subject'])], - 'link' => [false, [], HOST_URL.'/?go-to-comment&id='.$d['id']], + 'link' => [false, [], Cfg::get('HOST_URL').'/?go-to-comment&id='.$d['id']], 'description' => [true, [], htmlentities($d['preview'])."

".Lang::main('byUser', [$d['user'], '']) . Util::formatTimeDiff($d['date'], true)], 'pubDate' => [false, [], date(DATE_RSS, $d['date'])], - 'guid' => [false, [], HOST_URL.'/?go-to-comment&id='.$d['id']] + 'guid' => [false, [], Cfg::get('HOST_URL').'/?go-to-comment&id='.$d['id']] // 'domain' => [false, [], null] ); } @@ -100,10 +100,10 @@ class UtilityPage extends GenericPage // todo (low): preview should be html-formated $this->feedData[] = array( 'title' => [true, [], Lang::typeName($d['type']).Lang::main('colon').htmlentities($d['subject'])], - 'link' => [false, [], HOST_URL.'/?go-to-comment&id='.$d['id']], + 'link' => [false, [], Cfg::get('HOST_URL').'/?go-to-comment&id='.$d['id']], 'description' => [true, [], htmlentities($d['preview'])."

".Lang::main('byUser', [$d['user'], '']) . Util::formatTimeDiff($d['date'], true)], 'pubDate' => [false, [], date(DATE_RSS, $d['date'])], - 'guid' => [false, [], HOST_URL.'/?go-to-comment&id='.$d['id']] + 'guid' => [false, [], Cfg::get('HOST_URL').'/?go-to-comment&id='.$d['id']] // 'domain' => [false, [], null] ); } @@ -125,7 +125,7 @@ class UtilityPage extends GenericPage { foreach ($data as $d) { - $desc = ''; + $desc = ''; if ($d['caption']) $desc .= '
'.$d['caption']; $desc .= "

".Lang::main('byUser', [$d['user'], '']) . Util::formatTimeDiff($d['date'], true); @@ -133,11 +133,11 @@ class UtilityPage extends GenericPage // enclosure/length => filesize('static/uploads/screenshots/thumb/'.$d['id'].'.jpg') .. always set to this placeholder value though $this->feedData[] = array( 'title' => [true, [], Lang::typeName($d['type']).Lang::main('colon').htmlentities($d['subject'])], - 'link' => [false, [], HOST_URL.'/?'.Type::getFileString($d['type']).'='.$d['typeId'].'#screenshots:id='.$d['id']], + 'link' => [false, [], Cfg::get('HOST_URL').'/?'.Type::getFileString($d['type']).'='.$d['typeId'].'#screenshots:id='.$d['id']], 'description' => [true, [], $desc], 'pubDate' => [false, [], date(DATE_RSS, $d['date'])], - 'enclosure' => [false, ['url' => STATIC_URL.'/uploads/screenshots/thumb/'.$d['id'].'.jpg', 'length' => 12345, 'type' => 'image/jpeg'], null], - 'guid' => [false, [], HOST_URL.'/?'.Type::getFileString($d['type']).'='.$d['typeId'].'#screenshots:id='.$d['id']], + 'enclosure' => [false, ['url' => Cfg::get('STATIC_URL').'/uploads/screenshots/thumb/'.$d['id'].'.jpg', 'length' => 12345, 'type' => 'image/jpeg'], null], + 'guid' => [false, [], Cfg::get('HOST_URL').'/?'.Type::getFileString($d['type']).'='.$d['typeId'].'#screenshots:id='.$d['id']], // 'domain' => [false, [], live|ptr] ); } @@ -156,7 +156,7 @@ class UtilityPage extends GenericPage { foreach ($data as $d) { - $desc = ''; + $desc = ''; if ($d['caption']) $desc .= '
'.$d['caption']; $desc .= "

".Lang::main('byUser', [$d['user'], '']) . Util::formatTimeDiff($d['date'], true); @@ -164,11 +164,11 @@ class UtilityPage extends GenericPage // is enclosure/length .. is this even relevant..? $this->feedData[] = array( 'title' => [true, [], Lang::typeName($d['type']).Lang::main('colon').htmlentities($d['subject'])], - 'link' => [false, [], HOST_URL.'/?'.Type::getFileString($d['type']).'='.$d['typeId'].'#videos:id='.$d['id']], + 'link' => [false, [], Cfg::get('HOST_URL').'/?'.Type::getFileString($d['type']).'='.$d['typeId'].'#videos:id='.$d['id']], 'description' => [true, [], $desc], 'pubDate' => [false, [], date(DATE_RSS, $d['date'])], 'enclosure' => [false, ['url' => '//i3.ytimg.com/vi/'.$d['videoId'].'/default.jpg', 'length' => 12345, 'type' => 'image/jpeg'], null], - 'guid' => [false, [], HOST_URL.'/?'.Type::getFileString($d['type']).'='.$d['typeId'].'#videos:id='.$d['id']], + 'guid' => [false, [], Cfg::get('HOST_URL').'/?'.Type::getFileString($d['type']).'='.$d['typeId'].'#videos:id='.$d['id']], // 'domain' => [false, [], live|ptr] ); } @@ -238,7 +238,7 @@ class UtilityPage extends GenericPage $this->feedData[] = array( 'title' => [true, [], htmlentities(Type::getFileString($type) == 'item' ? mb_substr($d['name'], 1) : $d['name'])], 'type' => [false, [], Type::getFileString($type)], - 'link' => [false, [], HOST_URL.'/?'.Type::getFileString($type).'='.$d['id']], + 'link' => [false, [], Cfg::get('HOST_URL').'/?'.Type::getFileString($type).'='.$d['id']], 'ncomments' => [false, [], $comments[$typeId]] ); } @@ -272,11 +272,11 @@ class UtilityPage extends GenericPage $channel = $root->addChild('channel'); - $channel->addChild('title', CFG_NAME_SHORT.' - '.$this->name); - $channel->addChild('link', HOST_URL.'/?'.$this->page . ($this->category ? '='.$this->category[0] : null)); - $channel->addChild('description', CFG_NAME); + $channel->addChild('title', Cfg::get('NAME_SHORT').' - '.$this->name); + $channel->addChild('link', Cfg::get('HOST_URL').'/?'.$this->page . ($this->category ? '='.$this->category[0] : null)); + $channel->addChild('description', Cfg::get('NAME')); $channel->addChild('language', implode('-', str_split(User::$localeString, 2))); - $channel->addChild('ttl', CFG_TTL_RSS); + $channel->addChild('ttl', Cfg::get('TTL_RSS')); $channel->addChild('lastBuildDate', date(DATE_RSS)); foreach ($this->feedData as $row) diff --git a/pages/zone.php b/pages/zone.php index b0b99e99..58c39a80 100644 --- a/pages/zone.php +++ b/pages/zone.php @@ -177,7 +177,7 @@ class ZonePage extends GenericPage $cSpawns = DB::Aowow()->select('SELECT * FROM ?_spawns WHERE areaId = ?d AND type = ?d', $this->typeId, Type::NPC); $aSpawns = User::isInGroup(U_GROUP_STAFF) ? DB::Aowow()->select('SELECT * FROM ?_spawns WHERE areaId = ?d AND type = ?d', $this->typeId, Type::AREATRIGGER) : []; - $conditions = [CFG_SQL_LIMIT_NONE, ['s.areaId', $this->typeId]]; + $conditions = [Cfg::get('SQL_LIMIT_NONE'), ['s.areaId', $this->typeId]]; if (!User::isInGroup(U_GROUP_STAFF)) $conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0]; @@ -522,7 +522,7 @@ class ZonePage extends GenericPage 'note' => sprintf(Util::$filterResultString, '?npcs&filter=cr=6;crs='.$this->typeId.';crv=0') ); - if ($creatureSpawns->getMatches() > CFG_SQL_LIMIT_DEFAULT) + if ($creatureSpawns->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT')) $tabData['_truncated'] = 1; $this->extendGlobalData($creatureSpawns->getJSGlobals(GLOBALINFO_SELF)); @@ -538,7 +538,7 @@ class ZonePage extends GenericPage 'note' => sprintf(Util::$filterResultString, '?objects&filter=cr=1;crs='.$this->typeId.';crv=0') ); - if ($objectSpawns->getMatches() > CFG_SQL_LIMIT_DEFAULT) + if ($objectSpawns->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT')) $tabData['_truncated'] = 1; $this->extendGlobalData($objectSpawns->getJSGlobals(GLOBALINFO_SELF)); diff --git a/pages/zones.php b/pages/zones.php index b1effd6e..67ae14f8 100644 --- a/pages/zones.php +++ b/pages/zones.php @@ -31,7 +31,7 @@ class ZonesPage extends GenericPage protected function generateContent() { - $conditions = [CFG_SQL_LIMIT_NONE]; + $conditions = [Cfg::get('SQL_LIMIT_NONE')]; $visibleCols = []; $hiddenCols = []; $mapFile = 0; diff --git a/prQueue b/prQueue index a74bfe48..874fdc19 100755 --- a/prQueue +++ b/prQueue @@ -40,12 +40,12 @@ $error = function ($type, $realmGUID, $realmId) }; -// if (CFG_PROFILER_ENABLE) - wont work because it is not redefined if changed in config -while (DB::Aowow()->selectCell('SELECT value FROM ?_config WHERE `key` = "profiler_enable"')) +while (Cfg::get('PROFILER_ENABLE', true)) { - if (($tDiff = (microtime(true) - $tCycle)) < (CFG_PROFILER_QUEUE_DELAY / 1000)) + $delay = Cfg::get('PROFILER_QUEUE_DELAY') / 1000; + if (($tDiff = (microtime(true) - $tCycle)) < $delay) { - $wait = (CFG_PROFILER_QUEUE_DELAY / 1000) - $tDiff; + $wait = $delay - $tDiff; CLI::write('sleeping '.Lang::nf($wait, 2).'s..'); usleep($wait * 1000 * 1000); } diff --git a/setup/db_structure.sql b/setup/db_structure.sql index 8437686d..b11bd094 100644 --- a/setup/db_structure.sql +++ b/setup/db_structure.sql @@ -450,8 +450,9 @@ DROP TABLE IF EXISTS `aowow_config`; CREATE TABLE `aowow_config` ( `key` varchar(25) NOT NULL, `value` varchar(255) NOT NULL, - `cat` tinyint unsigned NOT NULL DEFAULT 5, - `flags` tinyint unsigned NOT NULL DEFAULT 0, + `default` varchar(255) DEFAULT NULL, + `cat` tinyint(3) unsigned NOT NULL DEFAULT 0, + `flags` smallint(5) unsigned NOT NULL DEFAULT 0, `comment` varchar(255) NOT NULL DEFAULT '', PRIMARY KEY (`key`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; @@ -3214,7 +3215,7 @@ UNLOCK TABLES; LOCK TABLES `aowow_config` WRITE; /*!40000 ALTER TABLE `aowow_config` DISABLE KEYS */; -INSERT INTO `aowow_config` VALUES ('sql_limit_search','500',1,129,'default: 500 - max results for search'),('sql_limit_default','300',1,129,'default: 300 - max results for listviews'),('sql_limit_quicksearch','10',1,129,'default: 10 - max results for suggestions'),('sql_limit_none','0',1,129,'default: 0 - unlimited results (i wouldn\'t change that mate)'),('ttl_rss','60',1,129,'default: 60 - time to live for RSS (in seconds)'),('name','Aowow Database Viewer (ADV)',1,136,' - website title'),('name_short','Aowow',1,136,' - feed title'),('board_url','http://www.wowhead.com/forums?board=',1,136,' - another halfbaked javascript thing..'),('contact_email','feedback@aowow.org',1,136,' - displayed sender for auth-mails, ect'),('battlegroup','Pure Pwnage',1,136,' - pretend, we belong to a battlegroup to satisfy profiler-related Jscripts'),('debug','0',1,132,'default: 0 - disable cache, enable sql-errors, enable error_reporting'),('maintenance','1',1,132,'default: 0 - display brb gnomes and block access for non-staff'),('user_max_votes','50',1,129,'default: 50 - vote limit per day'),('force_ssl','0',1,132,'default: 0 - enforce SSL, if the server is behind a load balancer'),('locales','349',1,161,'default: 0x15D - allowed locales - 0:English, 2:French, 3:German, 4:Chinese, 6:Spanish, 8:Russian'),('screenshot_min_size','200',1,129,'default: 200 - minimum dimensions of uploaded screenshots in px (yes, it\'s square)'),('site_host','',1,136,' - points js to executable files'),('static_host','',1,136,' - points js to images & scripts'),('cache_decay','25200',2,129,'default: 60 * 60 * 7 - time to keep cache in seconds'),('cache_mode','1',2,161,'default: 1 - set cache method - 0:filecache, 1:memcached'),('cache_dir','',2,136,'default: cache/template - generated pages are saved here (requires CACHE_MODE: filecache)'),('acc_failed_auth_block','900',3,129,'default: 15 * 60 - how long an account is closed after exceeding FAILED_AUTH_COUNT (in seconds)'),('acc_failed_auth_count','5',3,129,'default: 5 - how often invalid passwords are tolerated'),('acc_allow_register','1',3,132,'default: 1 - allow/disallow account creation (requires AUTH_MODE: aowow)'),('acc_auth_mode','0',3,145,'default: 0 - source to auth against - 0:aowow, 1:TC auth-table, 2:external script'),('acc_create_save_decay','604800',3,129,'default: 604800 - time in wich an unconfirmed account cannot be overwritten by new registrations'),('acc_recovery_decay','300',3,129,'default: 300 - time to recover your account and new recovery requests are blocked'),('acc_ext_create_url','',3,136,'default: - if auth mode is not self; link to external account creation'),('acc_ext_recover_url','',3,136,'default: - if auth mode is not self; link to external account recovery'),('session_timeout_delay','3600',4,129,'default: 60 * 60 - non-permanent session times out in time() + X'),('session.gc_maxlifetime','604800',4,200,'default: 7*24*60*60 - lifetime of session data'),('session.gc_probability','1',4,200,'default: 0 - probability to remove session data on garbage collection'),('session.gc_divisor','100',4,200,'default: 100 - probability to remove session data on garbage collection'),('session_cache_dir','',4,136,'default: - php sessions are saved here. Leave empty to use php default directory.'),('rep_req_upvote','125',5,129,'default: 125 - required reputation to upvote comments'),('rep_req_downvote','250',5,129,'default: 250 - required reputation to downvote comments'),('rep_req_comment','75',5,129,'default: 75 - required reputation to write a comment'),('rep_req_reply','75',5,129,'default: 75 - required reputation to write a reply'),('rep_req_supervote','2500',5,129,'default: 2500 - required reputation for double vote effect'),('rep_req_votemore_base','2000',5,129,'default: 2000 - gains more votes past this threshold'),('rep_reward_register','100',5,129,'default: 100 - activated an account'),('rep_reward_upvoted','5',5,129,'default: 5 - comment received upvote'),('rep_reward_downvoted','0',5,129,'default: 0 - comment received downvote'),('rep_reward_good_report','10',5,129,'default: 10 - filed an accepted report'),('rep_reward_bad_report','0',5,129,'default: 0 - filed a rejected report'),('rep_reward_dailyvisit','5',5,129,'default: 5 - daily visit'),('rep_reward_user_warned','-50',5,129,'default: -50 - moderator imposed a warning'),('rep_reward_comment','1',5,129,'default: 1 - created a comment (not a reply) '),('rep_req_premium','25000',5,129,'default: 25000 - required reputation for premium status through reputation'),('rep_reward_upload','10',5,129,'default: 10 - suggested / uploaded video / screenshot was approved'),('rep_reward_article','100',5,129,'default: 100 - submitted an approved article/guide'),('rep_reward_user_suspended','-200',5,129,'default: -200 - moderator revoked rights'),('rep_req_votemore_add','250',5,129,'default: 250 - required reputation per additional vote past threshold'),('serialize_precision','5',0,65,' - some derelict code, probably unused'),('memory_limit','1500M',0,200,'default: 1500M - parsing spell.dbc is quite intense'),('default_charset','UTF-8',0,72,'default: UTF-8'),('analytics_user','',6,136,'default: - enter your GA-user here to track site stats'),('profiler_enable','0',7,132,'default: 0 - enable/disable profiler feature'),('profiler_queue_delay','3000',7,129,'default: 3000 - min. delay between queue cycles (in ms)'),('profiler_resync_ping','5000',7,129,'default: 5000 - how often the javascript asks for for updates, when queued (in ms)'),('profiler_resync_delay','3600',7,129,'default: 1*60*60 - how often a character can be refreshed (in sec)'); +INSERT INTO `aowow_config` VALUES ('sql_limit_search','500','500',1,129,'max results for search'),('sql_limit_default','300','300',1,129,'max results for listviews'),('sql_limit_quicksearch','10','10',1,129,'max results for suggestions'),('sql_limit_none','0','0',1,129,'unlimited results (i wouldn\'t change that mate)'),('ttl_rss','60','60',1,129,'time to live for RSS (in seconds)'),('name','Aowow Database Viewer (ADV)',NULL,1,136,'website title'),('name_short','Aowow',NULL,1,136,'feed title'),('board_url','http://www.wowhead.com/forums?board=',NULL,1,136,'another halfbaked javascript thing..'),('contact_email','feedback@aowow.org',NULL,1,136,'displayed sender for auth-mails, ect'),('battlegroup','Pure Pwnage',NULL,1,136,'pretend, we belong to a battlegroup to satisfy profiler-related javascripts'),('debug','0','0',1,145,'disable cache, enable error_reporting - 0:None, 1:Error, 2:Warning, 3:Info'),('maintenance','1','0',1,132,'display brb gnomes and block access for non-staff'),('user_max_votes','50','50',1,129,'vote limit per day'),('force_ssl','0','0',1,132,'enforce SSL, if auto-detect fails'),('locales','349','0x15D',1,161,'allowed locales - 0:English, 2:French, 3:German, 4:Chinese, 6:Spanish, 8:Russian'),('screenshot_min_size','200','200',1,129,'minimum dimensions of uploaded screenshots in px (yes, it\'s square)'),('site_host','',NULL,1,904,'points js to executable files'),('static_host','',NULL,1,904,'points js to images & scripts'),('cache_decay','25200','60 * 60 * 7',2,129,'time to keep cache in seconds'),('cache_mode','1','1',2,161,'set cache method - 0:filecache, 1:memcached'),('cache_dir','','cache/template',2,136,'generated pages are saved here (requires CACHE_MODE: filecache)'),('acc_failed_auth_block','900','15 * 60',3,129,'how long an account is closed after exceeding FAILED_AUTH_COUNT (in seconds)'),('acc_failed_auth_count','5','5',3,129,'how often invalid passwords are tolerated'),('acc_allow_register','1','1',3,132,'allow/disallow account creation (requires AUTH_MODE: aowow)'),('acc_auth_mode','0','0',3,401,'source to auth against - 0:AoWoW, 1:TC auth-table, 2:External script (config/extAuth.php)'),('acc_create_save_decay','604800','604800',3,129,'time in wich an unconfirmed account cannot be overwritten by new registrations'),('acc_recovery_decay','300','300',3,129,'time to recover your account and new recovery requests are blocked'),('acc_ext_create_url','',NULL,3,136,'if auth mode is not self; link to external account creation'),('acc_ext_recover_url','',NULL,3,136,'if auth mode is not self; link to external account recovery'),('session_timeout_delay','3600','60 * 60',4,129,'non-permanent session times out in time() + X'),('session.gc_maxlifetime','604800','7 * 24 * 60 * 60',4,200,'lifetime of session data'),('session.gc_probability','1','0',4,200,'probability to remove session data on garbage collection'),('session.gc_divisor','100','100',4,200,'probability to remove session data on garbage collection'),('session_cache_dir','',NULL,4,136,'php sessions are saved here. Leave empty to use php default directory.'),('rep_req_upvote','125','125',5,129,'required reputation to upvote comments'),('rep_req_downvote','250','250',5,129,'required reputation to downvote comments'),('rep_req_comment','75','75',5,129,'required reputation to write a comment'),('rep_req_reply','75','75',5,129,'required reputation to write a reply'),('rep_req_supervote','2500','2500',5,129,'required reputation for double vote effect'),('rep_req_votemore_base','2000','2000',5,129,'gains more votes past this threshold'),('rep_reward_register','100','100',5,129,'activated an account'),('rep_reward_upvoted','5','5',5,129,'comment received upvote'),('rep_reward_downvoted','0','0',5,129,'comment received downvote'),('rep_reward_good_report','10','10',5,129,'filed an accepted report'),('rep_reward_bad_report','0','0',5,129,'filed a rejected report'),('rep_reward_dailyvisit','5','5',5,129,'daily visit'),('rep_reward_user_warned','-50','-50',5,129,'moderator imposed a warning'),('rep_reward_comment','1','1',5,129,'created a comment (not a reply)'),('rep_req_premium','25000','25000',5,129,'required reputation for premium status through reputation'),('rep_reward_upload','10','10',5,129,'suggested / uploaded video / screenshot was approved'),('rep_reward_article','100','100',5,129,'submitted an approved article/guide'),('rep_reward_user_suspended','-200','-200',5,129,'moderator revoked rights'),('rep_req_votemore_add','250','250',5,129,'required reputation per additional vote past threshold'),('serialize_precision','5',NULL,0,65,'some derelict code, probably unused'),('memory_limit','1500M','1500M',0,200,'parsing spell.dbc is quite intense'),('default_charset','UTF-8','UTF-8',0,72,'default: UTF-8'),('analytics_user','',NULL,6,136,'enter your GA-user here to track site stats'),('profiler_enable','0','0',7,388,'enable/disable profiler feature'),('profiler_queue_delay','3000','3000',7,129,'min. delay between queue cycles (in ms)'),('profiler_resync_ping','5000','5000',7,129,'how often the javascript asks for for updates, when queued (in ms)'),('profiler_resync_delay','3600','1 * 60 * 60',7,129,'how often a character can be refreshed (in sec)'),('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'); /*!40000 ALTER TABLE `aowow_config` ENABLE KEYS */; UNLOCK TABLES; @@ -3224,7 +3225,7 @@ UNLOCK TABLES; LOCK TABLES `aowow_dbversion` WRITE; /*!40000 ALTER TABLE `aowow_dbversion` DISABLE KEYS */; -INSERT INTO `aowow_dbversion` VALUES (1716918679,0,NULL,NULL); +INSERT INTO `aowow_dbversion` VALUES (1717076299,0,NULL,NULL); /*!40000 ALTER TABLE `aowow_dbversion` ENABLE KEYS */; UNLOCK TABLES; diff --git a/setup/tools/CLISetup.class.php b/setup/tools/CLISetup.class.php index 4b7a5dcf..b5bfc401 100644 --- a/setup/tools/CLISetup.class.php +++ b/setup/tools/CLISetup.class.php @@ -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); } diff --git a/setup/tools/clisetup/account.func.php b/setup/tools/clisetup/account.func.php index c0189dc0..541c96c7 100644 --- a/setup/tools/clisetup/account.func.php +++ b/setup/tools/clisetup/account.func.php @@ -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) diff --git a/setup/tools/clisetup/setup.func.php b/setup/tools/clisetup/setup.func.php index 20c21908..8a9a5494 100644 --- a/setup/tools/clisetup/setup.func.php +++ b/setup/tools/clisetup/setup.func.php @@ -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 diff --git a/setup/tools/clisetup/siteconfig.func.php b/setup/tools/clisetup/siteconfig.func.php index ab2f8f01..6e4f10a7 100644 --- a/setup/tools/clisetup/siteconfig.func.php +++ b/setup/tools/clisetup/siteconfig.func.php @@ -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= -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 ? '' : ''); + + 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('') : CLI::grey('')); + 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('') : ''; - 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'] ? '' : ''); - 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'] ? '' : ''; - 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); } ?> diff --git a/setup/tools/fileGen.class.php b/setup/tools/fileGen.class.php index 1704019e..b43563d1 100644 --- a/setup/tools/fileGen.class.php +++ b/setup/tools/fileGen.class.php @@ -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) diff --git a/setup/tools/filegen/enchants.func.php b/setup/tools/filegen/enchants.func.php index 787e8f79..30c9b646 100644 --- a/setup/tools/filegen/enchants.func.php +++ b/setup/tools/filegen/enchants.func.php @@ -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) { diff --git a/setup/tools/filegen/gems.func.php b/setup/tools/filegen/gems.func.php index 1d93fdc3..810631a4 100644 --- a/setup/tools/filegen/gems.func.php +++ b/setup/tools/filegen/gems.func.php @@ -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); diff --git a/setup/tools/filegen/glyphs.func.php b/setup/tools/filegen/glyphs.func.php index a7fd25bb..90d742a5 100644 --- a/setup/tools/filegen/glyphs.func.php +++ b/setup/tools/filegen/glyphs.func.php @@ -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) { diff --git a/setup/tools/filegen/itemScaling.func.php b/setup/tools/filegen/itemScaling.func.php index cbca24f9..a4875ca4 100644 --- a/setup/tools/filegen/itemScaling.func.php +++ b/setup/tools/filegen/itemScaling.func.php @@ -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); } - ?> diff --git a/setup/tools/filegen/profiler.func.php b/setup/tools/filegen/profiler.func.php index 6a4fb254..bfda47ea 100644 --- a/setup/tools/filegen/profiler.func.php +++ b/setup/tools/filegen/profiler.func.php @@ -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 ); diff --git a/setup/tools/filegen/realmMenu.func.php b/setup/tools/filegen/realmMenu.func.php index 90a612a5..afc8fca4 100644 --- a/setup/tools/filegen/realmMenu.func.php +++ b/setup/tools/filegen/realmMenu.func.php @@ -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) diff --git a/setup/tools/filegen/realms.func.php b/setup/tools/filegen/realms.func.php index e5bc7f59..543d6072 100644 --- a/setup/tools/filegen/realms.func.php +++ b/setup/tools/filegen/realms.func.php @@ -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']); }); diff --git a/setup/tools/filegen/talentCalc.func.php b/setup/tools/filegen/talentCalc.func.php index cb540920..f3b75ab3 100644 --- a/setup/tools/filegen/talentCalc.func.php +++ b/setup/tools/filegen/talentCalc.func.php @@ -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) { diff --git a/setup/tools/sqlgen/item_stats.func.php b/setup/tools/sqlgen/item_stats.func.php index bbcfd487..30485c7d 100644 --- a/setup/tools/sqlgen/item_stats.func.php +++ b/setup/tools/sqlgen/item_stats.func.php @@ -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) diff --git a/setup/tools/sqlgen/itemset.func.php b/setup/tools/sqlgen/itemset.func.php index 0ea08887..b6f0f152 100644 --- a/setup/tools/sqlgen/itemset.func.php +++ b/setup/tools/sqlgen/itemset.func.php @@ -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); diff --git a/setup/updates/1717076299_01.sql b/setup/updates/1717076299_01.sql new file mode 100644 index 00000000..b272f9de --- /dev/null +++ b/setup/updates/1717076299_01.sql @@ -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'; diff --git a/template/bricks/footer.tpl.php b/template/bricks/footer.tpl.php index 77d46c58..0c794171 100644 --- a/template/bricks/footer.tpl.php +++ b/template/bricks/footer.tpl.php @@ -33,7 +33,7 @@ endif; = CLI::LOG_INFO && User::isInGroup(U_GROUP_DEV | U_GROUP_ADMIN)): ?> Reminder +

Reminder

Your screenshot will not be approved if it doesn't correspond to the following guidelines.
    diff --git a/template/localized/ssReminder_3.tpl.php b/template/localized/ssReminder_3.tpl.php index f28b856f..d710be00 100644 --- a/template/localized/ssReminder_3.tpl.php +++ b/template/localized/ssReminder_3.tpl.php @@ -1,4 +1,4 @@ -

    Hinweis

    +

    Hinweis

    Euer Screenshot wird nicht zugelassen werden, wenn er nicht unseren Richtlinien entspricht.
      diff --git a/template/localized/ssReminder_4.tpl.php b/template/localized/ssReminder_4.tpl.php index 96f28aad..07bb1a02 100644 --- a/template/localized/ssReminder_4.tpl.php +++ b/template/localized/ssReminder_4.tpl.php @@ -1,4 +1,4 @@ -

      提醒

      +

      提醒

      你的截图将不会 通过审查假设不符合下列准则。
        diff --git a/template/pages/acc-signIn.tpl.php b/template/pages/acc-signIn.tpl.php index af4d5ad8..c17c943f 100644 --- a/template/pages/acc-signIn.tpl.php +++ b/template/pages/acc-signIn.tpl.php @@ -61,7 +61,7 @@
        '.Lang::account('accCreate')."\n"; endif; ?> diff --git a/template/pages/guide-edit.tpl.php b/template/pages/guide-edit.tpl.php index 8122c7f9..f9ae7c5e 100644 --- a/template/pages/guide-edit.tpl.php +++ b/template/pages/guide-edit.tpl.php @@ -54,7 +54,7 @@ $this->brick('pageTemplate');