-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgametypes.php
443 lines (379 loc) · 13.8 KB
/
gametypes.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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
<?php
include("config.php");
include("lib/functions.php");
require_once 'lib/steam-condenser/lib/steam-condenser.php';
$start = head();
mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_select_db($table) or die(mysql_error());
$gametype = $_GET['gametype'];
$update = $_GET['update'];
if ($update == "yes") {
$longname = $_GET['longname'];
mysql_query("UPDATE games SET longname = '$longname' WHERE shortname = '$gametype'");
echo '<b>Gametype ' . $gametype . ' Updated longname correctly</b><br/>';
}
if ($update == "players") {
$minplayers = $_GET['minplayers'];
if ($minplayers == "NULL") {
mysql_query("UPDATE games SET minplayers = NULL WHERE shortname = '$gametype'");
} else {
mysql_query("UPDATE games SET minplayers = '$minplayers' WHERE shortname = '$gametype'");
}
echo '<b>Gametype ' . $gametype . ' Updated playercount restart correctly</b><br/>';
}
if ($update == "optional") {
mysql_query("UPDATE servers SET restartsend='optional',cmdtosend='optional' WHERE type = '$gametype'");
echo '<b>Gametype ' . $gametype . ' Optional restart send</b><br/>';
}
if ($update == "update") {
mysql_query("UPDATE servers SET restartsend='update' WHERE shortname = '$gametype'");
echo '<b>Gametype ' . $gametype . ' Updated longname correctly</b><br/>';
}
$gametypes = gametypes();
if ($update) echo '<br/>';
echo '<form action="#">';
echo '<select name="gametype" onchange="this.form.submit()">';
echo '<option value="">Select Game</option>';
foreach (array_keys($gametypes) as $shortname) {
if ($gametype == $shortname) { echo '<option value="' . $shortname . '" selected="selected">' . $gametypes["$shortname"]['longname'] . '</option>';}
else { echo '<option value="'. $shortname . '">' . $gametypes["$shortname"]['longname'] . '</option>';}
}
echo '</select>';
echo '</form><br/>';
if ($gametype) {
echo "<img src=images/stockimages/$gametype.jpg align=left><br/><br/><br/><br/>";
echo '<fieldset>';
echo "<legend>Gametype configuration for " . $gametypes["$gametype"]['longname'] . "</legend>";
echo " <b>Current version is: " . $gametypes["$gametype"]['version'] . "</b><br/>";
echo " <b>Shortname: " . $gametype . "</b><br/>";
echo " <b>Out of date?: " . $gametypes["$gametype"]['expired'] ."<br/>";
echo " <b>AppCode: <a href=http://store.steampowered.com/app/" . $gametypes["$gametype"]['appid'] . "/>" . $gametypes["$gametype"]['appid'] . "</a></b>";
echo '<fieldset>';
echo '<legend>Options</legend>';
echo '<form>';
echo 'Long name description <input type=text size=50 name="longname" value="'. $gametypes["$gametype"]['longname'] . '">';
echo '<input type="hidden" name="gametype" value="'. $gametype . '">';
echo '<input type="hidden" name="update" value="yes"> ';
echo '<input type="submit" value="Update">';
echo '</form>';
echo '<form>';
echo 'Maximum numbers of players present for optional update <select size="1" name="minplayers" id="minplayers">';
$players=1;
$maxplayers=20;
if ($gametypes["$gametype"]['minplayers'] == NULL) {
echo '<option value=NULL id=minplayers selected=selected>Dont Check</option>';
} else {
echo '<option value=NULL id=minplayers>Dont Check</option>';
}
while($players<=$maxplayers) {
if ($gametypes["$gametype"]['minplayers'] == $players) {
echo "<option value=\"" . $players . "\" id=\"minplayers\" selected>" . $players . " " . ( $players == "1" ? "Player" : "Players") . "</option>";
} else {
echo "<option value=\"" . $players . "\" id=\"minplayers\">" . $players . " " . ( $players == "1" ? "Player" : "Players") . "</option>";
}
$players++;
}
echo '<input type="hidden" name="gametype" value="'. $gametype . '">';
echo '<input type="hidden" name="update" value="players"> ';
echo '<input type="submit" value="Update">';
echo '</form><br/>';
// add a call towards the singlerestart for the shutdown/quit command
echo '<form>';
echo 'An optional update means that Valve updated the files but it is not a required update<br/>';
echo "Press below button to restart all servers for type " . $gametypes["$gametype"]['longname'];
if ( $gametypes["$gametype"]['minplayers'] == NULL) { echo ", we DONT check for users present!!<br/>";}
else { echo " when usercount is below " . $gametypes["$gametype"]['minplayers'] . " player(s)<br/>"; }
echo '<input type="hidden" name="gametype" value="'. $gametype . '">';
echo '<input type="hidden" name="update" value="optional"> ';
echo '<input type="submit" value="Run Optional update">';
echo '</form>';
echo '<form>';
echo 'A Forced update means that a required update came out but the master servers were not updated yet. Because of this it didn\'t go automatically, below button will fake a update so it will restart all servers which will update. This will <b>NOT</b> check for playercounts on the server but will send out a message to the server\'s players!<br/>';
echo "Press below button to restart all servers for type " . $gametypes["$gametype"]['longname'];
echo '<br/><input type="hidden" name="gametype" value="'. $gametype . '">';
echo '<input type="hidden" name="update" value="update"> ';
echo '<input type="submit" value="Force update">';
echo '</form>';
echo '</fieldset>';
echo '</fieldset>';
echo '<fieldset><legend>Recent updates (Feed from Valve)</legend>';
getupdates($gametypes["$gametype"]['appid'],'style');
echo '</fieldset>';
} else {
?>
<div id="piechart1">
<?php
$sql = "SELECT * FROM servers";
$result = mysql_query($sql);
$data = array();
while ($row = mysql_fetch_array($result)) {
$type = $row['type'];
$current[$type] += (int)$row['currentplayers'];
$total = $total + (int)$row['currentplayers'];
$bots[$type] = $bots[$type] + (int)$row['currentbots'];
$max[$type] = $max[$type] + (int)$row['maxplayers'];
//echo $current[$type][current] .' ';
}
$data = json_encode($bots);// <<----------------- add this line
$percent['cur'] = 100 / $total;
$i = 1;
$len = count($current);
?>
</div>
<script type="text/javascript">
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'piechart1',
defaultSeriesType: 'bar'
},
title: {
text: 'Overall Game Type Activity'
},
xAxis: {
categories: [<?php
$graph1Active = '{name:\'Active\', data:[';
$graph1Bots = '{name:\'Bots\', data:[';
$first = true;
foreach(array_keys($current) as $type) {
if (!$first) {
echo ',';
$graph1Active .= ',';
$graph1Bots .= ',';
} else {
$first = false;
}
echo '\''. $gametypes[$type]['longname'] .'\'';
$graph1Active .= $current[$type];
$graph1Bots .= $bots[$type];
}
$graph1Active .= ']}';
$graph1Bots .= ']}';
?>]
},
yAxis: {
min: 0,
title: {
text: 'Players'
}
},
legend: {
backgroundColor: Highcharts.theme.legendBackgroundColorSolid || '#FFFFFF',
reversed: true
},
tooltip: {
formatter: function() {
return ''+
this.series.name +': '+ this.y +'';
}
},
plotOptions: {
series: {
stacking: 'normal'
}
},
series: [<?php echo $graph1Bots; ?>,
<?php echo $graph1Active; ?>]
});
});
</script>
<!--
<div id="piechart2">
<?php
$sql = "SELECT * FROM servers";
$result = mysql_query($sql);
$data = array();
while ($row = mysql_fetch_array($result)) {
$type = $row['type'];
$current[$type]['current'] = $current[$type][current] + (int)$row['currentplayers'];
$current[$type]['max'] = $current[$type][max] + (int)$row['maxplayers'];
$totalcur = $totalcur + (int)$row['currentplayers'];
$totalmax = $totalmax + (int)$row['maxplayers'];
$bots[$type] = $bots[$type] + (int)$row['currentbots'];
$max[$type] = $max[$type] + (int)$row['maxplayers'];
}
$data = json_encode($bots);// <<----------------- add this line
$percentcur = 100 / $totalcur;
$percentmax = 100 / $totalmax;
?>
<script type="text/javascript">
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'piechart2',
margin: [50, 0, 0, 0],
plotBackgroundColor: 'transparent',
plotBorderWidth: null,
backgroundColor : 'transparent',
plotShadow: false
},
title: {
text: 'Maximum Players/Active Players'
},
subtitle: {
text: 'Inner Circle: Maximum Players || Outer Circle: Active Players'
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
this.point.name +': '+ this.y +' %';
}
},
series: [{
// Inner Ring
type: 'pie',
name: 'Maximum Players',
size: '45%',
innerSize: '20%',
data: [
<?
$i = 1;
$len = count($current);
foreach (array_keys($current) as $type) {
$piece = round($current[$type][max] * $percentmax);
// $piece = $current[$type][max];
if ($i != $len) {
echo "['" . $gametypes[$type][longname] . "'," . $piece . "],\n";
} else {
echo "['" . $gametypes[$type][longname] . "'," . $piece . "]\n";
}
$i++;
}
?>
],
dataLabels: {
enabled: false
}
}, {
// Outer Ring
type: 'pie',
name: 'Active Players',
innerSize: '45%',
data: [
<?
$i = 1;
$len = count($current);
foreach (array_keys($current) as $type) {
$piece = round($current[$type][current] * $percentcur);
// echo "$current[$type][current] $percentcur";
// $piece = $current[$type][current];
if ($i != $len) {
echo "['" . $gametypes[$type][longname] . "'," . $piece . "],\n";
} else {
echo "['" . $gametypes[$type][longname] . "'," . $piece . "]\n";
}
$i++;
}
?>
],
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000'
}
}]
});
});
</script>
</div>
<div id="chart3">
<?php
$sql = "SELECT * FROM servers";
$result = mysql_query($sql);
$data = array();
while ($row = mysql_fetch_array($result)) {
$type = $row['type'];
$current[$type]['current'] = $current[$type][current] + (int)$row['currentplayers'];
$current[$type]['max'] = $current[$type][max] + (int)$row['maxplayers'];
$totalcur = $totalcur + (int)$row['currentplayers'];
$totalmax = $totalmax + (int)$row['maxplayers'];
$bots[$type] = $bots[$type] + (int)$row['currentbots'];
$max[$type] = $max[$type] + (int)$row['maxplayers'];
}
$data = json_encode($bots);// <<----------------- add this line
$percentcur = 100 / $totalcur;
$percentmax = 100 / $totalmax;
?>
<script type="text/javascript">
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'chart3',
defaultSeriesType: 'bar'
},
title: {
text: 'Overall Game Type Activity'
},
xAxis: {
<?
$i = 1;
$len = count($current);
echo "categories:[";
foreach (array_keys($current) as $type) {
if ($i != $len) {
echo "'" . $gametypes[$type][longname] . "',\n";
} else {
echo "'" . $gametypes[$type][longname] . "']\n";
}
$i++;
}
?>
//categories: ['1', '2', '3', '4']
},
yAxis: {
<?php
echo "max: " . $totalcur . ",";
?>
//max: 1500,
min: 0,
title: {
text: 'Players'
}
},
legend: {
reversed: true
},
tooltip: {
formatter: function() {
return ''+
this.series.name +': '+ this.y +'';
}
},
plotOptions: {
series: {
stacking: 'normal'
}
},
series: [{
name: 'Bots',
data: [2, 2, 3, 2]
}, {
name: 'Active',
<?php
$j = 1;
$len = count($current);
echo "data:[";
foreach (array_keys($current) as $type) {
if ($j != $len) {
echo $row['currentplayers'] . ",\n";
} else {
echo $row['currentplayers'] . "]\n";
}
$j++;
}
?>
//data: [6, 4, 4, 2]
}]
});
});
</script>
</div>
-->
<?
}
mysql_close();
bottom( $start );
?>