source: minimanager/stat.php@ 19

Last change on this file since 19 was 19, checked in by george, 18 years ago

Aktualizace MaNGOS Minimanageru na verzi 0.1.4a.

File size: 7.4 KB
Line 
1<?php
2/*
3 * Project Name: MiniManager for Mangos Server
4 * Date: 17.10.2006 inital version (0.0.1a)
5 * Author: Q.SA
6 * Copyright: Q.SA
7 * Email: *****
8 * License: GNU General Public License v2(GPL)
9 */
10
11require_once("header.php");
12valid_login(1);
13
14$race = Array(
15 1 => array(1,$lang_id_tab['human'],"",""),
16 2 => array(2,$lang_id_tab['orc'],"",""),
17 3 => array(3,$lang_id_tab['dwarf'],"",""),
18 4 => array(4,$lang_id_tab['nightelf'],"",""),
19 5 => array(5,$lang_id_tab['undead'],"",""),
20 6 => array(6,$lang_id_tab['tauren'],"",""),
21 7 => array(7,$lang_id_tab['gnome'],"",""),
22 8 => array(8,$lang_id_tab['troll'],"",""),
23 10 => array(10,$lang_id_tab['bloodelf'],"",""),
24 11 => array(11,$lang_id_tab['draenei'],"","")
25);
26
27$class = Array(
28 1 => array(1,$lang_id_tab['warrior'],"",""),
29 2 => array(2,$lang_id_tab['paladin'],"",""),
30 3 => array(3,$lang_id_tab['hunter'],"",""),
31 4 => array(4,$lang_id_tab['rogue'],"",""),
32 5 => array(5,$lang_id_tab['priest'],"",""),
33 7 => array(7,$lang_id_tab['shaman'],"",""),
34 8 => array(8,$lang_id_tab['mage'],"",""),
35 9 => array(9,$lang_id_tab['warlock'],"",""),
36 11 => array(11,$lang_id_tab['druid'],"","")
37);
38
39$level = Array(
40 1 => array(1,1,4,"",""),
41 2 => array(2,5,9,"",""),
42 3 => array(3,10,14,"",""),
43 4 => array(4,15,19,"",""),
44 5 => array(5,20,24,"",""),
45 6 => array(6,25,29,"",""),
46 7 => array(7,30,34,"",""),
47 8 => array(8,35,39,"",""),
48 9 => array(9,40,44,"",""),
49 10 => array(10,45,49,"",""),
50 11 => array(11,50,54,"",""),
51 12 => array(12,55,59,"",""),
52 13 => array(13,60,64,"",""),
53 14 => array(14,65,69,"",""),
54 15 => array(15,70,70,"","")
55);
56
57 $sql = new SQL;
58 $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
59 $query = $sql->query("SELECT count(*) FROM account UNION SELECT count(*) FROM account WHERE gmlevel > 0");
60 $total_acc = $sql->result($query,0);
61 $total_gms = $sql->result($query,1);
62
63 $sql->connect($mangos_db[$realm_id]['addr'], $mangos_db[$realm_id]['user'], $mangos_db[$realm_id]['pass'], $mangos_db[$realm_id]['name']);
64 $query = $sql->query("SELECT count(*) FROM `character`");
65 $total_chars = $sql->result($query,0);
66
67 $query = $sql->query("SELECT AVG(uptime)/60,MAX(uptime)/60,(100*SUM(uptime)/(UNIX_TIMESTAMP()-MIN(starttime))) FROM uptime");
68 $uptime = $sql->fetch_row($query);
69
70 if ($total_chars){
71
72 $order_race = (isset($_GET['race'])) ? "AND race =".$sql->quote_smart($_GET['race']) : "";
73 $order_class = (isset($_GET['class'])) ? "AND class =".$sql->quote_smart($_GET['class']) : "";
74
75 if(isset($_GET['level'])){
76 $lvl_min = $sql->quote_smart($_GET['level']);
77 $lvl_max = $lvl_min + 4;
78 $order_level = "AND SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ', 35), ' ', -1) >= $lvl_min AND SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ', 35), ' ', -1) <= $lvl_max";
79 } else $order_level = "";
80
81 if(isset($_GET['side'])) {
82 if ($sql->quote_smart($_GET['side']) == "h") $order_side = "AND race IN(2,5,6,8,10)";
83 elseif ($sql->quote_smart($_GET['side']) == "a") $order_side = "AND race IN (1,3,4,7,11)";
84 } else $order_side = "";
85
86
87 $output .= "<div class=\"top\"><h1>{$lang_stat['srv_statistics']}</h1></div>";
88
89 //there is always less hordies
90 $query = $sql->query("SELECT count(guid) FROM `character` WHERE race IN(2,5,6,8,10)");
91 $horde_chars = $sql->result($query,0);
92 $horde_pros = round(($horde_chars*100)/$total_chars ,1);
93 $allies_chars = $total_chars - $horde_chars;
94 $allies_pros = 100 - $horde_pros;
95
96 $output .= "<center>
97 <table class=\"hidden\">
98 <tr><td align=\"left\"><h1>{$lang_stat['general_info']}</h1></td></tr>
99 <tr align=\"left\"><td class=\"large\">
100 {$lang_stat['uptime_prec']}: ".round($uptime[2],1)."%<br />
101 {$lang_stat['avg_uptime']}: ".(int)($uptime[0]/60).":".(int)(($uptime[0]%60))."h<br />
102 {$lang_stat['max_uptime']}: ".(int)($uptime[1]/60).":".(int)(($uptime[1]%60))."h<br /><br />
103 {$lang_stat['tot_accounts']}: $total_acc<br />
104 {$lang_stat['total_of']} $total_gms {$lang_stat['gms_one_for']} ".round($total_acc/$total_gms,1)." {$lang_stat['players']}<br /><br />
105 {$lang_stat['tot_chars_on_realm']}: $total_chars<br />
106 {$lang_stat['average_of']} ".round($total_chars/$total_acc,1)." {$lang_stat['chars_per_acc']}<br /><br />
107
108 <table class=\"tot_bar\">
109 <tr>
110 <td width=\"$horde_pros%\" background=\"./img/bar_horde.gif\" height=\"40\"><a href=\"stat.php?side=h\">{$lang_stat['horde']}: $horde_chars ($horde_pros%)</a></td>
111 <td width=\"$allies_pros%\" background=\"./img/bar_allie.gif\" height=\"40\"><a href=\"stat.php?side=a\">{$lang_stat['alliance']}: $allies_chars ($allies_pros%)</a></td>
112 </tr>
113 </table>
114 <hr/>
115 </td></tr>";
116
117// RACE
118foreach ($race as $id){
119 $query = $sql->query("SELECT count(guid) FROM `character` WHERE race = $id[0] $order_class $order_level $order_side");
120 $race[$id[0]][2] = $sql->result($query,0);
121 $race[$id[0]][3] = round((($race[$id[0]][2])*100)/$total_chars,1);
122 }
123
124 $output .= "<tr align=\"left\"><td><h1>{$lang_stat['chars_by_race']}</h1></td></tr><tr><td>
125 <table class=\"bargraph\">
126 <tr>";
127 foreach ($race as $id){
128 $height = ($race[$id[0]][3])*4;
129 $output .= "<td><a href=\"stat.php?race={$id[0]}\" class=\"graph_link\">{$race[$id[0]][3]}%<img src=\"./templates/$css_template/column.gif\" width=\"69\" height=\"$height\" alt=\"{$race[$id[0]][2]}\" /></a></td>";
130 }
131$output .= "</tr><tr>";
132 foreach ($race as $id){
133 $output .= "<th>{$race[$id[0]][1]}<br />{$race[$id[0]][2]}</th>";
134 }
135$output .= "</tr>
136</table><br />
137 </td></tr>";
138// RACE END
139
140// CLASS
141foreach ($class as $id){
142 $query = $sql->query("SELECT count(guid) FROM `character` WHERE class = $id[0] $order_race $order_level $order_side");
143 $class[$id[0]][2] = $sql->result($query,0);
144 $class[$id[0]][3] = round((($class[$id[0]][2])*100)/$total_chars,1);
145 }
146
147 $output .= "<tr align=\"left\"><td><h1>{$lang_stat['chars_by_class']}</h1></td></tr><tr><td>
148 <table class=\"bargraph\">
149 <tr>";
150 foreach ($class as $id){
151 $height = ($class[$id[0]][3])*4;
152 $output .= "<td><a href=\"stat.php?class={$id[0]}\" class=\"graph_link\">{$class[$id[0]][3]}%<img src=\"./templates/$css_template/column.gif\" width=\"77\" height=\"$height\" alt=\"{$class[$id[0]][2]}\" /></a></td>";
153 }
154$output .= "</tr><tr>";
155 foreach ($class as $id){
156 $output .= "<th>{$class[$id[0]][1]}<br />{$class[$id[0]][2]}</th>";
157 }
158$output .= "</tr>
159</table><br />
160 </td></tr>";
161// CLASS END
162
163// LEVEL
164foreach ($level as $id){
165 $query = $sql->query("SELECT count(guid) FROM `character` WHERE SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ', 35), ' ', -1) >= $id[1]
166 AND SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ', 35), ' ', -1) <= $id[2] $order_race $order_class $order_side");
167 $level[$id[0]][3] = $sql->result($query,0);
168 $level[$id[0]][4] = round((($level[$id[0]][3])*100)/$total_chars,1);
169 }
170
171 $output .= "<tr align=\"left\"><td><h1>{$lang_stat['chars_by_level']}</h1></td></tr><tr><td>
172 <table class=\"bargraph\">
173 <tr>";
174 foreach ($level as $id){
175 $height = ($level[$id[0]][4])*4;
176 $output .= "<td><a href=\"stat.php?level={$id[1]}\" class=\"graph_link\">{$level[$id[0]][4]}%<img src=\"./templates/$css_template/column.gif\" width=\"45\" height=\"$height\" alt=\"{$level[$id[0]][3]}\" /></a></td>";
177 }
178$output .= "</tr><tr>";
179 foreach ($level as $id){
180 $output .= "<th>{$level[$id[0]][1]}-{$level[$id[0]][2]}<br />{$level[$id[0]][3]}</th>";
181 }
182$output .= "</tr>
183</table><br /><hr/>
184 </td></tr><tr><td>";
185// LEVEL END
186
187 makebutton($lang_stat['reset'], "stat.php", 720);
188 $output .= "</td></tr></table>
189 </center>";
190
191 $sql->close();
192
193} else {
194 $sql->close();
195 error($lang_global['err_no_result']);
196 }
197require_once("footer.php");
198?>
Note: See TracBrowser for help on using the repository browser.