Update getauthtoken.php
This commit is contained in:
parent
31cbeefa04
commit
ef5cedc963
|
|
@ -1,22 +1,21 @@
|
||||||
<?php
|
<?php
|
||||||
require_once 'core/classes.php';
|
require_once 'core/classes.php';
|
||||||
require_once 'core/classes/user.php';
|
require_once 'core/classes/user.php';
|
||||||
header('content-Type: text/plain');
|
header('content-Type: text/plain'); // set the content type to text plain
|
||||||
ob_start();
|
ob_start();
|
||||||
session_start();
|
session_start();
|
||||||
if($maintenance && $pagename !== "Maintenance") {
|
if($maintenance && $pagename !== "Maintenance") {
|
||||||
header("Location: /maintenance"
|
header("Location: /maintenance" // is maintenance enabled??
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$user = new User($con, $_SESSION['user'] ?? 0);
|
$user = new User($con, $_SESSION['user'] ?? 0);
|
||||||
if(!$user->isLoggedIn()) {
|
if(!$user->isLoggedIn()) {
|
||||||
header('location: /login');
|
header('location: /login'); // alr hes not signed in so get him out of here
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$placeid = $_GET['placeid'];
|
$placeid = $_GET['placeid'];
|
||||||
if (!isset($placeid)) {
|
if (!isset($placeid)) {
|
||||||
echo "No placeid";
|
die("No placeid"); // placeid was not found AND FUTURE MARIO HERE USE GOD DAMN DIE()
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
$username = $user->getUsername();
|
$username = $user->getUsername();
|
||||||
$id = $user->getID($con, $user->getUsername());
|
$id = $user->getID($con, $user->getUsername());
|
||||||
|
|
@ -29,7 +28,7 @@ function generateRandomString($length = 25) {
|
||||||
}
|
}
|
||||||
return $randomString;
|
return $randomString;
|
||||||
} // pls don't hurt me
|
} // pls don't hurt me
|
||||||
$checkifuser = $con->prepare('SELECT COUNT(*) FROM games WHERE id=:placeid');
|
$checkifuser = $con->prepare('SELECT COUNT(*) FROM games WHERE id=:placeid'); // check if the game even exists
|
||||||
$checkifuser->bindParam(':placeid', $placeid);
|
$checkifuser->bindParam(':placeid', $placeid);
|
||||||
$checkifuser->execute();
|
$checkifuser->execute();
|
||||||
$momentoftruth = $checkifuser->fetchColumn();
|
$momentoftruth = $checkifuser->fetchColumn();
|
||||||
|
|
@ -49,18 +48,17 @@ if ($momentoftruth == 1) {
|
||||||
$fbi2->execute();
|
$fbi2->execute();
|
||||||
$china3 = $fbi2->fetch(PDO::FETCH_BOTH);
|
$china3 = $fbi2->fetch(PDO::FETCH_BOTH);
|
||||||
$token = $china3['token'];
|
$token = $china3['token'];
|
||||||
die($token);
|
die($token); // DIE!
|
||||||
} elseif ($getintforchecktoken == '0') {
|
} elseif ($getintforchecktoken == '0') {
|
||||||
$token = generateRandomString(500);
|
$token = generateRandomString(500);
|
||||||
$fbi = $con->prepare('INSERT INTO tokens (token, placeid, userid) VALUES (:token, :placeid, :userid)');
|
$fbi = $con->prepare('INSERT INTO tokens (token, placeid, userid) VALUES (:token, :placeid, :userid)'); // make the token valid
|
||||||
$fbi->bindParam(':token', $token);
|
$fbi->bindParam(':token', $token);
|
||||||
$fbi->bindParam(':placeid', $placeid);
|
$fbi->bindParam(':placeid', $placeid);
|
||||||
$fbi->bindParam(':userid', $id);
|
$fbi->bindParam(':userid', $id);
|
||||||
$fbi->execute();
|
$fbi->execute();
|
||||||
die($token);
|
die($token); // HE FINALLY USED DIE
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
echo 'No placeId found';
|
die('No PlaceId found'); // reminder to use die
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue