1 | <?php
|
---|
2 | if(INCLUDED!==true)exit;
|
---|
3 | require_once 'core/defines.php';
|
---|
4 | // ==================== //
|
---|
5 | $pathway_info[] = array('title'=>$lang['players_online'],'link'=>'');
|
---|
6 | // ==================== //
|
---|
7 | $site_defines = Array(
|
---|
8 | 'character_race' => Array(
|
---|
9 | 1 => 'Human',
|
---|
10 | 2 => 'Orc',
|
---|
11 | 3 => 'Dwarf',
|
---|
12 | 4 => 'Night Elf',
|
---|
13 | 5 => 'Undead',
|
---|
14 | 6 => 'Tauren',
|
---|
15 | 7 => 'Gnome',
|
---|
16 | 8 => 'Troll',
|
---|
17 | 9 => 'Goblin',
|
---|
18 | ),
|
---|
19 | 'character_class' => Array(
|
---|
20 | 1 => 'Warrior',
|
---|
21 | 2 => 'Paladin',
|
---|
22 | 3 => 'Hunter',
|
---|
23 | 4 => 'Rogue',
|
---|
24 | 5 => 'Priest',
|
---|
25 | 7 => 'Shaman',
|
---|
26 | 8 => 'Mage',
|
---|
27 | 9 => 'Warlock',
|
---|
28 | 11 => 'Druid',
|
---|
29 | ),
|
---|
30 |
|
---|
31 | 'character_gender' => Array(
|
---|
32 | 0 => 'Male',
|
---|
33 | 1 => 'Female',
|
---|
34 | 2 => 'None'
|
---|
35 | ),
|
---|
36 | 'character_rank' => Array(
|
---|
37 | 'alliance' => Array(
|
---|
38 | 1 => 'Private',
|
---|
39 | 2 => 'Corporal',
|
---|
40 | 3 => 'Sergeant',
|
---|
41 | 4 => 'Master Sergeant',
|
---|
42 | 5 => 'Sergeant Major',
|
---|
43 | 6 => 'Knight',
|
---|
44 | 7 => 'Knight-Lieutenant',
|
---|
45 | 8 => 'Knight-Captain',
|
---|
46 | 9 => 'Knight-Champion',
|
---|
47 | 10 => 'Lieutenant Commander',
|
---|
48 | 11 => 'Commander',
|
---|
49 | 12 => 'Marshal',
|
---|
50 | 13 => 'Field Marshal',
|
---|
51 | 14 => 'Grand Marshal'
|
---|
52 | ),
|
---|
53 | 'horde' => Array(
|
---|
54 | 1 => 'Scout',
|
---|
55 | 2 => 'Grunt',
|
---|
56 | 3 => 'Sergeant',
|
---|
57 | 4 => 'Senior Sergeant',
|
---|
58 | 5 => 'First Sergeant',
|
---|
59 | 6 => 'Stone Guard',
|
---|
60 | 7 => 'Blood Guard',
|
---|
61 | 8 => 'Legionnare',
|
---|
62 | 9 => 'Centurion',
|
---|
63 | 10 => 'Champion',
|
---|
64 | 11 => 'Lieutenant General',
|
---|
65 | 12 => 'General',
|
---|
66 | 13 => 'Warlord',
|
---|
67 | 14 => 'High Warlord'
|
---|
68 | )
|
---|
69 | )
|
---|
70 | );
|
---|
71 |
|
---|
72 |
|
---|
73 | function realm_list()
|
---|
74 | {
|
---|
75 | global $DB;
|
---|
76 | $res = $DB->selectCol("SELECT id AS ARRAY_KEY,name FROM realmlist ORDER BY name");
|
---|
77 | return $res;
|
---|
78 | }
|
---|
79 | function get_realm_byid($id)
|
---|
80 | {
|
---|
81 | global $DB;
|
---|
82 | $search_q = $DB->selectRow("SELECT * FROM `realmlist` WHERE `id`=?d",$id);
|
---|
83 | return $search_q;
|
---|
84 | }
|
---|
85 | function parse_worlddb_info($str)
|
---|
86 | {
|
---|
87 | $arr = explode(';',$str);
|
---|
88 | $wsdb_info['host'] = $arr[0];
|
---|
89 | $wsdb_info['port'] = $arr[1];
|
---|
90 | $wsdb_info['user'] = $arr[2];
|
---|
91 | $wsdb_info['password'] = $arr[3];
|
---|
92 | $wsdb_info['db'] = $arr[4];
|
---|
93 | return $wsdb_info;
|
---|
94 | }
|
---|
95 | function check_port_status($ip, $port)
|
---|
96 | {
|
---|
97 | if($fp1=fsockopen($ip, $port, $ERROR_NO, $ERROR_STR,(float)1.0)){
|
---|
98 | return true;fclose($fp1);
|
---|
99 | }else{
|
---|
100 | return false;
|
---|
101 | }
|
---|
102 | }
|
---|
103 | function get_zone_name($mapid, $x, $y){
|
---|
104 | global $maps_a, $zone;
|
---|
105 | if (!empty($maps_a[$mapid]))
|
---|
106 | {
|
---|
107 | $zmap=$maps_a[$mapid];
|
---|
108 | if (($mapid==0) or ($mapid==1))
|
---|
109 | {
|
---|
110 | $i=0; $c=count($zone[$mapid]);
|
---|
111 | while ($i<$c)
|
---|
112 | {
|
---|
113 | if ($zone[$mapid][$i][2] < $x AND $zone[$mapid][$i][3] > $x AND $zone[$mapid][$i][1] < $y AND $zone[$mapid][$i][0] > $y) $zmap=$zone[$mapid][$i][4];
|
---|
114 | $i++;
|
---|
115 | }
|
---|
116 | }
|
---|
117 | } else $zmap="Unknown zone";
|
---|
118 | return $zmap;
|
---|
119 | }
|
---|
120 |
|
---|
121 | if($_GET['realm']){
|
---|
122 |
|
---|
123 | $res_info = array();
|
---|
124 | $query = array();
|
---|
125 | $realm_info = get_realm_byid($_GET['realm']);
|
---|
126 | $cc = 0;
|
---|
127 | if(check_port_status($realm_info['address'], $realm_info['port'])===true)
|
---|
128 | {
|
---|
129 | if(!$realm_info['dbinfo'])output_message('alert','Check field <u>dbinfo</u> in table `realmlist` for realm id='.$realm_info['id']);
|
---|
130 | $wsdb_info = parse_worlddb_info($realm_info['dbinfo']);
|
---|
131 | $WSDB = DbSimple_Generic::connect("".$config['db_type']."://".$wsdb_info['user'].":".$wsdb_info['password']."@".$wsdb_info['host'].":".$wsdb_info['port']."/".$wsdb_info['db']."");
|
---|
132 | if($WSDB)$WSDB->setErrorHandler('databaseErrorHandler');
|
---|
133 | if($WSDB)$WSDB->query("SET NAMES ".$config['db_encoding']);
|
---|
134 | if($WSDB)$query = $WSDB->select("SELECT * FROM `character` WHERE `online`='1' ORDER BY `name`");
|
---|
135 | }else{
|
---|
136 | output_message('alert','Realm <b>'.$realm_info['name'].'</b> is offline <img src="images/downarrow2.gif" border="0" align="top">');
|
---|
137 | }
|
---|
138 |
|
---|
139 | foreach ($query as $result) {
|
---|
140 | if($res_color==1)$res_color=2;else$res_color=1;
|
---|
141 | $cc++;
|
---|
142 | $res_race = $site_defines['character_race'][$result['race']];
|
---|
143 | $res_class = $site_defines['character_class'][$result['class']];
|
---|
144 | // $res_pos = "<b>x:</b>$result[position_x] <b>y:</b>$result[position_y] <b>z:</b>$result[position_z]";
|
---|
145 | $res_pos=get_zone_name($result['map'], $result['position_x'], $result['position_y']);
|
---|
146 | $char_data = explode(' ',$result['data']);
|
---|
147 |
|
---|
148 | $char_gender = dechex($char_data[36]);
|
---|
149 | $char_gender = str_pad($char_gender,8, 0, STR_PAD_LEFT);
|
---|
150 | $char_gender = $char_gender{3};
|
---|
151 |
|
---|
152 | $res_info[$cc]["number"] = $cc;
|
---|
153 | $res_info[$cc]["res_color"] = $res_color;
|
---|
154 | $res_info[$cc]["name"] = $result['name'];
|
---|
155 | $res_info[$cc]["race"] = $result['race'];
|
---|
156 | $res_info[$cc]["class"] = $result['class'];
|
---|
157 | $res_info[$cc]["gender"] = $char_gender;
|
---|
158 | $res_info[$cc]["level"] = $char_data[34];
|
---|
159 | $res_info[$cc]["pos"] = $res_pos;
|
---|
160 | }
|
---|
161 | unset($WSDB);
|
---|
162 | }else{
|
---|
163 | $realm_list = realm_list();
|
---|
164 | }
|
---|
165 |
|
---|
166 | ?>
|
---|