Update data with cron to prevent api rate limiting

This commit is contained in:
Lanta 2023-09-21 15:12:13 +02:00
parent d1ea67e18c
commit 5b15fddfe9
8 changed files with 1006 additions and 122 deletions

View file

@ -1,7 +1,6 @@
# DTCH - PUBG Clan User Stats # DTCH - PUBG Clan User Stats
This project displays the user statistics for members of the DTCH PUBG Clan. This project displays the user statistics for members of the DTCH PUBG Clan. While the code is tailored for the DTCH clan, you can modify it to suit your specific clan or needs.
While the code is tailored for the DTCH clan, you can modify it to suit your specific clan or needs.
## Features ## Features
@ -12,18 +11,17 @@ While the code is tailored for the DTCH clan, you can modify it to suit your spe
- PHP 7.4 or higher - PHP 7.4 or higher
- cURL extension for PHP - cURL extension for PHP
- PowerShell installed on your system
## Installation ## Installation
1. Clone this repository: 1. Clone this repository:
\`\`\`
git clone [repository-url] git clone [repository-url]
\`\`\`
2. Navigate to the project directory: 2. Navigate to the project directory:
\`\`\`
cd [project-directory] cd [project-directory]
\`\`\`
3. Rename the `config/config.php.rename` to `config/config.php`. 3. Rename the `config/config.php.rename` to `config/config.php`.
@ -31,14 +29,11 @@ While the code is tailored for the DTCH clan, you can modify it to suit your spe
5. Host the project on a PHP server (like Apache). 5. Host the project on a PHP server (like Apache).
6. Access the `user_stats.php` in your browser to view the stats.
## Usage ## Usage
1. Select a game mode to view stats (solo, duo, squad). 1. Use the PowerShell scripts in the `update` folder to generate the JSON files that are used in the clan and user PHP files.
2. Choose a clan member to view their specific stats. - `update_clan_member.ps1`: Update this once every 30 minutes. It's recommended to set up a cron job or scheduled task for this.
3. The rate limit headers for the PUBG API are displayed at the top. - `update_clan.ps1`: Update this once every day.
4. Modify the PHP files to adjust them to your requirements.
## Notes ## Notes
@ -49,4 +44,3 @@ While the code is tailored for the DTCH clan, you can modify it to suit your spe
## License ## License
This project is open-source. Feel free to modify and distribute as per your needs. This project is open-source. Feel free to modify and distribute as per your needs.
\`\`\`

View file

@ -4,8 +4,6 @@ ini_set('display_startup_errors', 1);
error_reporting(E_ALL); error_reporting(E_ALL);
?> ?>
<?php //include './includes/ratelimiter.php'; ?>
#
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
@ -25,31 +23,23 @@ error_reporting(E_ALL);
<?php <?php
include './config/config.php'; include './config/config.php';
$url = "https://api.pubg.com/shards/steam/clans/$clanid"; // Load clan data from claninfo.json
$headers = array( $clanInfoPath = './data/claninfo.json';
'Authorization: Bearer ' . $apiKey, if (file_exists($clanInfoPath)) {
'Accept: application/vnd.api+json' $clan = json_decode(file_get_contents($clanInfoPath), true);
); if (isset($clan) && !empty($clan)) {
echo "<table>";
$ch = curl_init(); echo "<tr><th>Attribute</th><th>Value</th></tr>";
curl_setopt($ch, CURLOPT_URL, $url); foreach ($clan as $key => $value) {
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); echo "<tr><td>" . htmlspecialchars($key) . "</td><td>" . htmlspecialchars($value) . "</td></tr>";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); }
$response = curl_exec($ch); echo "</table>";
curl_close($ch); } else {
$clan = json_decode($response, true); echo "<p>No clan attributes available</p>";
if (isset($clan['data']['attributes'])) {
echo "<table>";
echo "<tr><th>Attribute</th><th>Value</th></tr>";
foreach ($clan['data']['attributes'] as $key => $value) {
echo "<tr><td>" . htmlspecialchars($key) . "</td><td>" . htmlspecialchars($value) . "</td></tr>";
} }
echo "</table>";
} else { } else {
echo "<p>No clan attributes available</p>"; echo "<p>Clan info file missing</p>";
} }
?> ?>
</section> </section>
</main> </main>

6
data/claninfo.json Normal file
View file

@ -0,0 +1,6 @@
{
"clanLevel": 6,
"clanMemberCount": 12,
"clanName": "ChickenWingMen",
"clanTag": "DTCH"
}

View file

@ -0,0 +1,827 @@
{
"solo": {
"r00tger": {
"account.b39f1fc9e49b471f8cd9ccce15ad9676": {
"assists": 0,
"boosts": 0,
"dBNOs": 0,
"dailyKills": 0,
"dailyWins": 0,
"damageDealt": 0,
"days": 0,
"headshotKills": 0,
"heals": 0,
"killPoints": 0,
"kills": 0,
"longestKill": 0,
"longestTimeSurvived": 0,
"losses": 0,
"maxKillStreaks": 0,
"mostSurvivalTime": 0,
"rankPoints": 0,
"rankPointsTitle": "",
"revives": 0,
"rideDistance": 0,
"roadKills": 0,
"roundMostKills": 0,
"roundsPlayed": 0,
"suicides": 0,
"swimDistance": 0,
"teamKills": 0,
"timeSurvived": 0,
"top10s": 0,
"vehicleDestroys": 0,
"walkDistance": 0,
"weaponsAcquired": 0,
"weeklyKills": 0,
"weeklyWins": 0,
"winPoints": 0,
"wins": 0
}
},
"Jimbo_The_One": {
"account.0026f9f08725424fa477ba986991e064": {
"assists": 0,
"boosts": 0,
"dBNOs": 0,
"dailyKills": 0,
"dailyWins": 0,
"damageDealt": 0,
"days": 1,
"headshotKills": 0,
"heals": 0,
"killPoints": 0,
"kills": 0,
"longestKill": 0,
"longestTimeSurvived": 406,
"losses": 1,
"maxKillStreaks": 0,
"mostSurvivalTime": 406,
"rankPoints": 0,
"rankPointsTitle": "",
"revives": 0,
"rideDistance": 0,
"roadKills": 0,
"roundMostKills": 0,
"roundsPlayed": 1,
"suicides": 0,
"swimDistance": 0,
"teamKills": 0,
"timeSurvived": 406,
"top10s": 0,
"vehicleDestroys": 0,
"walkDistance": 929.076,
"weaponsAcquired": 5,
"weeklyKills": 0,
"weeklyWins": 0,
"winPoints": 0,
"wins": 0
}
},
"Petje1972": {
"account.889799e275e94395aa1a9e66ec3e1ff2": {
"assists": 3,
"boosts": 1080,
"dBNOs": 0,
"dailyKills": 18,
"dailyWins": 0,
"damageDealt": 209072.52,
"days": 183,
"headshotKills": 577,
"heals": 734,
"killPoints": 0,
"kills": 2213,
"longestKill": 568.85095,
"longestTimeSurvived": 1927,
"losses": 397,
"maxKillStreaks": 3,
"mostSurvivalTime": 1927,
"rankPoints": 0,
"rankPointsTitle": "",
"revives": 0,
"rideDistance": 1045924.3,
"roadKills": 58,
"roundMostKills": 19,
"roundsPlayed": 429,
"suicides": 10,
"swimDistance": 3233.0042,
"teamKills": 1,
"timeSurvived": 465564.8,
"top10s": 186,
"vehicleDestroys": 6,
"walkDistance": 722671.44,
"weaponsAcquired": 2086,
"weeklyKills": 18,
"weeklyWins": 0,
"winPoints": 0,
"wins": 32
}
},
"Lanta01": {
"account.3e75bc1560664817900f3747e2270659": {
"assists": 0,
"boosts": 272,
"dBNOs": 1,
"dailyKills": 3,
"dailyWins": 0,
"damageDealt": 29261.664,
"days": 97,
"headshotKills": 48,
"heals": 207,
"killPoints": 0,
"kills": 278,
"longestKill": 647.4343,
"longestTimeSurvived": 1969,
"losses": 162,
"maxKillStreaks": 4,
"mostSurvivalTime": 1969,
"rankPoints": 0,
"rankPointsTitle": "",
"revives": 1,
"rideDistance": 340843.12,
"roadKills": 3,
"roundMostKills": 12,
"roundsPlayed": 168,
"suicides": 6,
"swimDistance": 902.4652,
"teamKills": 0,
"timeSurvived": 138979.31,
"top10s": 42,
"vehicleDestroys": 3,
"walkDistance": 170135.72,
"weaponsAcquired": 834,
"weeklyKills": 3,
"weeklyWins": 0,
"winPoints": 0,
"wins": 6
}
},
"TaGMoM": {
"account.4622686b9d9f44209d64503b18d96a1d": {
"assists": 0,
"boosts": 30,
"dBNOs": 0,
"dailyKills": 0,
"dailyWins": 0,
"damageDealt": 1996.2902,
"days": 18,
"headshotKills": 4,
"heals": 50,
"killPoints": 0,
"kills": 14,
"longestKill": 240.44931,
"longestTimeSurvived": 1807,
"losses": 23,
"maxKillStreaks": 2,
"mostSurvivalTime": 1807,
"rankPoints": 0,
"rankPointsTitle": "",
"revives": 0,
"rideDistance": 60284.086,
"roadKills": 0,
"roundMostKills": 6,
"roundsPlayed": 23,
"suicides": 0,
"swimDistance": 158.53871,
"teamKills": 0,
"timeSurvived": 23126,
"top10s": 7,
"vehicleDestroys": 0,
"walkDistance": 33895.348,
"weaponsAcquired": 127,
"weeklyKills": 0,
"weeklyWins": 0,
"winPoints": 0,
"wins": 0
}
},
"RalphNorris": {
"account.275452133d6744d494a1b145da12f75a": {
"assists": 0,
"boosts": 0,
"dBNOs": 0,
"dailyKills": 0,
"dailyWins": 0,
"damageDealt": 0,
"days": 0,
"headshotKills": 0,
"heals": 0,
"killPoints": 0,
"kills": 0,
"longestKill": 0,
"longestTimeSurvived": 0,
"losses": 0,
"maxKillStreaks": 0,
"mostSurvivalTime": 0,
"rankPoints": 0,
"rankPointsTitle": "",
"revives": 0,
"rideDistance": 0,
"roadKills": 0,
"roundMostKills": 0,
"roundsPlayed": 0,
"suicides": 0,
"swimDistance": 0,
"teamKills": 0,
"timeSurvived": 0,
"top10s": 0,
"vehicleDestroys": 0,
"walkDistance": 0,
"weaponsAcquired": 0,
"weeklyKills": 0,
"weeklyWins": 0,
"winPoints": 0,
"wins": 0
}
},
"Masistuta": {
"account.2322e3d471a5418696b6f14271afd83a": {
"assists": 0,
"boosts": 448,
"dBNOs": 0,
"dailyKills": 20,
"dailyWins": 0,
"damageDealt": 36863.816,
"days": 93,
"headshotKills": 84,
"heals": 266,
"killPoints": 0,
"kills": 361,
"longestKill": 458.46564,
"longestTimeSurvived": 1944,
"losses": 172,
"maxKillStreaks": 2,
"mostSurvivalTime": 1944,
"rankPoints": 0,
"rankPointsTitle": "",
"revives": 0,
"rideDistance": 333928.22,
"roadKills": 21,
"roundMostKills": 12,
"roundsPlayed": 177,
"suicides": 9,
"swimDistance": 1460.9769,
"teamKills": 0,
"timeSurvived": 166117,
"top10s": 53,
"vehicleDestroys": 2,
"walkDistance": 235413.95,
"weaponsAcquired": 845,
"weeklyKills": 20,
"weeklyWins": 0,
"winPoints": 0,
"wins": 5
}
}
},
"duo": {
"r00tger": {
"account.b39f1fc9e49b471f8cd9ccce15ad9676": {
"assists": 4,
"boosts": 32,
"dBNOs": 5,
"dailyKills": 1,
"dailyWins": 1,
"damageDealt": 978.51666,
"days": 9,
"headshotKills": 0,
"heals": 33,
"killPoints": 0,
"kills": 5,
"longestKill": 128.73962,
"longestTimeSurvived": 1481,
"losses": 16,
"maxKillStreaks": 1,
"mostSurvivalTime": 1481,
"rankPoints": 0,
"rankPointsTitle": "",
"revives": 3,
"rideDistance": 39566.24,
"roadKills": 0,
"roundMostKills": 2,
"roundsPlayed": 17,
"suicides": 0,
"swimDistance": 2.4766102,
"teamKills": 0,
"timeSurvived": 14663.755,
"top10s": 6,
"vehicleDestroys": 0,
"walkDistance": 21671.293,
"weaponsAcquired": 72,
"weeklyKills": 1,
"weeklyWins": 1,
"winPoints": 0,
"wins": 1
}
},
"Jimbo_The_One": {
"account.0026f9f08725424fa477ba986991e064": {
"assists": 0,
"boosts": 1,
"dBNOs": 0,
"dailyKills": 0,
"dailyWins": 0,
"damageDealt": 66.78,
"days": 2,
"headshotKills": 0,
"heals": 4,
"killPoints": 0,
"kills": 0,
"longestKill": 0,
"longestTimeSurvived": 973,
"losses": 2,
"maxKillStreaks": 0,
"mostSurvivalTime": 973,
"rankPoints": 0,
"rankPointsTitle": "",
"revives": 0,
"rideDistance": 4502.344,
"roadKills": 0,
"roundMostKills": 0,
"roundsPlayed": 2,
"suicides": 0,
"swimDistance": 0,
"teamKills": 0,
"timeSurvived": 1376,
"top10s": 0,
"vehicleDestroys": 0,
"walkDistance": 1543.4169,
"weaponsAcquired": 11,
"weeklyKills": 0,
"weeklyWins": 0,
"winPoints": 0,
"wins": 0
}
},
"Petje1972": {
"account.889799e275e94395aa1a9e66ec3e1ff2": {
"assists": 36,
"boosts": 258,
"dBNOs": 110,
"dailyKills": 1,
"dailyWins": 0,
"damageDealt": 24378.89,
"days": 90,
"headshotKills": 28,
"heals": 287,
"killPoints": 0,
"kills": 148,
"longestKill": 232.37743,
"longestTimeSurvived": 1938.722,
"losses": 222,
"maxKillStreaks": 2,
"mostSurvivalTime": 1938.722,
"rankPoints": 1,
"rankPointsTitle": "",
"revives": 33,
"rideDistance": 214098.05,
"roadKills": 0,
"roundMostKills": 7,
"roundsPlayed": 224,
"suicides": 4,
"swimDistance": 1160.3948,
"teamKills": 3,
"timeSurvived": 173157.78,
"top10s": 47,
"vehicleDestroys": 0,
"walkDistance": 266150.5,
"weaponsAcquired": 1035,
"weeklyKills": 7,
"weeklyWins": 0,
"winPoints": 0,
"wins": 2
}
},
"Lanta01": {
"account.3e75bc1560664817900f3747e2270659": {
"assists": 74,
"boosts": 600,
"dBNOs": 311,
"dailyKills": 4,
"dailyWins": 0,
"damageDealt": 65681.57,
"days": 180,
"headshotKills": 94,
"heals": 790,
"killPoints": 0,
"kills": 432,
"longestKill": 396.7462,
"longestTimeSurvived": 1897,
"losses": 430,
"maxKillStreaks": 3,
"mostSurvivalTime": 1897,
"rankPoints": 0,
"rankPointsTitle": "",
"revives": 80,
"rideDistance": 802699.2,
"roadKills": 18,
"roundMostKills": 8,
"roundsPlayed": 438,
"suicides": 11,
"swimDistance": 1948.0481,
"teamKills": 4,
"timeSurvived": 341757.75,
"top10s": 131,
"vehicleDestroys": 7,
"walkDistance": 602869.4,
"weaponsAcquired": 2296,
"weeklyKills": 4,
"weeklyWins": 0,
"winPoints": 0,
"wins": 8
}
},
"TaGMoM": {
"account.4622686b9d9f44209d64503b18d96a1d": {
"assists": 5,
"boosts": 86,
"dBNOs": 10,
"dailyKills": 0,
"dailyWins": 0,
"damageDealt": 2483.6016,
"days": 26,
"headshotKills": 1,
"heals": 73,
"killPoints": 0,
"kills": 14,
"longestKill": 129.64589,
"longestTimeSurvived": 1917,
"losses": 57,
"maxKillStreaks": 2,
"mostSurvivalTime": 1917,
"rankPoints": 0,
"rankPointsTitle": "",
"revives": 2,
"rideDistance": 112791.69,
"roadKills": 0,
"roundMostKills": 5,
"roundsPlayed": 59,
"suicides": 1,
"swimDistance": 536.6035,
"teamKills": 2,
"timeSurvived": 52875,
"top10s": 22,
"vehicleDestroys": 0,
"walkDistance": 75226.24,
"weaponsAcquired": 319,
"weeklyKills": 0,
"weeklyWins": 0,
"winPoints": 0,
"wins": 2
}
},
"RalphNorris": {
"account.275452133d6744d494a1b145da12f75a": {
"assists": 19,
"boosts": 133,
"dBNOs": 35,
"dailyKills": 0,
"dailyWins": 0,
"damageDealt": 7404.458,
"days": 49,
"headshotKills": 8,
"heals": 171,
"killPoints": 0,
"kills": 48,
"longestKill": 167.74887,
"longestTimeSurvived": 1863,
"losses": 94,
"maxKillStreaks": 2,
"mostSurvivalTime": 1863,
"rankPoints": 0,
"rankPointsTitle": "",
"revives": 13,
"rideDistance": 160407.58,
"roadKills": 2,
"roundMostKills": 5,
"roundsPlayed": 96,
"suicides": 4,
"swimDistance": 531.9813,
"teamKills": 0,
"timeSurvived": 66916,
"top10s": 21,
"vehicleDestroys": 1,
"walkDistance": 90815.72,
"weaponsAcquired": 480,
"weeklyKills": 0,
"weeklyWins": 0,
"winPoints": 0,
"wins": 2
}
},
"Masistuta": {
"account.2322e3d471a5418696b6f14271afd83a": {
"assists": 40,
"boosts": 574,
"dBNOs": 116,
"dailyKills": 0,
"dailyWins": 0,
"damageDealt": 25657.559,
"days": 122,
"headshotKills": 43,
"heals": 352,
"killPoints": 0,
"kills": 156,
"longestKill": 379.67862,
"longestTimeSurvived": 1917,
"losses": 308,
"maxKillStreaks": 2,
"mostSurvivalTime": 1917,
"rankPoints": 0,
"rankPointsTitle": "",
"revives": 43,
"rideDistance": 525320.2,
"roadKills": 0,
"roundMostKills": 5,
"roundsPlayed": 312,
"suicides": 3,
"swimDistance": 957.83136,
"teamKills": 0,
"timeSurvived": 244791,
"top10s": 98,
"vehicleDestroys": 5,
"walkDistance": 316070.06,
"weaponsAcquired": 1432,
"weeklyKills": 0,
"weeklyWins": 0,
"winPoints": 0,
"wins": 4
}
}
},
"squad": {
"r00tger": {
"account.b39f1fc9e49b471f8cd9ccce15ad9676": {
"assists": 251,
"boosts": 1297,
"dBNOs": 692,
"dailyKills": 6,
"dailyWins": 1,
"damageDealt": 83855.42,
"days": 145,
"headshotKills": 176,
"heals": 1080,
"killPoints": 0,
"kills": 831,
"longestKill": 374.33276,
"longestTimeSurvived": 1975,
"losses": 412,
"maxKillStreaks": 4,
"mostSurvivalTime": 1975,
"rankPoints": 0,
"rankPointsTitle": "",
"revives": 124,
"rideDistance": 1084922.8,
"roadKills": 25,
"roundMostKills": 14,
"roundsPlayed": 507,
"suicides": 15,
"swimDistance": 1021.355,
"teamKills": 3,
"timeSurvived": 509005.44,
"top10s": 316,
"vehicleDestroys": 14,
"walkDistance": 682789.4,
"weaponsAcquired": 2686,
"weeklyKills": 6,
"weeklyWins": 1,
"winPoints": 0,
"wins": 103
}
},
"Jimbo_The_One": {
"account.0026f9f08725424fa477ba986991e064": {
"assists": 10,
"boosts": 68,
"dBNOs": 39,
"dailyKills": 4,
"dailyWins": 1,
"damageDealt": 4770.5073,
"days": 11,
"headshotKills": 15,
"heals": 119,
"killPoints": 0,
"kills": 50,
"longestKill": 258.01843,
"longestTimeSurvived": 1579,
"losses": 33,
"maxKillStreaks": 2,
"mostSurvivalTime": 1579,
"rankPoints": 0,
"rankPointsTitle": "",
"revives": 5,
"rideDistance": 98445.836,
"roadKills": 0,
"roundMostKills": 6,
"roundsPlayed": 39,
"suicides": 0,
"swimDistance": 89.939255,
"teamKills": 0,
"timeSurvived": 41014,
"top10s": 26,
"vehicleDestroys": 1,
"walkDistance": 50491.746,
"weaponsAcquired": 197,
"weeklyKills": 4,
"weeklyWins": 1,
"winPoints": 0,
"wins": 9
}
},
"Petje1972": {
"account.889799e275e94395aa1a9e66ec3e1ff2": {
"assists": 618,
"boosts": 1643,
"dBNOs": 2077,
"dailyKills": 13,
"dailyWins": 0,
"damageDealt": 277740.6,
"days": 219,
"headshotKills": 570,
"heals": 1488,
"killPoints": 0,
"kills": 2649,
"longestKill": 663.9124,
"longestTimeSurvived": 1861,
"losses": 567,
"maxKillStreaks": 5,
"mostSurvivalTime": 1861,
"rankPoints": 1,
"rankPointsTitle": "",
"revives": 198,
"rideDistance": 1828877.2,
"roadKills": 54,
"roundMostKills": 31,
"roundsPlayed": 719,
"suicides": 11,
"swimDistance": 4340.0566,
"teamKills": 4,
"timeSurvived": 722989.56,
"top10s": 446,
"vehicleDestroys": 10,
"walkDistance": 1114825.5,
"weaponsAcquired": 3689,
"weeklyKills": 13,
"weeklyWins": 0,
"winPoints": 0,
"wins": 159
}
},
"Lanta01": {
"account.3e75bc1560664817900f3747e2270659": {
"assists": 1283,
"boosts": 4172,
"dBNOs": 5322,
"dailyKills": 4,
"dailyWins": 1,
"damageDealt": 696072.7,
"days": 502,
"headshotKills": 1120,
"heals": 5425,
"killPoints": 0,
"kills": 6855,
"longestKill": 573.3457,
"longestTimeSurvived": 1950,
"losses": 1687,
"maxKillStreaks": 6,
"mostSurvivalTime": 1950,
"rankPoints": 0,
"rankPointsTitle": "",
"revives": 547,
"rideDistance": 5670516,
"roadKills": 688,
"roundMostKills": 26,
"roundsPlayed": 2082,
"suicides": 42,
"swimDistance": 10567.895,
"teamKills": 30,
"timeSurvived": 2083670.8,
"top10s": 1200,
"vehicleDestroys": 75,
"walkDistance": 2799205,
"weaponsAcquired": 11670,
"weeklyKills": 43,
"weeklyWins": 5,
"winPoints": 0,
"wins": 408
}
},
"TaGMoM": {
"account.4622686b9d9f44209d64503b18d96a1d": {
"assists": 266,
"boosts": 950,
"dBNOs": 610,
"dailyKills": 2,
"dailyWins": 0,
"damageDealt": 80130.17,
"days": 125,
"headshotKills": 111,
"heals": 1352,
"killPoints": 0,
"kills": 791,
"longestKill": 494.7613,
"longestTimeSurvived": 1911,
"losses": 360,
"maxKillStreaks": 4,
"mostSurvivalTime": 1911,
"rankPoints": 0,
"rankPointsTitle": "",
"revives": 102,
"rideDistance": 1212633,
"roadKills": 46,
"roundMostKills": 14,
"roundsPlayed": 439,
"suicides": 11,
"swimDistance": 1239.1948,
"teamKills": 1,
"timeSurvived": 464755,
"top10s": 290,
"vehicleDestroys": 3,
"walkDistance": 737040.2,
"weaponsAcquired": 2394,
"weeklyKills": 2,
"weeklyWins": 0,
"winPoints": 0,
"wins": 90
}
},
"RalphNorris": {
"account.275452133d6744d494a1b145da12f75a": {
"assists": 595,
"boosts": 2342,
"dBNOs": 1686,
"dailyKills": 4,
"dailyWins": 1,
"damageDealt": 217474.19,
"days": 360,
"headshotKills": 305,
"heals": 3069,
"killPoints": 0,
"kills": 2159,
"longestKill": 632.896,
"longestTimeSurvived": 2183,
"losses": 1175,
"maxKillStreaks": 6,
"mostSurvivalTime": 2183,
"rankPoints": 0,
"rankPointsTitle": "",
"revives": 249,
"rideDistance": 2892102.8,
"roadKills": 163,
"roundMostKills": 18,
"roundsPlayed": 1345,
"suicides": 24,
"swimDistance": 7767.365,
"teamKills": 13,
"timeSurvived": 1304571,
"top10s": 750,
"vehicleDestroys": 13,
"walkDistance": 2041986.8,
"weaponsAcquired": 7474,
"weeklyKills": 16,
"weeklyWins": 1,
"winPoints": 0,
"wins": 175
}
},
"Masistuta": {
"account.2322e3d471a5418696b6f14271afd83a": {
"assists": 692,
"boosts": 4159,
"dBNOs": 2535,
"dailyKills": 8,
"dailyWins": 2,
"damageDealt": 344990.78,
"days": 363,
"headshotKills": 694,
"heals": 2377,
"killPoints": 0,
"kills": 3343,
"longestKill": 498.75113,
"longestTimeSurvived": 1975,
"losses": 1188,
"maxKillStreaks": 5,
"mostSurvivalTime": 1975,
"rankPoints": 0,
"rankPointsTitle": "",
"revives": 391,
"rideDistance": 3599036.2,
"roadKills": 136,
"roundMostKills": 16,
"roundsPlayed": 1483,
"suicides": 18,
"swimDistance": 6016.207,
"teamKills": 5,
"timeSurvived": 1560614.8,
"top10s": 938,
"vehicleDestroys": 15,
"walkDistance": 2353229,
"weaponsAcquired": 7562,
"weeklyKills": 19,
"weeklyWins": 3,
"winPoints": 0,
"wins": 304
}
}
}
}

View file

@ -1,23 +0,0 @@

$playername = 'Lanta01'
$headers = @{
'accept' = 'application/vnd.api+json'
'Authorization' = 'YOURAPIKEY'
}
$playerinfo = Invoke-RestMethod -Uri "https://api.pubg.com/shards/steam/players?filter[playerNames]=$playername" -Method GET -Headers $headers
$playedid = $playerinfo.data.id
$seasons = Invoke-RestMethod -Uri 'https://api.pubg.com/shards/steam/seasons' -Method GET -Headers $headers
$season = ($seasons.data | Where-Object { $_.attributes.isCurrentSeason -eq $true }).id
$match_array = @()
$seasonstats = Invoke-RestMethod -Uri "https://api.pubg.com/shards/steam/players/$playedid/seasons/$season`?filter[gamepad]=false" -Method GET -Headers $headers
$pubgmatches = $seasonstats.data.relationships.matchesSquad.data.id
foreach ($match in $pubgmatches) {
Write-Output "checking $Match"
$match_array += Invoke-RestMethod -Uri "https://api.pubg.com/shards/steam/matches/$Match" -Method GET -Headers $headers
}

