Profiler/Realms

* generally allow all realm types
 * filter visibility/access by userGroup
This commit is contained in:
Sarjuuk
2024-05-12 14:32:12 +02:00
parent b2690aea08
commit a97cede1e0
14 changed files with 80 additions and 37 deletions

View File

@@ -501,6 +501,9 @@ class AjaxProfile extends AjaxHandler
if ($rId == $pBase['realm']) if ($rId == $pBase['realm'])
break; break;
if (!$rData) // realm doesn't exist or access is restricted
return '';
$profile = array( $profile = array(
'id' => $pBase['id'], 'id' => $pBase['id'],
'source' => $pBase['id'], 'source' => $pBase['id'],

View File

@@ -2150,9 +2150,16 @@ define('SAI_TEMPLATE_CAGED_GO_PART', 4); //
define('SAI_TEMPLATE_CAGED_NPC_PART', 5); // define('SAI_TEMPLATE_CAGED_NPC_PART', 5); //
define('SAI_SPAWN_FLAG_NONE', 0x00); define('SAI_SPAWN_FLAG_NONE', 0x00);
define('SAI_SPAWN_FLAG_IGNORE_RESPAWN', 0x01); // onSpawnIn - ignore & reset respawn timer 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_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_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 // profiler queue interactions
define('PR_QUEUE_STATUS_ENDED', 0); define('PR_QUEUE_STATUS_ENDED', 0);

View File

@@ -182,31 +182,54 @@ class Profiler
{ {
if (DB::isConnectable(DB_AUTH) && !self::$realms) if (DB::isConnectable(DB_AUTH) && !self::$realms)
{ {
self::$realms = DB::Auth()->select('SELECT self::$realms = DB::Auth()->select(
id AS ARRAY_KEY, 'SELECT `id` AS ARRAY_KEY,
`name`, `name`,
CASE CASE WHEN `timezone` BETWEEN 2 AND 5 THEN "us" # US, Oceanic, Latin America, Americas-Tournament
WHEN timezone IN (2, 3, 4) THEN "us" WHEN `timezone` BETWEEN 6 AND 7 THEN "kr" # KR, KR-Tournament
WHEN timezone IN (8, 9, 10, 11, 12) THEN "eu" WHEN `timezone` BETWEEN 8 AND 13 THEN "eu" # GB, DE, FR, ES, RU, EU-Tournament
WHEN timezone = 6 THEN "kr" WHEN `timezone` BETWEEN 14 AND 15 THEN "tw" # TW, TW-Tournament
WHEN timezone = 14 THEN "tw" WHEN `timezone` BETWEEN 16 AND 25 THEN "cn" # CN, CN1-8, CN-Tournament
WHEN timezone = 16 THEN "cn" ELSE "dev" END AS "region", # 1: Dev, 26: Test, 28: QA, 30: Test2, 31+: misc
END AS region `allowedSecurityLevel` AS "access"
FROM FROM `realmlist`
realmlist WHERE `gamebuild` = ?d',
WHERE
allowedSecurityLevel = 0 AND
gamebuild = ?d',
WOW_BUILD 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 // 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;
}
}
} }
} }

View File

@@ -661,11 +661,12 @@ class User
foreach (self::$profiles->iterate() as $id => $_) foreach (self::$profiles->iterate() as $id => $_)
if (self::$profiles->getField('cuFlags') & PROFILER_CU_PINNED) if (self::$profiles->getField('cuFlags') & PROFILER_CU_PINNED)
return [ if (isset($realms[self::$profiles->getField('realm')]))
$id, return [
self::$profiles->getField('name'), $id,
self::$profiles->getField('region') . '.' . Profiler::urlize($realms[self::$profiles->getField('realm')]['name'], true) . '.' . Profiler::urlize(self::$profiles->getField('name'), true, true) 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 []; return [];
} }

View File

@@ -473,7 +473,7 @@ abstract class Util
); );
public static $regions = array( 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 # todo (high): find a sensible way to write data here on setup

View File

@@ -244,7 +244,8 @@ $lang = array(
'eu' => "Europa", 'eu' => "Europa",
'kr' => "Korea", 'kr' => "Korea",
'tw' => "Taiwan", 'tw' => "Taiwan",
'cn' => "China" 'cn' => "China",
'dev' => "Entwicklung"
), ),
'encounterNames'=> array( 'encounterNames'=> array(
243 => "Die Sieben", 243 => "Die Sieben",

View File

@@ -244,7 +244,8 @@ $lang = array(
'eu' => "Europe", 'eu' => "Europe",
'kr' => "Korea", 'kr' => "Korea",
'tw' => "Taiwan", 'tw' => "Taiwan",
'cn' => "China" 'cn' => "China",
'dev' => "Development"
), ),
'encounterNames'=> array( // from dungeonencounter.dbc 'encounterNames'=> array( // from dungeonencounter.dbc
243 => "The Seven", 243 => "The Seven",

View File

@@ -244,7 +244,8 @@ $lang = array(
'eu' => "Europa", 'eu' => "Europa",
'kr' => "Corea", 'kr' => "Corea",
'tw' => "Taiwán", 'tw' => "Taiwán",
'cn' => "China" 'cn' => "China",
'dev' => "Desarrollo"
), ),
'encounterNames'=> array( 'encounterNames'=> array(
243 => "Los Siete", 243 => "Los Siete",

View File

@@ -244,7 +244,8 @@ $lang = array(
'eu' => "L'Europe", 'eu' => "L'Europe",
'kr' => "Corée", 'kr' => "Corée",
'tw' => "Taïwan", 'tw' => "Taïwan",
'cn' => "Chine" 'cn' => "Chine",
'dev' => "Développement"
), ),
'encounterNames'=> array( 'encounterNames'=> array(
243 => "Les Sept", 243 => "Les Sept",

View File

@@ -244,7 +244,8 @@ $lang = array(
'eu' => "Европа", 'eu' => "Европа",
'kr' => "Корея", 'kr' => "Корея",
'tw' => "Тайвань", 'tw' => "Тайвань",
'cn' => "Китай" 'cn' => "Китай",
'dev' => "Разработка"
), ),
'encounterNames'=> array( 'encounterNames'=> array(
243 => "Семеро", 243 => "Семеро",

View File

@@ -244,7 +244,8 @@ $lang = array(
'eu' => "欧洲", 'eu' => "欧洲",
'kr' => "韩国", 'kr' => "韩国",
'tw' => "台湾", 'tw' => "台湾",
'cn' => "中国" 'cn' => "中国",
'dev' => "开发"
), ),
'encounterNames'=> array( 'encounterNames'=> array(
243 => "黑铁七贤", 243 => "黑铁七贤",

View File

@@ -300,7 +300,7 @@ function setup() : void
$res = call_user_func($step[0], $step[1]); $res = call_user_func($step[0], $step[1]);
else else
{ {
$args = &$step[1]; $args = &$step[1]; // see: https://github.com/php/php-src/issues/14202
$res = $step[0]($args); $res = $step[0]($args);
} }

View File

@@ -55,7 +55,7 @@ if (!CLI)
if ($idx !== false) if ($idx !== false)
{ {
$set |= (1 << $idx); $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];
} }
} }

View File

@@ -35,6 +35,9 @@ if (!CLI)
// foreach ($realms as &$r) // foreach ($realms as &$r)
// $r['battlegroup'] = CFG_BATTLEGROUP; // $r['battlegroup'] = CFG_BATTLEGROUP;
// remove access column
array_walk($realms, function (&$x) { unset($x['access']); });
$toFile = "var g_realms = ".Util::toJSON($realms).";"; $toFile = "var g_realms = ".Util::toJSON($realms).";";
$file = 'datasets/realms'; $file = 'datasets/realms';