Merge pull request #148 from OpzekerIT/dev

ranks on frontpage
This commit is contained in:
Lanta 2023-11-28 10:03:29 +01:00 committed by GitHub
commit fdb58af8a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 58 additions and 7 deletions

BIN
images/ranks/Bronze-1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 444 KiB

BIN
images/ranks/Bronze-2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 443 KiB

BIN
images/ranks/Bronze-3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 445 KiB

BIN
images/ranks/Bronze-4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 KiB

BIN
images/ranks/Bronze-5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 446 KiB

BIN
images/ranks/Diamond-1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 456 KiB

BIN
images/ranks/Diamond-2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 KiB

BIN
images/ranks/Diamond-3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 KiB

BIN
images/ranks/Diamond-4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 459 KiB

BIN
images/ranks/Diamond-5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 KiB

BIN
images/ranks/Gold-1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 516 KiB

BIN
images/ranks/Gold-2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 498 KiB

BIN
images/ranks/Gold-3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 495 KiB

BIN
images/ranks/Gold-4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 505 KiB

BIN
images/ranks/Gold-5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 KiB

BIN
images/ranks/Master.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 KiB

BIN
images/ranks/Platinum-1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 KiB

BIN
images/ranks/Platinum-2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 KiB

BIN
images/ranks/Platinum-3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 KiB

BIN
images/ranks/Platinum-4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 KiB

BIN
images/ranks/Platinum-5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 312 KiB

BIN
images/ranks/Silver-1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 KiB

BIN
images/ranks/Silver-2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 KiB

BIN
images/ranks/Silver-3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 KiB

BIN
images/ranks/Silver-4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 KiB

BIN
images/ranks/Silver-5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 KiB

BIN
images/ranks/Unranked.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 KiB

View file

@ -13,6 +13,15 @@ body {
-o-background-size: cover; -o-background-size: cover;
background-size: cover; background-size: cover;
} }
.table-image {
max-height: 50px;
max-width: 50px;
width: auto;
height: auto;
display: block;
margin-left: auto;
margin-right: auto;
}
nav { nav {
background: linear-gradient(to right, #FF416C, #FF4B2B); background: linear-gradient(to right, #FF416C, #FF4B2B);

View file

@ -93,14 +93,31 @@ $lastMatches = array_slice($allMatches, 0, 8);
//CLANINFO //CLANINFO
$clanInfoPath = './data/claninfo.json'; $clanInfoPath = './data/claninfo.json';
$clanmembersfile = './config/clanmembers.json'; $clanmembersfile = './config/clanmembers.json';
$rankedfile = './data/player_season_data.json';
$clanmembers = json_decode(file_get_contents($clanmembersfile), true); $clanmembers = json_decode(file_get_contents($clanmembersfile), true);
$playerRanks = json_decode(file_get_contents($rankedfile), true);
if (file_exists($clanInfoPath)) { if (file_exists($clanInfoPath)) {
$clan = json_decode(file_get_contents($clanInfoPath), true); $clan = json_decode(file_get_contents($clanInfoPath), true);
if (isset($clan) && !empty($clan)) { if (isset($clan) && !empty($clan)) {
echo "<table>"; echo "<table>";
echo "<tr><th>Attribute</th><th>Value</th></tr>"; echo "<tr><th>Attribute</th><th>Value</th><th>Rank(FPP SQUAD)</th><th>Points</th></tr>";
foreach ($clanmembers['clanMembers'] as $value) { 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 ($playerRanks as $rank) {
if ($rank['name'] == $value) {
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 . ".png";
$rankPoint = htmlspecialchars($rank['stat']['data']['attributes']['rankedGameModeStats']['squad-fpp']['currentRankPoint']);
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><td><img src='" . $image . "' class='table-image'></td><td>" . $rankPoint . "</td></tr>";
} else {
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><td><img src='./images/ranks/Unranked.png' class='table-image'></td><td></td></tr>";
}
}
}
} }
foreach ($clan as $key => $value) { foreach ($clan as $key => $value) {
if ($key == 'updated') { if ($key == 'updated') {
@ -108,12 +125,11 @@ $lastMatches = array_slice($allMatches, 0, 8);
} }
echo "<tr><td>" . htmlspecialchars($key) . "</td><td>" . htmlspecialchars($value) . "</td></tr>"; echo "<tr><td>" . htmlspecialchars($key) . "</td><td>" . htmlspecialchars($value) . "</td></tr>";
} }
echo "</table>"; echo "</table>";
} else { } else {
echo "<p>No clan attributes available</p>"; echo "<p>No clan attributes available</p>";
} }
} else { } else {
echo "<p>Clan info file missing</p>"; echo "<p>Clan info file missing</p>";
} }

View file

@ -46,12 +46,12 @@ if ($chunk.Count -gt 0) {
} }
$clanMembers = $clanMembersArray -join ',' $clanMembers = $clanMembersArray -join ','
$headers = @{ $headers = @{
'accept' = 'application/vnd.api+json' 'accept' = 'application/vnd.api+json'
'Authorization' = "$apiKey" 'Authorization' = "$apiKey"
} }
$playerinfo = @() $playerinfo = @()
foreach ($key in $clanmemberchunks.keys) { foreach ($key in $clanmemberchunks.keys) {
@ -171,4 +171,30 @@ $lifetimestats['updated'] = $formattedString
$lifetimestats | convertto-json -Depth 100 | out-file "$scriptroot/../data/player_lifetime_data.json" $lifetimestats | convertto-json -Depth 100 | out-file "$scriptroot/../data/player_lifetime_data.json"
remove-lock remove-lock
Stop-Transcript Stop-Transcript
$seasons = Invoke-RestMethod -Uri "https://api.pubg.com/shards/steam/seasons" -Method GET -Headers $headers
$current_season = $seasons.data | Where-Object {$_.attributes.isCurrentSeason -eq $true}
$i = 0
$seasonstats = @()
while($playerinfo.data.Count -gt $i) {
write-host $clanMembersArray[$i]
try{
$rankedstat = Invoke-RestMethod -Uri "https://api.pubg.com/shards/steam/players/$($playerinfo.data[$i].id)/seasons/$($current_season.id)/ranked" -Method GET -Headers $headers
}catch{
write-output 'sleeping for 61 seconds'
start-sleep -Seconds 61
$rankedstat = Invoke-RestMethod -Uri "https://api.pubg.com/shards/steam/players/$($playerinfo.data[$i].id)/seasons/$($current_season.id)/ranked" -Method GET -Headers $headers
}
$seasonstats += [PSCustomObject]@{
stat = $rankedstat
name = $playerinfo.data[$i].attributes.name
}
$i++
}
$seasonstats | convertto-json -Depth 100| Out-File "$scriptroot/../data/player_season_data.json"