Repository navigation
Expand file tree
/
Copy pathpomm_play.php
More file actions
351 lines (310 loc) · 10.6 KB
/
Copy pathpomm_play.php
File metadata and controls
351 lines (310 loc) · 10.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
<?php
require_once("defines.php");
require_once("pomm_conf.php");
require_once("func.php");
$lang_file = __DIR__ . "/map_" . $lang . ".php";
if (!file_exists($lang_file)) {
$lang_file = __DIR__ . "/map_en.php";
}
require_once($lang_file);
$_RESULT = [];
$maps_count = isset($lang_defs['maps_names']) ? count($lang_defs['maps_names']) : 0;
$Horde_races = 0x2B2;
$Alliance_races = 0x44D;
$outland_inst = [540,542,543,544,545,546,547,548,550,552,553,554,555,556,557,558,559,562,564,565];
$northrend_inst = [533,574,575,576,578,599,600,601,602,603,604,608,615,616,617,619,624,631,632,649,650,658,668,724];
require_once "libs/js/JsHttpRequest/Php.php";
$JsHttpRequest = new Subsys_JsHttpRequest_Php("utf-8");
$realm_db = new DBLayer($hostr, $userr, $passwordr, $dbr);
if (!$realm_db->isValid()) {
$_RESULT['status']['online'] = 2;
exit();
}
$realm_db->query("SET NAMES $database_encoding");
$gm_online = 0;
$gm_accounts = [];
$query = null;
if ($server_type == 1) { // if AzerothCore/TrinityCore
$query = $realm_db->query("SELECT GROUP_CONCAT(`id` SEPARATOR ' ') FROM `account_access` WHERE `gmlevel` > 0");
} else {
$query = $realm_db->query("SELECT GROUP_CONCAT(`id` SEPARATOR ' ') FROM `account` WHERE `gmlevel` > 0");
}
if ($query && ($result = $realm_db->fetch_row($query))) {
$gm_accounts = explode(' ', $result[0]);
}
$groups = [];
$characters_db = new DBLayer($host, $user, $password, $db);
if (!$characters_db->isValid()) {
$_RESULT['status']['online'] = 2;
exit();
}
$characters_db->query("SET NAMES $database_encoding");
$query = $characters_db->query("
SELECT gm.`memberGuid`, g.`leaderGuid`
FROM `group_member` gm
JOIN `groups` g ON g.`guid` = gm.`guid`
WHERE gm.`memberGuid` IN (
SELECT `guid`
FROM `characters`
WHERE `online` = 1
)
");
if ($query) {
while ($result = $characters_db->fetch_assoc($query)) {
$groups[$result['memberGuid']] = $result['leaderGuid'];
}
}
$Count = array_fill(0, $maps_count, [0, 0]); // Default array for Count initialization
$arr = [];
$i = $maps_count;
/*
* Active battlegrounds shown in the bottom bar.
* WotLK battleground map IDs:
* 30 = Alterac Valley
* 489 = Warsong Gulch
* 529 = Arathi Basin
* 566 = Eye of the Storm
* 607 = Strand of the Ancients
* 628 = Isle of Conquest
*/
$playermap_battleground_maps = array(
30 => 'Alterac Valley',
489 => 'Warsong Gulch',
529 => 'Arathi Basin',
566 => 'Eye of the Storm',
607 => 'Strand of the Ancients',
628 => 'Isle of Conquest'
);
/*
* Active PvE instances shown in the bottom bar.
* WotLK 3.3.5 map IDs, vanilla + TBC + WotLK.
*/
$playermap_instance_maps = array(
// Vanilla dungeons / raids
33 => 'Shadowfang Keep',
34 => 'The Stockade',
36 => 'The Deadmines',
43 => 'Wailing Caverns',
47 => 'Razorfen Kraul',
48 => 'Blackfathom Deeps',
70 => 'Uldaman',
90 => 'Gnomeregan',
109 => 'Sunken Temple',
129 => 'Razorfen Downs',
189 => 'Scarlet Monastery',
209 => 'Zul\'Farrak',
229 => 'Blackrock Spire',
230 => 'Blackrock Depths',
249 => 'Onyxia\'s Lair',
309 => 'Zul\'Gurub',
329 => 'Stratholme',
349 => 'Maraudon',
389 => 'Ragefire Chasm',
409 => 'Molten Core',
429 => 'Dire Maul',
469 => 'Blackwing Lair',
509 => 'Ruins of Ahn\'Qiraj',
531 => 'Temple of Ahn\'Qiraj',
// The Burning Crusade dungeons / raids
269 => 'The Black Morass',
532 => 'Karazhan',
534 => 'Hyjal Summit',
540 => 'The Shattered Halls',
542 => 'The Blood Furnace',
543 => 'Hellfire Ramparts',
544 => 'Magtheridon\'s Lair',
545 => 'The Steamvault',
546 => 'The Underbog',
547 => 'The Slave Pens',
548 => 'Serpentshrine Cavern',
550 => 'Tempest Keep',
552 => 'The Arcatraz',
553 => 'The Botanica',
554 => 'The Mechanar',
555 => 'Shadow Labyrinth',
556 => 'Sethekk Halls',
557 => 'Mana-Tombs',
558 => 'Auchenai Crypts',
560 => 'Old Hillsbrad Foothills',
564 => 'Black Temple',
565 => 'Gruul\'s Lair',
568 => 'Zul\'Aman',
580 => 'Sunwell Plateau',
585 => 'Magisters\' Terrace',
// Wrath of the Lich King dungeons / raids
533 => 'Naxxramas',
574 => 'Utgarde Keep',
575 => 'Utgarde Pinnacle',
576 => 'The Nexus',
578 => 'The Oculus',
595 => 'The Culling of Stratholme',
599 => 'Halls of Stone',
600 => 'Drak\'Tharon Keep',
601 => 'Azjol-Nerub',
602 => 'Halls of Lightning',
603 => 'Ulduar',
604 => 'Gundrak',
608 => 'The Violet Hold',
615 => 'The Obsidian Sanctum',
616 => 'The Eye of Eternity',
619 => 'Ahn\'kahet: The Old Kingdom',
624 => 'Vault of Archavon',
631 => 'Icecrown Citadel',
632 => 'The Forge of Souls',
649 => 'Trial of the Crusader',
650 => 'Trial of the Champion',
658 => 'Pit of Saron',
668 => 'Halls of Reflection',
724 => 'The Ruby Sanctum'
);
$battlegrounds = array();
$active_instances = array();
$query = $characters_db->query("SELECT `account`, `name`, `class`, `race`, `level`, `gender`, `position_x`, `position_y`, `map`, `zone`, `instance_id`, `instance_mode_mask`, `extra_flags` FROM `characters` WHERE `online` = 1 ORDER BY `name`");
while ($result = $characters_db->fetch_assoc($query)) {
$Extention = 0;
if (($result['map'] == 530 && $result['position_y'] > -1000) || in_array($result['map'], $outland_inst)) {
$Extention = 1;
} elseif ($result['map'] == 571 || in_array($result['map'], $northrend_inst)) {
$Extention = 2;
}
$gm_player = false;
$show_player = true;
if (in_array($result['account'], $gm_accounts)) {
$gm_player = true;
$show_player = false;
if ($gm_show_online == 1) {
$show_player = true;
if (($result['extra_flags'] & 0x1) != 0 && $gm_show_online_only_gmoff == 1) {
$show_player = false;
}
if (($result['extra_flags'] & 0x10) != 0 && $gm_show_online_only_gmvisible == 1) {
$show_player = false;
}
if ($gm_add_suffix && $show_player) {
$result['name'] .= ' {GM}';
}
}
}
if (!$gm_player || ($gm_player && $gm_include_online == 1)) {
if ($Horde_races & (0x1 << ($result['race'] - 1))) {
$Count[$Extention][1]++;
} elseif ($Alliance_races & (0x1 << ($result['race'] - 1))) {
$Count[$Extention][0]++;
}
}
if ($gm_player && !$show_player) {
continue;
}
$player_faction = null;
if ($Horde_races & (0x1 << ($result['race'] - 1))) {
$player_faction = 'horde';
} elseif ($Alliance_races & (0x1 << ($result['race'] - 1))) {
$player_faction = 'alliance';
}
if (isset($playermap_battleground_maps[(int)$result['map']])) {
$bg_map_id = (int)$result['map'];
if (!isset($battlegrounds[$bg_map_id])) {
$battlegrounds[$bg_map_id] = array(
'map' => $bg_map_id,
'name' => $playermap_battleground_maps[$bg_map_id],
'alliance' => 0,
'horde' => 0,
'players' => array()
);
}
if ($player_faction === 'horde') {
$battlegrounds[$bg_map_id]['horde']++;
} elseif ($player_faction === 'alliance') {
$battlegrounds[$bg_map_id]['alliance']++;
}
$battlegrounds[$bg_map_id]['players'][] = array(
'name' => $result['name'],
'level' => $result['level'],
'race' => $result['race'],
'class' => $result['class'],
'gender' => $result['gender'],
'faction' => $player_faction
);
}
if (isset($playermap_instance_maps[(int)$result['map']])) {
$instance_map_id = (int)$result['map'];
$instance_id = isset($result['instance_id']) ? (int)$result['instance_id'] : 0;
$instance_mode_mask = isset($result['instance_mode_mask']) ? (int)$result['instance_mode_mask'] : 0;
/*
* Group by map + instance_id.
* This avoids merging two different groups inside the same dungeon/raid.
*/
$instance_key = $instance_map_id . ':' . $instance_id;
if (!isset($active_instances[$instance_key])) {
$active_instances[$instance_key] = array(
'map' => $instance_map_id,
'instance_id' => $instance_id,
'instance_mode_mask' => $instance_mode_mask,
'name' => $playermap_instance_maps[$instance_map_id],
'alliance' => 0,
'horde' => 0,
'players' => array()
);
}
if ($player_faction === 'horde') {
$active_instances[$instance_key]['horde']++;
} elseif ($player_faction === 'alliance') {
$active_instances[$instance_key]['alliance']++;
}
$active_instances[$instance_key]['players'][] = array(
'name' => $result['name'],
'level' => $result['level'],
'race' => $result['race'],
'class' => $result['class'],
'gender' => $result['gender'],
'faction' => $player_faction
);
}
$char_data = 0;
$char_dead = ($char_data & 0x11) ? 1 : 0;
$arr[$i] = [
'x' => $result['position_x'],
'y' => $result['position_y'],
'dead' => $char_dead,
'name' => $result['name'],
'map' => $result['map'],
'zone' => get_zone_name($result['zone']),
'cl' => $result['class'],
'race' => $result['race'],
'level' => $result['level'],
'gender' => $result['gender'],
'Extention' => $Extention,
'leaderGuid' => $groups[$char_data] ?? 0
];
$i++;
}
$characters_db->close();
unset($characters_db);
if (empty($arr) && !test_realm()) {
$res['online'] = null;
} else {
usort($arr, "sort_players");
$arr = array_merge($Count, $arr);
$res['online'] = $arr;
}
if ($show_status) {
$query = $realm_db->query("SELECT UNIX_TIMESTAMP(), `starttime`, `maxplayers` FROM `uptime` WHERE `starttime` = (SELECT MAX(`starttime`) FROM `uptime`)");
if ($result = $realm_db->fetch_row($query)) {
$status = [
'online' => test_realm() ? 1 : 0,
'uptime' => $result[0] - $result[1],
'maxplayers' => $result[2],
'gmonline' => $gm_online
];
} else {
$status = null;
}
} else {
$status = null;
}
$realm_db->close();
unset($realm_db);
$res['status'] = $status;
$res['battlegrounds'] = array_values($battlegrounds);
$res['instances'] = array_values($active_instances);
$_RESULT = $res;