forked from freeciv/freeciv-metaserver
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclients.phtml
110 lines (95 loc) · 2.85 KB
/
clients.phtml
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
<!-- This is for the HTML validator -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- The real code begins here -->
<?php
# Copyright (C) 2007 - Paul Zastoupil, Reinier Post, Marko Lindqvist
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
// include the php-code finder
ini_set("include_path",
ini_get("include_path") . ":" . $_SERVER["DOCUMENT_ROOT"]
);
include_once("php_code/settings.php");
include_once("php_code/php_code_find.php");
// includes for support routines
include_once(php_code_find("fcdb.php"));
include_once(php_code_find("img.php"));
?>
<HTML>
<HEAD>
<TITLE>Freeciv Client Stats</TITLE>
<META HTTP-EQUIV=Content-Language CONTENT=en>
</HEAD>
<BODY BGCOLOR="#FFFAF0">
<?
echo "<CENTER>";
img_html("headers/clients.gif", "Client Statistics", NULL, NULL);
echo "</CENTER><BR><CENTER>";
$start = "start";
if ( isset($_REQUEST[$start]) ) {
$where[]="date >= \"$_REQUEST[$start]\"";
}
$end = "end";
if ( isset($_REQUEST[$end]) ) {
$where[]="date <= \"$_REQUEST[$end]\"";
}
$list=array("version","gui","os","arch","tileset");
foreach ($list as $type) {
if ( isset($_REQUEST[$type]) ) {
$where[]="$type = \"$_REQUEST[$type]\"";
}
}
if ( $where[0] ) {
$swhere="where ". join(" and ", $where);
}
fcdb_default_connect();
$stmt="select sum(count) from clients $swhere";
$total=fcdb_query_single_value($stmt);
foreach ($list as $type) {
echo "<TABLE BORDER BGCOLOR=\"#9FB6CD\">\n";
echo "<TR><TH>$type</TH><TH>Count</TH><TH COLSPAN=2>Percentage</TR>\n"; echo "<TR></TR>\n";
$stmt="select distinct $type from clients $swhere order by $type";
$res = fcdb_exec($stmt);
for ( $inx = 0; $inx < fcdb_num_rows($res); $inx++ ) {
$row = fcdb_fetch_array($res, $inx);
if ( $swhere ) {
$cond="$swhere and $type='$row[$type]'";
} else {
$cond="where $type='$row[$type]'";
}
$stmt="select sum(count) from clients $cond";
/* echo "\n\n<!-- query $stmt -->\n"; */
$count=fcdb_query_single_value($stmt);
$l=round($count*100/$total+.0001);
echo "<TR><TD ALIGN=\"LEFT\">";
if ( $row[$type] == "" ) {
echo "Unknown";
} else {
echo $row[$type];
}
echo "</TD><TD ALIGN=\"RIGHT\">";
echo $count;
echo "</TD><TD ALIGN=LEFT>";
$img_tag_extra= "height=\"16\" width=\"" . strval($l*6+1) . "\"";
img_html("line.png", NULL, "$img_tag_extra", NULL);
echo "<TD ALIGN=RIGHT>$l%</TD></TR>\n";
}
echo "</TABLE><BR>";
}
?>
</CENTER>
<BR>
<HR>Return to <a href="/">the main page</A>
<HR>In case of technical problems, please contact
<?php echo $webmaster_html ?>.
<BR><BR>
<P ALIGN="center">
<?
img_html("hr.gif", "--------", NULL, NULL);
?>
<BR><BR>
</BODY>
</HTML>