diff --git a/getauthtoken.php b/getauthtoken.php index 223ff0f..541186b 100644 --- a/getauthtoken.php +++ b/getauthtoken.php @@ -34,13 +34,31 @@ $checkifuser->bindParam(':placeid', $placeid); $checkifuser->execute(); $momentoftruth = $checkifuser->fetchColumn(); if ($momentoftruth == 1) { - $token = generateRandomString(500); - $fbi = $con->prepare('INSERT INTO tokens (token, placeid, userid) VALUES (:token, :placeid, :userid)'); - $fbi->bindParam(':token', $token); - $fbi->bindParam(':placeid', $placeid); - $fbi->bindParam(':userid', $id); - $fbi->execute(); - die($token); + $checktoken = $con->prepare('SELECT COUNT(*) FROM tokens WHERE placeid=:placeid AND passedplacelauncher=:passedplacelauncher AND passedjoinscript=:passedjoinscript'); + $checktoken->bindParam(':placeid', $placeid); + $funnyint = '0'; + $checktoken->bindParam(':passedplacelauncher', $funnyint); + $checktoken->bindParam(':passedjoinscript', $funnyint); + $checktoken->execute(); + $getintforchecktoken = $checktoken->fetchColumn(); + if ($getintforchecktoken == '1') { + $fbi2 = $con->prepare('SELECT token FROM tokens WHERE placeid=:placeid AND passedplacelauncher=:passedplacelauncher AND passedjoinscript=:passedjoinscript'); + $fbi2->bindParam(':placeid', $placeid); + $fbi2->bindParam(':passedplacelauncher', $funnyint); + $fbi2->bindParam(':passedjoinscript', $funnyint); + $fbi2->execute(); + $china3 = $fbi2->fetch(PDO::FETCH_BOTH); + $token = $china3['token']; + die($token); + } elseif ($getintforchecktoken == '0') { + $token = generateRandomString(500); + $fbi = $con->prepare('INSERT INTO tokens (token, placeid, userid) VALUES (:token, :placeid, :userid)'); + $fbi->bindParam(':token', $token); + $fbi->bindParam(':placeid', $placeid); + $fbi->bindParam(':userid', $id); + $fbi->execute(); + die($token); + } } else { echo 'No placeId found'; exit;