summaryrefslogtreecommitdiff
path: root/pages/api/chrome.php
diff options
context:
space:
mode:
Diffstat (limited to 'pages/api/chrome.php')
-rw-r--r--pages/api/chrome.php87
1 files changed, 87 insertions, 0 deletions
diff --git a/pages/api/chrome.php b/pages/api/chrome.php
new file mode 100644
index 0000000..0be8a94
--- /dev/null
+++ b/pages/api/chrome.php
@@ -0,0 +1,87 @@
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn;
+
+
+if (isset($_GET["e"])) {
+ header("Access-Control-Allow-Origin: chrome-extension://klenhenmabddpffgdaijdkjmfkkafbno");
+} else {
+ header("Access-Control-Allow-Origin: *");
+}
+
+header("Access-Control-Allow-Credentials: true");
+header("Access-Control-Allow-Methods: *");
+header("Access-Control-Allow-Headers: *");
+
+if (!isset($_GET["t"])) {
+ header("Content-Type: application/json");
+
+ if ($isLoggedIn) {
+ die("true");
+ } else {
+ die("false");
+ }
+} else {
+ switch ($_GET["t"]) {
+ case "onboarding":
+ header("Content-Type: text/html");
+
+ ?>
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <link rel="icon" href="https://git.equestria.dev/repo-avatars/1c0dad449a8e21ad16fa0efb1426c1a3301b1f26a8cb3b3902eec88bb568e34c" type="image/png">
+ <title>Luna for Chrome OS</title>
+ <style>
+ html, body {
+ background-color: #0d0b16;
+ color: white;
+ font-family: sans-serif;
+ overflow: hidden;
+ }
+
+ button:hover {
+ opacity: .75;
+ }
+
+ button:active {
+ opacity: .5;
+ }
+ </style>
+</head>
+<body>
+<div style="max-width: 65vw; margin-left: auto; margin-right: auto; height: 100vh; display: flex; align-items: center; justify-content: center; text-align: center;">
+ <div>
+ <img src="https://git.equestria.dev/repo-avatars/1c0dad449a8e21ad16fa0efb1426c1a3301b1f26a8cb3b3902eec88bb568e34c" width="128px">
+ <h1>Please login to Cold Haze</h1>
+ <p>To proceed with activating Luna on this Chromebook, you need to login to Cold Haze. You also need to make sure you properly enroled this computer into Chrome Enterprise.</p>
+ <button onclick='window.open("https://ponies.equestria.horse/-/login/?return=/api/close&mini", "_blank", "popup,top=100,width=100,height:250")' style="cursor: pointer; background: #5958ad; color: white; border: none; padding: 5px 10px; border-radius: 5px;">Login</button>
+ </div>
+</div>
+
+<script>
+ setTimeout(async () => {
+ if (JSON.parse(await (await fetch("https://ponies.equestria.horse/api/chrome")).text())) {
+ window.close();
+ }
+ });
+
+ setInterval(async () => {
+ if (JSON.parse(await (await fetch("https://ponies.equestria.horse/api/chrome")).text())) {
+ window.close();
+ }
+ }, 5000);
+</script>
+</body>
+</html>
+<?php
+
+ die();
+ default:
+ header("Location: /");
+ die();
+ }
+} \ No newline at end of file