diff options
author | Minteck <contact@minteck.org> | 2023-03-03 07:04:02 +0100 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2023-03-03 07:04:02 +0100 |
commit | 29928887e733f3bc2c2baaf06dafd495a006753b (patch) | |
tree | 90f5fa4c5273f201cc2d26086298ad094d9dadda | |
parent | 3d77712a9ab014635c75a33ea0f491bbda6aead3 (diff) | |
download | pluralconnect-29928887e733f3bc2c2baaf06dafd495a006753b.tar.gz pluralconnect-29928887e733f3bc2c2baaf06dafd495a006753b.tar.bz2 pluralconnect-29928887e733f3bc2c2baaf06dafd495a006753b.zip |
Updated 18 files and added 10 files (automated)
28 files changed, 510 insertions, 112 deletions
@@ -13,4 +13,10 @@ assets/banners assets/bodies assets/heads assets/ponies -assets/uploads
\ No newline at end of file +assets/uploads +includes/external/discord/*.js +includes/external/discord/*.js.map +includes/external/discord/**.js +includes/external/discord/**.js.map +includes/external/discord/**/*.js +includes/external/discord/**/*.js.map
\ No newline at end of file diff --git a/assets/editor/ponytown/step1.png b/assets/editor/ponytown/step1.png Binary files differnew file mode 100644 index 0000000..ad99540 --- /dev/null +++ b/assets/editor/ponytown/step1.png diff --git a/assets/editor/ponytown/step2.png b/assets/editor/ponytown/step2.png Binary files differnew file mode 100644 index 0000000..baad7c9 --- /dev/null +++ b/assets/editor/ponytown/step2.png diff --git a/assets/editor/ponytown/step2b.png b/assets/editor/ponytown/step2b.png Binary files differnew file mode 100644 index 0000000..64d8eca --- /dev/null +++ b/assets/editor/ponytown/step2b.png diff --git a/assets/editor/ponytown/step3.png b/assets/editor/ponytown/step3.png Binary files differnew file mode 100644 index 0000000..0daab07 --- /dev/null +++ b/assets/editor/ponytown/step3.png diff --git a/assets/editor/ponytown/step4.png b/assets/editor/ponytown/step4.png Binary files differnew file mode 100644 index 0000000..188c4d5 --- /dev/null +++ b/assets/editor/ponytown/step4.png diff --git a/assets/editor/ponytown/step4b.png b/assets/editor/ponytown/step4b.png Binary files differnew file mode 100644 index 0000000..341995d --- /dev/null +++ b/assets/editor/ponytown/step4b.png diff --git a/assets/editor/ponytown/step5.png b/assets/editor/ponytown/step5.png Binary files differnew file mode 100644 index 0000000..203c3f5 --- /dev/null +++ b/assets/editor/ponytown/step5.png diff --git a/assets/editor/ponytown/step9.png b/assets/editor/ponytown/step9.png Binary files differnew file mode 100644 index 0000000..d3134ee --- /dev/null +++ b/assets/editor/ponytown/step9.png diff --git a/assets/logo/banner.js b/assets/logo/banner.js index 38a88aa..3f41912 100644 --- a/assets/logo/banner.js +++ b/assets/logo/banner.js @@ -6,11 +6,7 @@ function timeAgo(time) { time = new Date(time).getTime(); } - let periods = ["sec.", "mn.", "hr.", "d.", "wk.", "mo.", "y.", "ages"]; - - if (bannerFrench) { - periods = ["sec.", "min.", "h.", "j.", "sem.", "mois", "an.", "des années"]; - } + let periods = ["sec", "min", "hr", "d", "wk", "mo", "y", "ages"]; let lengths = ["60", "60", "24", "7", "4.35", "12", "100"]; @@ -20,22 +16,12 @@ function timeAgo(time) { let tense; let period; - if (bannerFrench) { - if (difference <= 10 && difference >= 0) { - return "à l'instant"; - } else if (difference > 0) { - tense = "il y a"; - } else { - tense = "dans"; - } + if (difference <= 10 && difference >= 0) { + return "now"; + } else if (difference > 0) { + tense = "ago"; } else { - if (difference <= 10 && difference >= 0) { - return "now"; - } else if (difference > 0) { - tense = "ago"; - } else { - tense = "later"; - } + tense = "later"; } let j; @@ -48,11 +34,7 @@ function timeAgo(time) { period = periods[j]; - if (bannerFrench) { - return `${tense} ${difference} ${period}`; - } else { - return `${difference} ${period} ${tense}`; - } + return `${difference} ${period} ${tense}`; } async function refreshBanner(_, french) { diff --git a/assets/logo/custom.css b/assets/logo/custom.css index 4237274..adde95f 100644 --- a/assets/logo/custom.css +++ b/assets/logo/custom.css @@ -1,3 +1,7 @@ +img { + image-rendering: pixelated !important; +} + #admin-page { margin-left: 32px; } diff --git a/assets/uploads/pt-scootaloo.png b/assets/uploads/pt-scootaloo.png Binary files differindex 436d6a3..c1823b8 100644 --- a/assets/uploads/pt-scootaloo.png +++ b/assets/uploads/pt-scootaloo.png diff --git a/includes/assets.inc b/includes/assets.inc index b64c821..3f2d652 100644 --- a/includes/assets.inc +++ b/includes/assets.inc @@ -68,12 +68,12 @@ function downloadAssets($system, $path = null) { } else { $url = "../assets/uploads/pt.png"; } - echo(" /heads/$id.webp\n"); - exec("convert -resize 64x64 \"" . $url . "\" ../assets/heads/" . $id . ".webp"); + echo(" /heads/$id.png\n"); + exec("convert \"" . $url . "\" ../assets/heads/" . $id . ".png"); if (file_exists("../assets/ponies/" . $member["id"] . ".png")) { - echo(" /bodies/$id.webp\n"); - exec("convert -resize 128x128 \"" . "../assets/ponies/" . $member["id"] . ".png" . "\" ../assets/bodies/" . $id . ".webp"); + echo(" /bodies/$id.png\n"); + exec("convert \"" . "../assets/ponies/" . $member["id"] . ".png" . "\" ../assets/bodies/" . $id . ".png"); } } } diff --git a/includes/external/school/index.js b/includes/external/school/index.js index ad601d6..c8f053c 100644 --- a/includes/external/school/index.js +++ b/includes/external/school/index.js @@ -196,5 +196,5 @@ async function display(offset) { } console.log(json); - require('fs').writeFileSync("../includes/data/school.json", JSON.stringify(json)); + require('fs').writeFileSync("../../data/school.json", JSON.stringify(json)); })()
\ No newline at end of file diff --git a/includes/functions.inc b/includes/functions.inc index 1d467a0..e9024d1 100644 --- a/includes/functions.inc +++ b/includes/functions.inc @@ -53,10 +53,18 @@ if (!function_exists("getAsset")) { $id = $id1; } - if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/" . $type . "/" . $id . ".webp")) { - return "/assets/" . $type . "/" . $id . ".webp"; + if ($type === "bodies" || $type === "heads") { + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/" . $type . "/" . $id . ".png")) { + return "/assets/" . $type . "/" . $id . ".png"; + } else { + return "/error/nofile/?s=$systemID&m=$memberID&t=$type"; + } } else { - return "/error/nofile/?s=$systemID&m=$memberID&t=$type"; + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/" . $type . "/" . $id . ".webp")) { + return "/assets/" . $type . "/" . $id . ".webp"; + } else { + return "/error/nofile/?s=$systemID&m=$memberID&t=$type"; + } } } else { return "/error/nosys/?s=$systemID&m=$memberID&t=$type"; @@ -266,8 +274,7 @@ if (!function_exists("getMemberWithoutSystem")) { if (!function_exists("showMembersFromList")) { function showMembersFromList(array $list) { foreach ($list as $member) { if ($member['name'] !== "unknown" && $member['name'] !== "fusion") { - echo('<!-- ' . ($member['display_name'] ?? $member['name']) . ' --> -<a href="/' . $member['name'] . '" style="text-decoration:none !important;filter:none !important;"><div class="hpd-item-card" style="background-color:rgba(255, 255, 255, .1);border:1px solid ' . (isset($member['color']) ? "#" . $member['color'] . "55" : "transparent") . ';outline-color:' . (isset($member['color']) ? "#" . $member['color'] . "55" : "transparent") . ';border-radius:10px;text-align:center;display:flex;align-items:center;justify-content:center;padding:5px;' . (isset($member["equestria"]) && $member["equestria"] ? 'opacity:.5;' : '') . '"><div> + echo('<a href="/' . $member['name'] . '" style="text-decoration:none !important;filter:none !important;"><div class="hpd-item-card" style="background-color:rgba(255, 255, 255, .1);border:1px solid ' . (isset($member['color']) ? "#" . $member['color'] . "55" : "transparent") . ';outline-color:' . (isset($member['color']) ? "#" . $member['color'] . "55" : "transparent") . ';border-radius:10px;text-align:center;display:flex;align-items:center;justify-content:center;padding:5px;' . (isset($member["equestria"]) && $member["equestria"] ? 'opacity:.5;' : '') . '"><div> <img alt="" src="' . getAsset($member["system"], $member["id"]) . '" style="border-radius:999px;background-color:rgba(0, 0, 0, .25);height:48px;width:48px;display:block;margin-left:auto;margin-right:auto;"> <div style="text-decoration:none;color:white;margin-top:5px;">' . ($member['display_name'] ?? $member['name']) . '</div> <div style="text-decoration:none !important;color:black !important;"><code style="text-decoration:none !important;color:white !important;">' . (isset($member['travelling']) && $member['travelling'] ? "+" . ($member['proxy_tags'][0]['prefix'] ?? " ") : ($member['proxy_tags'][0]['prefix'] ?? " ")) . '</code></div> @@ -302,14 +309,11 @@ if (!function_exists("showSystem")) { $global = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . (isset($app["other"]) && $id === $app["other"]["id"] ? "other" : $id) . "/general.json"), true); if ($hideTitle) { - echo('<!-- ' . $name . ' --> -<div id="hpd-' . ($id === "gdapd" ? "raindrops" : ($id === "ynmuc" ? "cloudburst" : "other")) . '" style="background:rgba(255, 255, 255, .1);border-radius:10px;padding:10px;display:grid;grid-template-columns: 1fr;margin-bottom:10px;">'); + echo('<div id="hpd-' . ($id === "gdapd" ? "raindrops" : ($id === "ynmuc" ? "cloudburst" : "other")) . '" style="background:rgba(255, 255, 255, .1);border-radius:10px;padding:10px;display:grid;grid-template-columns: 1fr;margin-bottom:10px;">'); } else { - echo('<!-- ' . $name . ' --> -<div id="hpd-' . ($id === "gdapd" ? "raindrops" : ($id === "ynmuc" ? "cloudburst" : "other")) . '" style="background:rgba(255, 255, 255, .1);border-radius:10px;padding:10px 10px 10px 20px;display:grid;grid-template-columns: 128px 1fr;margin-bottom:10px;">'); + echo('<div id="hpd-' . ($id === "gdapd" ? "raindrops" : ($id === "ynmuc" ? "cloudburst" : "other")) . '" style="background:rgba(255, 255, 255, .1);border-radius:10px;padding:10px 10px 10px 20px;display:grid;grid-template-columns: 128px 1fr;margin-bottom:10px;">'); } - if (!$hideTitle) echo('<!-- System Name --> -<a style="display:flex;margin: -10px -20px;align-items:center;justify-content:center;text-align:center;padding: 10px 20px;border-radius: 10px;background: #' . $global['color'] . '55;width: 148px;text-decoration:none;color:white;filter:none !important;" href="/' . ($id === "gdapd" ? "raindrops" : ($id === $app["other"]["id"] ? $app["other"]["slug"] : "cloudburst")) . '" class="hpd-system"> + if (!$hideTitle) echo('<a style="display:flex;margin: -10px -20px;align-items:center;justify-content:center;text-align:center;padding: 10px 20px;border-radius: 10px;background: #' . $global['color'] . '55;width: 148px;text-decoration:none;color:white;filter:none !important;" href="/' . ($id === "gdapd" ? "raindrops" : ($id === $app["other"]["id"] ? $app["other"]["slug"] : "cloudburst")) . '" class="hpd-system"> <div style="text-align:center;"><img src="' . getAsset($id) . '" style="width:64px;"><br>' . $name . '</div> </a>'); diff --git a/includes/homepage.inc b/includes/homepage.inc index c078e89..900d8f1 100644 --- a/includes/homepage.inc +++ b/includes/homepage.inc @@ -4,6 +4,7 @@ global $app; global $travelling; function newHomepage($id, $page, $title) { + global $travelling; $system = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $id . "/general.json"), true); ?> @@ -17,10 +18,17 @@ function newHomepage($id, $page, $title) { <?php endif; ?> <div class="new-homepage-system-list" id="new-homepage-system-<?= $id ?>-list"> - <?php $list = array_values(withTravelers(scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $id . "/members.json"), true), $id), $id)); foreach ($list as $index => $member): ?> + <?php $list = array_values(scoreOrder(withTravelers(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $id . "/members.json"), true), $id), $id)); foreach ($list as $index => $member): ?> <a href="/<?= $member["name"] ?>" class="new-homepage-link <?= $index === count($list) - 1 ? "new-homepage-link-last" : "" ?>" style="color: white !important; text-decoration: none !important; display: block; background-color: #<?= $member["color"] ?>22; padding: 5px 10px;"> - <img src="<?= getAsset($id, $member["id"]) ?>" style="width: 32px; height: 32px; vertical-align: middle; background-color: rgba(0, 0, 0, .25); border-radius: 999px;"> + <img src="<?= getAsset(($travelling[$member["id"]]["travelling"] && !$travelling[$member["id"]]["equestria"]) ? ($id === "gdapd" ? "ynmuc" : "gdapd") : $id, $member["id"]) ?>" style="width: 32px; height: 32px; vertical-align: middle; background-color: rgba(0, 0, 0, .25); border-radius: 999px;"> <span style="width: calc(100% - 37px); vertical-align: middle; margin-left: 5px;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;"><?= $member["display_name"] ?? $member["name"] ?></span> + <span style="vertical-align: middle; float:right;"> + <?php if ($travelling[$member["id"]]["travelling"] && $travelling[$member["id"]]["equestria"]): ?> + <img src="/assets/logo/equestria.png" style="width: 24px; height: 24px; margin-top: 5px;"> + <?php elseif ($travelling[$member["id"]]["travelling"]): ?> + <img src="<?= getAsset($id === "gdapd" ? "ynmuc" : "gdapd") ?>" style="width: 24px; height: 24px; margin-top: 5px;"> + <?php endif; ?> + </span> </a> <?php endforeach; ?> </div> diff --git a/includes/member.inc b/includes/member.inc index 8d03285..b98d0f5 100644 --- a/includes/member.inc +++ b/includes/member.inc @@ -104,9 +104,9 @@ if ($memberData["name"] === "fusion") { <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="/-/edit/<?= $system ?>/<?= $memberData['name'] ?>">page</a>)</small> + <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="/-/edit/<?= $system ?>/<?= $memberData['name'] ?>">public</a>, <a href="/-/edit-private/<?= $system ?>/<?= $memberData['name'] ?>">private</a>)</small> + <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; ?> </summary> <div class="alert alert-dark"> diff --git a/includes/pages.json b/includes/pages.json index f2326c0..2a7bbe6 100644 --- a/includes/pages.json +++ b/includes/pages.json @@ -239,6 +239,16 @@ "limited": false, "rail": true }, + "ponytown": { + "name": { + "en": "Pony Town uploader", + "fr": "Pony Town uploader" + }, + "short": null, + "admin": true, + "limited": true, + "rail": true + }, "profiles": { "name": { "en": "Profile scores", diff --git a/includes/sysbanner.inc b/includes/sysbanner.inc index 2ca3ee8..763c961 100644 --- a/includes/sysbanner.inc +++ b/includes/sysbanner.inc @@ -21,30 +21,6 @@ $pages = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/pa <div style="display: grid; grid-template-columns: 1fr;height:100%;grid-template-rows: max-content max-content 1fr;"> <h3 style="height:max-content;"><?= $systemCommonName ?></h3> <div style="height:max-content;display:grid;grid-template-columns: repeat(4, 1fr);" id="member-card"> - <!--<span> - <b><abbr title="Most common fronter" data-bs-toggle="tooltip">MCF</abbr>: </b><?php - - $foundHost = false; - $hostGoneTravelling = false; - - $members = array_filter(scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/members.json"), true), $systemID), function ($i) use ($travelling) { - global $hostGoneTravelling; - if ($travelling[$i['id']]['travelling'] && $i["_metadata"]["host"]) $hostGoneTravelling = true; - return true; - }); - foreach ($members as $member) { - $data = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true)); - if ($data["host"]): $foundHost = true; ?> - <a class="member-link" href="/<?= $member["name"] ?>"><img src="<?= getAsset($systemID, $member["id"], "heads") ?>" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> - <?php endif; - } - - if (!$foundHost) echo("-"); - if ($hostGoneTravelling) echo("<br>(travelling)"); - - ?> - - </span>--> <span> <?php $fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/fronters.json"), true); ?> <b><?= $lang["system"]["fronter"] ?> </b> @@ -117,12 +93,4 @@ $pages = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/pa <img src="/assets/icons/compare.svg" style="vertical-align: middle;height: 24px;width: 24px;filter: invert(1)" alt=""> <span style="vertical-align: middle;" class="list-separator-desktop"><?= $pages["s:compare"]["name"][$lang["_name"]] ?></span> </a> - <!--<a title="<?= $pages["s:tree"]["name"][$lang["_name"]] ?>" data-bs-toggle="tooltip" style="display:inline-block;padding:5px 10px;text-align: center" class="system-action tooltip-nohelp" href="/<?= $system ?>/-/tree"> - <img src="/assets/icons/tree.svg" style="vertical-align: middle;height: 24px;width: 24px;filter: invert(1)" alt=""> - <span style="vertical-align: middle;" class="list-separator-desktop"><?= $pages["s:tree"]["name"][$lang["_name"]] ?></span> - </a>--> - <!--<a title="<?= $pages["s:species"]["name"][$lang["_name"]] ?>" data-bs-toggle="tooltip" style="display:inline-block;padding:5px 10px;text-align: center" class="system-action tooltip-nohelp" href="/<?= $system ?>/-/species"> - <img src="/assets/icons/species.svg" style="vertical-align: middle;height: 24px;width: 24px;filter: invert(1)" alt=""> - <span style="vertical-align: middle;" class="list-separator-desktop"><?= $pages["s:species"]["name"][$lang["_name"]] ?></span> - </a>--> </div>
\ No newline at end of file diff --git a/includes/titlebar.inc b/includes/titlebar.inc index a6ccd67..e941179 100644 --- a/includes/titlebar.inc +++ b/includes/titlebar.inc @@ -571,7 +571,7 @@ if ($isLowerLoggedIn || $isLoggedIn) { $linksList = $links[isset($links[$actionsProfile]) ? $actionsProfile : "default"]; -?><!-- (<code><?= $actionsProfile ?></code>)--><!--<pre><?php var_dump($parts); ?></pre>--> +?> <span id="title-bar-actions"> <?php foreach ($linksList as $index => $link): if (!(isset($link["show"]) && !$link["show"])): ?><a style="height: 33px; display: inline-block; padding: 4px;" id="title-bar-action-<?= $index ?>" <?php if ($link["link"]["type"] === "url"): ?>href<?php else: ?>onclick<?php endif; ?>="<?= $link["link"]["text"] ?>" title="<?= $link["name"] ?>" data-bs-toggle="tooltip" class="title-bar-action tooltip-nohelp"><img src="<?= $link["icon"] ?>" <?php if ($link["invert"]): ?>class="dropdown-icon"<?php endif; ?> alt="" style="width:24px;vertical-align: middle;"></a><?php endif; endforeach; ?> </span> diff --git a/includes/travelling.inc b/includes/travelling.inc index 4487956..0d1696a 100644 --- a/includes/travelling.inc +++ b/includes/travelling.inc @@ -39,19 +39,24 @@ foreach ($members as $member) { function withTravelers(array $members, string $system): array { global $travelling; - - return [ - ...array_map(function ($i) use ($system) { - $i['system'] = $system; - return $i; - }, array_filter($members, function ($i) use ($travelling) { - return !(isset($travelling[$i['id']]) && $travelling[$i['id']]['travelling'] && (!isset($travelling[$i['id']]['equestria']) || !$travelling[$i['id']]['equestria'])); - })), - ...array_filter(array_map(function ($i) use ($system) { - $i['system'] = $system === "gdapd" ? "ynmuc" : "gdapd"; - return $i; - }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($system === "gdapd" ? "ynmuc" : "gdapd") . "/members.json"), true)), function ($i) use ($travelling) { - return isset($travelling[$i['id']]) && $travelling[$i['id']]['travelling'] && (!isset($travelling[$i['id']]['equestria']) || !$travelling[$i['id']]['equestria']); - }) + global $app; + + if ($system === $app["other"]["id"]) { + return $members; + } else { + return [ + ...array_map(function ($i) use ($system) { + $i['system'] = $system; + return $i; + }, array_filter($members, function ($i) use ($travelling) { + return !(isset($travelling[$i['id']]) && $travelling[$i['id']]['travelling'] && (!isset($travelling[$i['id']]['equestria']) || !$travelling[$i['id']]['equestria'])); + })), + ...array_filter(array_map(function ($i) use ($system) { + $i['system'] = $system === "gdapd" ? "ynmuc" : "gdapd"; + return $i; + }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($system === "gdapd" ? "ynmuc" : "gdapd") . "/members.json"), true)), function ($i) use ($travelling) { + return isset($travelling[$i['id']]) && $travelling[$i['id']]['travelling'] && (!isset($travelling[$i['id']]['equestria']) || !$travelling[$i['id']]['equestria']); + }) ]; + } }
\ No newline at end of file diff --git a/pages/api/ponytown.php b/pages/api/ponytown.php new file mode 100644 index 0000000..f41ac01 --- /dev/null +++ b/pages/api/ponytown.php @@ -0,0 +1,117 @@ +<?php + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.inc"; global $isLoggedIn; global $_PROFILE; global $isLowerLoggedIn; global $app; +if (!$isLoggedIn && !$isLowerLoggedIn) header("Location: /-/login") and die(); + +$request_raw = file_get_contents('php://input'); +$json_object = json_decode($request_raw, true); + +$select = $_GET['id'] ?? null; + +if (!isset($select)) { + peh_error("System member not found", 404); + return; +} + +if (getMemberWithoutSystem($select) === null) { + peh_error("System member not found", 404); + return; +} + +$member = getMemberWithoutSystem($select); + +if ($isLowerLoggedIn && $member["_system"] !== $app["other"]["id"]) { + peh_error("System member not found", 404); + return; +} + +if (!isset($json_object[0]) || !isset($json_object[1])) { + die("Missing data"); +} + +$errors = []; + +foreach ([1, 2] as $_) { + $input = $json_object[$_ - 1]; + + $mime = explode(";", substr($input, 5))[0]; + $file = base64_decode(explode(",", explode(";", substr($input, 5))[1])[1]); + + $image = @imagecreatefromstring($file); + $size = @getimagesizefromstring($file); + + if ($image === false) { + $errors[] = "0x{$_}000000F: Failed to open image #" . $_ . ", it is probably not using a supported format"; + } + + if ($size === false) { + $errors[] = "0x{$_}000000E: Failed to get metadata for image #" . $_ . ", it is probably corrupted"; + } + + if ($image === false || $size === false) continue; + + $foundColor = false; + + for ($i = 0; $i < $size[0]; $i++) { + if (imagecolorat($image, $i, 0) !== 2130706432) { + $foundColor = true; + } + } + + if (!$foundColor) { + $errors[] = "0x{$_}000001A: Image #" . $_ . " seems to contain padding (based on the first row of pixels)"; + } + + $foundColor = false; + + for ($i = 0; $i < $size[1]; $i++) { + if (imagecolorat($image, 0, $i) !== 2130706432) { + $foundColor = true; + } + } + + if (!$foundColor) { + $errors[] = "0x{$_}000001B: Image #" . $_ . " seems to contain padding (based on the first column of pixels)"; + } + + if ($_ === 1 && $size[0] > 70) { + $errors[] = "0x{$_}000002A: Image #" . $_ . " is wider than it should, are you sure you set zoom to 1x? Maybe you inverted the files?"; + } + + if ($_ === 1 && $size[1] > 70) { + $errors[] = "0x{$_}000002B: Image #" . $_ . " is higher than it should, are you sure you set zoom to 1x? Maybe you inverted the files?"; + } + + if ($_ === 2 && $size[0] > 35) { + $errors[] = "0x{$_}000002A: Image #" . $_ . " is wider than it should, are you sure you set zoom to 1x? Maybe you inverted the files?"; + } + + if ($_ === 2 && $size[1] > 35) { + $errors[] = "0x{$_}000002B: Image #" . $_ . " is higher than it should, are you sure you set zoom to 1x? Maybe you inverted the files?"; + } +} + +if (count($errors) === 0 && isset($_GET["real"])) { + foreach ([1, 2] as $_) { + $input = $json_object[$_ - 1]; + + $mime = explode(";", substr($input, 5))[0]; + $file = base64_decode(explode(",", explode(";", substr($input, 5))[1])[1]); + + $image = @imagecreatefromstring($file); + + imagealphablending($image, false); + imagesavealpha($image, true); + + if ($_ === 1) { + imagepng($image, $_SERVER['DOCUMENT_ROOT'] . "/assets/ponies/" . $member["id"] . ".png"); + } else { + imagepng($image, $_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $member["name"] . ".png"); + } + } +} + +die(json_encode([ + "success" => count($errors) === 0, + "errors" => $errors +]));
\ No newline at end of file diff --git a/pages/docs.inc b/pages/docs.inc index 3b212df..2e43727 100644 --- a/pages/docs.inc +++ b/pages/docs.inc @@ -345,7 +345,7 @@ function showDocument($item) { ?> time = new Date(time).getTime(); } - let periods = ["sec.", "mn.", "hr.", "d.", "wk.", "mo.", "y.", "ages"]; + let periods = ["sec", "min", "hr", "d", "wk", "mo", "y", "ages"]; let lengths = ["60", "60", "24", "7", "4.35", "12", "100"]; diff --git a/pages/home.old.inc b/pages/home.old.inc index 4249947..f918549 100644 --- a/pages/home.old.inc +++ b/pages/home.old.inc @@ -47,18 +47,6 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; require_once $_SE </div> <hr style="border-color:rgba(255, 255, 255, .25);"> - <!--<?php global $isLoggedIn; if ($isLoggedIn && ((int)date('H') >= 20 || (int)date('H') < 6)): ?> - <a href="/-/emergency" style="text-decoration: none;margin-top:15px;display:block;"> - <div class="alert alert-danger"> - <b>Are you in need of help?</b> If you need immediate help from a loved one, you may want to enable the emergency alert by clicking here, even if that wakes up the <?= $_PROFILE['name'] === "Raindrops System" ? "Cloudburst System" : "Raindrops System" ?>. Use it as you need. - </div> - </a> - <?php endif; ?>--> - - <!--<div class="alert alert-info"> - <b>Coming soon:</b> Free hosting for Project Scout (the software powering Cold Haze), so you can have your own website for your system. If you are interested and/or want to pre-register, feel free to <a href="https://equestria.horse/contact" target="_blank">contact us</a>. - </div>--> - <div id="homepage-desktop" style="margin-top:10px;"> <?php cloudburst(false); ?> diff --git a/pages/money.inc b/pages/money.inc index b297231..257b87f 100644 --- a/pages/money.inc +++ b/pages/money.inc @@ -1,5 +1,8 @@ <?php +$minimumRaindrops = 200; +$minimumCloudburst = 500; + require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages; global $_PROFILE; $parts = explode("/", $_GET["_"]); @@ -70,7 +73,7 @@ if ((isset($_GET["create"]) || isset($_GET["delete"])) && isset($parts[2])) { "Title: " . (getMember($myId)["display_name"] ?? getMember($myId)["name"]) . " created a transaction to " . $account["name"] . " (" . ucfirst($account["owner"]) . ")\r\n" . "Tags: bits\r\n" . "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => $account["currency"] === "gbp" ? "£" : "€" . abs((float)$_GET["amount"]) . " were " . ((float)$_GET["amount"] >= 0 ? "added" : "removed") . " just now" . (trim($_GET["description"]) !== "" ? ": " . $_GET["description"] : "") + 'content' => ($account["currency"] === "gbp" ? "£" : "€") . abs((float)$_GET["amount"]) . " were " . ((float)$_GET["amount"] >= 0 ? "added" : "removed") . " just now" . (trim($_GET["description"]) !== "" ? ": " . $_GET["description"] : "") ] ])); @@ -96,7 +99,7 @@ if ((isset($_GET["create"]) || isset($_GET["delete"])) && isset($parts[2])) { "Title: " . (getMember($myId)["display_name"] ?? getMember($myId)["name"]) . " deleted a transaction from " . $account["name"] . " (" . ucfirst($account["owner"]) . ")\r\n" . "Tags: bits\r\n" . "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => $account["currency"] === "gbp" ? "£" : "€" . abs((float)$account["transactions"][(int)$_GET["id"]]["amount"]) . " " . ((float)$account["transactions"][(int)$_GET["id"]]["amount"] >= 0 ? "advance" : "withdrawal") . " created by " . (getMemberWithoutSystem($account["transactions"][(int)$_GET["id"]]["author"])["display_name"] ?? getMemberWithoutSystem($account["transactions"][(int)$_GET["id"]]["author"])["name"]) . " " . timeAgo($account["transactions"][(int)$_GET["id"]]["date"]) + 'content' => ($account["currency"] === "gbp" ? "£" : "€") . abs((float)$account["transactions"][(int)$_GET["id"]]["amount"]) . " " . ((float)$account["transactions"][(int)$_GET["id"]]["amount"] >= 0 ? "advance" : "withdrawal") . " created by " . (getMemberWithoutSystem($account["transactions"][(int)$_GET["id"]]["author"])["display_name"] ?? getMemberWithoutSystem($account["transactions"][(int)$_GET["id"]]["author"])["name"]) . " " . timeAgo($account["transactions"][(int)$_GET["id"]]["date"]) ] ])); @@ -297,6 +300,30 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; </a> <?php endif; endforeach; ?> </div> + + <div class="progress" style="margin-top: 20px;"> + <?php + + $part1 = 0; + $part2 = 1; + $difference = 0; + + if ($allAccounts > $minimumCloudburst) { + $part2 = ($allAccounts - $minimumCloudburst) / $allAccounts; + $part1 = 1 - $part2; + $difference = $allAccounts - $minimumCloudburst; + } else { + $part1 = 1; + $part2 = 0; + $difference = $minimumCloudburst - $allAccounts; + } + + ?> + <div class="progress-bar bg-danger" style="width:<?= $part1 * 100 ?>%"></div> + <div class="progress-bar bg-success" style="width:<?= $part2 * 100 ?>%"></div> + </div> + <p style="text-align: center; margin-top: 5px;" class="<?= $allAccounts > $minimumCloudburst ? "" : "bold text-danger" ?>">£<?= number_format($difference, 2, '.', ',') ?><?php if ($allAccounts > $minimumCloudburst): ?> (<?= round($part2 * 100, 2) ?>%)<?php endif; ?> <?= $allAccounts > $minimumCloudburst ? "over" : "under" ?> the minimum</p> + <canvas id="history-cloudburst" style="margin-top: 10px; width: 100%; height: 200px; max-height: 100%;"></canvas> <?php @@ -391,6 +418,30 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; </a> <?php endif; endforeach; ?> </div> + + <div class="progress" style="margin-top: 20px;"> + <?php + + $part1 = 0; + $part2 = 1; + $difference = 0; + + if ($allAccounts > $minimumRaindrops) { + $part2 = ($allAccounts - $minimumRaindrops) / $allAccounts; + $part1 = 1 - $part2; + $difference = $allAccounts - $minimumRaindrops; + } else { + $part1 = 1; + $part2 = 0; + $difference = $minimumRaindrops - $allAccounts; + } + + ?> + <div class="progress-bar bg-danger" style="width:<?= $part1 * 100 ?>%"></div> + <div class="progress-bar bg-success" style="width:<?= $part2 * 100 ?>%"></div> + </div> + <p style="text-align: center; margin-top: 5px;" class="<?= $allAccounts > $minimumRaindrops ? "" : "bold text-danger" ?>">€<?= number_format($difference, 2, '.', ',') ?><?php if ($allAccounts > $minimumCloudburst): ?> (<?= round($part2 * 100, 2) ?>%)<?php endif; ?> <?= $allAccounts > $minimumRaindrops ? "over" : "under" ?> the minimum</p> + <canvas id="history-raindrops" style="margin-top: 10px; width: 100%; height: 200px; max-height: 100%;"></canvas> <?php diff --git a/pages/ponytown.inc b/pages/ponytown.inc new file mode 100644 index 0000000..d055c9c --- /dev/null +++ b/pages/ponytown.inc @@ -0,0 +1,258 @@ +<?php + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages; global $isLowerLoggedIn; global $app; + +$parts = explode("/", $_GET["_"]); + +if (!isset($parts[2])) { + peh_error("System member not found", 404); + return; +} + +if (getMemberWithoutSystem($parts[2]) === null) { + peh_error("System member not found", 404); + return; +} + +$member = getMemberWithoutSystem($parts[2]); + +if ($isLowerLoggedIn && $member["_system"] !== $app["other"]["id"]) { + peh_error("System member not found", 404); + return; +} + +$title = ($member["display_name"] ?? $member["name"]) . " · " . $title; + +require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; + +$member = getMemberWithoutSystem($parts[2]); + +?> + +<br> +<div class="container"> + <div id="page-content"> + <h2>Pony Town uploader for <?= $member["display_name"] ?? $member["name"] ?></h2> + + <?php if (isset($_GET["updated"])): ?> + <div class="alert alert-success">Successfully uploaded a new Pony Town character for this member, it may take a few minutes to update across the website.</div> + <?php endif; ?> + + <div style="display: grid; grid-template-columns: repeat(2, 1fr); grid-gap: 20px; margin-top: 15px;"> + <div class="card"> + <div class="card-body"> + <h3>Current version</h3> + + <div style="display: grid; grid-template-columns: repeat(2, 1fr); grid-gap: 10px;"> + <div style="display: flex; align-items: center; justify-content: center;"> + <img src="data:image/png;base64,<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/ponies/" . $member["id"] . ".png") ? base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/assets/ponies/" . $member["id"] . ".png")) : "" ?>" style="width: 100%; border: 1px dashed rgba(255, 255, 255, .5); border-radius: 10px;"> + </div> + <div style="display: flex; align-items: center; justify-content: center;"> + <img src="data:image/png;base64,<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $member["name"] . ".png") ? base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $member["name"] . ".png")) : "" ?>" style="width: 100%; border: 1px dashed rgba(255, 255, 255, .5); border-radius: 10px;"> + </div> + </div> + + <?php + + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/ponies/" . $member["id"] . ".png")) { + $info = getimagesize($_SERVER['DOCUMENT_ROOT'] . "/assets/ponies/" . $member["id"] . ".png"); + } else { + $info = [null, 61]; + } + + if ($info[1] > 60): ?> + <p class="text-warning" style="margin-top: 15px; margin-bottom: 0; text-align: center;"><b>This Pony Town character needs to be updated.</b><br>Cold Haze now relies on pixel-perfect versions of one's Pony Town character to work properly, and the current character for this member is not compliant or non-existant.</p> + <?php endif; ?> + </div> + </div> + + <div class="card"> + <div class="card-body"> + <h3>Upload a new version</h3> + + <div id="uploader"> + <ol> + <li>Open Pony Town [<a href="https://pony.town/" target="_blank">main</a>, <a href="https://event.pony.town/" target="_blank">event</a>, <a href="https://eventblue.pony.town/" target="_blank">eventblue</a>, <a href="https://eventgreen.pony.town/" target="_blank">eventgreen</a>, <a href="https://breezy.pony.town/" target="_blank">breezy</a>], login if needed, and select the right pony</li> + <li>Click on <img alt="edit" src="/assets/editor/ponytown/step1.png" style="height: 2rem;"></li> + <li>Focus on <img alt="Export" src="/assets/editor/ponytown/step2.png" style="height: 2rem;"> and click on <img alt="Image export zoom" src="/assets/editor/ponytown/step2b.png" style="height: 2rem;"></li> + <li>In the menu, select <img alt="1x" src="/assets/editor/ponytown/step3.png" style="height: 2rem;"></li> + <li>Click on <img alt="Image export settings" src="/assets/editor/ponytown/step4.png" style="height: 2rem;"> and uncheck everything, like this:<br><img alt="[all settings unchecked]" src="/assets/editor/ponytown/step4b.png" style="width: 25%;"></li> + <li>Click on <img alt="PNG" src="/assets/editor/ponytown/step5.png" style="height: 2rem;"> and download the file to your device</li> + <li>Upload this file here (yes this is a button):<br><input type="file" id="file-uploader"></li> + <li>Go back to Pony Town, click on <img alt="Image export settings" src="/assets/editor/ponytown/step4.png" style="height: 2rem;"> again</li> + <li>Check "Head only", and nothing else, like this:<br><img alt="[Head only checked]" src="/assets/editor/ponytown/step9.png" style="width: 25%;"></li> + <li>Click on <img alt="PNG" src="/assets/editor/ponytown/step5.png" style="height: 2rem;"> once again and download the file to your device</li> + <li>Upload this file (the second one) here (yes this is also a button):<br><input type="file" id="file-uploader2"></li> + <li>We will check if you used the correct settings and save it if everything is good.</li> + </ol> + </div> + + <div id="checker" style="display: none;"> + <img src="/assets/editor/load.svg" style="width: 36px;"><span style="vertical-align: middle;" id="checker-message">Reading files...</span> + </div> + + <div id="error" style="display: none;"> + <p>Hmm, I don't think this is working! Check the errors below and try again:</p> + <ul id="errors"></ul> + <span class="btn btn-primary" onclick="upload();">Back</span> + </div> + + <div id="confirm" style="display: none;"> + <div style="display: grid; grid-template-columns: repeat(2, 1fr); grid-gap: 10px;"> + <div style="display: flex; align-items: center; justify-content: center;"> + <img id="confirm-preview-1" style="width: 100%; border: 1px dashed rgba(255, 255, 255, .5); border-radius: 10px;"> + </div> + <div style="display: flex; align-items: center; justify-content: center;"> + <img id="confirm-preview-2" style="width: 100%; border: 1px dashed rgba(255, 255, 255, .5); border-radius: 10px;"> + </div> + </div> + + <div style="margin-top: 10px;"> + <span class="btn btn-primary" onclick="uploadActual();">Upload</span> + <span class="btn btn-outline-primary" onclick='document.getElementById("file-uploader").value = "";document.getElementById("file-uploader2").value = "";upload();'>Cancel</span> + </div> + </div> + </div> + </div> + + <script> + function errors(list) { + document.getElementById("file-uploader").value = ""; + document.getElementById("file-uploader2").value = ""; + + document.getElementById("uploader").style.display = "none"; + document.getElementById("error").style.display = ""; + document.getElementById("checker").style.display = "none"; + document.getElementById("confirm").style.display = "none"; + + document.getElementById("errors").innerHTML = `<li>${list.map(i => i.replaceAll("<", "<").replaceAll(">", ">")).join("</li><li>")}</li>`; + } + + let files = [ + null, + null + ]; + + function uploadCandidate() { + if (files[0] && files[1]) { + document.getElementById("checker-message").innerText = "Uploading files for review..."; + + let data = JSON.stringify(files); + + if (data.length > 1024 ** 2) { + errors(["0xFF000001: The data being sent to the server is too large, your images are huge!"]); + return; + } + + window.fetch("/api/ponytown/?id=<?= $member["id"] ?>", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: data + }).then((res) => { + res.json().then((data) => { + document.getElementById("checker-message").innerText = "Processing response..."; + console.log(data); + + if (data.success) { + document.getElementById("confirm-preview-1").src = files[0]; + document.getElementById("confirm-preview-2").src = files[1]; + + document.getElementById("uploader").style.display = "none"; + document.getElementById("checker").style.display = "none"; + document.getElementById("confirm").style.display = ""; + document.getElementById("error").style.display = "none"; + } else { + errors(data.errors); + } + }) + }) + } + } + + function uploadActual() { + if (files[0] && files[1]) { + document.getElementById("checker-message").innerText = "Uploading final files..."; + + let data = JSON.stringify(files); + + if (data.length > 1024 ** 2) { + errors(["0xFF000001: The data being sent to the server is too large, your images are huge!"]); + return; + } + + window.fetch("/api/ponytown/?id=<?= $member["id"] ?>&real", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: data + }).then((res) => { + res.json().then((data) => { + document.getElementById("checker-message").innerText = "Processing response..."; + console.log(data); + + if (data.success) { + document.getElementById("checker-message").innerText = "Reloading..."; + location.href = "/-/ponytown/<?= $member["id"] ?>/?updated"; + } else { + errors(data.errors); + } + }) + }) + } + } + + document.getElementById("file-uploader").onchange = document.getElementById("file-uploader2").onchange = upload = () => { + files = [ + null, + null + ]; + + if (document.getElementById("file-uploader").files.length >= 1 && document.getElementById("file-uploader2").files.length >= 1) { + document.getElementById("errors").innerHTML = ""; + + document.getElementById("uploader").style.display = "none"; + document.getElementById("checker").style.display = ""; + document.getElementById("confirm").style.display = "none"; + document.getElementById("error").style.display = "none"; + + let file1 = document.getElementById("file-uploader").files[0]; + let file2 = document.getElementById("file-uploader2").files[0]; + + let reader1 = new FileReader(); + let reader2 = new FileReader(); + + reader1.readAsDataURL(file1); + reader2.readAsDataURL(file2); + + reader1.onerror = () => { + errors(["Unable to read file #1, an internal error occurred"]); + } + reader2.onerror = () => { + errors(["Unable to read file #2, an internal error occurred"]); + } + + reader1.onload = () => { + files[0] = reader1.result; + uploadCandidate(); + } + + reader2.onload = () => { + files[1] = reader2.result; + uploadCandidate(); + } + } else { + document.getElementById("uploader").style.display = ""; + document.getElementById("checker").style.display = "none"; + document.getElementById("confirm").style.display = "none"; + document.getElementById("error").style.display = "none"; + } + } + </script> + </div> + </div> +</div> + +<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.inc'; ?>
\ No newline at end of file diff --git a/pages/rules.inc b/pages/rules.inc index 7257cf1..ec007df 100644 --- a/pages/rules.inc +++ b/pages/rules.inc @@ -117,7 +117,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; </style> <div class="modal fade" id="editor"> - <div class="modal-dialog"> + <div class="modal-dialog modal-xl"> <div class="modal-content"> <div class="modal-header"> <h4 class="modal-title">Rules editor</h4> diff --git a/pages/stats.inc b/pages/stats.inc index 510c317..1b0fe31 100644 --- a/pages/stats.inc +++ b/pages/stats.inc @@ -196,9 +196,6 @@ $switchesCloudburst = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . $frontersMonthMembers[$key][$month] = $frontersMonthRectified[$month][$key] ?? [ "duration" => 0 ]; - /*$frontersMonthMembers[$key][$month] = array_map(function ($i) { - return $i["duration"]; - }, $frontersMonthMembers[$key][$month]);*/ } } |