-
Notifications
You must be signed in to change notification settings - Fork 0
/
stats.php
287 lines (236 loc) · 8.01 KB
/
stats.php
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
<?php
define("ABS_PATH", dirname(__FILE__));
set_include_path(get_include_path() . PATH_SEPARATOR . ABS_PATH);
require './lib/functions.php';
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes" />
<title>Serverstats</title>
<link href="img/homescreen.gif" rel="apple-touch-icon" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
<link rel="stylesheet" href="css/app.css" type="text/css">
<link href="css/photoswipe.css" type="text/css" rel="stylesheet" />
<link href="css/ps_jquery-mobile.css" type="text/css" rel="stylesheet" />
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
<!-- code for photoswipe on page two -->
<script type="text/javascript" src="js/code.photoswipe.jquery-3.0.4.min.js"></script>
<script type="text/javascript" src="js/lib/klass.min.js"></script>
<script type="text/javascript">
/*
* IMPORTANT!!!
* REMEMBER TO ADD rel="external" to your anchor tags.
* If you don't this will mess with how jQuery Mobile works
*/
(function(window, $, PhotoSwipe){
$(document).ready(function(){
$('div.gallery-page')
.live('pageshow', function(e){
var
currentPage = $(e.target),
options = {},
photoSwipeInstance = $("ul.gallery a", e.target).photoSwipe(options, currentPage.attr('id'));
return true;
})
.live('pagehide', function(e){
var
currentPage = $(e.target),
photoSwipeInstance = PhotoSwipe.getInstance(currentPage.attr('id'));
if (typeof photoSwipeInstance != "undefined" && photoSwipeInstance != null) {
PhotoSwipe.detatch(photoSwipeInstance);
}
return true;
});
});
}(window, window.jQuery, window.Code.PhotoSwipe));
</script>
</head>
<body>
<!-- SIDA 1 - inloggade -->
<div data-role="page" id="one">
<div data-role="header" id="myheader">
<div class="centered">
<img src="img/mcraft_header.jpg" alt="Minecraft Serverstats" />
</div>
<div data-role="navbar" data-iconpos="bottom">
<ul>
<li><a href="#one" data-icon="home" class="ui-btn-active ui-state-persist">Inloggade</a></li>
<li><a href="#two" data-icon="grid">Karta</a></li>
<li><a href="#three" data-icon="gear">Inställningar</a></li>
<li><a href="#four" data-icon="star">Topplista</a></li>
</ul>
</div><!-- /navbar -->
</div> <!-- /header -->
<div data-role="content">
<div>
<strong>Servernamn: </strong>lambda.servegame.com
<!-- print out a red or green sign to show server status -->
<?php
$serverinfo=get_serverinfo();
if ($serverinfo['up'] == "online") {
$status = "green";
}
else {
$status = "red";
}
?>
<img src="img/<?php echo $status; ?>_light.png" width="30px" alt="Statuslampa" />
</div>
<?php
$online = get_online_users();
$online_count = $online['count'];
unset($online['count']);
?>
<ul data-role="listview" data-inset="true" data-filter="false">
<li data-role="list-divider">Inloggade just nu: <?php echo $online_count; ?> användare</li>
<?php
foreach ($online as $user) {
echo " <li>" . $user . "</li>\n";
}
?>
</ul>
</div>
<div data-role="footer" id="myfooter">
<h4>© 2011 Johan Klinge</h4>
</div>
</div> <!--end page one-->
<!-- SIDA 2 - karta -->
<div data-role="page" id="two" class="gallery-page">
<div data-role="header" id="myheader">
<div class="centered">
<img src="img/mcraft_header.jpg" alt="Minecraft Serverstats" />
</div>
<div data-role="navbar" data-iconpos="bottom">
<ul>
<li><a href="#one" data-icon="home">Inloggade</a></li>
<li><a href="#two" data-icon="grid" class="ui-btn-active ui-state-persist">Karta</a></li>
<li><a href="#three" data-icon="gear">Inställningar</a></li>
<li><a href="#four" data-icon="star">Topplista</a></li>
</ul>
</div><!-- /navbar -->
</div> <!-- /header -->
<div data-role="content">
<ul class="gallery">
<li><a href="maps/normal.png" rel="external">
<img src="maps/thumbs/thumb_normal.png.jpg" alt="Normal" />
</a></li>
<li><a href="maps/isometric.png" rel="external">
<img src="maps/thumbs/thumb_isometric.png.jpg" alt="Isometric" />
</a></li>
<li>
<a href="maps/oblique.png" rel="external">
<img src="maps/thumbs/thumb_oblique.png.jpg" alt="Oblique" />
</a></li>
<li><a href="maps/oblique_angle.png" rel="external">
<img src="maps/thumbs/thumb_oblique_angle.png.jpg" alt="Oblique-vinkel" />
</a></li>
</ul>
</div> <!-- /content -->
<div data-role="footer" id="myfooter">
<h4>© 2011 Johan Klinge</h4>
</div>
</div> <!--end page one-->
<!-- SIDA 3 - serverinfo -->
<div data-role="page" id="three">
<div data-role="header">
<div class="centered">
<img src="img/mcraft_header.jpg" alt="Minecraft Serverstats" />
</div>
<div data-role="navbar" data-iconpos="bottom">
<ul>
<li><a href="#one" data-icon="home">Inloggade</a></li>
<li><a href="#two" data-icon="grid">Karta</a></li>
<li><a href="#three" data-icon="gear" class="ui-btn-active ui-state-persist">Inställningar</a></li>
<li><a href="#four" data-icon="star">Topplista</a></li>
</ul>
</div> <!-- /navbar -->
</div>
<div data-role="content">
<?php
$serverinfo = get_serverinfo();
?>
<table>
<tr>
<td>Status:</td>
<td><?php echo $serverinfo['up']; ?></td>
</tr>
<tr>
<td>Uppe sedan:</td>
<td><?php echo $serverinfo['up_since']; ?></td>
</tr>
<tr>
<td>Uppe i:</td>
<td><?php echo $serverinfo['up_for']; ?></td>
</tr>
<tr>
<td>Version:</td>
<td><?php echo $serverinfo['version']; ?></td>
</tr>
<tr>
<td>Karta:</td>
<td><?php echo $serverinfo['map']; ?></td>
</tr>
<tr>
<td>Max spelare:</td>
<td><?php echo $serverinfo['max_players']; ?></td>
</tr>
<tr>
<td>PVP:</td>
<td><?php echo $serverinfo['pvp']; ?></td>
</tr>
</table>
</div> <!-- end content -->
<div data-role="footer">
<h4>©2011 Johan Klinge</h4>
</div>
</div>
<!-- SIDA 4 - topplista över inloggningar -->
<div data-role="page" id="four">
<div data-role="header">
<div class="centered">
<img src="img/mcraft_header.jpg" alt="Minecraft Serverstats" />
</div>
<div data-role="navbar" data-iconpos="bottom">
<ul>
<li><a href="#one" data-icon="home">Inloggade</a></li>
<li><a href="#two" data-icon="grid">Karta</a></li>
<li><a href="#three" data-icon="gear">Inställningar</a></li>
<li><a href="#four" data-icon="star" class="ui-btn-active ui-state-persist">Topplista</a></li>
</ul>
</div><!-- /navbar -->
</div>
<div data-role="content">
<?php
//fetch results from function
$topusers = get_toplist();
//fetch dates, and unset them
$startdate = $topusers['startdate'];
$enddate = $topusers['enddate'];
unset($topusers['startdate']);
unset($topusers['enddate']);
echo "<p>Antal inloggningar mellan <strong>" . $startdate . "</strong> och <strong>" . $enddate . "</strong></p>\n";
echo '<ul data-role="listview" data-inset="true" data-theme="c" data-divider-theme="b">';
echo ' <li data-role="list-divider">Topplista på inloggade</li>';
//loop over users and get usernames and logins
while ($user = current($topusers)) {
echo " <li><span class='ui-li-count'>" .
$user . "</span>" . key($topusers) .
"</li>\n";
next($topusers);
}
// foreach ($topusers as $user) {
// echo " <li><span class='ui-li-count'>" . $user . "</span>" . key($user) . "</li>\n";
// }
?>
</ul>
</div>
<div data-role="footer">
<h4>© 2011, Johan Klinge</h4>
</div>
</div>
</body>
</html>