From de91d56d4b518eea34697c8c732dd438a092ceaf Mon Sep 17 00:00:00 2001 From: Mario <100047175+Mariopizza1@users.noreply.github.com> Date: Thu, 2 Mar 2023 10:41:05 +0200 Subject: [PATCH] Create UpdatePlayerCount.php --- api/UpdatePlayerCount.php | 59 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 api/UpdatePlayerCount.php diff --git a/api/UpdatePlayerCount.php b/api/UpdatePlayerCount.php new file mode 100644 index 0000000..9500de1 --- /dev/null +++ b/api/UpdatePlayerCount.php @@ -0,0 +1,59 @@ +prepare('SELECT COUNT(*) FROM accesstokens WHERE accesstoken=:accesstoken'); + $forthebestofgrublox->bindParam(':accesstoken', $accesstoken); + $forthebestofgrublox->execute(); + $yesdoit = $forthebestofgrublox->fetchColumn(); + if ($yesdoit == '1') { + $yesstuff = $con->prepare('SELECT placeid,hasgrabbedplace,hasbeeninvalidated,ip,jobid FROM accesstokens WHERE accesstoken=:accesstoken'); + $yesstuff->bindParam(':accesstoken', $accesstoken); + $yesstuff->execute(); + $alanfackler = $yesstuff->fetch(PDO::FETCH_BOTH); + $placeid = $alanfackler['placeid']; + $jobid = $alanfackler['jobid']; + $ipfromaccesstoken3 = $alanfackler['ip']; + $hasgrabbedplace = $alanfackler['hasgrabbedplace']; + $hasbeeninvalidated = $alanfackler['hasbeeninvalidated']; + $twentyfourteen = $con->prepare('SELECT hasended FROM jobs WHERE jobid=:jobid AND placeid=:placeid'); + $twentyfourteen->bindParam(':jobid', $jobid); + $twentyfourteen->bindParam(':placeid', $placeid); + $twentyfourteen->execute(); + $twentysixteen = $twentyfourteen->fetch(PDO::FETCH_BOTH); + $hasended = $twentysixteen['hasended']; + if ($hasended == '0' && $hasbeeninvalidated == '0') { + if ($devmode == "true") { + $ip = $_SERVER['REMOTE_ADDR']; + + } elseif ($devmode == "false") { + $ip = $_SERVER["HTTP_CF_CONNECTING_IP"]; + } + if ($ip == "::1") { + $ip = '127.0.0.1'; + } + if ($ipfromaccesstoken3 == $ip) { + $trolling8k = '1'; + $yessss = $con->prepare('UPDATE games SET playercount = :playercount WHERE id=:id'); + $yessss->bindParam(':playercount', $playercount); + $yessss->bindParam(':id', $placeid); + $yessss->execute(); + echo 'OK'; + } else { + header("content-type: text/html"); + echo ''; + die(); + } + } else { + header("content-type: text/html"); + echo ''; + die(); + } + } else { + header("content-type: text/html"); + echo ''; + die(); + } +}