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'])
|
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'],
|
||||||
|
|||||||
@@ -2154,6 +2154,13 @@ define('SAI_SPAWN_FLAG_IGNORE_RESPAWN', 0x01); // onSpawnIn - igno
|
|||||||
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);
|
||||||
define('PR_QUEUE_STATUS_WAITING', 1);
|
define('PR_QUEUE_STATUS_WAITING', 1);
|
||||||
|
|||||||
@@ -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
|
||||||
|
if (!DB::isConnectable(DB_CHARACTERS . $rId))
|
||||||
|
{
|
||||||
unset(self::$realms[$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,6 +661,7 @@ 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)
|
||||||
|
if (isset($realms[self::$profiles->getField('realm')]))
|
||||||
return [
|
return [
|
||||||
$id,
|
$id,
|
||||||
self::$profiles->getField('name'),
|
self::$profiles->getField('name'),
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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",
|
||||||
|
|||||||
@@ -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",
|
||||||
|
|||||||
@@ -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",
|
||||||
|
|||||||
@@ -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",
|
||||||
|
|||||||
@@ -244,7 +244,8 @@ $lang = array(
|
|||||||
'eu' => "Европа",
|
'eu' => "Европа",
|
||||||
'kr' => "Корея",
|
'kr' => "Корея",
|
||||||
'tw' => "Тайвань",
|
'tw' => "Тайвань",
|
||||||
'cn' => "Китай"
|
'cn' => "Китай",
|
||||||
|
'dev' => "Разработка"
|
||||||
),
|
),
|
||||||
'encounterNames'=> array(
|
'encounterNames'=> array(
|
||||||
243 => "Семеро",
|
243 => "Семеро",
|
||||||
|
|||||||
@@ -244,7 +244,8 @@ $lang = array(
|
|||||||
'eu' => "欧洲",
|
'eu' => "欧洲",
|
||||||
'kr' => "韩国",
|
'kr' => "韩国",
|
||||||
'tw' => "台湾",
|
'tw' => "台湾",
|
||||||
'cn' => "中国"
|
'cn' => "中国",
|
||||||
|
'dev' => "开发"
|
||||||
),
|
),
|
||||||
'encounterNames'=> array(
|
'encounterNames'=> array(
|
||||||
243 => "黑铁七贤",
|
243 => "黑铁七贤",
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user