25
update/update_clan.ps1 Normal file
View file

@ -0,0 +1,25 @@

# Read the content of the file as a single string
$fileContent = Get-Content -Path "../config/config.php" -Raw
# Use regex to match the apiKey value
if ($fileContent -match "\`$apiKey\s*=\s*\'([^\']+)\'") {
$apiKey = $matches[1]
}else {
Write-Output "API Key not found"
}
if ($fileContent -match "\`$clanid\s*=\s*\'([^\']+)\'") {
$clanid = $matches[1]
} else {
Write-Output "No clanid found in $configPath"
}
$headers = @{
'accept' = 'application/vnd.api+json'
'Authorization' = "$apiKey"
}
$claninfo = Invoke-RestMethod -Uri "https://api.pubg.com/shards/steam/clans/$clanid" -Method GET -Headers $headers
$claninfo.data.attributes | convertto-json -Depth 100 | out-file '../data/claninfo.json'

View file

@ -0,0 +1,94 @@

# Read the content of the file as a single string
$fileContent = Get-Content -Path "../config/config.php" -Raw
# Use regex to match the apiKey value
if ($fileContent -match "\`$apiKey\s*=\s*\'([^\']+)\'") {
$apiKey = $matches[1]
}
else {
Write-Output "API Key not found"
}
if ($fileContent -match "\`$clanmembers\s*=\s*array\(([^)]+)\)") {
# Remove quotes and split by comma to get individual members
$clanMembers = ($matches[1] -replace '"|\'', '' -split ","').replace(" ", "")
$clanMembersArray = $clanMembers.split(",").trim()
Write-Output "Clan Members: $($clanMembersArray -join ', ')"
}
else {
Write-Output "Clan members not found"
}
if ($clanMembersArray.count -ge 10 ) {
write-output "Currently not able to process more then 10 players"
exit
}
$headers = @{
'accept' = 'application/vnd.api+json'
'Authorization' = "$apiKey"
}
$playerinfo = Invoke-RestMethod -Uri "https://api.pubg.com/shards/steam/players?filter[playerNames]=$clanMembers" -Method GET -Headers $headers
$playerList = @()
$playerinfo.data | ForEach-Object {
$playerObject = [PSCustomObject]@{
PlayerName = $_.attributes.name
PlayerID = $_.id
}
$playerList += $playerObject
}
# Display the list
$playerList
$playeridstring = ""
foreach ($playerid in $playerinfo.data.id){
$playeridstring += "$playerid,"
}
$playeridstring = $playeridstring.Substring(0, $playeridstring.Length - 1)
$playermodes = @(
"solo",
"duo",
"squad"
#"solo-fpp",
#"duo-fpp",
#"squad-fpp"
)
# Initialize the master hashtable
$lifetimestats = @{}
$webrequestlimiter = 0
foreach ($playmode in $playermodes) {
# Fetch stats for the current playmode
if($webrequestlimiter -le 8){
$stats = Invoke-RestMethod -Uri "https://api.pubg.com/shards/steam/seasons/lifetime/gameMode/$playmode/players?filter[playerIds]=$playeridstring" -Method GET -Headers $headers
$webrequestlimiter++
}else{
write-ouput "sleeping for 60 seconds"
$webrequestlimiter = 0
}
# Check if the playmode doesn't exist in the hashtable, then add it
if (-not $lifetimestats.ContainsKey($playmode)) {
$lifetimestats[$playmode] = @{}
}
foreach ($stat in $stats.data.relationships.player.data.id) {
# Fetch the player name for the current stat (account ID) from the dictionary
$playerName = $playerList | Where-Object { $_.PlayerID -eq $stat } | Select-Object -ExpandProperty PlayerName
# Fetch the specific stat data for the current stat
$specificStat = ($stats.data | where-object {$_.relationships.player.data.id -eq $stat}).attributes.gamemodestats.$playmode
# Create a new hashtable entry for the player and insert the specific stat data
if (-not $lifetimestats[$playmode].ContainsKey($playerName)) {
$lifetimestats[$playmode][$playerName] = @{}
}
$lifetimestats[$playmode][$playerName][$stat] = $specificStat
}
}
$lifetimestats | convertto-json -Depth 100 | out-file '../data/player_lifetime_data.json'

View file

@ -4,8 +4,6 @@ ini_set('display_startup_errors', 1);
error_reporting(E_ALL); error_reporting(E_ALL);
?> ?>
<?php //include './includes/ratelimiter.php'; ?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
@ -23,71 +21,44 @@ error_reporting(E_ALL);
<section> <section>
<h2>User Stats</h2> <h2>User Stats</h2>
<?php <?php
include './config/config.php'; include './config/config.php';
$players_data = json_decode(file_get_contents('./data/player_lifetime_data.json'), true);
$headers = array( $selected_mode = isset($_POST['game_mode']) ? $_POST['game_mode'] : 'squad';
'Authorization: Bearer ' . $apiKey,
'Accept: application/vnd.api+json'
);
$selected_mode = isset($_POST['game_mode']) ? $_POST['game_mode'] : 'squad'; // Form to select game mode
echo "<form method='post' action=''>
<input type='submit' name='game_mode' value='solo'>
<input type='submit' name='game_mode' value='duo'>
<input type='submit' name='game_mode' value='squad'>
</form><br>";
// Form to select game mode // Buttons for each player
echo "<form method='post' action=''> echo "<form method='post' action=''>";
<input type='submit' name='game_mode' value='solo'> foreach ($players_data[$selected_mode] as $player_name => $player_details) {
<input type='submit' name='game_mode' value='duo'> echo "<button type='submit' name='selected_player' value='$player_name'>$player_name</button>";
<input type='submit' name='game_mode' value='squad'> }
</form><br>"; echo "</form><br>";
// Buttons for each player $selected_player = $_POST['selected_player'] ?? array_key_first($players_data[$selected_mode]);
echo "<form method='post' action=''>";
foreach ($clanmembers as $player) {
echo "<button type='submit' name='selected_player' value='$player'>$player</button>";
}
echo "</form><br>";
$selected_player = $_POST['selected_player'] ?? $clanmembers[0]; // Fetch the player stats based on game mode and selected player
if (isset($players_data[$selected_mode][$selected_player])) {
$account_id = array_key_first($players_data[$selected_mode][$selected_player]);
$stats = $players_data[$selected_mode][$selected_player][$account_id];
// Retrieve user IDs echo "<h2>" . ucfirst($selected_mode) . " Lifetime Stats for $selected_player</h2>";
$players_url = "https://api.pubg.com/shards/steam/players?filter[playerNames]=$selected_player"; echo "<table border='1'>";
$ch = curl_init(); echo "<tr><th>Stat Name</th><th>Value</th></tr>";
curl_setopt($ch, CURLOPT_URL, $players_url); foreach ($stats as $stat_name => $stat_value) {
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); echo "<tr><td>$stat_name</td><td>$stat_value</td></tr>";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); }
$players_response = curl_exec($ch); echo "</table><br>";
curl_close($ch); } else {
$players_data = json_decode($players_response, true); echo "No player data available.";
}
if (isset($players_data['data'])) { ?>
$player = $players_data['data'][0];
$player_id = $player['id'];
$player_name = $player['attributes']['name'];
// Retrieve lifetime stats
$lifetime_url = "https://api.pubg.com/shards/steam/players/$player_id/seasons/lifetime?filter[gamepad]=false";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $lifetime_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$lifetime_response = curl_exec($ch);
curl_close($ch);
$lifetime_data = json_decode($lifetime_response, true);
if (isset($lifetime_data['data']['attributes']['gameModeStats'][$selected_mode])) {
$stats = $lifetime_data['data']['attributes']['gameModeStats'][$selected_mode];
echo "<h2>" . ucfirst($selected_mode) . " Lifetime Stats for $player_name</h2>";
echo "<table border='1'>";
echo "<tr><th>Stat Name</th><th>Value</th></tr>";
foreach ($stats as $stat_name => $stat_value) {
echo "<tr><td>$stat_name</td><td>$stat_value</td></tr>";
}
echo "</table><br>";
}
} else {
echo "No player data available.";
}
?>
</section> </section>
</main> </main>