-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatchinfo.php
More file actions
208 lines (172 loc) · 10.4 KB
/
matchinfo.php
File metadata and controls
208 lines (172 loc) · 10.4 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
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
<?php
$ogDescription = "Get in-depth insights into recent PUBG matches. Discover detailed match information including player stats, game modes, match types, and map names. Updated regularly to provide the latest and most comprehensive match data for PUBG enthusiasts.";
?>
<?php
// Read the JSON file
$jsonData = file_get_contents('data/player_matches.json');
$playersData = json_decode($jsonData, true);
// Combine matches from all players
$allMatches = [];
foreach ($playersData as $player) {
foreach ($player['player_matches'] as $match) {
$match['playername'] = $player['playername']; // Add playername to each match for reference
$allMatches[] = $match;
}
}
// Sort matches by createdAt date
usort($allMatches, function ($a, $b) {
return strtotime($b['createdAt']) - strtotime($a['createdAt']);
});
// Get the last 5 matches
$lastMatches = array_slice($allMatches, 0, 8);
?>
<!DOCTYPE html>
<html lang="en">
<?php include './includes/head.php'; ?>
<body>
<?php
include './includes/navigation.php';
include './includes/header.php';
?>
<main>
<section>
<h2>Match info</h2>
<?php
include './includes/mapsmap.php';
// Check if a match ID is provided in the GET request
if (isset($_GET['matchid'])) {
$matchId = $_GET['matchid'];
$filename = "data/matches/" . $matchId . ".json";
// Check if the JSON file for the given match ID exists
if (file_exists($filename)) {
// Read and decode the JSON file
$jsonData = json_decode(file_get_contents($filename), true);
$matchinfo = $jsonData['data']['attributes'];
$matchdata = $jsonData['data'];
echo "<table class='sortable'><tr><th>matchType</th><th>gameMode</th><th>duration</th><th>mapName</th><th>createdAt</th><th>id</th></tr>";
echo "<tr>";
echo "<td>" . htmlspecialchars($matchinfo['matchType']) . "</td>";
echo "<td>" . htmlspecialchars($matchinfo['gameMode']) . "</td>";
echo "<td>" . htmlspecialchars($matchinfo['duration']) . "</td>";
echo "<td>" . htmlspecialchars(isset($mapNames[$matchinfo['mapName']]) ? $mapNames[$matchinfo['mapName']] : $matchinfo['mapName']) . "</td>";
echo "<td>" . htmlspecialchars($matchinfo['createdAt']) . "</td>";
echo "<td>" . htmlspecialchars($matchdata['id']) . "</td>";
echo "</tr>";
echo "</table>";
$directory = 'data/killstats/';
$prefix = $matchdata['id'];
$files = glob($directory . $prefix . '*');
if (count($files) == 0) {
// Get current time
$currentTime = new DateTime();
$minutes = intval($currentTime->format('i'));
// Calculate minutes to next update
$minutesToNextUpdate = 30 - ($minutes % 30);
if ($minutesToNextUpdate === 30) {
// If it's exactly on the hour or half-hour, set the next update to 30 minutes
$minutesToNextUpdate = 0;
}
// Display the message
if ($minutesToNextUpdate > 0) {
echo "Check back in $minutesToNextUpdate minutes. Data is updated every half hour.";
} else {
echo "Data is updating, please check back shortly.";
}
} else {
echo "<table class='sortable'>";
echo "<tr>
<th>Player Name</th>
<th>humankills</th>
<th>HumanDmg </th>
<th>Kills</th>
<th>Total Damage</th>
<th>Rank</th>
<th>DBNOs</th>
</tr>";
foreach ($files as $file) {
$jsonData_individual_player = json_decode(file_get_contents($file), true);
$individualPlayerName = $jsonData_individual_player['stats']['playername'];
// Search for the player in $jsonData['included'] to find damageDealt
$damageDealt = 0;
foreach ($jsonData['included'] as $includedItem) {
if ($includedItem['type'] == "participant") {
$playerStats = $includedItem['attributes']['stats'];
if ($individualPlayerName == $playerStats['name']) {
$damageDealt = $playerStats['damageDealt'];
$rank = $playerStats['winPlace'];
$DBNOs = $playerStats['DBNOs'];
break;
}
}
}
echo "<tr>";
echo "<td>" . htmlspecialchars($individualPlayerName) . "</td>";
echo "<td>" . htmlspecialchars($jsonData_individual_player['stats']['humankills']) . "</td>";
echo "<td>" . htmlspecialchars($jsonData_individual_player['stats']['HumanDmg']) . "</td>";
echo "<td>" . htmlspecialchars($jsonData_individual_player['stats']['kills']) . "</td>";
echo "<td>" . htmlspecialchars($damageDealt) . "</td>";
echo "<td>" . htmlspecialchars($rank) . "</td>";
echo "<td>" . htmlspecialchars($DBNOs) . "</td>";
echo "</tr>";
}
echo "</table>";
}
echo "<table class='sortable'>";
echo "<tr>
<th>Player Name</th>
<th>Sort</th>
<th>Kills</th>
<th>Damage Dealt</th>
<th>Time Survived</th>
<th>Rank</th>
<th>Revs</th>
<th>DBNOs</th>
<th>Assists</th>
</tr>";
foreach ($jsonData['included'] as $includedItem) {
if ($includedItem['type'] == "participant") {
$playerStats = $includedItem['attributes']['stats'];
if (substr($playerStats['playerId'], 0, 2) !== 'ai') {
// Create links for each stat
echo "<tr>";
echo "<td><a href='https://www.pubg-meta.com/player-stats/steam/" . urlencode($playerStats['name']) . "' target='_blank'>" . htmlspecialchars($playerStats['name']) . "</a></td>";
echo "<td><a href='https://www.pubg-meta.com/player-stats/steam/" . urlencode($playerStats['name']) . "' target='_blank'> Human </a></td>";
echo "<td><a href='https://www.pubg-meta.com/player-stats/steam/" . urlencode($playerStats['name']) . "' target='_blank'>" . htmlspecialchars($playerStats['kills']) . "</a></td>";
echo "<td><a href='https://www.pubg-meta.com/player-stats/steam/" . urlencode($playerStats['name']) . "' target='_blank'>" . htmlspecialchars($playerStats['HumanDmg']) . "</a></td>";
echo "<td><a href='https://www.pubg-meta.com/player-stats/steam/" . urlencode($playerStats['name']) . "' target='_blank'>" . htmlspecialchars($playerStats['timeSurvived']) . "</a></td>";
echo "<td><a href='https://www.pubg-meta.com/player-stats/steam/" . urlencode($playerStats['name']) . "' target='_blank'>" . htmlspecialchars($playerStats['winPlace']) . "</a></td>";
echo "<td><a href='https://www.pubg-meta.com/player-stats/steam/" . urlencode($playerStats['name']) . "' target='_blank'>" . htmlspecialchars($playerStats['revives']) . "</a></td>";
echo "<td><a href='https://www.pubg-meta.com/player-stats/steam/" . urlencode($playerStats['name']) . "' target='_blank'>" . htmlspecialchars($playerStats['DBNOs']) . "</a></td>";
echo "<td><a href='https://www.pubg-meta.com/player-stats/steam/" . urlencode($playerStats['name']) . "' target='_blank'>" . htmlspecialchars($playerStats['assists']) . "</a></td>";
echo "</tr>";
} else {
// Display without link
echo "<tr>";
echo "<td>" . htmlspecialchars($playerStats['name']) . "</td>";
echo "<td>Bot</a></td>";
echo "<td>" . htmlspecialchars($playerStats['kills']) . "</td>";
echo "<td>" . htmlspecialchars($playerStats['damageDealt']) . "</td>";
echo "<td>" . htmlspecialchars($playerStats['timeSurvived']) . "</td>";
echo "<td>" . htmlspecialchars($playerStats['winPlace']) . "</td>";
echo "<td>" . htmlspecialchars($playerStats['revives']) . "</td>";
echo "<td>" . htmlspecialchars($playerStats['DBNOs']) . "</td>";
echo "<td>" . htmlspecialchars($playerStats['headshotKills']) . "</td>";
echo "<td>" . htmlspecialchars($playerStats['assists']) . "</td>";
echo "</tr>";
}
}
}
echo "</table>";
} else {
echo "JSON file not found for the given match ID.";
}
} else {
echo "No match ID provided.";
}
?>
</table>
</section>
</main>
<?php include './includes/footer.php'; ?>
</body>
</html>