From 1d62401c897a5ba82d0def92d97d09195a6d676f Mon Sep 17 00:00:00 2001 From: Minteck <46352972+Minteck@users.noreply.github.com> Date: Thu, 1 Jul 2021 00:54:32 +0200 Subject: Fixed stuff + official logo --- _site/admin/callback/index.php | 59 ++++++++++++++++++++++++++++++++++++++++++ _site/admin/denied/index.php | 10 +++++++ _site/admin/index.php | 15 +++++++++++ _site/admin/login/index.php | 4 +++ _site/admin/offline/index.php | 13 ++++++++++ _site/admin/status/index.php | 40 ++++++++++++++++++++++++++++ 6 files changed, 141 insertions(+) create mode 100644 _site/admin/callback/index.php create mode 100644 _site/admin/denied/index.php create mode 100644 _site/admin/index.php create mode 100644 _site/admin/login/index.php create mode 100644 _site/admin/offline/index.php create mode 100644 _site/admin/status/index.php (limited to '_site/admin') diff --git a/_site/admin/callback/index.php b/_site/admin/callback/index.php new file mode 100644 index 0000000..4243799 --- /dev/null +++ b/_site/admin/callback/index.php @@ -0,0 +1,59 @@ + 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: Blogchain-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, "/", "blogchain.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 new file mode 100644 index 0000000..8eb88c2 --- /dev/null +++ b/_site/admin/denied/index.php @@ -0,0 +1,10 @@ + + +
+

Access is denied

+

This is a "staff only" page

+

You tried to access a page that is on Blogchain's Administrators Workplace, which you cannot get access to because your GitHub account is not registered as a Blogchain Administrator.

+

You probably want to go back home.

+
+ + \ No newline at end of file diff --git a/_site/admin/index.php b/_site/admin/index.php new file mode 100644 index 0000000..62d4fa7 --- /dev/null +++ b/_site/admin/index.php @@ -0,0 +1,15 @@ + + +
+

Welcome back !

+

You now have access to all unpublished blog articles, except on the RSS feed.

+
+ +
+

Tasks

+ +
+ + \ No newline at end of file diff --git a/_site/admin/login/index.php b/_site/admin/login/index.php new file mode 100644 index 0000000..0741757 --- /dev/null +++ b/_site/admin/login/index.php @@ -0,0 +1,4 @@ + + +
+

Extensively and simply manage Blogchain

+

View unpublished articles, get statistics, export data and more.

+ +

+ Login with Minteck Central Admin + Login with GitHub +

+
+ + \ No newline at end of file diff --git a/_site/admin/status/index.php b/_site/admin/status/index.php new file mode 100644 index 0000000..6d46f34 --- /dev/null +++ b/_site/admin/status/index.php @@ -0,0 +1,40 @@ + + +
+

Data Sync Status

+

Check if everything is good!

+
+ +
+ +
+ + \ No newline at end of file -- cgit