diff --git a/includes/ajaxHandler/profile.class.php b/includes/ajaxHandler/profile.class.php index fcd46882..453c09ea 100644 --- a/includes/ajaxHandler/profile.class.php +++ b/includes/ajaxHandler/profile.class.php @@ -501,6 +501,9 @@ class AjaxProfile extends AjaxHandler if ($rId == $pBase['realm']) break; + if (!$rData) // realm doesn't exist or access is restricted + return ''; + $profile = array( 'id' => $pBase['id'], 'source' => $pBase['id'], diff --git a/includes/defines.php b/includes/defines.php index 539b7dc8..d5e907bd 100644 --- a/includes/defines.php +++ b/includes/defines.php @@ -2150,9 +2150,16 @@ define('SAI_TEMPLATE_CAGED_GO_PART', 4); // define('SAI_TEMPLATE_CAGED_NPC_PART', 5); // define('SAI_SPAWN_FLAG_NONE', 0x00); -define('SAI_SPAWN_FLAG_IGNORE_RESPAWN', 0x01); // onSpawnIn - ignore & reset respawn timer -define('SAI_SPAWN_FLAG_FORCE_SPAWN', 0x02); // onSpawnIn - force additional spawn if already in world -define('SAI_SPAWN_FLAG_NOSAVE_RESPAWN', 0x04); // onDespawn - remove respawn time +define('SAI_SPAWN_FLAG_IGNORE_RESPAWN', 0x01); // onSpawnIn - ignore & reset respawn timer +define('SAI_SPAWN_FLAG_FORCE_SPAWN', 0x02); // onSpawnIn - force additional spawn if already in world +define('SAI_SPAWN_FLAG_NOSAVE_RESPAWN', 0x04); // onDespawn - remove respawn time + +// TrinityCore - Account Security +define('SEC_PLAYER', 0); +define('SEC_MODERATOR', 1); +define('SEC_GAMEMASTER', 2); +define('SEC_ADMINISTRATOR', 3); +define('SEC_CONSOLE', 4); // console only - should not be encountered // profiler queue interactions define('PR_QUEUE_STATUS_ENDED', 0); diff --git a/includes/profiler.class.php b/includes/profiler.class.php index 010be28a..168c37a2 100644 --- a/includes/profiler.class.php +++ b/includes/profiler.class.php @@ -182,31 +182,54 @@ class Profiler { if (DB::isConnectable(DB_AUTH) && !self::$realms) { - self::$realms = DB::Auth()->select('SELECT - id AS ARRAY_KEY, - `name`, - CASE - WHEN timezone IN (2, 3, 4) THEN "us" - WHEN timezone IN (8, 9, 10, 11, 12) THEN "eu" - WHEN timezone = 6 THEN "kr" - WHEN timezone = 14 THEN "tw" - WHEN timezone = 16 THEN "cn" - END AS region - FROM - realmlist - WHERE - allowedSecurityLevel = 0 AND - gamebuild = ?d', + self::$realms = DB::Auth()->select( + 'SELECT `id` AS ARRAY_KEY, + `name`, + CASE WHEN `timezone` BETWEEN 2 AND 5 THEN "us" # US, Oceanic, Latin America, Americas-Tournament + WHEN `timezone` BETWEEN 6 AND 7 THEN "kr" # KR, KR-Tournament + WHEN `timezone` BETWEEN 8 AND 13 THEN "eu" # GB, DE, FR, ES, RU, EU-Tournament + WHEN `timezone` BETWEEN 14 AND 15 THEN "tw" # TW, TW-Tournament + WHEN `timezone` BETWEEN 16 AND 25 THEN "cn" # CN, CN1-8, CN-Tournament + ELSE "dev" END AS "region", # 1: Dev, 26: Test, 28: QA, 30: Test2, 31+: misc + `allowedSecurityLevel` AS "access" + FROM `realmlist` + WHERE `gamebuild` = ?d', WOW_BUILD ); - foreach (self::$realms as $rId => $rData) + foreach (self::$realms as $rId => &$rData) { - if (DB::isConnectable(DB_CHARACTERS . $rId)) - continue; - // realm in db but no connection info set - unset(self::$realms[$rId]); + if (!DB::isConnectable(DB_CHARACTERS . $rId)) + { + unset(self::$realms[$rId]); + continue; + } + + // filter by access level + if ($rData['access'] == SEC_ADMINISTRATOR && (CLI || User::isInGroup(U_GROUP_DEV | U_GROUP_ADMIN))) + $rData['access'] = U_GROUP_DEV | U_GROUP_ADMIN; + else if ($rData['access'] == SEC_GAMEMASTER && (CLI || User::isInGroup(U_GROUP_DEV | U_GROUP_ADMIN | U_GROUP_MOD))) + $rData['access'] = U_GROUP_DEV | U_GROUP_ADMIN | U_GROUP_MOD; + else if ($rData['access'] == SEC_MODERATOR && (CLI || User::isInGroup(U_GROUP_DEV | U_GROUP_ADMIN | U_GROUP_MOD | U_GROUP_BUREAU))) + $rData['access'] = U_GROUP_DEV | U_GROUP_ADMIN | U_GROUP_MOD | U_GROUP_BUREAU; + else if ($rData['access'] > SEC_PLAYER && !CLI) + { + unset(self::$realms[$rId]); + continue; + } + + // filter dev realms + if ($rData['region'] === 'dev') + { + if (CLI || User::isInGroup(U_GROUP_DEV | U_GROUP_ADMIN)) + $rData['access'] = U_GROUP_DEV | U_GROUP_ADMIN; + else + { + unset(self::$realms[$rId]); + continue; + } + } } } diff --git a/includes/user.class.php b/includes/user.class.php index 76eed4f1..5cd1a711 100644 --- a/includes/user.class.php +++ b/includes/user.class.php @@ -661,11 +661,12 @@ class User foreach (self::$profiles->iterate() as $id => $_) if (self::$profiles->getField('cuFlags') & PROFILER_CU_PINNED) - return [ - $id, - self::$profiles->getField('name'), - self::$profiles->getField('region') . '.' . Profiler::urlize($realms[self::$profiles->getField('realm')]['name'], true) . '.' . Profiler::urlize(self::$profiles->getField('name'), true, true) - ]; + if (isset($realms[self::$profiles->getField('realm')])) + return [ + $id, + self::$profiles->getField('name'), + self::$profiles->getField('region') . '.' . Profiler::urlize($realms[self::$profiles->getField('realm')]['name'], true) . '.' . Profiler::urlize(self::$profiles->getField('name'), true, true) + ]; return []; } diff --git a/includes/utilities.php b/includes/utilities.php index 27c3fd33..aec7dfa2 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -473,7 +473,7 @@ abstract class Util ); public static $regions = array( - 'us', 'eu', 'kr', 'tw', 'cn' + 'us', 'eu', 'kr', 'tw', 'cn', 'dev' ); # todo (high): find a sensible way to write data here on setup diff --git a/localization/locale_dede.php b/localization/locale_dede.php index f08d5715..47bd1815 100644 --- a/localization/locale_dede.php +++ b/localization/locale_dede.php @@ -244,7 +244,8 @@ $lang = array( 'eu' => "Europa", 'kr' => "Korea", 'tw' => "Taiwan", - 'cn' => "China" + 'cn' => "China", + 'dev' => "Entwicklung" ), 'encounterNames'=> array( 243 => "Die Sieben", diff --git a/localization/locale_enus.php b/localization/locale_enus.php index 4fc5ce00..efa03f65 100644 --- a/localization/locale_enus.php +++ b/localization/locale_enus.php @@ -244,7 +244,8 @@ $lang = array( 'eu' => "Europe", 'kr' => "Korea", 'tw' => "Taiwan", - 'cn' => "China" + 'cn' => "China", + 'dev' => "Development" ), 'encounterNames'=> array( // from dungeonencounter.dbc 243 => "The Seven", diff --git a/localization/locale_eses.php b/localization/locale_eses.php index 0ac8e496..19170270 100644 --- a/localization/locale_eses.php +++ b/localization/locale_eses.php @@ -244,7 +244,8 @@ $lang = array( 'eu' => "Europa", 'kr' => "Corea", 'tw' => "Taiwán", - 'cn' => "China" + 'cn' => "China", + 'dev' => "Desarrollo" ), 'encounterNames'=> array( 243 => "Los Siete", diff --git a/localization/locale_frfr.php b/localization/locale_frfr.php index 97cebbe4..a3bb991d 100644 --- a/localization/locale_frfr.php +++ b/localization/locale_frfr.php @@ -244,7 +244,8 @@ $lang = array( 'eu' => "L'Europe", 'kr' => "Corée", 'tw' => "Taïwan", - 'cn' => "Chine" + 'cn' => "Chine", + 'dev' => "Développement" ), 'encounterNames'=> array( 243 => "Les Sept", diff --git a/localization/locale_ruru.php b/localization/locale_ruru.php index 2e489a05..995459ba 100644 --- a/localization/locale_ruru.php +++ b/localization/locale_ruru.php @@ -244,7 +244,8 @@ $lang = array( 'eu' => "Европа", 'kr' => "Корея", 'tw' => "Тайвань", - 'cn' => "Китай" + 'cn' => "Китай", + 'dev' => "Разработка" ), 'encounterNames'=> array( 243 => "Семеро", diff --git a/localization/locale_zhcn.php b/localization/locale_zhcn.php index 2590b20b..d9a1ef8e 100644 --- a/localization/locale_zhcn.php +++ b/localization/locale_zhcn.php @@ -244,7 +244,8 @@ $lang = array( 'eu' => "欧洲", 'kr' => "韩国", 'tw' => "台湾", - 'cn' => "中国" + 'cn' => "中国", + 'dev' => "开发" ), 'encounterNames'=> array( 243 => "黑铁七贤", diff --git a/setup/tools/clisetup/setup.func.php b/setup/tools/clisetup/setup.func.php index f04bfff6..87b7510c 100644 --- a/setup/tools/clisetup/setup.func.php +++ b/setup/tools/clisetup/setup.func.php @@ -300,7 +300,7 @@ function setup() : void $res = call_user_func($step[0], $step[1]); else { - $args = &$step[1]; + $args = &$step[1]; // see: https://github.com/php/php-src/issues/14202 $res = $step[0]($args); } diff --git a/setup/tools/filegen/realmMenu.func.php b/setup/tools/filegen/realmMenu.func.php index a0379e06..90a612a5 100644 --- a/setup/tools/filegen/realmMenu.func.php +++ b/setup/tools/filegen/realmMenu.func.php @@ -55,7 +55,7 @@ if (!CLI) if ($idx !== false) { $set |= (1 << $idx); - $subs[$idx][] = [Profiler::urlize($row['name'], true), $row['name']]; + $subs[$idx][] = [Profiler::urlize($row['name'], true), $row['name'], null, null, $row['access'] ? ['requiredAccess' => $row['access']] : null]; } } diff --git a/setup/tools/filegen/realms.func.php b/setup/tools/filegen/realms.func.php index 44453f19..e5bc7f59 100644 --- a/setup/tools/filegen/realms.func.php +++ b/setup/tools/filegen/realms.func.php @@ -35,6 +35,9 @@ if (!CLI) // foreach ($realms as &$r) // $r['battlegroup'] = CFG_BATTLEGROUP; + // remove access column + array_walk($realms, function (&$x) { unset($x['access']); }); + $toFile = "var g_realms = ".Util::toJSON($realms).";"; $file = 'datasets/realms';