aboutsummaryrefslogtreecommitdiff
path: root/_site/includes/modules
diff options
context:
space:
mode:
Diffstat (limited to '_site/includes/modules')
-rw-r--r--_site/includes/modules/admin.php17
-rw-r--r--_site/includes/modules/desktop.php40
-rw-r--r--_site/includes/modules/errors.php182
-rw-r--r--_site/includes/modules/github.php22
-rw-r--r--_site/includes/modules/mobile.php38
-rw-r--r--_site/includes/modules/search.php16
6 files changed, 315 insertions, 0 deletions
diff --git a/_site/includes/modules/admin.php b/_site/includes/modules/admin.php
new file mode 100644
index 0000000..099ea00
--- /dev/null
+++ b/_site/includes/modules/admin.php
@@ -0,0 +1,17 @@
+<?php
+$admin = true;
+if (!isset($_COOKIE["ADMIN_TOKEN"])) {
+ $admin = false;
+ if (isset($__ADMIN)) header("Location: /admin/offline") and die();
+} else {
+ if (!(strpos("/", $_COOKIE['ADMIN_TOKEN']) === false && strpos(".", $_COOKIE['ADMIN_TOKEN']) === false && (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/admin/tokens/" . $_COOKIE['ADMIN_TOKEN']) || file_exists("/mnt/minteckrolt-main/admin/private/tokens/" . $_COOKIE['ADMIN_TOKEN'])))) {
+ $admin = false;
+ if (isset($__ADMIN)) header("Location: /admin/offline") and die();
+ } else {
+ if (file_exists("/mnt/minteckrolt-main/admin/private/tokens/" . $_COOKIE['ADMIN_TOKEN'])) {
+ $_USER = trim(file_get_contents("/mnt/minteckrolt-main/admin/private/tokens/" . $_COOKIE['ADMIN_TOKEN']));
+ } else {
+ $_USER = trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/admin/tokens/" . $_COOKIE['ADMIN_TOKEN']));
+ }
+ }
+} \ No newline at end of file
diff --git a/_site/includes/modules/desktop.php b/_site/includes/modules/desktop.php
new file mode 100644
index 0000000..9f93735
--- /dev/null
+++ b/_site/includes/modules/desktop.php
@@ -0,0 +1,40 @@
+<nav class="navbar navbar-expand-sm bg-dark navbar-dark" id="navbar-primary">
+ <div class="container">
+ <a class="navbar-brand" id="easteregg" href="/">♥ (Un)<?= $egg ?>Tech</a>
+
+ <ul class="navbar-nav" style="float:right;">
+ <li class="nav-item">
+ <a class="nav-link" href="/articles">Articles</a>
+ </li>
+ <li class="nav-item">
+ <a class="nav-link" href="/latest">Latest</a>
+ </li>
+ <li class="nav-item">
+ <a class="nav-link" href="/random">Random</a>
+ </li>
+ <?php if ($admin): ?>
+ <li class="nav-item">
+ <a class="nav-link nav-admin" href="/admin">Administration</a>
+ </li>
+ <?php endif; ?>
+
+ <li class="nav-item dropdown">
+ <a class="nav-link dropdown-toggle" href="#" id="apps_outer" data-toggle="dropdown">
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" class="glyph_f10"><path d="M1 19h4v-4H1zm7 0h4v-4H8zm7 0h4v-4h-4zM1 12h4V8H1zm7 0h4V8H8zm7 0h4V8h-4zM1 5h4V1H1zm7 0h4V1H8zm7-4v4h4V1z" id="apps_path"></path></svg>
+ </a>
+ <div class="dropdown-menu" id="apps" style="position:fixed;top:48px;left:0;right:0;pointer-events: none;">
+ <div class="dropdown-menu-outer container" style="pointer-events: none;">
+ <div class="dropdown-menu-inner" style="pointer-events: fill;max-width:max-content;margin-left:auto;">
+ <a href="https://github.com/Minteck" class="dropdown-item"><img alt="" src="/apps/github.png" class="app-icon"> <span class="app-title">GitHub</span></a>
+ <a href="https://kartik.hopto.org/online" class="dropdown-item"><img alt="" src="/apps/kartik.png" class="app-icon"> <span class="app-title">Kartik Online</span></a>
+ <a href="https://minteck.ro.lt" class="dropdown-item"><span class="app-title"><img alt="" src="/apps/minteck.svg" class="app-icon"> Minteck's Space</span></a>
+ <a href="https://unchainedtech.minteck.ro.lt" class="dropdown-item"><span class="app-title"><img alt="" src="/apps/unchainedtech.png" class="app-icon"> UnchainedTech</span></a>
+ <a href="https://jetbrains.minteck.ro.lt/hub" class="dropdown-item"><img alt="" src="/apps/hub.svg" class="app-icon"> <span class="app-title">Minteck's Hub</span></a>
+ <a href="https://jetbrains.minteck.ro.lt/youtrack" class="dropdown-item"><img alt="" src="/apps/youtrack.svg" class="app-icon"> <span class="app-title">YouTrack</span></a>
+ </div>
+ </div>
+ </div>
+ </li>
+ </ul>
+ </div>
+</nav> \ No newline at end of file
diff --git a/_site/includes/modules/errors.php b/_site/includes/modules/errors.php
new file mode 100644
index 0000000..ecb640f
--- /dev/null
+++ b/_site/includes/modules/errors.php
@@ -0,0 +1,182 @@
+<?php
+function customShutdown() {
+ global $debug;
+
+ if (!is_null(error_get_last())) {
+ ob_clean();
+ $d = error_get_last();
+ echo "
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Something went wrong on UnchainedTech 🌙</title>
+ <style>
+
+ @font-face {
+ src: url(\"/font/regular.woff2\");
+ font-family: \"JetBrains Mono\";
+ font-style: normal;
+ }
+
+ @font-face {
+ src: url(\"/font/italic.woff2\");
+ font-family: \"JetBrains Mono\";
+ font-style: italic;
+ }
+
+ *, pre {
+ font-family: \"JetBrains Mono\", sans-serif;
+ transition: none !important;
+ }
+
+ nav, * {
+ color: #00ff00 !important;
+ }
+
+ html, body, nav.navbar, .card {
+ background-color: black !important;
+ }
+
+ a:hover {
+ color: black !important;
+ background: #00ff00;
+ }
+
+ pre {
+ background: #00ff00;
+ border-radius: 5px;
+ padding: 10px;
+ color: black !important;
+ text-align: left;
+ }
+
+ @media (min-width: 700px) {
+ pre {
+ margin-left: 25%;
+ margin-right: 25%;
+ }
+ }
+
+ </style>
+</head>
+<body>
+ <div style='margin-top:50px;text-align: center;'>
+ <h1>Something went wrong <small>(like, for real!)</small></h1>
+ <p>An error occured and UnchainedTech cannot load right now. Even us can make mistakes sometimes, and because you are really nice you will <a href='https://jetbrains.minteck.ro.lt:1024/youtrack/newIssue?project=UT' target='_blank'>report this bug</a>.</p>
+ <p>For you, really tech-savvy people, here is that alien language thing you're probably looking for:</p>
+ <pre>
+#99{$d["type"]}: ";
+
+ $pparts = explode(": ", $d["message"]);
+ array_shift($pparts);
+
+ $parts = explode(" in ", implode(": ", $pparts));
+ echo($parts[0]);
+
+ $stp = explode("\nStack trace:", $parts[1]);
+ echo("\n at " . $stp[0]);
+
+ $stlines = explode("\n", $stp[1]);
+ array_shift($stlines);
+
+ foreach ($stlines as $stline) {
+ $stpparts = explode(" ", $stline);
+ array_shift($stpparts);
+ $stline = implode(" ", $stpparts);
+
+ if ($stline !== " thrown" && $stline !== "{main}") {
+ $pp2 = explode("(", $stline);
+ $pp2n = explode(")", $pp2[1]);
+
+ echo("\n at " . $pp2[0] . ":" . $pp2n[0]);
+ } else if ($stline === "{main}") {
+ echo("\n at UnchainedTech.\$Core (UCT Core " . file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/../version.txt") . ", PHP " . PHP_VERSION . ")");
+ }
+ }
+
+ echo "
+</pre>
+ </div>
+</body>
+</html>
+ ";
+ die();
+ }
+}
+
+function customError($errno, $errstr, $errfile = "&lt;unknown file&gt;", $errline = "&lt;unknown line&gt;") {
+ global $debug;
+
+ ob_clean();
+ echo "
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Something went wrong on UnchainedTech 🌙</title>
+ <style>
+
+ @font-face {
+ src: url(\"/font/regular.woff2\");
+ font-family: \"JetBrains Mono\";
+ font-style: normal;
+ }
+
+ @font-face {
+ src: url(\"/font/italic.woff2\");
+ font-family: \"JetBrains Mono\";
+ font-style: italic;
+ }
+
+ *, pre {
+ font-family: \"JetBrains Mono\", sans-serif;
+ transition: none !important;
+ }
+
+ nav, * {
+ color: #00ff00 !important;
+ }
+
+ html, body, nav.navbar, .card {
+ background-color: black !important;
+ }
+
+ a:hover {
+ color: black !important;
+ background: #00ff00;
+ }
+
+ pre {
+ background: #00ff00;
+ border-radius: 5px;
+ padding: 10px;
+ color: black !important;
+ text-align: left;
+ }
+
+ @media (min-width: 700px) {
+ pre {
+ margin-left: 25%;
+ margin-right: 25%;
+ }
+ }
+
+ </style>
+</head>
+<body>
+ <div style='margin-top:50px;text-align: center;'>
+ <h1>Something went wrong <small>(like, for real!)</small></h1>
+ <p>An error occured and UnchainedTech cannot load right now. Even us can make mistakes sometimes, and because you are really nice you will <a href='https://jetbrains.minteck.ro.lt:1024/youtrack/newIssue?project=UT' target='_blank'>report this bug</a>.</p>
+ <p>For you, really tech-savvy people, here is that alien language thing you're probably looking for:</p>
+ <pre>
+#{$errno}: {$errstr}
+ at {$errfile}:{$errline}
+ at UnchainedTech.\$Core (UCT Core " . file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/../version.txt") . ", PHP " . PHP_VERSION . ")
+</pre>
+ </div>
+</body>
+</html>
+ ";
+ die();
+}
+set_error_handler("customError", E_ALL);
+register_shutdown_function("customShutdown"); \ No newline at end of file
diff --git a/_site/includes/modules/github.php b/_site/includes/modules/github.php
new file mode 100644
index 0000000..596d984
--- /dev/null
+++ b/_site/includes/modules/github.php
@@ -0,0 +1,22 @@
+<?php
+function gh_api($api) {
+ $crl = curl_init("https://api.github.com/" . $api);
+ 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 " . json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/admin/credentials.json"), true)["token"],
+ "User-Agent: UnchainedTech-Admin/0.0.0 (nekostarfan@gmail.com)"
+ ));
+
+ $result = curl_exec($crl);
+
+ if ($result === false) {
+ throw new ErrorException("GitHub API unexpectedly interrupted", 214, E_ERROR);
+ }
+
+ return $result;
+} \ No newline at end of file
diff --git a/_site/includes/modules/mobile.php b/_site/includes/modules/mobile.php
new file mode 100644
index 0000000..967925e
--- /dev/null
+++ b/_site/includes/modules/mobile.php
@@ -0,0 +1,38 @@
+<nav class="navbar navbar-expand-sm bg-dark navbar-dark" id="navbar-mobile" style="display:none;">
+ <a class="navbar-brand" href="/">UnchainedTech</a>
+
+ <ul class="navbar-nav" style="text-align: center;display: grid;grid-template-columns: 1fr 1fr;">
+ <li class="nav-item">
+ <a class="nav-link" href="/articles">Articles</a>
+ </li>
+ <li class="nav-item">
+ <a class="nav-link" href="/latest">Latest</a>
+ </li>
+ <li class="nav-item">
+ <a class="nav-link" href="/random">Random</a>
+ </li>
+ <?php if ($admin): ?>
+ <li class="nav-item">
+ <a class="nav-link nav-admin" href="/admin">Administration</a>
+ </li>
+ <?php endif; ?>
+
+ <li class="nav-item dropdown" style="text-align: center;">
+ <a class="nav-link dropdown-toggle" href="#" id="apps_outer" data-toggle="dropdown">
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" class="glyph_f10"><path d="M1 19h4v-4H1zm7 0h4v-4H8zm7 0h4v-4h-4zM1 12h4V8H1zm7 0h4V8H8zm7 0h4V8h-4zM1 5h4V1H1zm7 0h4V1H8zm7-4v4h4V1z" id="apps_path"></path></svg>
+ </a>
+ <div class="dropdown-menu" id="apps" style="position:fixed;top:48px;left:0;right:0;pointer-events: none;">
+ <div class="dropdown-menu-outer container" style="pointer-events: none;">
+ <div class="dropdown-menu-inner" style="pointer-events: fill;max-width:max-content;margin-left:auto;">
+ <a href="https://github.com/Minteck" class="dropdown-item"><img alt="" src="/apps/github.png" class="app-icon"> <span class="app-title">GitHub</span></a>
+ <a href="https://kartik.hopto.org/online" class="dropdown-item"><img alt="" src="/apps/kartik.png" class="app-icon"> <span class="app-title">Kartik Online</span></a>
+ <a href="https://minteck.ro.lt" class="dropdown-item"><span class="app-title"><img alt="" src="/apps/minteck.svg" class="app-icon"> Minteck's Space</span></a>
+ <a href="https://unchainedtech.minteck.ro.lt" class="dropdown-item"><span class="app-title"><img alt="" src="/apps/unchainedtech.png" class="app-icon"> UnchainedTech</span></a>
+ <a href="https://jetbrains.minteck.ro.lt/hub" class="dropdown-item"><img alt="" src="/apps/hub.svg" class="app-icon"> <span class="app-title">Minteck's Hub</span></a>
+ <a href="https://jetbrains.minteck.ro.lt/youtrack" class="dropdown-item"><img alt="" src="/apps/youtrack.svg" class="app-icon"> <span class="app-title">YouTrack</span></a>
+ </div>
+ </div>
+ </div>
+ </li>
+ </ul>
+</nav> \ No newline at end of file
diff --git a/_site/includes/modules/search.php b/_site/includes/modules/search.php
new file mode 100644
index 0000000..fe37786
--- /dev/null
+++ b/_site/includes/modules/search.php
@@ -0,0 +1,16 @@
+<nav class="navbar navbar-expand-sm bg-dark navbar-dark" id="navbar-search">
+ <div class="container">
+ <a class="navbar-brand" href="/"><img src="/logo.svg" width="36px" style="vertical-align: middle;">&nbsp; <span style="vertical-align: middle;">UnchainedTech</span></a>
+
+ <form class="form-inline" action="/search" id="search-form">
+ <input class="form-control mr-sm-2" type="text" name="q" value="<?php
+
+ if (isset($_GET['q']) && strpos($_GET['q'], "/") === false && strpos($_GET['q'], "&") === false && strpos($_GET['q'], ">") === false && strpos($_GET['q'], ">") === false) {
+ echo($_GET['q']);
+ }
+
+ ?>" placeholder="Search articles">
+ <button class="btn btn-success" type="submit" id="search-submit">Search</button>
+ </form>
+ </div>
+</nav> \ No newline at end of file