mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Profiler/Realms
* generally allow all realm types * filter visibility/access by userGroup
This commit is contained in:
@@ -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'],
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 [];
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -244,7 +244,8 @@ $lang = array(
|
||||
'eu' => "Europa",
|
||||
'kr' => "Korea",
|
||||
'tw' => "Taiwan",
|
||||
'cn' => "China"
|
||||
'cn' => "China",
|
||||
'dev' => "Entwicklung"
|
||||
),
|
||||
'encounterNames'=> array(
|
||||
243 => "Die Sieben",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -244,7 +244,8 @@ $lang = array(
|
||||
'eu' => "Europa",
|
||||
'kr' => "Corea",
|
||||
'tw' => "Taiwán",
|
||||
'cn' => "China"
|
||||
'cn' => "China",
|
||||
'dev' => "Desarrollo"
|
||||
),
|
||||
'encounterNames'=> array(
|
||||
243 => "Los Siete",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -244,7 +244,8 @@ $lang = array(
|
||||
'eu' => "Европа",
|
||||
'kr' => "Корея",
|
||||
'tw' => "Тайвань",
|
||||
'cn' => "Китай"
|
||||
'cn' => "Китай",
|
||||
'dev' => "Разработка"
|
||||
),
|
||||
'encounterNames'=> array(
|
||||
243 => "Семеро",
|
||||
|
||||
@@ -244,7 +244,8 @@ $lang = array(
|
||||
'eu' => "欧洲",
|
||||
'kr' => "韩国",
|
||||
'tw' => "台湾",
|
||||
'cn' => "中国"
|
||||
'cn' => "中国",
|
||||
'dev' => "开发"
|
||||
),
|
||||
'encounterNames'=> array(
|
||||
243 => "黑铁七贤",
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user