diff options
Diffstat (limited to '_site/admin')
-rw-r--r-- | _site/admin/callback/index.php | 116 | ||||
-rw-r--r-- | _site/admin/denied/index.php | 18 | ||||
-rw-r--r-- | _site/admin/index.php | 28 | ||||
-rw-r--r-- | _site/admin/login/index.php | 6 | ||||
-rw-r--r-- | _site/admin/offline/index.php | 24 | ||||
-rw-r--r-- | _site/admin/status/index.php | 78 |
6 files changed, 135 insertions, 135 deletions
diff --git a/_site/admin/callback/index.php b/_site/admin/callback/index.php index 9c85d46..eb3597e 100644 --- a/_site/admin/callback/index.php +++ b/_site/admin/callback/index.php @@ -1,59 +1,59 @@ -<?php - -if (!isset($_GET['code'])) { - throw new ErrorException("GitHub OAuth Flow interrupted", 214, E_ERROR); -} - -$data = array( - 'client_id' => json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/admin/credentials.json"), true)["id"], - 'client_secret' => json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/admin/credentials.json"), true)["secret"], - 'code' => $_GET['code'] -); - -$post_data = json_encode($data); - -$crl = curl_init('https://github.com/login/oauth/access_token'); -curl_setopt($crl, CURLOPT_RETURNTRANSFER, true); -curl_setopt($crl, CURLINFO_HEADER_OUT, true); -curl_setopt($crl, CURLOPT_POST, true); -curl_setopt($crl, CURLOPT_POSTFIELDS, $post_data); - -curl_setopt($crl, CURLOPT_HTTPHEADER, array( - 'Content-Type: application/json', - "Accept: application/json" -)); - -$result = curl_exec($crl); - -if ($result === false) { - throw new ErrorException("GitHub OAuth Flow interrupted", 214, E_ERROR); -} - -curl_close($crl); - -$data = json_decode($result, true); -$crl = curl_init('https://api.github.com/user'); -curl_setopt($crl, CURLOPT_RETURNTRANSFER, true); -curl_setopt($crl, CURLINFO_HEADER_OUT, true); -curl_setopt($crl, CURLOPT_POST, false); - -curl_setopt($crl, CURLOPT_HTTPHEADER, array( - 'Content-Type: application/json', - "Accept: application/json", - "Authorization: token " . $data["access_token"], - "User-Agent: UnchainedTech-Admin/0.0.0 (nekostarfan@gmail.com)" -)); - -$result = curl_exec($crl); -$ndata = json_decode($result, true); - -if (!in_array($ndata["login"], json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/admin/authorized.json"), true))) { - header("Location: /admin/denied"); - die(); -} - -file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/admin/tokens/" . $data["access_token"], $ndata["login"]); -setcookie("ADMIN_TOKEN", $data["access_token"], 0, "/", "unchainedtech.minteck.ro.lt", true, true); - -header("Location: /admin"); +<?php
+
+if (!isset($_GET['code'])) {
+ throw new ErrorException("GitHub OAuth Flow interrupted", 214, E_ERROR);
+}
+
+$data = array(
+ 'client_id' => json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/admin/credentials.json"), true)["id"],
+ 'client_secret' => json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/admin/credentials.json"), true)["secret"],
+ 'code' => $_GET['code']
+);
+
+$post_data = json_encode($data);
+
+$crl = curl_init('https://github.com/login/oauth/access_token');
+curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
+curl_setopt($crl, CURLINFO_HEADER_OUT, true);
+curl_setopt($crl, CURLOPT_POST, true);
+curl_setopt($crl, CURLOPT_POSTFIELDS, $post_data);
+
+curl_setopt($crl, CURLOPT_HTTPHEADER, array(
+ 'Content-Type: application/json',
+ "Accept: application/json"
+));
+
+$result = curl_exec($crl);
+
+if ($result === false) {
+ throw new ErrorException("GitHub OAuth Flow interrupted", 214, E_ERROR);
+}
+
+curl_close($crl);
+
+$data = json_decode($result, true);
+$crl = curl_init('https://api.github.com/user');
+curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
+curl_setopt($crl, CURLINFO_HEADER_OUT, true);
+curl_setopt($crl, CURLOPT_POST, false);
+
+curl_setopt($crl, CURLOPT_HTTPHEADER, array(
+ 'Content-Type: application/json',
+ "Accept: application/json",
+ "Authorization: token " . $data["access_token"],
+ "User-Agent: UnchainedTech-Admin/0.0.0 (nekostarfan@gmail.com)"
+));
+
+$result = curl_exec($crl);
+$ndata = json_decode($result, true);
+
+if (!in_array($ndata["login"], json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/admin/authorized.json"), true))) {
+ header("Location: /admin/denied");
+ die();
+}
+
+file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/admin/tokens/" . $data["access_token"], $ndata["login"]);
+setcookie("ADMIN_TOKEN", $data["access_token"], 0, "/", ".minteck.ro.lt", true, true);
+
+header("Location: /admin");
die();
\ No newline at end of file diff --git a/_site/admin/denied/index.php b/_site/admin/denied/index.php index ec51020..2e33a01 100644 --- a/_site/admin/denied/index.php +++ b/_site/admin/denied/index.php @@ -1,10 +1,10 @@ -<?php $_TITLE = "Access is denied"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/dom/header.php"; ?> - -<div class="container" style="margin-top:30px;text-align: center;"> - <h1>Access is denied</h1> - <h4 style="margin-bottom:20px;">This is a "staff only" page</h4> - <p>You tried to access a page that is on UnchainedTech's Administrators Workplace, which you cannot get access to because your GitHub account is not registered as a UnchainedTech Administrator.</p> - <p>You probably want to <a href="/" style="text-decoration: underline;">go back home</a>.</p> -</div> - +<?php $_TITLE = "Access is denied"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/dom/header.php"; ?>
+
+<div class="container" style="margin-top:30px;text-align: center;">
+ <h1>Access is denied</h1>
+ <h4 style="margin-bottom:20px;">This is a "staff only" page</h4>
+ <p>You tried to access a page that is on UnchainedTech's Administrators Workplace, which you cannot get access to because your GitHub account is not registered as a UnchainedTech Administrator.</p>
+ <p>You probably want to <a href="/" style="text-decoration: underline;">go back home</a>.</p>
+</div>
+
<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/dom/footer.php"; ?>
\ No newline at end of file diff --git a/_site/admin/index.php b/_site/admin/index.php index 4697dfd..7d396bb 100644 --- a/_site/admin/index.php +++ b/_site/admin/index.php @@ -1,15 +1,15 @@ -<?php $__ADMIN = true; $_TITLE = "UnchainedTech Administration"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/dom/header.php"; ?> - -<div class="container" style="margin-top:30px;text-align: center;"> - <h2>Welcome back <?= $_USER ?>!</h2> - <p>You now have access to all unpublished blog articles, except on the RSS feed.</p> -</div> - -<div class="container"> - <h3>Tasks</h3> - <ul class="list-group"> - <a class="list-group-item list-group-item-action" href="/admin/status">Data Sync Status</a> - </ul> -</div> - +<?php $__ADMIN = true; $_TITLE = "UnchainedTech Administration"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/dom/header.php"; ?>
+
+<div class="container" style="margin-top:30px;text-align: center;">
+ <h2>Welcome back!</h2>
+ <p>You now have access to all unpublished blog articles, except on the RSS feed.</p>
+</div>
+
+<div class="container">
+ <h3>Tasks</h3>
+ <ul class="list-group">
+ <a class="list-group-item list-group-item-action" href="/admin/status">Data Sync Status</a>
+ </ul>
+</div>
+
<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/dom/footer.php"; ?>
\ No newline at end of file diff --git a/_site/admin/login/index.php b/_site/admin/login/index.php index 44db39c..d89b5a5 100644 --- a/_site/admin/login/index.php +++ b/_site/admin/login/index.php @@ -1,4 +1,4 @@ -<?php - -header("Location: https://github.com/login/oauth/authorize?client_id=" . json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/admin/credentials.json"), true)["id"] . "&redirect_uri=https://unchainedtech.minteck.ro.lt/admin/callback/&allow_signups=false&scope=read:user"); +<?php
+
+header("Location: https://github.com/login/oauth/authorize?client_id=" . json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/admin/credentials.json"), true)["id"] . "&redirect_uri=https://unchainedtech.minteck.ro.lt/admin/callback/&allow_signups=false&scope=read:user");
die();
\ No newline at end of file diff --git a/_site/admin/offline/index.php b/_site/admin/offline/index.php index a013a17..f250faa 100644 --- a/_site/admin/offline/index.php +++ b/_site/admin/offline/index.php @@ -1,13 +1,13 @@ -<?php $_TITLE = "UnchainedTech Administration"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/dom/header.php"; ?> - -<div class="container" style="margin-top:30px;text-align: center;"> - <h2>Extensively and simply manage UnchainedTech</h2> - <p>View unpublished articles, get statistics, export data and more.</p> - - <p> - <a class="btn btn-primary" href="https://minteck.ro.lt/admin/unchainedtech">Login with Minteck Central Admin</a> - <a class="btn btn-primary" href="/admin/login">Login with GitHub</a> - </p> -</div> - +<?php $_TITLE = "UnchainedTech Administration"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/dom/header.php"; ?>
+
+<div class="container" style="margin-top:30px;text-align: center;">
+ <h2>Extensively and simply manage UnchainedTech</h2>
+ <p>View unpublished articles, get statistics, export data and more.</p>
+
+ <p>
+ <a class="btn btn-primary" href="https://minteck.ro.lt/admin">Login with Minteck Admin (beta)</a>
+ <a class="btn btn-primary" href="/admin/login">Login with GitHub</a>
+ </p>
+</div>
+
<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/dom/footer.php"; ?>
\ No newline at end of file diff --git a/_site/admin/status/index.php b/_site/admin/status/index.php index 40671c2..2698c5b 100644 --- a/_site/admin/status/index.php +++ b/_site/admin/status/index.php @@ -1,40 +1,40 @@ -<?php $__ADMIN = true; $_TITLE = "Data Sync Status - UnchainedTech Administration"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/dom/header.php"; ?> - -<div class="container" style="margin-top:30px;text-align: center;"> - <h2>Data Sync Status</h2> - <p>Check if everything is good!</p> -</div> - -<div class="container"> - <ul> - <?php - - $commit = json_decode(gh_api("repos/Minteck/UnchainedTech-Content/commits"), true)[0]; - if (!isset($commit["commit"]["verification"]) || !isset($commit["commit"]["verification"]["verified"]) || !$commit["commit"]["verification"]["verified"]) { - echo("<li class='list-admin-warning'>This version is <b>not</b> digitally signed, its content may have been compromised.</li>"); - } - - ?> - <li><b>Upstream version:</b> <?php - - echo(substr($commit["sha"], 0, 7) . " « " . $commit["commit"]["message"] . " » · commited by " . $commit["commit"]["author"]["name"]); - - ?></li> - <li><b>Downstream version:</b> <?php - - echo(substr(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/../_posts/.git/refs/heads/master"), 0, 7)); - - ?></li> - <li><?php - - if (trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/../_posts/.git/refs/heads/master")) === trim($commit["sha"])) { - echo("Downstream is up to date"); - } else { - echo("Downstream <b>rebase needed</b>"); - } - - ?></li> - </ul> -</div> - +<?php $__ADMIN = true; $_TITLE = "Data Sync Status - UnchainedTech Administration"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/dom/header.php"; ?>
+
+<div class="container" style="margin-top:30px;text-align: center;">
+ <h2>Data Sync Status</h2>
+ <p>Check if everything is good!</p>
+</div>
+
+<div class="container">
+ <ul>
+ <?php
+
+ $commit = json_decode(gh_api("repos/Minteck/UnchainedTech-Content/commits"), true)[0];
+ if (!isset($commit["commit"]["verification"]) || !isset($commit["commit"]["verification"]["verified"]) || !$commit["commit"]["verification"]["verified"]) {
+ echo("<li class='list-admin-warning'>This version is <b>not</b> digitally signed, its content may have been compromised.</li>");
+ }
+
+ ?>
+ <li><b>Upstream version:</b> <?php
+
+ echo(substr($commit["sha"], 0, 7) . " « " . $commit["commit"]["message"] . " » · commited by " . $commit["commit"]["author"]["name"]);
+
+ ?></li>
+ <li><b>Downstream version:</b> <?php
+
+ echo(substr(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/../_posts/.git/refs/heads/master"), 0, 7));
+
+ ?></li>
+ <li><?php
+
+ if (trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/../_posts/.git/refs/heads/master")) === trim($commit["sha"])) {
+ echo("Downstream is up to date");
+ } else {
+ echo("Downstream <b>rebase needed</b>");
+ }
+
+ ?></li>
+ </ul>
+</div>
+
<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/dom/footer.php"; ?>
\ No newline at end of file |