65 lines
2.6 KiB
PHP
65 lines
2.6 KiB
PHP
<?php
|
|
require_once '../core/config.php';
|
|
header('content-type:application/json');
|
|
$allstatus = [
|
|
1 => "0 or 1 is not an error - it is a sign that we should wait",
|
|
2 => "Success",
|
|
3 => "Disabled",
|
|
4 => "Failed to start",
|
|
5 => "Game ended",
|
|
6 => "GAME_FULL",
|
|
10 => "USER_LEFT"
|
|
];
|
|
$token = $_GET["token"];
|
|
$checkifuser = $con->prepare('SELECT COUNT(*) FROM tokens WHERE token=:token'); // bruh im too lazy to actually make a auto token generator thing and a table so rn this will be temporary
|
|
$checkifuser->bindParam(':token', $token);
|
|
$checkifuser->execute();
|
|
$momentoftruth = $checkifuser->fetchColumn();
|
|
if ($momentoftruth == 1) {
|
|
$okbruh = "1";
|
|
$haha = $con->prepare('SELECT COUNT(*) FROM tokens WHERE token=:token AND passedplacelauncher=:passed');
|
|
$haha->bindParam(':token', $token);
|
|
$haha->bindParam(':passed', $okbruh);
|
|
$haha->execute();
|
|
$moretrolling = $haha->fetchColumn();
|
|
if ($moretrolling == 1) {
|
|
header("Location: /");
|
|
} else if ($moretrolling == 0) {
|
|
$hahatroll = $con->prepare('UPDATE tokens SET passedplacelauncher = 1 WHERE token=:token');
|
|
$hahatroll->bindParam(':token', $token);
|
|
$hahatroll->execute();
|
|
$getstuff = $con->prepare('SELECT placeid FROM tokens WHERE token=:token');
|
|
$getstuff->bindParam(':token', $token);
|
|
$getstuff->execute();
|
|
$china = $getstuff->fetch(PDO::FETCH_BOTH);
|
|
$placeid = $china['placeid']; // use this to start the job
|
|
$status = "2";
|
|
$ip = $AvailableGameservers[1];
|
|
$port = 64989;
|
|
$PortForGame = ""; // also pls define this
|
|
$job = ""; // we will define this later when we start the job
|
|
// JOB STARTING CODE GOES HERE PLS HELP NOLAN
|
|
// anyways after ur done with that
|
|
$sendthatjob = $con->prepare('INSERT INTO jobs (jobid, placeid, port) VALUES (:jobid, :placeid, :port)');
|
|
$jobid = "notnull"; // this is just a temp workaround
|
|
$sendthatjob->bindParam(':jobid', $jobid);
|
|
$tempplaceid = "1818";
|
|
$sendthatjob->bindParam(':placeid', $tempplaceid); // another temporary thing since we don't have random token generator thing and token table
|
|
$sendthatjob->bindParam(':port', $PortForGame);
|
|
$sendthatjob->execute();
|
|
$response = [
|
|
"jobId" => $jobid,
|
|
"status" => $status,
|
|
"joinScriptUrl" => "http://". $soapcfg['url'] ."/game/join?token=". $token ."&jobid=". $jobid,
|
|
"authenticationUrl" => "http://". $soapcfg['url'] ."/Login/Negotiate.ashx",
|
|
"authenticationTicket" => $token,
|
|
"message" => $allstatus[$status]
|
|
];
|
|
echo json_encode($response);
|
|
// if u would of paid me to do all of these spaces i would rob u
|
|
} else {
|
|
header("Location: /");
|
|
}
|
|
}
|
|
?>
|