diff options
author | RaindropsSys <raindrops@equestria.dev> | 2023-11-17 23:25:29 +0100 |
---|---|---|
committer | RaindropsSys <raindrops@equestria.dev> | 2023-11-17 23:25:29 +0100 |
commit | 953ddd82e48dd206cef5ac94456549aed13b3ad5 (patch) | |
tree | 8f003106ee2e7f422e5a22d2ee04d0db302e66c0 /includes/fragments | |
parent | 62a9199846b0c07c03218703b33e8385764f42d9 (diff) | |
download | pluralconnect-953ddd82e48dd206cef5ac94456549aed13b3ad5.tar.gz pluralconnect-953ddd82e48dd206cef5ac94456549aed13b3ad5.tar.bz2 pluralconnect-953ddd82e48dd206cef5ac94456549aed13b3ad5.zip |
Updated 30 files and deleted 2976 files (automated)
Diffstat (limited to 'includes/fragments')
-rw-r--r-- | includes/fragments/edit-private.inc | 142 | ||||
-rw-r--r-- | includes/fragments/edit.inc | 142 | ||||
-rw-r--r-- | includes/fragments/evening.inc | 245 | ||||
-rw-r--r-- | includes/fragments/member.inc | 104 | ||||
-rw-r--r-- | includes/fragments/metadata.inc | 54 | ||||
-rw-r--r-- | includes/fragments/sysedit.inc | 153 | ||||
-rw-r--r-- | includes/fragments/system.inc | 12 |
7 files changed, 7 insertions, 845 deletions
diff --git a/includes/fragments/edit-private.inc b/includes/fragments/edit-private.inc deleted file mode 100644 index 998dfdd..0000000 --- a/includes/fragments/edit-private.inc +++ /dev/null @@ -1,142 +0,0 @@ -<?php global $system; global $systemCommonName; global $systemID; global $member; global $memberData; global $memberCommonName; global $memberID; $title = "Editing " . $memberCommonName . " (private page) · " . $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; - -if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $memberID . ".json")) { - $metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $memberID . ".json"), true)); -} - -?> - -<br> -<div class="container"> - <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/components/fullbanner.inc"; ?> - - <p class="text-muted" id="page-content"> - <span id="editor-save-status" class="text-muted">Saved</span> · <span id="editor-size"><?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID-private.html") ? strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID-private.html")) : "0" ?></span> bytes · <a href="/<?= $memberData["name"] ?>">View page</a> - </p> - - <!--suppress HtmlFormInputWithoutLabel --> - <textarea id="page-editor"> - <?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID-private.html") ? file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID-private.html") : "" ?> - </textarea> - - <script src="/assets/editor/editor.js"></script> - <script> - let editor; - ClassicEditor - .create( document.querySelector( '#page-editor' ), { - toolbar: [ - 'undo', 'redo', '|', 'removeFormat', '|', 'heading', '|', 'fontSize', 'fontColor', 'fontBackgroundColor', 'alignment', '|', 'bold', 'italic', 'underline', 'strikethrough', '|', 'subscript', 'superscript', '|', 'code', '|', 'outdent', 'indent', '|', 'bulletedList', 'numberedList', '|', 'link', 'imageUpload', 'mediaEmbed', 'blockQuote', 'insertTable', 'codeBlock', '|', 'horizontalLine' - ] - } ) - - .then( newEditor => { - editor = newEditor; - } ) - .catch( error => { - console.error( error ); - } ); - </script> - <style> - :root { - --ck-color-base-background: transparent; - } - - .ck-toolbar { - filter: invert(1); - } - - .ck-tooltip__text { - color: white !important; - } - - .ck-dropdown__panel { - background: #ddd !important; - } - - .ck-color-grid__tile { - filter: invert(1); - } - - .ck-balloon-rotator { - background-color: #ccc !important; - } - - .ck-balloon-panel { - filter: invert(1); - } - </style> - <script> - let lastSavedData = editor.getData(); - let lastFetchedData = editor.getData(); - let timeSinceLastModified = 0; - let saving = false; - - async function save() { - let data = editor.getData(); - document.getElementById("editor-save-status").innerHTML = "Saving..."; - document.getElementById("editor-save-status").classList.remove("text-danger"); - document.getElementById("editor-save-status").classList.remove("text-muted"); - document.getElementById("editor-save-status").classList.remove("text-warning"); - document.getElementById("editor-save-status").classList.add("text-primary"); - saving = true; - - try { - await window.fetch("/api/save-private?system=<?= $systemID ?>&member=<?= $memberID ?>", { - method: "POST", - body: JSON.stringify({ content: data }) - }); - document.getElementById("editor-save-status").innerHTML = "Saved"; - document.getElementById("editor-save-status").classList.remove("text-danger"); - document.getElementById("editor-save-status").classList.add("text-muted"); - document.getElementById("editor-save-status").classList.remove("text-warning"); - document.getElementById("editor-save-status").classList.remove("text-primary"); - lastSavedData = data; - saving = false; - } catch (e) { - console.error(e); - document.getElementById("editor-save-status").innerHTML = "Failed to save"; - document.getElementById("editor-save-status").classList.add("text-danger"); - document.getElementById("editor-save-status").classList.remove("text-muted"); - document.getElementById("editor-save-status").classList.remove("text-warning"); - document.getElementById("editor-save-status").classList.remove("text-primary"); - } - } - - document.onclick = async () => { - if (saving) return; - - if (editor.getData() !== lastSavedData) { - await save(); - } - } - - setInterval(async () => { - if (saving) return; - - document.getElementById("editor-size").innerHTML = editor.getData().length; - - if (editor.getData() !== lastSavedData) { - document.getElementById("editor-save-status").innerHTML = "Modified"; - document.getElementById("editor-save-status").classList.remove("text-danger"); - document.getElementById("editor-save-status").classList.remove("text-muted"); - document.getElementById("editor-save-status").classList.add("text-warning"); - document.getElementById("editor-save-status").classList.remove("text-primary"); - - if (editor.getData() !== lastFetchedData) { - lastFetchedData = editor.getData(); - timeSinceLastModified = 0; - } else { - timeSinceLastModified++; - } - - if (timeSinceLastModified > 20) { - await save(); - } - } else { - timeSinceLastModified = 0; - } - }, 100) - </script> -</div> - -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?>
\ No newline at end of file diff --git a/includes/fragments/edit.inc b/includes/fragments/edit.inc deleted file mode 100644 index b5617f2..0000000 --- a/includes/fragments/edit.inc +++ /dev/null @@ -1,142 +0,0 @@ -<?php global $system; global $systemCommonName; global $systemID; global $member; global $memberData; global $memberCommonName; global $memberID; $title = "Editing " . $memberCommonName . " (public page) · " . $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; - -if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $memberID . ".json")) { - $metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $memberID . ".json"), true)); -} - -?> - -<br> -<div class="container"> - <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/components/fullbanner.inc"; ?> - - <p class="text-muted" id="page-content"> - <span id="editor-save-status" class="text-muted">Saved</span> · <span id="editor-size"><?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID-private.html") ? strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID-private.html")) : "0" ?></span> bytes · <a href="/<?= $memberData["name"] ?>">View page</a> - </p> - - <!--suppress HtmlFormInputWithoutLabel --> - <textarea id="page-editor"> - <?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID.html") ? file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID.html") : "" ?> - </textarea> - - <script src="/assets/editor/editor.js"></script> - <script> - let editor; - ClassicEditor - .create( document.querySelector( '#page-editor' ), { - toolbar: [ - 'undo', 'redo', '|', 'removeFormat', '|', 'heading', '|', 'fontSize', 'fontColor', 'fontBackgroundColor', 'alignment', '|', 'bold', 'italic', 'underline', 'strikethrough', '|', 'subscript', 'superscript', '|', 'code', '|', 'outdent', 'indent', '|', 'bulletedList', 'numberedList', '|', 'link', 'imageUpload', 'mediaEmbed', 'blockQuote', 'insertTable', 'codeBlock', '|', 'horizontalLine' - ] - } ) - - .then( newEditor => { - editor = newEditor; - } ) - .catch( error => { - console.error( error ); - } ); - </script> - <style> - :root { - --ck-color-base-background: transparent; - } - - .ck-toolbar { - filter: invert(1); - } - - .ck-tooltip__text { - color: white !important; - } - - .ck-dropdown__panel { - background: #ddd !important; - } - - .ck-color-grid__tile { - filter: invert(1); - } - - .ck-balloon-rotator { - background-color: #ccc !important; - } - - .ck-balloon-panel { - filter: invert(1); - } - </style> - <script> - let lastSavedData = editor.getData(); - let lastFetchedData = editor.getData(); - let timeSinceLastModified = 0; - let saving = false; - - async function save() { - let data = editor.getData(); - document.getElementById("editor-save-status").innerHTML = "Saving..."; - document.getElementById("editor-save-status").classList.remove("text-danger"); - document.getElementById("editor-save-status").classList.remove("text-muted"); - document.getElementById("editor-save-status").classList.remove("text-warning"); - document.getElementById("editor-save-status").classList.add("text-primary"); - saving = true; - - try { - await window.fetch("/api/save?system=<?= $systemID ?>&member=<?= $memberID ?>", { - method: "POST", - body: JSON.stringify({ content: data }) - }); - document.getElementById("editor-save-status").innerHTML = "Saved"; - document.getElementById("editor-save-status").classList.remove("text-danger"); - document.getElementById("editor-save-status").classList.add("text-muted"); - document.getElementById("editor-save-status").classList.remove("text-warning"); - document.getElementById("editor-save-status").classList.remove("text-primary"); - lastSavedData = data; - saving = false; - } catch (e) { - console.error(e); - document.getElementById("editor-save-status").innerHTML = "Failed to save"; - document.getElementById("editor-save-status").classList.add("text-danger"); - document.getElementById("editor-save-status").classList.remove("text-muted"); - document.getElementById("editor-save-status").classList.remove("text-warning"); - document.getElementById("editor-save-status").classList.remove("text-primary"); - } - } - - document.onclick = async () => { - if (saving) return; - - if (editor.getData() !== lastSavedData) { - await save(); - } - } - - setInterval(async () => { - if (saving) return; - - document.getElementById("editor-size").innerHTML = editor.getData().length; - - if (editor.getData() !== lastSavedData) { - document.getElementById("editor-save-status").innerHTML = "Modified"; - document.getElementById("editor-save-status").classList.remove("text-danger"); - document.getElementById("editor-save-status").classList.remove("text-muted"); - document.getElementById("editor-save-status").classList.add("text-warning"); - document.getElementById("editor-save-status").classList.remove("text-primary"); - - if (editor.getData() !== lastFetchedData) { - lastFetchedData = editor.getData(); - timeSinceLastModified = 0; - } else { - timeSinceLastModified++; - } - - if (timeSinceLastModified > 20) { - await save(); - } - } else { - timeSinceLastModified = 0; - } - }, 100) - </script> -</div> - -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?>
\ No newline at end of file diff --git a/includes/fragments/evening.inc b/includes/fragments/evening.inc deleted file mode 100644 index 851b69f..0000000 --- a/includes/fragments/evening.inc +++ /dev/null @@ -1,245 +0,0 @@ -<?php - -if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/evening.json")) file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/evening.json", "{}"); -$cache = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/evening.json"), true); - -if (!isset($cache["content"]) || date('Y-m-d') !== $cache["day"]) { - ob_start(); - - $members = $members = [ - ...array_map(function ($i) { - $system = "ynmuc"; - $i["_lastFronted"] = -1; - $id = $i["id"]; - $memberData = $i; - - $fronters = array_map(function ($item) { - return $item["id"]; - }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json"), true)["members"]); - - if (in_array($id, $fronters)) { - $i["_lastFronted"] = time(); - } else { - $switches = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/switches.json"), true); - - $thisMember = array_filter($switches, function ($item) use ($memberData) { - return in_array($memberData["id"], $item["members"]); - }); - - $thisMember = array_values($thisMember); - $frontingEnd = null; - - if (count($thisMember) > 0) { - $thisIndex = array_search($thisMember[0], $switches); - - $frontingStart = $thisMember[0]; - $frontingEnd = $switches[$thisIndex - 1]; - } - - if ($frontingEnd !== null && isset($frontingStart)) { - $i["_lastFronted"] = strtotime($frontingEnd["timestamp"]); - } - } - - return $i; - }, array_values(array_filter(scoreOrderGlobal(), function ($i) { - return $i["_system"] === "ynmuc"; - }))), - ...array_map(function ($i) { - $system = "gdapd"; - $i["_lastFronted"] = -1; - $id = $i["id"]; - $memberData = $i; - - $fronters = array_map(function ($item) { - return $item["id"]; - }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json"), true)["members"]); - - if (in_array($id, $fronters)) { - $i["_lastFronted"] = time(); - } else { - $switches = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/switches.json"), true); - - $thisMember = array_filter($switches, function ($item) use ($memberData) { - return in_array($memberData["id"], $item["members"]); - }); - - $thisMember = array_values($thisMember); - $frontingEnd = null; - - if (count($thisMember) > 0) { - $thisIndex = array_search($thisMember[0], $switches); - - $frontingStart = $thisMember[0]; - $frontingEnd = $switches[$thisIndex - 1]; - } - - if ($frontingEnd !== null && isset($frontingStart)) { - $i["_lastFronted"] = strtotime($frontingEnd["timestamp"]); - } - } - - return $i; - }, array_values(array_filter(scoreOrderGlobal(), function ($i) { - return $i["_system"] === "gdapd"; - }))) - ]; global $pages; global $lang; global $use2023UI; global $ignored; ?> - -<style> - @media (max-width: 767px) { - .member-name, .member-list-separator { - display: none; - } - - .member-collection { - width: 100%; - text-align: center; - } - } - - .member-link:hover { - opacity: .75; - } -</style> - -<div class="container"> - <div> - <?php global $use2023UI; if ($use2023UI): ?> - <h4>Evening schedule</h4> - <?php else: ?> - <h2>Evening schedule</h2> - <?php endif; ?> - - <?php if (time() < 1686787200): ?> - <div class="alert alert-warning"> - <b>The evening schedule will replace the fronting schedule starting June 15<sup>th</sup>.</b> The fronting schedule page contains more information and shows the schedule up to that date. The evening schedule is experimental until then. - </div> - <?php endif; ?> - - <details> - <summary style="list-style: none; outline: none; cursor: text;"> - <p>Click on the "Ignore" button to mark an evening as ignored and shift the schedule one day after. You can revert this by clicking on "Unignore".</p> - </summary> - <ul> - <?php usort($pairs, function ($a, $b) use ($members) { - $times = []; - - foreach ($a[0] as $id) { - if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id); - } - foreach ($a[1] as $id) { - if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id); - } - - $timeA = time() - min($times); - $times = []; - - foreach ($b[0] as $id) { - if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id); - } - foreach ($b[1] as $id) { - if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id); - } - - $timeB = time() - min($times); - - return $timeB - $timeA; - }); $pairs = array_values($pairs); foreach ($pairs as $pair): $times = []; ?> - <li> - <?php foreach ($pair[0] as $id): ?> - <img style="width: 24px;" src="<?= getAsset("ynmuc", $id) ?>"> <?= getMemberWithoutSystem($id)["display_name"] ?> - <?php $times[] = getLastFronted($members, $id); endforeach; ?> - with - <?php foreach ($pair[1] as $id): ?> - <img style="width: 24px;" src="<?= getAsset("gdapd", $id) ?>"> <?= getMemberWithoutSystem($id)["display_name"] ?> - <?php $times[] = getLastFronted($members, $id); endforeach; ?> - (<?= time() - max($times) ?>) - </li> - <?php endforeach; ?> - </ul> - </details> - - <?php $listI = 0; for ($i = 0; $i < 15; $i++): $pair = $pairs[$listI]; - $realPair = $pair; - - if (isset($locked[date('Y-m-d', time() + 86400 * $i)])) { - $pair = array_map(function ($i) { - return explode(",", $i); - }, explode("|", $locked[date('Y-m-d', time() + 86400 * $i)])); - } - - if (time() + 86400 * $i >= 1686787200): ?> - <?php global $use2023UI; if ($use2023UI): ?> - <h6><?= date('l j', time() + 86400 * $i) ?></h6> - <?php else: ?> - <h4><?= date('l j', time() + 86400 * $i) ?></h4> - <?php endif; ?> - <div style="display: grid; grid-template-columns: repeat(2, 1fr) 100px 150px; grid-gap: 20px; margin-bottom: 10px;"> - <div style="display: flex; align-items: center;<?php if (in_array(date('Y-m-d', time() + 86400 * $i), $ignored)): ?>opacity: .75; filter: saturate(0);<?php endif; ?>"> - <div class="member-collection"> - <?php foreach ($pair[0] as $id): ?> - <a class="member-link <?php if (isset($locked[date('Y-m-d', time() + 86400 * $i)])): ?>text-warning" style="font-weight: bold;<?php endif; ?>" href="/<?= getMemberWithoutSystem($id)["name"] ?>"><img style="width: 24px;" src="<?= getAsset("ynmuc", $id, "heads") ?>"> <span class="member-name" style="<?php if (in_array(date('Y-m-d', time() + 86400 * $i), $ignored)): ?>text-decoration: line-through;<?php endif; ?>"><?= getMemberWithoutSystem($id)["display_name"] ?></span></a><br class="member-list-separator"> - <?php $times[] = getLastFronted($members, $id); endforeach; ?> - </div> - </div> - <div style="display: flex; align-items: center;<?php if (in_array(date('Y-m-d', time() + 86400 * $i), $ignored)): ?>opacity: .75; filter: saturate(0);<?php endif; ?>"> - <div class="member-collection"> - <?php foreach ($pair[1] as $id): ?> - <a class="member-link <?php if (isset($locked[date('Y-m-d', time() + 86400 * $i)])): ?>text-warning" style="font-weight: bold;<?php endif; ?>" href="/<?= getMemberWithoutSystem($id)["name"] ?>"><img style="width: 24px;" src="<?= getAsset("gdapd", $id, "heads") ?>"> <span class="member-name" style="<?php if (in_array(date('Y-m-d', time() + 86400 * $i), $ignored)): ?>text-decoration: line-through;<?php endif; ?>"><?= getMemberWithoutSystem($id)["display_name"] ?></span></a><br class="member-list-separator"> - <?php $times[] = getLastFronted($members, $id); endforeach; ?> - </div> - </div> - <div style="display: flex; align-items: center; justify-content: center;"> - <?php - - $times = []; - - foreach ($pair[0] as $id) { - if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id); - } - foreach ($pair[1] as $id) { - if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id); - } - - $time = time() - min($times); - echo(timeAgo(time() - $time)); - - ?> - </div> - <div style="display: flex; align-items: center; justify-content: center;"> - <?php if (isset($locked[date('Y-m-d', time() + 86400 * $i)])): ?> - <a href="?lock&day=<?= date('Y-m-d', time() + 86400 * $i) ?>&data=<?= implode(",", $pair[0]) . "|" . implode(",", $pair[1]) ?>" class="btn btn-outline-secondary">Unlock</a> - <?php else: ?> - <a href="?lock&day=<?= date('Y-m-d', time() + 86400 * $i) ?>&data=<?= implode(",", $pair[0]) . "|" . implode(",", $pair[1]) ?>" class="btn btn-outline-primary">Lock</a> - <?php endif; ?> - <?php if (in_array(date('Y-m-d', time() + 86400 * $i), $ignored)): ?> - <a href="?ignore=0&day=<?= date('Y-m-d', time() + 86400 * $i) ?>" class="btn btn-outline-<?= $use2023UI ? "secondary" : "success" ?>">Unignore</a> - <?php else: ?> - <a href="?ignore=1&day=<?= date('Y-m-d', time() + 86400 * $i) ?>" class="btn btn-outline-<?= $use2023UI ? "primary" : "danger" ?>">Ignore</a> - <?php endif; ?> - </div> - </div> - <?= $i < 14 ? "<hr>" : "" ?> - <?php endif; - - if ( - (!isset($locked[date('Y-m-d', time() + 86400 * $i)]) && !in_array(date('Y-m-d', time() + 86400 * $i), $ignored)) - || (isset($locked[date('Y-m-d', time() + 86400 * $i)]) && $locked[date('Y-m-d', time() + 86400 * $i)] === implode(",", $realPair[0]) . "|" . implode(",", $realPair[1])) - ) { - $listI++; - } - - if ($listI === count($pairs)) $listI = 0; endfor; ?> - </div> -</div> -<?php - - $cache["content"] = ob_get_contents(); - $cache["day"] = date('Y-m-d'); - ob_end_clean(); -} - -echo($cache["content"]); -file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/evening.json", json_encode($cache)); - -?>
\ No newline at end of file diff --git a/includes/fragments/member.inc b/includes/fragments/member.inc index e927fd4..10cd241 100644 --- a/includes/fragments/member.inc +++ b/includes/fragments/member.inc @@ -88,24 +88,6 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/ponies/" . $memberID . ".pn document.getElementById("private-page-hidden").style.display = "block"; } - function updateDesignName(id) { - if (id === "_main" && document.getElementById("design-" + id + "-name").value.trim() === "") { - document.getElementById("design-" + id + "-name").value = "Main"; - } else { - fetch("/api/design/?member=<?= $memberID ?>&type=name&id=" + id + "&value=" + encodeURIComponent(btoa(document.getElementById("design-" + id + "-name").value))).then((a) => { - a.text().then((b) => { - if (b.trim() === "&") { - location.reload(); - } - }) - }) - } - } - - function updateDesignNote(id) { - fetch("/api/design/?member=<?= $memberID ?>&type=note&id=" + id + "&value=" + encodeURIComponent(btoa(document.getElementById("design-" + id + "-note").value))); - } - function _arrayBufferToBase64( buffer ) { var binary = ''; var bytes = new Uint8Array( buffer ); @@ -115,63 +97,12 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/ponies/" . $memberID . ".pn } return window.btoa( binary ); } - - async function uploadNewDesign() { - let handles = await window.showOpenFilePicker({ - multiple: false - }); - - if (handles.length >= 1) { - let file = await handles[0].getFile(); - - if (file.size > 2*1024**2) {} else { - let reader = new FileReader(); - reader.readAsArrayBuffer(file); - - reader.onload = () => { - let content = _arrayBufferToBase64(reader.result); - - fetch("/api/design/?member=<?= $memberID ?>&type=upload", { - method: "post", - body: JSON.stringify({ - file: content - }) - }).then(() => { - location.reload(); - }); - } - - reader.onerror = () => {} - } - } - } </script> <br> <div class="container"> - <div id="member-page" style="background-color: rgba(26,26,26,0.8);border-radius: 10px;padding:20px; backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px);margin-top:<?= !isset($memberData["banner"]) ? "15vh" : "30vh" ?>;<?php if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID.html") && !($isLoggedIn && file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID-private.html"))): ?> padding-bottom: 0 !important;<?php endif; ?>"> + <div id="member-page" style="background-color: rgba(26,26,26,0.8);border-radius: 10px;padding:20px; backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px);margin-top:<?= !isset($memberData["banner"]) ? "15vh" : "30vh" ?>; padding-bottom: 0 !important;"> <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/components/fullbanner.inc"; ?> - <?php $member = $memberData; if (($isLoggedIn || $isLowerLoggedIn) && file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/ponies/" . $member["id"] . ".png")): ?> - <div style="padding-top: 20px; padding-bottom: 20px;" id="member-designs"> - <div id="member-designs-inner" style="background-color: rgba(200, 200, 200, .05); border-radius: 10px; padding: 10px 20px; overflow-x: scroll; display: flex; grid-gap: 20px;"> - <?php foreach ($designs as $id => $design): if (isset($design)): ?> - <div style="display: grid; grid-template-rows: 208px 48px; width: max-content;"> - <div style="display: flex; align-items: center; justify-content: center;"> - <img src="data:image/png;base64,<?= $design["image"] ?>" style="height: 208px;"> - </div> - <div style="text-align: center; margin-top: 5px; height: 48px; width: max-content;"> - <b><input onkeyup="updateDesignName('<?= $id ?>');" maxlength="100" class="input-inherit" value="<?= $design["name"] ?>" id="design-<?= $id ?>-name"></b><br><input onkeyup="updateDesignNote('<?= $id ?>');" maxlength="100" class="input-inherit" value="<?= $design["note"] ?>" id="design-<?= $id ?>-note"> - </div> - </div> - <?php endif; endforeach; global $use2023UI; ?> - - <div onclick="uploadNewDesign();" style="cursor: pointer; display: flex; height: 256px; align-items: center; justify-content: center; width: 64px;"> - <img src="<?= $use2023UI ? icon("add") : "/assets/icons/add.svg" ?>" style="filter: invert(1); opacity: .5; width: 64px;"> - </div> - </div> - </div> - <?php endif; ?> - <div id="page-content"> <?php if ($memberData["name"] === "unknown"): ?> <br> @@ -198,32 +129,7 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/ponies/" . $memberID . ".pn <?php endif; ?> </div> <br> - <?php else: ?> - <?php if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID-private.html") && $isLoggedIn): ?> - <?php - - $text = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID-private.html"); - $censor = false; - - if (str_contains(strtolower($text), "sex") || str_contains(strtolower($text), "nsfw") || str_contains(strtolower($text), "pleasure") || str_contains(strtolower($text), "dildo") || str_contains(strtolower($text), "dick") || str_contains(strtolower($text), "penis") || str_contains(strtolower($text), "vagina") || str_contains(strtolower($text), "pussy")) { - $censor = true; - } - - if ($censor) { - echo("<a href='#' id='private-page-link' onclick='requestExplicit(\"refresh\"); showPrivate();'>Show private page (NSFW)</a><div id='private-page-hidden' style='display: none;'>" . $text . "</div>"); - } else { - echo($text); - } - - ?> - <?php if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID.html")): ?><hr><?php endif; ?> - <?php endif; ?> - - <?php if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID.html")): ?> - <?php if (!$isLoggedIn || !file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID-private.html")) echo("<br>"); ?> - <?= file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID.html") ?> - <?php endif; ?> - <?php endif; ?> + <?php else: ?><?php endif; ?> </div> </div> </div> @@ -234,11 +140,7 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/ponies/" . $memberID . ".pn <details> <summary style="list-style: none;"> - <?php if ($systemID === $app["other"]["id"]): ?> - <small style="opacity:.5;display:block;">(edit: <a href="/-/metadata/<?= $system ?>/<?= $memberData['name'] ?>">metadata</a>, <a href="/-/ponytown/<?= $memberData['id'] ?>">pony town</a>, <a href="/-/edit/<?= $system ?>/<?= $memberData['name'] ?>">page</a>)</small> - <?php else: ?> - <small style="opacity:.5;display:block;">(edit: <a href="/-/metadata/<?= $system ?>/<?= $memberData['name'] ?>">metadata</a>, <a href="/-/ponytown/<?= $memberData['id'] ?>">pony town</a>, <a href="/-/edit/<?= $system ?>/<?= $memberData['name'] ?>">public</a>, <a href="/-/edit-private/<?= $system ?>/<?= $memberData['name'] ?>">private</a>)</small> - <?php endif; ?> + <small style="opacity:.5;display:block;"><a href="/-/metadata/<?= $system ?>/<?= $memberData['name'] ?>">Edit metadata</a> · <a href="/-/ponytown/<?= $memberData['id'] ?>">Upload Pony Town character</a></small> </summary> <div class="alert alert-dark"> <ul style="margin-bottom:0;"> diff --git a/includes/fragments/metadata.inc b/includes/fragments/metadata.inc index 430f117..da3c326 100644 --- a/includes/fragments/metadata.inc +++ b/includes/fragments/metadata.inc @@ -61,26 +61,9 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $member <hr> - <h3>General information</h3> + <h3>Species</h3> <div style="margin-bottom: 1rem;"> - <b>General:</b><br> - <div style="display: grid; grid-template-columns: repeat(2, 1fr); grid-gap: 10px;"> - <select class="tooltip-nohelp form-select" style='display:inline-block;filter:invert(1) hue-rotate(180deg);background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23000000' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");' name="food"> - <option <?= $metadata["food"] === 0 ? "selected" : "" ?> value="0">Doesn't need to eat</option> - <option <?= $metadata["food"] === 1 ? "selected" : "" ?> value="1">Can't eat fish or meat</option> - <option <?= $metadata["food"] === 2 ? "selected" : "" ?> value="2">Can't eat meat</option> - <option <?= $metadata["food"] === 3 ? "selected" : "" ?> value="3">Can eat everything</option> - </select> - <select class="tooltip-nohelp form-select" style='display:inline-block;filter:invert(1) hue-rotate(180deg);background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23000000' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");' name="shared_memory"> - <option <?= $metadata["shared_memory"] === 2 ? "selected" : "" ?> value="2">Doing subconsciously</option> - <option <?= $metadata["shared_memory"] === 1 ? "selected" : "" ?> value="1">Consciously willing</option> - <option <?= $metadata["shared_memory"] === 0 ? "selected" : "" ?> value="0">Incapable/not willing</option> - </select> - </div> - </div> - <div style="margin-bottom: 1rem;"> - <b>Species</b><br> <div style="display: grid; grid-template-columns: repeat(2, 1fr); grid-gap: 10px;"> <select class="tooltip-nohelp form-select" style='display:inline-block;filter:invert(1) hue-rotate(180deg);background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23000000' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");' name="species[0]"> <option <?= !isset($metadata["species"][0]) || $metadata["species"][0] === "" ? "selected" : "" ?> value="">None</option> @@ -112,33 +95,6 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $member </select> </div> </div> - <div style="margin-bottom: 1rem;"> - <b>Alignment</b><br> - <div style="display: grid; grid-template-columns: repeat(2, 1fr); grid-gap: 10px;"> - <select class="tooltip-nohelp form-select" style='display:inline-block;filter:invert(1) hue-rotate(180deg);background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23000000' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");' name="alignment[sexual]"> - <option <?= $metadata["alignment"]["sexual"] === "unsure" ? "selected" : "" ?> value="unsure">Unsure</option> - <option <?= $metadata["alignment"]["sexual"] === "aroace" ? "selected" : "" ?> value="aroace">Asexual</option> - <option <?= $metadata["alignment"]["sexual"] === "hetero" ? "selected" : "" ?> value="hetero">Heterosexual</option> - <option <?= $metadata["alignment"]["sexual"] === "homo" ? "selected" : "" ?> value="homo">Homosexual</option> - <option <?= $metadata["alignment"]["sexual"] === "bi" ? "selected" : "" ?> value="bi">Bisexual</option> - <option <?= $metadata["alignment"]["sexual"] === "pan" ? "selected" : "" ?> value="pan">Pansexual</option> - <option <?= $metadata["alignment"]["sexual"] === "poly" ? "selected" : "" ?> value="poly">Polysexual</option> - </select> - <select class="tooltip-nohelp form-select" style='display:inline-block;filter:invert(1) hue-rotate(180deg);background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23000000' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");' name="alignment[romantic]"> - <option <?= $metadata["alignment"]["romantic"] === "unsure" ? "selected" : "" ?> value="unsure">Unsure</option> - <option <?= $metadata["alignment"]["romantic"] === "aroace" ? "selected" : "" ?> value="aroace">Aromantic</option> - <option <?= $metadata["alignment"]["romantic"] === "hetero" ? "selected" : "" ?> value="hetero">Heteroromantic</option> - <option <?= $metadata["alignment"]["romantic"] === "homo" ? "selected" : "" ?> value="homo">Homoromantic</option> - <option <?= $metadata["alignment"]["romantic"] === "bi" ? "selected" : "" ?> value="bi">Biromantic</option> - <option <?= $metadata["alignment"]["romantic"] === "pan" ? "selected" : "" ?> value="pan">Panromantic</option> - <option <?= $metadata["alignment"]["romantic"] === "poly" ? "selected" : "" ?> value="poly">Polyromantic</option> - </select> - </div> - </div> - <p> - <b>Gender</b><br> - <input name="gender" class="form-control" style="filter: invert(1) hue-rotate(180deg);" type="text" value="<?= $metadata["gender"] ?? "" ?>"> - </p> <hr> @@ -307,7 +263,7 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $member <hr> - <h3>Age and interests</h3> + <h3>Age and birth</h3> <p> <b>Birth date (use January 1<sup>st</sup> for none, fixed age takes priority over birth year if applicable)</b><br> @@ -317,12 +273,6 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $member <b>Age (for ponies with fixed age, takes priority over birth year)</b><br> <input name="age" class="form-control" style="filter: invert(1) hue-rotate(180deg);" type="text" pattern="^(-\d{1,2}|\d{1,2}(-\d{1,2}|))$" value="<?= $metadata["birth"]["age"] ?? "" ?>"> </p> - <?php if ($systemID !== $app["other"]["id"]): ?> - <p> - <b>Primary interest (keep it short)</b><br> - <input name="interest" class="form-control" style="filter: invert(1) hue-rotate(180deg);" type="text" value="<?= $metadata["interest"] ?? "" ?>"> - </p> - <?php endif; ?> <hr> diff --git a/includes/fragments/sysedit.inc b/includes/fragments/sysedit.inc deleted file mode 100644 index a743e03..0000000 --- a/includes/fragments/sysedit.inc +++ /dev/null @@ -1,153 +0,0 @@ -<?php global $system; global $systemCommonName; global $systemID; $title = "Editing " . $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; - -?> - -<div id="system-banner-container" style="width: 100%;height: 65vh;position: fixed;background-image: url('<?= getAsset($systemID, null, "banners") ?>');background-size: cover;background-position: center; top: 0;"> - <div id="system-banner-inner" style="height: 100%;width: 100%;background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 100%);"></div> -</div> - -<br> -<div class="container"> - <div class="container"> - - <div id="system-page" style="background-color: rgba(26,26,26,0.8);border-radius: 10px;padding:20px; backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px);margin-top:30vh;"> - <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/components/sysbanner.inc"; ?> - <br> - - <p class="text-muted"> - <span id="editor-save-status">Saved</span> · <span id="editor-size"><?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/content.html") ? strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/content.html")) : "0" ?></span> bytes - </p> - - <!--suppress HtmlFormInputWithoutLabel --> - <textarea id="page-editor"> - <?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/content.html") ? file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/content.html") : "" ?> - </textarea> - - <script src="/assets/editor/editor.js"></script> - <script> - let editor; - ClassicEditor - .create( document.querySelector( '#page-editor' ), { - toolbar: [ - 'undo', 'redo', '|', 'removeFormat', '|', 'heading', '|', 'fontSize', 'fontColor', 'fontBackgroundColor', 'alignment', '|', 'bold', 'italic', 'underline', 'strikethrough', '|', 'subscript', 'superscript', '|', 'code', '|', 'outdent', 'indent', '|', 'bulletedList', 'numberedList', '|', 'link', 'imageUpload', 'mediaEmbed', 'blockQuote', 'insertTable', 'codeBlock', '|', 'horizontalLine' - ] - } ) - - .then( newEditor => { - editor = newEditor; - } ) - .catch( error => { - console.error( error ); - } ); - </script> - <style> - :root { - --ck-color-base-background: transparent; - } - - .ck-toolbar { - filter: invert(1); - } - - .ck-tooltip__text { - color: white !important; - } - - .ck-dropdown__panel { - background: #ddd !important; - } - - .ck-color-grid__tile { - filter: invert(1); - } - - .ck-balloon-rotator { - background-color: #ccc !important; - } - - .ck-balloon-panel { - filter: invert(1); - } - </style> - <script> - let lastSavedData = editor.getData(); - let lastFetchedData = editor.getData(); - let timeSinceLastModified = 0; - let saving = false; - - async function save() { - let data = editor.getData(); - document.getElementById("editor-save-status").innerHTML = "Saving..."; - document.getElementById("editor-save-status").classList.remove("text-danger"); - document.getElementById("editor-save-status").classList.remove("text-muted"); - document.getElementById("editor-save-status").classList.remove("text-warning"); - document.getElementById("editor-save-status").classList.add("text-primary"); - saving = true; - - try { - await window.fetch("/api/save?system=<?= $systemID ?>&member=null", { - method: "POST", - body: JSON.stringify({ content: data }) - }); - document.getElementById("editor-save-status").innerHTML = "Saved"; - document.getElementById("editor-save-status").classList.remove("text-danger"); - document.getElementById("editor-save-status").classList.add("text-muted"); - document.getElementById("editor-save-status").classList.remove("text-warning"); - document.getElementById("editor-save-status").classList.remove("text-primary"); - lastSavedData = data; - saving = false; - } catch (e) { - console.error(e); - document.getElementById("editor-save-status").innerHTML = "Failed to save"; - document.getElementById("editor-save-status").classList.add("text-danger"); - document.getElementById("editor-save-status").classList.remove("text-muted"); - document.getElementById("editor-save-status").classList.remove("text-warning"); - document.getElementById("editor-save-status").classList.remove("text-primary"); - } - } - - document.onclick = async () => { - if (saving) return; - - if (editor.getData() !== lastSavedData) { - await save(); - } - } - - setInterval(async () => { - if (saving) return; - - document.getElementById("editor-size").innerHTML = editor.getData().length; - - if (editor.getData() !== lastSavedData) { - document.getElementById("editor-save-status").innerHTML = "Modified"; - document.getElementById("editor-save-status").classList.remove("text-danger"); - document.getElementById("editor-save-status").classList.remove("text-muted"); - document.getElementById("editor-save-status").classList.add("text-warning"); - document.getElementById("editor-save-status").classList.remove("text-primary"); - - if (editor.getData() !== lastFetchedData) { - lastFetchedData = editor.getData(); - timeSinceLastModified = 0; - } else { - timeSinceLastModified++; - } - - if (timeSinceLastModified > 20) { - await save(); - } - } else { - timeSinceLastModified = 0; - document.getElementById("editor-save-status").innerHTML = "Saved"; - document.getElementById("editor-save-status").classList.add("text-muted"); - document.getElementById("editor-save-status").classList.remove("text-warning"); - document.getElementById("editor-save-status").classList.remove("text-primary"); - } - }, 100) - </script> - </div> - </div> - <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/components/sysbanner.inc"; ?> -</div> - -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?>
\ No newline at end of file diff --git a/includes/fragments/system.inc b/includes/fragments/system.inc index 8d31f4d..bc1b0df 100644 --- a/includes/fragments/system.inc +++ b/includes/fragments/system.inc @@ -1,6 +1,4 @@ -<?php global $system; global $isLowerLoggedIn; global $systemCommonName; global $systemID; $title = $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; global $app; global $isLoggedIn; - -?> +<?php global $system; global $isLowerLoggedIn; global $systemCommonName; global $systemID; $title = $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; global $app; global $isLoggedIn; ?> <div id="system-banner-container" style="width: calc(100% - 300px);height: 65vh;position: fixed;background-image: url('<?= getAsset($systemID, null, "banners") ?>');background-size: cover;background-position: center; top: 0;"> <div id="system-banner-inner" style="height: 100%;width: 100%;background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,.25) 50%, rgba(0,0,0,1) 100%);"></div> @@ -19,18 +17,12 @@ <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/components/sysbanner.inc"; ?> <br> - <div id="page-content"> - <?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/content.html") ? file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/content.html") : "" ?> - </div> - <?php if ($system === "cloudburst") cloudburst(true); elseif ($system === "raindrops") raindrops(true); elseif ($isLoggedIn || $isLowerLoggedIn) other(true); ?> + <?php if ($system === "cloudburst") cloudburst(true); elseif ($system === "raindrops") raindrops(true); elseif ($system === "moonglow") moonglow(true); elseif ($isLoggedIn || $isLowerLoggedIn) other(true); ?> </div> </div> <div class="container"> <hr> - <?php global $isLoggedIn; if ($isLoggedIn): ?> - <small style="opacity:.5;display:block;">(edit: <a href="/-/edit/<?= $system ?>"><?= $systemID === $app["other"]["id"] ? "page" : "public" ?></a>)</small> - <?php endif; ?> </div> <style> |