From e3bc26bd3dfde6bcfdc26b12f49c4b74c9042372 Mon Sep 17 00:00:00 2001 From: Duncan MacFarlane Date: Thu, 15 Jun 2023 12:11:25 +1000 Subject: [PATCH] Fix: Time-based tracking fix for ASP (#51) These changes fix the error that gets thrown when attempting to view player details in Private Stats Admin. --- src/ASP/aspx/selectunlock.php | 5 +++-- src/ASP/system/framework/TimeSpan.php | 4 ++-- src/ASP/system/sql/schema.sql | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ASP/aspx/selectunlock.php b/src/ASP/aspx/selectunlock.php index b759ad4d..f6f114b3 100644 --- a/src/ASP/aspx/selectunlock.php +++ b/src/ASP/aspx/selectunlock.php @@ -77,7 +77,8 @@ // Finally, if the user HAS available unlocks, let them choose this one if ($available > 0) { - $connection->exec("INSERT INTO player_unlock VALUES ($pid, $id)"); + $time = time(); + $connection->exec("INSERT INTO player_unlock VALUES ($pid, $id, $time)"); $Response->writeLine("OK"); $Response->send(); } @@ -186,4 +187,4 @@ function getBonusUnlockCountByBadges($pid, $rank, $connection) SQL; return (int)$connection->query($query)->fetchColumn(0); -} \ No newline at end of file +} diff --git a/src/ASP/system/framework/TimeSpan.php b/src/ASP/system/framework/TimeSpan.php index 54c395c8..5ba61ba3 100644 --- a/src/ASP/system/framework/TimeSpan.php +++ b/src/ASP/system/framework/TimeSpan.php @@ -328,7 +328,7 @@ public function format($format) $return .= substr($format, $o, $p); if (($o += $p + 2) <= $l) { - switch ($format{$o - 1}) + switch ($format[$o - 1]) { case 's': $return .= $this->getSeconds(); @@ -403,4 +403,4 @@ public function __toString() { return $this->toString(); } -} \ No newline at end of file +} diff --git a/src/ASP/system/sql/schema.sql b/src/ASP/system/sql/schema.sql index cffbbe5a..b5526d1e 100644 --- a/src/ASP/system/sql/schema.sql +++ b/src/ASP/system/sql/schema.sql @@ -574,6 +574,7 @@ CREATE TABLE `player_rank_history` ( CREATE TABLE `player_unlock` ( `player_id` INT UNSIGNED NOT NULL, `unlock_id` SMALLINT UNSIGNED NOT NULL, + `timestamp` INT UNSIGNED NOT NULL, PRIMARY KEY(`player_id`,`unlock_id`), FOREIGN KEY(`player_id`) REFERENCES `player`(`id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY(`unlock_id`) REFERENCES `unlock`(`id`) ON DELETE CASCADE ON UPDATE CASCADE @@ -880,4 +881,4 @@ CREATE PROCEDURE `create_player`( SELECT pid; END $$ -delimiter ; \ No newline at end of file +delimiter ;