This repository was archived by the owner on Aug 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstatistics.php
More file actions
110 lines (104 loc) · 4.88 KB
/
statistics.php
File metadata and controls
110 lines (104 loc) · 4.88 KB
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
<?php
/**
* Name: statistics.php (create.php on official server)
* Creator: 101601828
* Version: v1.0
* Description: A web script designed to handle the POST
* request sent by the War program when a match ends if
* web statistics were enabled and configured correctly.
*/
include_once('help.php'); // Include the color-code-to-font-color converter.
$secret = $_POST['secret']; // Get the secret phrase from POST.
if ($secret != "your_secret_here") return; // Don't run the script if the secret doesn't match.
$stats = json_decode($_POST['stats'], true); // Decode the JSON body of the message into nested arrays.
ob_start(); // Start recording with the buffer.
?><!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Match Report <?php echo $stats['matchid']; // e.g. 15 ?></title>
<meta name="description" content="<?php echo $stats['matchid']; ?>">
<meta name="author" content="Skyuh">
<link rel="stylesheet" href="../assets/css/match.css">
<link rel="stylesheet" href="../assets/css/mc_color.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway">
<!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<article class="s800 dark525">
<header>
<h1>Match Report <?php echo $stats['matchid']; ?></h1>
</header>
<hr/>
<br/>
<section id="match" class="contentContainer">
<h3>Match Information:</h3>
<section class="matchInfoContainer left">
<h5><b>Map: </b> <?php echo $stats['mapname']; // e.g. Test Map 1 ?></h5>
<h5><b>Gamemode: </b> <?php echo $stats['gamemode']; // e.g. King of The Hill ?></h5>
<h5><b>Duration: </b> <?php echo $stats['duration']; // e.g. 06:26 ?></h5>
<h5><b>Played On: </b> <?php echo $stats['date']; // e.g. 12/12/16 ?></h5>
<h5><b>Winner: </b> <?php echo MineToWeb($stats['winner']); // e.g. Red Team ?></h5>
</section>
<section class="matchInfoContainer right">
<h5><b>Total Kills: </b> <?php echo $stats['totalkills']; // e.g. 15 ?></h5>
<h5><b>Total Deaths: </b> <?php echo $stats['totaldeaths']; // e.g. 26 ?></h5>
<h5><b>Environmental Deaths: </b> <?php echo $stats['envdeaths']; // e.g. 3 ?></h5>
<h5><b>Kills per Minute: </b> <?php echo $stats['kpm']; // e.g. 4.25 ?></h5>
</section>
</section>
<hr class="clear"/>
<br/>
<section id="teams" class="contentContainer">
<h3>Team Information:</h3>
<?php
$i = 0; // Current index is even.
// Odd i values are put on the left, and even i values are put on the right.
foreach ($stats['teams'] as $key => $val) { // For every value in the 'teams' array as $key and $val.
$i++; // Increment.
?>
<section
class="teamStatsContainer <?php echo "" . ($i % 2 == 0 ? "right" : "left"); // Layout properly. ?>">
<h4><b><strong><?php echo MineToWeb($val['color'] . $key) // Return the team name and color. ?></strong>:</b>
</h4>
<h5><b>Kills:</b> <?php echo $val['kills']; // The amount of kills this team got. ?></h5>
<h5><b>Deaths:</b> <?php echo $val['deaths']; // The amount of deaths this team had. ?></h5>
<h5><b>Players:</b> <?php echo $val['players']; // The amount of end-match participants on this team. ?>
</h5>
<?php
foreach ($val['extra'] as $key2 => $val2) // For every value in the extra data array as $key2 and $val2.
echo MineToWeb("<h5><b>" . $key2 . ":</b> " . $val2 . "</h5>"); // Display each of them on the bottom.
?>
</section>
<?php
}
?>
</section>
<hr class="clear"/>
<br/>
<section id="events" class="contentContainer">
<h3>Event Log:</h3>
<?php
// Echo out every event in the array as its own line, format it using color codes.
foreach ($stats['events'] as $event)
echo "<h5>" . MineToWeb($event) . "</h5>";
?>
</section>
<hr class="clear"/>
<br>
<footer class="contentContainer">
<h5 style="text-align: center">This static page was generated by War.</h5>
</footer>
</article>
</body>
</html>
<?php
$content = ob_get_contents(); // Get the content of the buffer, which is what was generated above.
ob_end_clean(); // End the buffer, we're done.
file_put_contents("match" . $stats['matchid'] . ".html", $content);
// Put the content generated by this page in its own html page.
// The official usage of this script uses a htaccess regex to format links.
// For example, match 3 would be accessible at https://rpg.solar/match/3.
?>