New features #124

Merged
OpzekerIT merged 12 commits from dev into main 2023-11-16 13:57:48 +00:00
5 changed files with 94 additions and 100 deletions

View file

@ -1,48 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<?php include './includes/head.php'; ?>
<body>
<?php include './includes/navigation.php'; ?>
<header>
<img src="./images/banner2.png" alt="banner" class="banner">
</header>
<main>
<section>
<h2>Clan Stats</h2>
<?php
include './config/config.php';
// Load clan data from claninfo.json
$clanInfoPath = './data/claninfo.json';
$clanmembersfile = './config/clanmembers.json';
$clanmembers = json_decode(file_get_contents($clanmembersfile), true);
if (file_exists($clanInfoPath)) {
$clan = json_decode(file_get_contents($clanInfoPath), true);
if (isset($clan) && !empty($clan)) {
echo "<table>";
echo "<tr><th>Attribute</th><th>Value</th></tr>";
foreach ($clan as $key => $value) {
echo "<tr><td>" . htmlspecialchars($key) . "</td><td>" . htmlspecialchars($value) . "</td></tr>";
}
foreach ($clanmembers['clanMembers'] as $value) {
echo "<tr><td><a href='latestmatches.php?selected_player=" . htmlspecialchars($value) . "'>name</a></td><td><a href='latestmatches.php?selected_player=" . htmlspecialchars($value) . "'>" . htmlspecialchars($value) . "</a></td></tr>";
}
echo "</table>";
} else {
echo "<p>No clan attributes available</p>";
}
} else {
echo "<p>Clan info file missing</p>";
}
?>
</section>
</main>
<?php include './includes/footer.php'; ?>
</body>
</html>

View file

@ -9,7 +9,6 @@ if ($host == 'dev.dtch.online') {
<a href="index.php" class="active">Home</a> <a href="index.php" class="active">Home</a>
<div id="myLinks"> <div id="myLinks">
<a href="clan_stats.php">Clan Stats</a>
<a href="user_stats.php">User Stats</a> <a href="user_stats.php">User Stats</a>
<a href="topstats.php">Top10</a> <a href="topstats.php">Top10</a>
<a href="topstatsavg.php">Match % T10</a> <a href="topstatsavg.php">Match % T10</a>

View file

@ -13,7 +13,7 @@ foreach ($playersData as $player) {
} }
// Sort matches by createdAt date // Sort matches by createdAt date
usort($allMatches, function($a, $b) { usort($allMatches, function ($a, $b) {
return strtotime($b['createdAt']) - strtotime($a['createdAt']); return strtotime($b['createdAt']) - strtotime($a['createdAt']);
}); });
@ -25,19 +25,20 @@ $lastMatches = array_slice($allMatches, 0, 8);
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<?php include './includes/head.php'; ?> <?php include './includes/head.php'; ?>
<body> <body>
<?php include './includes/navigation.php'; ?> <?php include './includes/navigation.php'; ?>
<header> <header>
<img src="./images/banner2.png" alt="banner" class="banner"> <img src="./images/banner2.png" alt="banner" class="banner">
</header> </header>
<main> <main>
<section> <section>
<h2>Latest Matches</h2> <h2>Latest Matches</h2>
<table> <table>
<thead>
<tr> <tr>
<!-- <th>Match Date</th> --> <!-- <th>Match Date</th> -->
<th>Player Name</th> <th>Player Name</th>
@ -48,8 +49,8 @@ $lastMatches = array_slice($allMatches, 0, 8);
<th>Damage</th> <th>Damage</th>
<th>Place</th> <th>Place</th>
</tr> </tr>
</thead>
<tbody>
<?php <?php
$mapNames = array( $mapNames = array(
"Baltic_Main" => "Erangel", "Baltic_Main" => "Erangel",
@ -65,7 +66,7 @@ $lastMatches = array_slice($allMatches, 0, 8);
"Tiger_Main" => "Taego" "Tiger_Main" => "Taego"
); );
foreach($lastMatches as $match) { foreach ($lastMatches as $match) {
$matchid = $match['id']; $matchid = $match['id'];
echo "<tr> echo "<tr>
@ -79,15 +80,47 @@ $lastMatches = array_slice($allMatches, 0, 8);
</tr>"; </tr>";
} ?> } ?>
</tbody>
</table>
</table>
<h2>Clan Info</h2>
<?php
//CLANINFO
$clanInfoPath = './data/claninfo.json';
$clanmembersfile = './config/clanmembers.json';
$clanmembers = json_decode(file_get_contents($clanmembersfile), true);
if (file_exists($clanInfoPath)) {
$clan = json_decode(file_get_contents($clanInfoPath), true);
if (isset($clan) && !empty($clan)) {
echo "<table>";
echo "<tr><th>Attribute</th><th>Value</th></tr>";
foreach ($clanmembers['clanMembers'] as $value) {
echo "<tr><td><a href='latestmatches.php?selected_player=" . htmlspecialchars($value) . "'>name</a></td><td><a href='latestmatches.php?selected_player=" . htmlspecialchars($value) . "'>" . htmlspecialchars($value) . "</a></td></tr>";
}
foreach ($clan as $key => $value) {
if($key == 'updated'){
continue;
}
echo "<tr><td>" . htmlspecialchars($key) . "</td><td>" . htmlspecialchars($value) . "</td></tr>";
}
echo "</table>";
} else {
echo "<p>No clan attributes available</p>";
}
} else {
echo "<p>Clan info file missing</p>";
}
?>
</section> </section>
</main> </main>
<?php include './includes/footer.php'; ?> <?php include './includes/footer.php'; ?>
</body> </body>
</html> </html>

