diff options
Diffstat (limited to 'online/ingame')
-rw-r--r-- | online/ingame/allow/index.php | 16 | ||||
-rw-r--r-- | online/ingame/api/profile.level.php | 15 | ||||
-rw-r--r-- | online/ingame/api/profile.logout.php | 15 | ||||
-rw-r--r-- | online/ingame/api/profile.name.php | 11 | ||||
-rw-r--r-- | online/ingame/api/profile.picture.php | 11 | ||||
-rw-r--r-- | online/ingame/api/profile.stats.php | 15 | ||||
-rw-r--r-- | online/ingame/api/profile.token.php | 13 | ||||
-rw-r--r-- | online/ingame/api/set.level.php | 13 | ||||
-rw-r--r-- | online/ingame/api/set.stats.php | 13 | ||||
-rw-r--r-- | online/ingame/index.php | 74 |
10 files changed, 196 insertions, 0 deletions
diff --git a/online/ingame/allow/index.php b/online/ingame/allow/index.php new file mode 100644 index 0000000..16171b6 --- /dev/null +++ b/online/ingame/allow/index.php @@ -0,0 +1,16 @@ +<?php
+
+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();
+}
+
+$token = bin2hex(random_bytes(96));
+file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/online/private/gametokens/" . $token, json_encode($_DATA));
+header("Location: http://localhost:14552/kartik-auth?_=" . $token);
+die();
\ No newline at end of file diff --git a/online/ingame/api/profile.level.php b/online/ingame/api/profile.level.php new file mode 100644 index 0000000..f7c8f8c --- /dev/null +++ b/online/ingame/api/profile.level.php @@ -0,0 +1,15 @@ +<?php
+
+if (!isset($_GET["kartik_online_token"])) {
+ die();
+} else if (ctype_xdigit($_GET["kartik_online_token"]) && file_exists($_SERVER['DOCUMENT_ROOT'] . "/online/private/gametokens/" . $_GET['kartik_online_token'])) {
+ $_DATA = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/online/private/gametokens/" . $_GET['kartik_online_token']), true);
+} else {
+ die();
+}
+
+if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/online/private/levels/" . $_DATA["id"])) {
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/online/private/levels/" . $_DATA["id"], "0");
+}
+
+echo(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/online/private/levels/" . $_DATA["id"]));
\ No newline at end of file diff --git a/online/ingame/api/profile.logout.php b/online/ingame/api/profile.logout.php new file mode 100644 index 0000000..c3f2e88 --- /dev/null +++ b/online/ingame/api/profile.logout.php @@ -0,0 +1,15 @@ +<?php
+
+if (!isset($_GET["kartik_online_token"])) {
+ echo("false");
+ die();
+} else if (ctype_xdigit($_GET["kartik_online_token"]) && file_exists($_SERVER['DOCUMENT_ROOT'] . "/online/private/gametokens/" . $_GET['kartik_online_token'])) {
+ $_DATA = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/online/private/gametokens/" . $_GET['kartik_online_token']), true);
+} else {
+ echo("false");
+ die();
+}
+
+echo("true");
+unlink($_SERVER['DOCUMENT_ROOT'] . "/online/private/gametokens/" . $_GET['kartik_online_token']);
+die();
\ No newline at end of file diff --git a/online/ingame/api/profile.name.php b/online/ingame/api/profile.name.php new file mode 100644 index 0000000..b8d70fa --- /dev/null +++ b/online/ingame/api/profile.name.php @@ -0,0 +1,11 @@ +<?php
+
+if (!isset($_GET["kartik_online_token"])) {
+ die();
+} else if (ctype_xdigit($_GET["kartik_online_token"]) && file_exists($_SERVER['DOCUMENT_ROOT'] . "/online/private/gametokens/" . $_GET['kartik_online_token'])) {
+ $_DATA = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/online/private/gametokens/" . $_GET['kartik_online_token']), true);
+} else {
+ die();
+}
+
+echo($_DATA["name"]);
\ No newline at end of file diff --git a/online/ingame/api/profile.picture.php b/online/ingame/api/profile.picture.php new file mode 100644 index 0000000..2dab624 --- /dev/null +++ b/online/ingame/api/profile.picture.php @@ -0,0 +1,11 @@ +<?php
+
+if (!isset($_GET["kartik_online_token"])) {
+ die();
+} else if (ctype_xdigit($_GET["kartik_online_token"]) && file_exists($_SERVER['DOCUMENT_ROOT'] . "/online/private/gametokens/" . $_GET['kartik_online_token'])) {
+ $_DATA = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/online/private/gametokens/" . $_GET['kartik_online_token']), true);
+} else {
+ die();
+}
+
+echo("data:image/jpeg;base64," . base64_encode(file_get_contents($_DATA["avatar"]["url"])));
\ No newline at end of file diff --git a/online/ingame/api/profile.stats.php b/online/ingame/api/profile.stats.php new file mode 100644 index 0000000..338febe --- /dev/null +++ b/online/ingame/api/profile.stats.php @@ -0,0 +1,15 @@ +<?php
+
+if (!isset($_GET["kartik_online_token"])) {
+ die();
+} else if (ctype_xdigit($_GET["kartik_online_token"]) && file_exists($_SERVER['DOCUMENT_ROOT'] . "/online/private/gametokens/" . $_GET['kartik_online_token'])) {
+ $_DATA = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/online/private/gametokens/" . $_GET['kartik_online_token']), true);
+} else {
+ die();
+}
+
+if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/online/private/stats/" . $_DATA["id"])) {
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/online/private/stats/" . $_DATA["id"], "null");
+}
+
+echo(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/online/private/stats/" . $_DATA["id"]));
\ No newline at end of file diff --git a/online/ingame/api/profile.token.php b/online/ingame/api/profile.token.php new file mode 100644 index 0000000..32aaaff --- /dev/null +++ b/online/ingame/api/profile.token.php @@ -0,0 +1,13 @@ +<?php
+
+if (!isset($_GET["kartik_online_token"])) {
+ echo("false");
+ die();
+} else if (ctype_xdigit($_GET["kartik_online_token"]) && file_exists($_SERVER['DOCUMENT_ROOT'] . "/online/private/gametokens/" . $_GET['kartik_online_token'])) {
+ $_DATA = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/online/private/gametokens/" . $_GET['kartik_online_token']), true);
+} else {
+ echo("false");
+ die();
+}
+
+echo("true");
\ No newline at end of file diff --git a/online/ingame/api/set.level.php b/online/ingame/api/set.level.php new file mode 100644 index 0000000..032d048 --- /dev/null +++ b/online/ingame/api/set.level.php @@ -0,0 +1,13 @@ +<?php
+
+if (!isset($_GET["kartik_online_token"])) {
+ die();
+} else if (ctype_xdigit($_GET["kartik_online_token"]) && file_exists($_SERVER['DOCUMENT_ROOT'] . "/online/private/gametokens/" . $_GET['kartik_online_token'])) {
+ $_DATA = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/online/private/gametokens/" . $_GET['kartik_online_token']), true);
+} else {
+ die();
+}
+
+if (is_integer((int)$_GET['level'])) {
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/online/private/levels/" . $_DATA["id"], $_GET['level']);
+}
\ No newline at end of file diff --git a/online/ingame/api/set.stats.php b/online/ingame/api/set.stats.php new file mode 100644 index 0000000..145cc30 --- /dev/null +++ b/online/ingame/api/set.stats.php @@ -0,0 +1,13 @@ +<?php
+
+if (!isset($_GET["kartik_online_token"])) {
+ die();
+} else if (ctype_xdigit($_GET["kartik_online_token"]) && file_exists($_SERVER['DOCUMENT_ROOT'] . "/online/private/gametokens/" . $_GET['kartik_online_token'])) {
+ $_DATA = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/online/private/gametokens/" . $_GET['kartik_online_token']), true);
+} else {
+ die();
+}
+
+if (strlen(base64_decode($_GET['stats'])) < 256) {
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/online/private/stats/" . $_DATA["id"], base64_decode($_GET['stats']));
+}
\ No newline at end of file diff --git a/online/ingame/index.php b/online/ingame/index.php new file mode 100644 index 0000000..5a6c3c4 --- /dev/null +++ b/online/ingame/index.php @@ -0,0 +1,74 @@ +<?php
+
+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();
+}
+
+function l($fr, $en) {
+ if (isset($_GET['lang'])) {
+ if ($_GET['lang'] == "en") {
+ $_SERVER['HTTP_ACCEPT_LANGUAGE'] = "en";
+ } else if ($_GET['lang'] == "fr") {
+ $_SERVER['HTTP_ACCEPT_LANGUAGE'] = "fr";
+ }
+ }
+ if (substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) == "fr") {
+ return $fr;
+ } else {
+ return $en;
+ }
+}
+
+?>
+<!DOCTYPE html>
+<html lang="en" style="height:100%;">
+<head>
+ <meta charset="UTF-8">
+ <title>Kartik Online</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <link rel="icon" href="/static/favicon.png">
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
+ <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
+ <link rel="stylesheet" href="/appsicons.css">
+</head>
+<body style="height:100%;">
+
+<nav class="navbar navbar-expand-sm bg-dark navbar-dark fixed-top">
+
+ <a class="navbar-brand" href="/">
+ <img src="/static/logo.png" alt="Kartik" style="height:32px;"><span style="vertical-align: middle;font-size: 14px;">Online</span>
+ </a>
+
+ <div class="collapse navbar-collapse" id="collapsibleNavbar">
+ <ul class="navbar-nav">
+ <li class="nav-item">
+ <a class="nav-link" href="/">← <?= l("Retourner au site de Kartik", "Go back to Kartik website") ?></a>
+ </li>
+ <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/apps.php"; ?>
+ </ul>
+ </div>
+</nav>
+
+<div id="separator" style="margin-top:90px;"></div>
+
+<div class="container" style="margin-top:25px;">
+ <h2 style="text-align: center;"><?= l("Jouer en tant que", "Play as") ?> <?= $_DATA["name"] ?> <?= l("sur Kartik", "on Kartik") ?></h2>
+ <h4 style="text-align: center;"><?= l("Vous serez connecté avec l'adresse email", "You will be logged in with the email") ?> <b><?= $_DATA["profile"]["email"]["email"] ?></b> <?= l("sur Kartik", "on Kartik") ?>. <u><?= l("N'autorisez que si cette page a été ouverte par une version non modifiée de Kartik", "Only allow if this page was opened from an unmodified version of Kartik.") ?></u></h4>
+ <br>
+ <p style="text-align:center;" class="btn-group container">
+ <a class="btn btn-success" href="/online/ingame/allow"><?= l("Autoriser", "Allow") ?></a>
+ <a class="btn btn-danger" href="/online"><?= l("Refuser", "Deny") ?></a>
+ </p>
+</div>
+
+</body>
+</html>
+
|