<?php //Checks whether the last completed season's data has been saved. //Ideally this is called on the first day of every second month (February, April..) require_once 'config/.keys.php'; //Auth key $admin_key is stored here require_once 'data_functions.php'; //Check if qualified call if (!isset($_GET['key']) || htmlspecialchars($_GET["key"]) != $admin_key) { die("Unauthorized call."); } $current_season_ids = getLeaderboardId(NULL); $penultimate_season = $current_season_ids[0] - 1; if (checkSeasonTable($penultimate_season)) { echo "Historic data for season {$penultimate_season} is already saved."; } else { $chars = getCharacterData(); $ids = getLeaderboardId($penultimate_season); $xml = getLeaderboardXML($ids[1]); $data = getLeaderboardData($xml, $chars); if (saveLeaderboardData($penultimate_season, $data)) { echo "Data saved for season " . $penultimate_season . "<br>\n"; } else { echo "Couldn't save data for season " . $penultimate_season . "<br>\n"; } }
<?php /** * Script for saving all previous seasons. * From 8 to latest, which is provided as a parameter. */ set_time_limit(0); //Can take long time require_once 'config/.keys.php'; //Auth key $admin_key is stored here require_once 'data_functions.php'; //Check if qualified call if (!isset($_GET['key']) || htmlspecialchars($_GET["key"]) != $admin_key) { die("Unauthorized call."); } if (!isset($_GET['current'])) { die("Missing parameter \"current\""); } $current_season = $_GET['current']; $chars = getCharacterData(); for ($i = 8; $i < $current_season; $i++) { $ids = getLeaderboardId($i); $xml = getLeaderboardXML($ids[1]); $data = getLeaderboardData($xml, $chars); if (saveLeaderboardData($ids[0], $data)) { echo "Data saved for season " . $i . "<br>\n"; } else { echo "Couldn't save data for season " . $i . "<br>\n"; } }
<?php /* Script for updating current leaderboard */ //set_time_limit(0); //Can take long time require_once 'config/.keys.php'; //Auth key $admin_key is stored here require_once 'data_functions.php'; //Check if qualified call if (!isset($_GET['key']) || htmlspecialchars($_GET["key"]) != $admin_key) { die("Unauthorized call."); } else { $t = time(); $chars = getCharacterData(); // IDS $ids = getLeaderboardId(NULL); $xml = getLeaderboardXML($ids[1]); $data = getLeaderboardData($xml, $chars); //NULL -> saving to current leaderboard if (saveLeaderboardData(NULL, $data)) { echo "Current leaderboard data saved (season " . $ids[0] . "). Time spent on script: " . (time() - $t) . " seconds.<br>\n"; } else { echo "Couldn't save current leaderboard data (season " . $ids[0] . ", leaderboard " . $ids[1] . ")<br>\n"; } }