View file

@ -24,10 +24,19 @@
echo "<button type='submit' name='selected_player' value='$player_name' class='btn'>$player_name</button>"; echo "<button type='submit' name='selected_player' value='$player_name' class='btn'>$player_name</button>";
} }
} }
echo "</form><br>"; echo "</form><br>";
$selected_player = $_GET['selected_player'] ?? $players_matches[0]['playername']; $selected_player = $_GET['selected_player'] ?? $players_matches[0]['playername'];
echo "<form method='get' action=''>
<input type='submit' name='filter_by_match_type' value='all' class='btn'>
<input type='submit' name='filter_by_match_type' value='airoyale' class='btn'>
<input type='submit' name='filter_by_match_type' value='official' class='btn'>
<input type='submit' name='filter_by_match_type' value='custom' class='btn'>
<input type='submit' name='filter_by_match_type' value='event' class='btn'>
<input type='hidden' name='selected_player' value='$selected_player'>
</form><br>";
$mapNames = array( $mapNames = array(
"Baltic_Main" => "Erangel", "Baltic_Main" => "Erangel",
"Chimera_Main" => "Paramo", "Chimera_Main" => "Paramo",
@ -50,10 +59,11 @@
echo "<tr><th>Match Date</th><th>Game Mode</th><th>Match Type</th><th>Map</th><th>Kills</th><th>Damage Dealt</th><th>Time Survived</th><th>win Place</th></tr>"; echo "<tr><th>Match Date</th><th>Game Mode</th><th>Match Type</th><th>Map</th><th>Kills</th><th>Damage Dealt</th><th>Time Survived</th><th>win Place</th></tr>";
foreach ($player_data['player_matches'] as $match) { foreach ($player_data['player_matches'] as $match) {
if (isset($_GET['filter_by_match_type'])) { if (isset($_GET['filter_by_match_type'])) {
if ($match['matchType'] !== $_GET['filter_by_match_type']) { if ($_GET['filter_by_match_type'] !== 'all' && $match['matchType'] !== $_GET['filter_by_match_type']) {
continue; continue;
} }
} }
$date = new DateTime($match['createdAt']); $date = new DateTime($match['createdAt']);
$date->modify('+2 hours'); $date->modify('+2 hours');

View file

@ -20,10 +20,10 @@ error_reporting(E_ALL);
include './config/config.php'; include './config/config.php';
$players_data = json_decode(file_get_contents('./data/player_lifetime_data.json'), true); $players_data = json_decode(file_get_contents('./data/player_lifetime_data.json'), true);
$selected_mode = isset($_POST['game_mode']) ? $_POST['game_mode'] : 'squad'; $selected_mode = isset($_GET['game_mode']) ? $_GET['game_mode'] : 'squad';
// Form to select game mode // Form to select game mode
echo "<form method='post' action=''> echo "<form method='get' action=''>
<input type='submit' name='game_mode' value='solo' class='btn'> <input type='submit' name='game_mode' value='solo' class='btn'>
<input type='submit' name='game_mode' value='duo' class='btn'> <input type='submit' name='game_mode' value='duo' class='btn'>
<input type='submit' name='game_mode' value='squad' class='btn'> <input type='submit' name='game_mode' value='squad' class='btn'>