AI
This commit is contained in:
parent
1be9732279
commit
01aa843d0b
18 changed files with 4122 additions and 2393 deletions
284
index.php
284
index.php
|
|
@ -1,32 +1,86 @@
|
|||
<?php
|
||||
// --- Configuration and Data Fetching ---
|
||||
$ogDescription = "Welcome to the epicenter of PUBG action! Catch up on the latest matches with detailed stats including player names, match dates, modes, types, maps, kills, and more. Plus, get an inside look at our clan's profile, including member details and key attributes. Stay connected with the pulse of our PUBG community!";
|
||||
|
||||
// Read the JSON file
|
||||
$jsonData = file_get_contents('data/player_matches.json');
|
||||
$playersData = json_decode($jsonData, true);
|
||||
// Include map names mapping
|
||||
include './includes/mapsmap.php'; // Contains the $mapNames array
|
||||
|
||||
// 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;
|
||||
// --- Latest Matches Data ---
|
||||
$matchesJsonPath = 'data/player_matches.json';
|
||||
$lastMatches = [];
|
||||
$matchesError = '';
|
||||
|
||||
if (file_exists($matchesJsonPath)) {
|
||||
$jsonData = file_get_contents($matchesJsonPath);
|
||||
$playersData = json_decode($jsonData, true);
|
||||
|
||||
if (is_array($playersData)) {
|
||||
// Combine matches from all players
|
||||
$allMatches = [];
|
||||
foreach ($playersData as $player) {
|
||||
if (isset($player['player_matches']) && is_array($player['player_matches'])) {
|
||||
foreach ($player['player_matches'] as $match) {
|
||||
$match['playername'] = $player['playername'] ?? 'Unknown'; // Add playername to each match for reference
|
||||
$allMatches[] = $match;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sort matches by createdAt date (descending)
|
||||
usort($allMatches, function ($a, $b) {
|
||||
$timeA = isset($a['createdAt']) ? strtotime($a['createdAt']) : 0;
|
||||
$timeB = isset($b['createdAt']) ? strtotime($b['createdAt']) : 0;
|
||||
return $timeB - $timeA;
|
||||
});
|
||||
|
||||
// Get the last 8 matches
|
||||
$lastMatches = array_slice($allMatches, 0, 8);
|
||||
} else {
|
||||
$matchesError = "Error decoding player matches data.";
|
||||
}
|
||||
} else {
|
||||
$matchesError = "Player matches data file not found.";
|
||||
}
|
||||
|
||||
// Sort matches by createdAt date
|
||||
usort($allMatches, function ($a, $b) {
|
||||
return strtotime($b['createdAt']) - strtotime($a['createdAt']);
|
||||
});
|
||||
// --- Clan Info Data ---
|
||||
$clanInfoPath = './data/claninfo.json';
|
||||
$clanmembersfile = './config/clanmembers.json';
|
||||
$rankedfile = './data/player_season_data.json';
|
||||
|
||||
// Get the last 5 matches
|
||||
$lastMatches = array_slice($allMatches, 0, 8);
|
||||
$clan = null;
|
||||
$playerRanks = null;
|
||||
$clanInfoError = '';
|
||||
|
||||
if (file_exists($clanInfoPath)) {
|
||||
$clanJson = file_get_contents($clanInfoPath);
|
||||
$clan = json_decode($clanJson, true);
|
||||
if (!is_array($clan)) {
|
||||
$clanInfoError = "Error decoding clan info data.";
|
||||
$clan = null;
|
||||
}
|
||||
} else {
|
||||
$clanInfoError = "Clan info file missing.";
|
||||
}
|
||||
|
||||
if (file_exists($rankedfile)) {
|
||||
$rankedJson = file_get_contents($rankedfile);
|
||||
$playerRanks = json_decode($rankedJson, true);
|
||||
if (!is_array($playerRanks)) {
|
||||
$clanInfoError .= " Error decoding player rank data.";
|
||||
$playerRanks = null;
|
||||
}
|
||||
} else {
|
||||
$clanInfoError .= " Player rank file missing.";
|
||||
}
|
||||
|
||||
// Note: $clanmembers is read but not used directly in this refactored version's display logic.
|
||||
// If needed elsewhere, ensure file_exists check is added.
|
||||
// $clanmembers = file_exists($clanmembersfile) ? json_decode(file_get_contents($clanmembersfile), true) : null;
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<?php include './includes/head.php'; ?>
|
||||
<?php include './includes/head.php'; // Includes $ogDescription ?>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
|
|
@ -36,100 +90,124 @@ $lastMatches = array_slice($allMatches, 0, 8);
|
|||
<main>
|
||||
<section>
|
||||
<h2>Latest Matches</h2>
|
||||
|
||||
<table>
|
||||
|
||||
<tr>
|
||||
<th>Player Name</th>
|
||||
<th>Match Date</th>
|
||||
<th>Mode</th>
|
||||
<th>Type</th>
|
||||
<th>Map</th>
|
||||
<th>Kills</th>
|
||||
<th>Damage</th>
|
||||
<th>Place</th>
|
||||
</tr>
|
||||
|
||||
|
||||
<?php
|
||||
include './includes/mapsmap.php';
|
||||
|
||||
|
||||
foreach ($lastMatches as $match) {
|
||||
$matchid = $match['id'];
|
||||
$date = new DateTime($match['createdAt']);
|
||||
$date->modify('+1 hours');
|
||||
$formattedDate = $date->format('m-d H:i:s');
|
||||
echo "<tr>
|
||||
|
||||
<td><a href='matchinfo.php?matchid=$matchid'>" . $match['playername'] . "</a></td>
|
||||
<td><a href='matchinfo.php?matchid=$matchid'>" . $formattedDate . "</a></td>
|
||||
<td><a href='matchinfo.php?matchid=$matchid'>" . $match['gameMode'] . "</a></td>
|
||||
<td><a href='matchinfo.php?matchid=$matchid'>" . $match['matchType'] . "</a></td>
|
||||
<td><a href='matchinfo.php?matchid=$matchid'>" . (isset($mapNames[$match['mapName']]) ? $mapNames[$match['mapName']] : $match['mapName']) . "</a></td>
|
||||
<td><a href='matchinfo.php?matchid=$matchid'>" . $match['stats']['kills'] . "</a></td>
|
||||
<td><a href='matchinfo.php?matchid=$matchid'>" . number_format($match['stats']['damageDealt'], 0, '.', '') . "</a></td>
|
||||
<td><a href='matchinfo.php?matchid=$matchid'>" . $match['stats']['winPlace'] . "</a></td>
|
||||
|
||||
</tr>";
|
||||
} ?>
|
||||
|
||||
</table>
|
||||
<h2>Clan Info</h2>
|
||||
<?php
|
||||
|
||||
|
||||
//CLANINFO
|
||||
$clanInfoPath = './data/claninfo.json';
|
||||
$clanmembersfile = './config/clanmembers.json';
|
||||
$rankedfile = './data/player_season_data.json';
|
||||
$clanmembers = json_decode(file_get_contents($clanmembersfile), true);
|
||||
$playerRanks = json_decode(file_get_contents($rankedfile), true);
|
||||
if (file_exists($clanInfoPath)) {
|
||||
$clan = json_decode(file_get_contents($clanInfoPath), true);
|
||||
if (isset($clan) && !empty($clan)) {
|
||||
echo "<table class='sortable'>";
|
||||
echo "<tr><th>Attribute</th><th>Value</th><th>Rank(FPP SQUAD)</th><th>Points</th></tr>";
|
||||
|
||||
foreach ($playerRanks as $rank) {
|
||||
|
||||
$playername = $rank['name'];
|
||||
if (isset($rank['stat']['data']['attributes']['rankedGameModeStats']['squad-fpp'])) {
|
||||
$tier = $rank['stat']['data']['attributes']['rankedGameModeStats']['squad-fpp']['currentTier']['tier'];
|
||||
$subTier = $rank['stat']['data']['attributes']['rankedGameModeStats']['squad-fpp']['currentTier']['subTier'];
|
||||
$image = "./images/ranks/" . $tier . "-" . $subTier . ".webp";
|
||||
$rankPoint = htmlspecialchars($rank['stat']['data']['attributes']['rankedGameModeStats']['squad-fpp']['currentRankPoint']);
|
||||
echo "<tr><td><a href='latestmatches.php?selected_player=" . htmlspecialchars($playername) . "'>name</a></td><td><a href='latestmatches.php?selected_player=" . htmlspecialchars($playername) . "'>" . htmlspecialchars($playername) . "</a></td><td><img src='" . $image . "' class='table-image' alt='$tier'></td><td>" . $rankPoint . "</td></tr>";
|
||||
} else {
|
||||
echo "<tr><td><a href='latestmatches.php?selected_player=" . htmlspecialchars($playername) . "'>name</a></td><td><a href='latestmatches.php?selected_player=" . htmlspecialchars($playername) . "'>" . htmlspecialchars($playername) . "</a></td><td><img src='./images/ranks/Unranked.webp' class='table-image' alt='$tier'></td><td></td></tr>";
|
||||
<?php if ($matchesError): ?>
|
||||
<p style="color: red;"><?php echo htmlspecialchars($matchesError); ?></p>
|
||||
<?php elseif (empty($lastMatches)): ?>
|
||||
<p>No recent matches found.</p>
|
||||
<?php else: ?>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Player Name</th>
|
||||
<th>Match Date</th>
|
||||
<th>Mode</th>
|
||||
<th>Type</th>
|
||||
<th>Map</th>
|
||||
<th>Kills</th>
|
||||
<th>Damage</th>
|
||||
<th>Place</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($lastMatches as $match):
|
||||
$matchid = htmlspecialchars($match['id'] ?? '');
|
||||
$playerName = htmlspecialchars($match['playername'] ?? 'N/A');
|
||||
$gameMode = htmlspecialchars($match['gameMode'] ?? 'N/A');
|
||||
$matchType = htmlspecialchars($match['matchType'] ?? 'N/A');
|
||||
$mapNameRaw = $match['mapName'] ?? 'N/A';
|
||||
$mapName = htmlspecialchars(isset($mapNames[$mapNameRaw]) ? $mapNames[$mapNameRaw] : $mapNameRaw);
|
||||
$kills = htmlspecialchars($match['stats']['kills'] ?? 'N/A');
|
||||
$damageDealt = isset($match['stats']['damageDealt']) ? number_format($match['stats']['damageDealt'], 0, '.', '') : 'N/A';
|
||||
$winPlace = htmlspecialchars($match['stats']['winPlace'] ?? 'N/A');
|
||||
$createdAt = $match['createdAt'] ?? null;
|
||||
$formattedDate = 'N/A';
|
||||
if ($createdAt) {
|
||||
try {
|
||||
$date = new DateTime($createdAt);
|
||||
$date->modify('+1 hours'); // Adjust timezone or add offset as needed
|
||||
$formattedDate = $date->format('m-d H:i:s');
|
||||
} catch (Exception $e) {
|
||||
$formattedDate = 'Invalid Date';
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="matchinfo.php?matchid=<?php echo $matchid; ?>"><?php echo $playerName; ?></a></td>
|
||||
<td><a href="matchinfo.php?matchid=<?php echo $matchid; ?>"><?php echo $formattedDate; ?></a></td>
|
||||
<td><a href="matchinfo.php?matchid=<?php echo $matchid; ?>"><?php echo $gameMode; ?></a></td>
|
||||
<td><a href="matchinfo.php?matchid=<?php echo $matchid; ?>"><?php echo $matchType; ?></a></td>
|
||||
<td><a href="matchinfo.php?matchid=<?php echo $matchid; ?>"><?php echo $mapName; ?></a></td>
|
||||
<td><a href="matchinfo.php?matchid=<?php echo $matchid; ?>"><?php echo $kills; ?></a></td>
|
||||
<td><a href="matchinfo.php?matchid=<?php echo $matchid; ?>"><?php echo $damageDealt; ?></a></td>
|
||||
<td><a href="matchinfo.php?matchid=<?php echo $matchid; ?>"><?php echo $winPlace; ?></a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Clan Info</h2>
|
||||
<?php if ($clanInfoError && !$clan && !$playerRanks): ?>
|
||||
<p style="color: red;"><?php echo htmlspecialchars(trim($clanInfoError)); ?></p>
|
||||
<?php else: ?>
|
||||
<?php if ($clanInfoError): // Show non-fatal errors ?>
|
||||
<p style="color: orange;"><?php echo htmlspecialchars(trim($clanInfoError)); ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
}
|
||||
|
||||
foreach ($clan as $key => $value) {
|
||||
if ($key == 'updated') {
|
||||
continue;
|
||||
}
|
||||
echo "<tr><td>" . htmlspecialchars($key) . "</td><td>" . htmlspecialchars($value) . "</td><td></td><td></td></tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
} else {
|
||||
echo "<p>No clan attributes available</p>";
|
||||
}
|
||||
|
||||
} else {
|
||||
echo "<p>Clan info file missing</p>";
|
||||
}
|
||||
?>
|
||||
<?php if (isset($clan) && !empty($clan)): ?>
|
||||
<table class="sortable">
|
||||
<thead>
|
||||
<tr><th>Attribute</th><th>Value</th><th>Rank (FPP SQUAD)</th><th>Points</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (isset($playerRanks) && is_array($playerRanks)): ?>
|
||||
<?php foreach ($playerRanks as $rank):
|
||||
$playername = htmlspecialchars($rank['name'] ?? 'N/A');
|
||||
$playerLink = 'latestmatches.php?selected_player=' . urlencode($rank['name'] ?? '');
|
||||
$tier = 'Unranked';
|
||||
$subTier = '';
|
||||
$image = './images/ranks/Unranked.webp';
|
||||
$rankPoint = '';
|
||||
|
||||
if (isset($rank['stat']['data']['attributes']['rankedGameModeStats']['squad-fpp'])) {
|
||||
$squadFppStats = $rank['stat']['data']['attributes']['rankedGameModeStats']['squad-fpp'];
|
||||
$tier = htmlspecialchars($squadFppStats['currentTier']['tier'] ?? 'N/A');
|
||||
$subTier = htmlspecialchars($squadFppStats['currentTier']['subTier'] ?? '');
|
||||
$image = "./images/ranks/" . $tier . "-" . $subTier . ".webp";
|
||||
$rankPoint = htmlspecialchars($squadFppStats['currentRankPoint'] ?? '');
|
||||
}
|
||||
$altText = $tier . ($subTier ? '-' . $subTier : '');
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="<?php echo $playerLink; ?>">name</a></td>
|
||||
<td><a href="<?php echo $playerLink; ?>"><?php echo $playername; ?></a></td>
|
||||
<td><img src="<?php echo htmlspecialchars($image); ?>" class="table-image" alt="<?php echo htmlspecialchars($altText); ?>"></td>
|
||||
<td><?php echo $rankPoint; ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php foreach ($clan as $key => $value):
|
||||
if ($key == 'updated') continue; // Skip updated timestamp
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo htmlspecialchars($key); ?></td>
|
||||
<td><?php echo htmlspecialchars(is_scalar($value) ? $value : json_encode($value)); ?></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php elseif (!$clanInfoError): // Only show if no error message was already displayed ?>
|
||||
<p>No clan attributes available.</p>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
|
||||
<?php include './includes/footer.php'; ?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue