source: trunk/test_server/map/pomm_play.php@ 649

Last change on this file since 649 was 649, checked in by barny, 16 years ago

*Přidán minimanager pro test server

File size: 5.2 KB
Line 
1<?php
2/*
3 POMM v1.3
4 Player Online Map for MangOs
5
6 Show online players position on map. Update without refresh.
7 Show tooltip with location, race, class and level of player.
8 Show realm status.
9
10 16.09.2006 http://pomm.da.ru/
11
12 Created by mirage666 (c) (mailto:mirage666@pisem.net icq# 152263154)
13 2006-2009 Modified by killdozer.
14*/
15
16require_once("pomm_conf.php");
17require_once("func.php");
18
19if (file_exists("map_".$lang.".php") && file_exists("zone_names_".$lang.".php"))
20 require_once("map_".$lang.".php");
21else
22 require_once("map_english.php");
23
24$_RESULT = NULL;
25
26$maps_count = count($lang_defs['maps_names']);
27
28$Horde_races = 0x2B2;
29$Alliance_races = 0x44D;
30$outland_inst = array(540,542,543,544,545,546,547,548,550,552,553,554,555,556,557,558,559,562,564,565);
31$northrend_inst = array(533,574,575,576,578,599,600,601,602,603,604,608,615,616,617,619,624);
32
33require_once "../libs/js/JsHttpRequest/Php.php";
34$JsHttpRequest = new Subsys_JsHttpRequest_Php("utf-8");
35
36$realm_db = new DBLayer($hostr, $userr, $passwordr, $dbr);
37if(!$realm_db->isValid())
38{
39 $_RESULT['status']['online'] = 2;
40 exit();
41}
42$realm_db->query("SET NAMES $database_encoding");
43
44$gm_online = 0;
45$gm_accounts = array();
46$query = $realm_db->query("SELECT GROUP_CONCAT(`id` SEPARATOR ' ') FROM `account` WHERE `gmlevel`>'0'");
47if($query)
48 if($result = $realm_db->fetch_row($query))
49 $gm_accounts = explode(' ', $result[0]);
50$groups = array();
51$characters_db = new DBLayer($host, $user, $password, $db);
52if(!$characters_db->isValid())
53{
54 $_RESULT['status']['online'] = 2;
55 exit();
56}
57$characters_db->query("SET NAMES $database_encoding");
58$query = $characters_db->query("SELECT `leaderGuid`,`memberGuid` FROM `group_member` WHERE `memberGuid` IN(SELECT `guid` FROM `characters` WHERE `online`='1')");
59if($query)
60 while($result = $characters_db->fetch_assoc($query))
61 $groups[$result['memberGuid']] = $result['leaderGuid'];
62
63$Count = array();
64for($i = 0; $i < $maps_count; $i++) {
65 $Count[$i] = array(0,0);
66 }
67$arr = array();
68$i=$maps_count;
69$query = $characters_db->query("SELECT `account`,`data`,`name`,`class`,`race`, `level`, `gender`, `position_x`,`position_y`,`map`,`zone`,`extra_flags` FROM `characters` WHERE `online`='1' ORDER BY `name`");
70while($result = $characters_db->fetch_assoc($query))
71{
72 if($result['map'] == 530 && $result['position_y'] > -1000 || in_array($result['map'], $outland_inst))
73 $Extention = 1;
74 else if($result['map'] == 571 || in_array($result['map'], $northrend_inst))
75 $Extention = 2;
76 else
77 $Extention = 0;
78
79 $gm_player = false;
80 $show_player = true;
81 if(in_array($result['account'], $gm_accounts))
82 {
83 $gm_player = true;
84 $show_player = false;
85 if($gm_show_online == 1)
86 {
87 $show_player = true;
88 if(($result['extra_flags'] & 0x1) != 0 && $gm_show_online_only_gmoff == 1)
89 $show_player = false;
90 if(($result['extra_flags'] & 0x10) != 0 && $gm_show_online_only_gmvisible == 1)
91 $show_player = false;
92 if($gm_add_suffix && $show_player)
93 $result['name'] = $result['name'].' <small style="color: #EABA28;">{GM}</small>';
94 }
95 }
96
97 if($gm_player == false || ($gm_player == true && $gm_include_online == 1))
98 {
99 if($Horde_races & (0x1 << ($result['race']-1)))
100 $Count[$Extention][1]++;
101 else if($Alliance_races & (0x1 << ($result['race']-1)))
102 $Count[$Extention][0]++;
103 }
104
105 if(($gm_player && $show_player) || ($gm_player && !$show_player && $status_gm_include_all))
106 $gm_online++;
107 if($gm_player && $show_player == false)
108 continue;
109
110 $char_data = explode(' ',$result['data']);
111 $char_flags = $char_data[$PLAYER_FLAGS];
112 $char_dead = ($char_flags & 0x11)?1:0;
113 $arr[$i]['x'] = $result['position_x'];
114 $arr[$i]['y'] = $result['position_y'];
115 $arr[$i]['dead'] = $char_dead;
116 $arr[$i]['name']=$result['name'];
117 $arr[$i]['map']=$result['map'];
118 $arr[$i]['zone']=get_zone_name($result['zone']);
119 $arr[$i]['cl'] = $result['class'];
120 $arr[$i]['race'] = $result['race'];
121 $arr[$i]['level']=$result['level'];
122 $arr[$i]['gender'] = $result['gender'];
123 $arr[$i]['Extention'] = $Extention;
124 $arr[$i]['leaderGuid'] = isset($groups[$char_data[0]]) ? $groups[$char_data[0]] : 0;
125 $i++;
126}
127$characters_db->close();
128unset($characters_db);
129
130if(!count($arr) && !test_realm())
131 $res['online'] = NULL;
132else
133{
134 usort($arr, "sort_players");
135 $arr = array_merge($Count, $arr);
136 $res['online'] = $arr;
137}
138
139if($show_status) {
140 $query = $realm_db->query("SELECT UNIX_TIMESTAMP(),`starttime`,`maxplayers` FROM `uptime` WHERE `starttime`=(SELECT MAX(`starttime`) FROM `uptime`)");
141 if($result = $realm_db->fetch_row($query)) {
142 $status['online'] = test_realm() ? 1 : 0;
143 $status['uptime'] = $result[0] - $result[1];
144 $status['maxplayers'] = $result[2];
145 $status['gmonline'] = $gm_online;
146 }
147 else
148 $status = NULL;
149 }
150else
151 $status = NULL;
152
153$realm_db->close();
154unset($realm_db);
155
156$res['status'] = $status;
157
158$_RESULT = $res;
159?>
Note: See TracBrowser for help on using the repository browser.