summaryrefslogtreecommitdiff
path: root/online/logout/confirm
diff options
context:
space:
mode:
Diffstat (limited to 'online/logout/confirm')
-rw-r--r--online/logout/confirm/index.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/online/logout/confirm/index.php b/online/logout/confirm/index.php
new file mode 100644
index 0000000..36ecda6
--- /dev/null
+++ b/online/logout/confirm/index.php
@@ -0,0 +1,28 @@
+<?php
+
+if (!isset($_GET['_'])) {
+ header("Location: /online");
+ die();
+} else if (!ctype_alnum($_GET['_'])) {
+ header("Location: /online");
+ die();
+}
+
+if (!isset($_COOKIE["kartik_online_token"])) {
+ header("Location: https://jetbrains.minteck.ro.lt:1024/hub/hub/api/rest/oauth2/auth?client_id=2d3ca3a8-38b7-4193-990a-a9454bb8d44c&response_type=code&redirect_uri=https://kartik.hopto.org/online/callback_ig&scope=hub&request_credentials=default&access_type=offline");
+ die();
+} else if (ctype_xdigit($_COOKIE["kartik_online_token"]) && file_exists($_SERVER['DOCUMENT_ROOT'] . "/online/private/tokens/" . $_COOKIE['kartik_online_token'])) {
+ $_DATA = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/online/private/tokens/" . $_COOKIE['kartik_online_token']), true);
+} else {
+ header("Location: https://jetbrains.minteck.ro.lt:1024/hub/hub/api/rest/oauth2/auth?client_id=2d3ca3a8-38b7-4193-990a-a9454bb8d44c&response_type=code&redirect_uri=https://kartik.hopto.org/online/callback_ig&scope=hub&request_credentials=default&access_type=offline");
+ die();
+}
+
+foreach (scandir($_SERVER['DOCUMENT_ROOT'] . "/online/private/gametokens") as $token) {
+ if (trim($token) !== "." && trim($token) !== ".." && json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/online/private/gametokens/" . $token), true)["id"] === $_DATA["id"] && substr($token, 0, strlen($_GET['_'])) === $_GET['_']) {
+ unlink($_SERVER['DOCUMENT_ROOT'] . "/online/private/gametokens/" . $token);
+ }
+}
+
+header("Location: /online");
+die(); \ No newline at end of file