From eb89b15c0f044673c1206a418a21d0baba1a675e Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Sun, 12 Mar 2023 19:16:53 +0100 Subject: Updated 104 files, added 3 files, deleted 4 files and renamed 36 files (automated) --- app.php | 10 +- assets/logo/custom.css | 4 +- assets/logo/newlogo-template.png | Bin 31787 -> 38404 bytes assets/logo/newlogo.png | Bin 4707 -> 5613 bytes assets/logo/newlogo3-template.png | Bin 38736 -> 39166 bytes assets/logo/newlogo3.png | Bin 5653 -> 5693 bytes assets/uploads/pt-applebloom.png | Bin 6219 -> 900 bytes assets/uploads/pt-babsseed.png | Bin 4820 -> 884 bytes assets/uploads/pt-blueberrycloud.png | Bin 4903 -> 682 bytes assets/uploads/pt-cinnamonfire.png | Bin 4749 -> 715 bytes assets/uploads/pt-cloudydreams.png | Bin 5523 -> 842 bytes assets/uploads/pt-colorspray.png | Bin 4375 -> 708 bytes assets/uploads/pt-coral.png | Bin 4722 -> 738 bytes assets/uploads/pt-cozyglow.png | Bin 6561 -> 1123 bytes assets/uploads/pt-creamychocolate.png | Bin 5227 -> 723 bytes assets/uploads/pt-duskrainbow.png | Bin 4821 -> 743 bytes assets/uploads/pt-floralorchid.png | Bin 4525 -> 705 bytes assets/uploads/pt-fluttershy.png | Bin 5282 -> 728 bytes assets/uploads/pt-forestpaint.png | Bin 3633 -> 619 bytes assets/uploads/pt-frostcrystals.png | Bin 4891 -> 894 bytes assets/uploads/pt-glory.png | Bin 4724 -> 782 bytes assets/uploads/pt-izzymoonbow.png | Bin 6379 -> 1089 bytes assets/uploads/pt-lavender.png | Bin 5332 -> 848 bytes assets/uploads/pt-lilacbloom.png | Bin 5212 -> 828 bytes assets/uploads/pt-mintygrape.png | Bin 7218 -> 1066 bytes assets/uploads/pt-mistybrightdawn.png | Bin 6142 -> 1092 bytes assets/uploads/pt-mistycloud.png | Bin 5234 -> 816 bytes assets/uploads/pt-mossystorm.png | Bin 4592 -> 682 bytes assets/uploads/pt-opalinearcana.png | Bin 4472 -> 945 bytes assets/uploads/pt-peachfizz.png | Bin 4508 -> 818 bytes assets/uploads/pt-pinkiepie.png | Bin 4595 -> 672 bytes assets/uploads/pt-pipppetals.png | Bin 5636 -> 794 bytes assets/uploads/pt-plushie.png | Bin 5443 -> 943 bytes assets/uploads/pt-poseybloom.png | Bin 5718 -> 771 bytes assets/uploads/pt-princesscelestia.png | Bin 5637 -> 1104 bytes assets/uploads/pt-princessluna.png | Bin 5609 -> 974 bytes assets/uploads/pt-rainbowdash.png | Bin 5005 -> 824 bytes assets/uploads/pt-rarity.png | Bin 4405 -> 754 bytes assets/uploads/pt-seashell.png | Bin 4588 -> 778 bytes assets/uploads/pt-skydream.png | Bin 6533 -> 1042 bytes assets/uploads/pt-starrynight.png | Bin 4982 -> 821 bytes assets/uploads/pt-stuffie.png | Bin 4984 -> 757 bytes assets/uploads/pt-sunnystarscout.png | Bin 4797 -> 809 bytes assets/uploads/pt-sweetiebelle.png | Bin 5136 -> 794 bytes assets/uploads/pt-sweetiebot.png | Bin 5175 -> 809 bytes assets/uploads/pt-thunder.png | Bin 5214 -> 755 bytes assets/uploads/pt-twi.png | Bin 4700 -> 728 bytes assets/uploads/pt-twilightsparkle.png | Bin 3997 -> 829 bytes assets/uploads/pt-velvet.png | Bin 5998 -> 840 bytes assets/uploads/pt-violetdawn.png | Bin 4652 -> 955 bytes assets/uploads/pt-windy.png | Bin 5054 -> 655 bytes assets/uploads/pt-windyleaves.png | Bin 4985 -> 675 bytes assets/uploads/pt-zippstorm.png | Bin 4180 -> 690 bytes assets/uploads/pt-zoomzephyrwing.png | Bin 4696 -> 735 bytes auth/callback/index.php | 8 +- includes/Parsedown.php | 1994 -------------------------------- includes/agewarning.inc | 35 - includes/assets.inc | 86 -- includes/backup.inc | 102 -- includes/banner.inc | 480 -------- includes/bitset.inc | 21 - includes/cleanup.inc | 45 - includes/components/details.inc | 166 +++ includes/components/emergency.inc | 194 ++++ includes/components/footer.inc | 42 + includes/components/fullbanner.inc | 28 + includes/components/header.inc | 220 ++++ includes/components/mobilenav.inc | 88 ++ includes/components/navigation.inc | 424 +++++++ includes/components/pane.inc | 129 +++ includes/components/planner.inc | 1046 +++++++++++++++++ includes/components/search.inc | 534 +++++++++ includes/components/sysbanner.inc | 96 ++ includes/components/wakeup.inc | 114 ++ includes/details.inc | 166 --- includes/edit-private.inc | 142 --- includes/edit.inc | 142 --- includes/emergency.inc | 194 ---- includes/exchange.txt | 2 +- includes/footer.inc | 42 - includes/fragments/edit-private.inc | 142 +++ includes/fragments/edit.inc | 142 +++ includes/fragments/member.inc | 150 +++ includes/fragments/metadata.inc | 169 +++ includes/fragments/sysedit.inc | 153 +++ includes/fragments/system.inc | 52 + includes/fullbanner.inc | 28 - includes/functions.inc | 551 --------- includes/header.inc | 231 ---- includes/homepage.inc | 36 - includes/init.inc | 6 +- includes/language.inc | 10 - includes/logo.inc | 322 ------ includes/member.inc | 150 --- includes/metadata.inc | 169 --- includes/mobilenav.inc | 88 -- includes/navigation.inc | 432 ------- includes/pages.json | 2 +- includes/pane.inc | 129 --- includes/planner.inc | 1046 ----------------- includes/profiles.inc | 97 -- includes/pronouns.inc | 149 --- includes/rail.inc | 167 --- includes/rainbow.inc | 56 - includes/random.inc | 15 - includes/refresh.php | 8 +- includes/refresh/assets.inc | 86 ++ includes/refresh/backup.inc | 97 ++ includes/refresh/cleanup.inc | 24 + includes/refresh/logo.inc | 322 ++++++ includes/score.inc | 136 --- includes/search.inc | 534 --------- includes/session.inc | 29 - includes/short.inc | 55 - includes/sysbanner.inc | 96 -- includes/sysedit.inc | 153 --- includes/system.inc | 52 - includes/system/compare.inc | 4 +- includes/system/history.inc | 4 +- includes/titlebar.inc | 606 ---------- includes/travelling.inc | 62 - includes/util/Parsedown.php | 1994 ++++++++++++++++++++++++++++++++ includes/util/agewarning.inc | 35 + includes/util/banner.inc | 480 ++++++++ includes/util/bitset.inc | 21 + includes/util/functions.inc | 551 +++++++++ includes/util/homepage.inc | 36 + includes/util/language.inc | 3 + includes/util/profiles.inc | 97 ++ includes/util/pronouns.inc | 149 +++ includes/util/rainbow.inc | 56 + includes/util/random.inc | 15 + includes/util/score.inc | 136 +++ includes/util/session.inc | 29 + includes/util/short.inc | 55 + includes/util/travelling.inc | 62 + includes/wakeup.inc | 114 -- pages/about.inc | 80 -- pages/alphabet.inc | 4 +- pages/api/chrome.php | 87 ++ pages/api/close.php | 1 + pages/api/cloudburst-img.php | 2 +- pages/api/computer.php | 8 +- pages/api/data.php | 4 +- pages/api/docs.php | 2 +- pages/api/emergency-real.php | 2 +- pages/api/emergency.php | 2 +- pages/api/fronter.php | 2 +- pages/api/me.php | 2 +- pages/api/plex.php | 4 +- pages/api/pluralkit-integration.php | 120 +- pages/api/ponytown.php | 2 +- pages/api/raindrops-img.php | 2 +- pages/api/save-private.php | 2 +- pages/api/save.php | 2 +- pages/api/token.php | 2 +- pages/api/wakeup-real.php | 2 +- pages/api/wakeup.php | 2 +- pages/byfront.inc | 4 +- pages/byspecies.inc | 6 +- pages/computers.inc | 48 +- pages/debug.inc | 4 +- pages/docs.inc | 6 +- pages/edit-private.inc | 2 +- pages/edit.inc | 4 +- pages/emergency.inc | 6 +- pages/fronting.inc | 6 +- pages/games.inc | 4 +- pages/home.inc | 10 +- pages/home.old.inc | 10 +- pages/login.inc | 20 +- pages/metadata.inc | 6 +- pages/money.inc | 6 +- pages/page.inc | 8 +- pages/ponytown.inc | 4 +- pages/profiles.inc | 6 +- pages/relations.inc | 4 +- pages/rules.inc | 8 +- pages/splitting.inc | 4 +- pages/stats.inc | 4 +- pages/terminology.inc | 4 +- pages/travelling.inc | 6 +- pages/wakeup.inc | 6 +- 183 files changed, 8429 insertions(+), 9248 deletions(-) delete mode 100644 includes/Parsedown.php delete mode 100644 includes/agewarning.inc delete mode 100644 includes/assets.inc delete mode 100644 includes/backup.inc delete mode 100644 includes/banner.inc delete mode 100644 includes/bitset.inc delete mode 100644 includes/cleanup.inc create mode 100644 includes/components/details.inc create mode 100644 includes/components/emergency.inc create mode 100644 includes/components/footer.inc create mode 100644 includes/components/fullbanner.inc create mode 100644 includes/components/header.inc create mode 100644 includes/components/mobilenav.inc create mode 100644 includes/components/navigation.inc create mode 100644 includes/components/pane.inc create mode 100644 includes/components/planner.inc create mode 100644 includes/components/search.inc create mode 100644 includes/components/sysbanner.inc create mode 100644 includes/components/wakeup.inc delete mode 100644 includes/details.inc delete mode 100644 includes/edit-private.inc delete mode 100644 includes/edit.inc delete mode 100644 includes/emergency.inc delete mode 100644 includes/footer.inc create mode 100644 includes/fragments/edit-private.inc create mode 100644 includes/fragments/edit.inc create mode 100644 includes/fragments/member.inc create mode 100644 includes/fragments/metadata.inc create mode 100644 includes/fragments/sysedit.inc create mode 100644 includes/fragments/system.inc delete mode 100644 includes/fullbanner.inc delete mode 100644 includes/functions.inc delete mode 100644 includes/header.inc delete mode 100644 includes/homepage.inc delete mode 100644 includes/language.inc delete mode 100644 includes/logo.inc delete mode 100644 includes/member.inc delete mode 100644 includes/metadata.inc delete mode 100644 includes/mobilenav.inc delete mode 100644 includes/navigation.inc delete mode 100644 includes/pane.inc delete mode 100644 includes/planner.inc delete mode 100644 includes/profiles.inc delete mode 100644 includes/pronouns.inc delete mode 100644 includes/rail.inc delete mode 100644 includes/rainbow.inc delete mode 100644 includes/random.inc create mode 100644 includes/refresh/assets.inc create mode 100644 includes/refresh/backup.inc create mode 100644 includes/refresh/cleanup.inc create mode 100644 includes/refresh/logo.inc delete mode 100644 includes/score.inc delete mode 100644 includes/search.inc delete mode 100644 includes/session.inc delete mode 100644 includes/short.inc delete mode 100644 includes/sysbanner.inc delete mode 100644 includes/sysedit.inc delete mode 100644 includes/system.inc delete mode 100644 includes/titlebar.inc delete mode 100644 includes/travelling.inc create mode 100644 includes/util/Parsedown.php create mode 100644 includes/util/agewarning.inc create mode 100644 includes/util/banner.inc create mode 100644 includes/util/bitset.inc create mode 100644 includes/util/functions.inc create mode 100644 includes/util/homepage.inc create mode 100644 includes/util/language.inc create mode 100644 includes/util/profiles.inc create mode 100644 includes/util/pronouns.inc create mode 100644 includes/util/rainbow.inc create mode 100644 includes/util/random.inc create mode 100644 includes/util/score.inc create mode 100644 includes/util/session.inc create mode 100644 includes/util/short.inc create mode 100644 includes/util/travelling.inc delete mode 100644 includes/wakeup.inc delete mode 100644 pages/about.inc create mode 100644 pages/api/chrome.php create mode 100644 pages/api/close.php diff --git a/app.php b/app.php index 8d3cb02..b6651c9 100644 --- a/app.php +++ b/app.php @@ -2,9 +2,9 @@ ob_start(); -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/language.inc"; global $lang; global $pages; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.inc"; global $isLoggedIn; global $isLowerLoggedIn; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.inc"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/language.inc"; global $lang; global $pages; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; $app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true); @@ -84,8 +84,8 @@ if (in_array($toplevel, ["editor", "icons", "species", "uploads"])) { require_once $_SERVER['DOCUMENT_ROOT'] . "/pages/page.inc"; } else { global $toplevel; - $pageFile = $_SERVER['DOCUMENT_ROOT'] . "/includes/short.inc"; - require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/short.inc"; + $pageFile = $_SERVER['DOCUMENT_ROOT'] . "/includes/util/short.inc"; + require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/short.inc"; } } } diff --git a/assets/logo/custom.css b/assets/logo/custom.css index 44f7331..59200f9 100644 --- a/assets/logo/custom.css +++ b/assets/logo/custom.css @@ -696,7 +696,7 @@ peh-muted { } @media (max-width: 991px) { - div#member-details.member-details-loggedIn { + div#member-details.member-details-loggedIn, div#member-details.member-details-loggedIn2 { grid-template-columns: repeat(3, 1fr) !important; text-align: center; } @@ -708,7 +708,7 @@ peh-muted { } @media (max-width: 767px) { - div#member-details.member-details-loggedIn { + div#member-details.member-details-loggedIn, div#member-details.member-details-loggedIn2 { grid-template-columns: repeat(2, 1fr) !important; text-align: left; } diff --git a/assets/logo/newlogo-template.png b/assets/logo/newlogo-template.png index e796e5a..859ecbf 100644 Binary files a/assets/logo/newlogo-template.png and b/assets/logo/newlogo-template.png differ diff --git a/assets/logo/newlogo.png b/assets/logo/newlogo.png index f32cbae..c3a7b4f 100644 Binary files a/assets/logo/newlogo.png and b/assets/logo/newlogo.png differ diff --git a/assets/logo/newlogo3-template.png b/assets/logo/newlogo3-template.png index bec8d1b..b998a82 100644 Binary files a/assets/logo/newlogo3-template.png and b/assets/logo/newlogo3-template.png differ diff --git a/assets/logo/newlogo3.png b/assets/logo/newlogo3.png index 28ff3e1..54c681f 100644 Binary files a/assets/logo/newlogo3.png and b/assets/logo/newlogo3.png differ diff --git a/assets/uploads/pt-applebloom.png b/assets/uploads/pt-applebloom.png index 35f844f..56bb5c9 100644 Binary files a/assets/uploads/pt-applebloom.png and b/assets/uploads/pt-applebloom.png differ diff --git a/assets/uploads/pt-babsseed.png b/assets/uploads/pt-babsseed.png index 92e76f2..6e940bc 100644 Binary files a/assets/uploads/pt-babsseed.png and b/assets/uploads/pt-babsseed.png differ diff --git a/assets/uploads/pt-blueberrycloud.png b/assets/uploads/pt-blueberrycloud.png index 7ac1aae..f34bc60 100644 Binary files a/assets/uploads/pt-blueberrycloud.png and b/assets/uploads/pt-blueberrycloud.png differ diff --git a/assets/uploads/pt-cinnamonfire.png b/assets/uploads/pt-cinnamonfire.png index c23c1ad..3b001ba 100644 Binary files a/assets/uploads/pt-cinnamonfire.png and b/assets/uploads/pt-cinnamonfire.png differ diff --git a/assets/uploads/pt-cloudydreams.png b/assets/uploads/pt-cloudydreams.png index e8387d8..17567c3 100644 Binary files a/assets/uploads/pt-cloudydreams.png and b/assets/uploads/pt-cloudydreams.png differ diff --git a/assets/uploads/pt-colorspray.png b/assets/uploads/pt-colorspray.png index ad0b37b..ed76565 100644 Binary files a/assets/uploads/pt-colorspray.png and b/assets/uploads/pt-colorspray.png differ diff --git a/assets/uploads/pt-coral.png b/assets/uploads/pt-coral.png index 0eaee1e..a558c4d 100644 Binary files a/assets/uploads/pt-coral.png and b/assets/uploads/pt-coral.png differ diff --git a/assets/uploads/pt-cozyglow.png b/assets/uploads/pt-cozyglow.png index 4f65ee9..2a75399 100644 Binary files a/assets/uploads/pt-cozyglow.png and b/assets/uploads/pt-cozyglow.png differ diff --git a/assets/uploads/pt-creamychocolate.png b/assets/uploads/pt-creamychocolate.png index 1cb2699..04cd5d3 100644 Binary files a/assets/uploads/pt-creamychocolate.png and b/assets/uploads/pt-creamychocolate.png differ diff --git a/assets/uploads/pt-duskrainbow.png b/assets/uploads/pt-duskrainbow.png index 012c4eb..ee2da4a 100644 Binary files a/assets/uploads/pt-duskrainbow.png and b/assets/uploads/pt-duskrainbow.png differ diff --git a/assets/uploads/pt-floralorchid.png b/assets/uploads/pt-floralorchid.png index 0b396aa..fbb6899 100644 Binary files a/assets/uploads/pt-floralorchid.png and b/assets/uploads/pt-floralorchid.png differ diff --git a/assets/uploads/pt-fluttershy.png b/assets/uploads/pt-fluttershy.png index 3997890..2ae1eba 100644 Binary files a/assets/uploads/pt-fluttershy.png and b/assets/uploads/pt-fluttershy.png differ diff --git a/assets/uploads/pt-forestpaint.png b/assets/uploads/pt-forestpaint.png index 639da8b..aafc93a 100644 Binary files a/assets/uploads/pt-forestpaint.png and b/assets/uploads/pt-forestpaint.png differ diff --git a/assets/uploads/pt-frostcrystals.png b/assets/uploads/pt-frostcrystals.png index 09845f3..71f0422 100644 Binary files a/assets/uploads/pt-frostcrystals.png and b/assets/uploads/pt-frostcrystals.png differ diff --git a/assets/uploads/pt-glory.png b/assets/uploads/pt-glory.png index fd84f7a..5b159a9 100644 Binary files a/assets/uploads/pt-glory.png and b/assets/uploads/pt-glory.png differ diff --git a/assets/uploads/pt-izzymoonbow.png b/assets/uploads/pt-izzymoonbow.png index e01ab3b..3799a68 100644 Binary files a/assets/uploads/pt-izzymoonbow.png and b/assets/uploads/pt-izzymoonbow.png differ diff --git a/assets/uploads/pt-lavender.png b/assets/uploads/pt-lavender.png index 3289720..202fbe2 100644 Binary files a/assets/uploads/pt-lavender.png and b/assets/uploads/pt-lavender.png differ diff --git a/assets/uploads/pt-lilacbloom.png b/assets/uploads/pt-lilacbloom.png index b131821..9801ee0 100644 Binary files a/assets/uploads/pt-lilacbloom.png and b/assets/uploads/pt-lilacbloom.png differ diff --git a/assets/uploads/pt-mintygrape.png b/assets/uploads/pt-mintygrape.png index 820b657..e6e0497 100644 Binary files a/assets/uploads/pt-mintygrape.png and b/assets/uploads/pt-mintygrape.png differ diff --git a/assets/uploads/pt-mistybrightdawn.png b/assets/uploads/pt-mistybrightdawn.png index 3afb56c..bc07a9b 100644 Binary files a/assets/uploads/pt-mistybrightdawn.png and b/assets/uploads/pt-mistybrightdawn.png differ diff --git a/assets/uploads/pt-mistycloud.png b/assets/uploads/pt-mistycloud.png index 16db8fb..34d6ae0 100644 Binary files a/assets/uploads/pt-mistycloud.png and b/assets/uploads/pt-mistycloud.png differ diff --git a/assets/uploads/pt-mossystorm.png b/assets/uploads/pt-mossystorm.png index 6a26877..e15c241 100644 Binary files a/assets/uploads/pt-mossystorm.png and b/assets/uploads/pt-mossystorm.png differ diff --git a/assets/uploads/pt-opalinearcana.png b/assets/uploads/pt-opalinearcana.png index 261f40d..bd7883d 100644 Binary files a/assets/uploads/pt-opalinearcana.png and b/assets/uploads/pt-opalinearcana.png differ diff --git a/assets/uploads/pt-peachfizz.png b/assets/uploads/pt-peachfizz.png index ab8e9c9..73d3ac6 100644 Binary files a/assets/uploads/pt-peachfizz.png and b/assets/uploads/pt-peachfizz.png differ diff --git a/assets/uploads/pt-pinkiepie.png b/assets/uploads/pt-pinkiepie.png index 75e9071..5ca4d10 100644 Binary files a/assets/uploads/pt-pinkiepie.png and b/assets/uploads/pt-pinkiepie.png differ diff --git a/assets/uploads/pt-pipppetals.png b/assets/uploads/pt-pipppetals.png index 57ab4a1..21666e6 100644 Binary files a/assets/uploads/pt-pipppetals.png and b/assets/uploads/pt-pipppetals.png differ diff --git a/assets/uploads/pt-plushie.png b/assets/uploads/pt-plushie.png index 0cf6b62..b4dffc4 100644 Binary files a/assets/uploads/pt-plushie.png and b/assets/uploads/pt-plushie.png differ diff --git a/assets/uploads/pt-poseybloom.png b/assets/uploads/pt-poseybloom.png index 508ffe4..1edaad7 100644 Binary files a/assets/uploads/pt-poseybloom.png and b/assets/uploads/pt-poseybloom.png differ diff --git a/assets/uploads/pt-princesscelestia.png b/assets/uploads/pt-princesscelestia.png index baa8055..b9251ec 100644 Binary files a/assets/uploads/pt-princesscelestia.png and b/assets/uploads/pt-princesscelestia.png differ diff --git a/assets/uploads/pt-princessluna.png b/assets/uploads/pt-princessluna.png index 804690a..cfb7c47 100644 Binary files a/assets/uploads/pt-princessluna.png and b/assets/uploads/pt-princessluna.png differ diff --git a/assets/uploads/pt-rainbowdash.png b/assets/uploads/pt-rainbowdash.png index e7bed73..271d216 100644 Binary files a/assets/uploads/pt-rainbowdash.png and b/assets/uploads/pt-rainbowdash.png differ diff --git a/assets/uploads/pt-rarity.png b/assets/uploads/pt-rarity.png index 5a2cd2b..2c1f663 100644 Binary files a/assets/uploads/pt-rarity.png and b/assets/uploads/pt-rarity.png differ diff --git a/assets/uploads/pt-seashell.png b/assets/uploads/pt-seashell.png index b28d664..f5c8568 100644 Binary files a/assets/uploads/pt-seashell.png and b/assets/uploads/pt-seashell.png differ diff --git a/assets/uploads/pt-skydream.png b/assets/uploads/pt-skydream.png index a6cb979..793755b 100644 Binary files a/assets/uploads/pt-skydream.png and b/assets/uploads/pt-skydream.png differ diff --git a/assets/uploads/pt-starrynight.png b/assets/uploads/pt-starrynight.png index bcbfe7b..18b5b89 100644 Binary files a/assets/uploads/pt-starrynight.png and b/assets/uploads/pt-starrynight.png differ diff --git a/assets/uploads/pt-stuffie.png b/assets/uploads/pt-stuffie.png index 7ba4226..1285bcd 100644 Binary files a/assets/uploads/pt-stuffie.png and b/assets/uploads/pt-stuffie.png differ diff --git a/assets/uploads/pt-sunnystarscout.png b/assets/uploads/pt-sunnystarscout.png index c44b2fd..ad3121d 100644 Binary files a/assets/uploads/pt-sunnystarscout.png and b/assets/uploads/pt-sunnystarscout.png differ diff --git a/assets/uploads/pt-sweetiebelle.png b/assets/uploads/pt-sweetiebelle.png index 4a9cf15..50098f1 100644 Binary files a/assets/uploads/pt-sweetiebelle.png and b/assets/uploads/pt-sweetiebelle.png differ diff --git a/assets/uploads/pt-sweetiebot.png b/assets/uploads/pt-sweetiebot.png index 04daac6..e5ee414 100644 Binary files a/assets/uploads/pt-sweetiebot.png and b/assets/uploads/pt-sweetiebot.png differ diff --git a/assets/uploads/pt-thunder.png b/assets/uploads/pt-thunder.png index 48ed462..6bd7a0d 100644 Binary files a/assets/uploads/pt-thunder.png and b/assets/uploads/pt-thunder.png differ diff --git a/assets/uploads/pt-twi.png b/assets/uploads/pt-twi.png index 766f3fc..c56fdc9 100644 Binary files a/assets/uploads/pt-twi.png and b/assets/uploads/pt-twi.png differ diff --git a/assets/uploads/pt-twilightsparkle.png b/assets/uploads/pt-twilightsparkle.png index e996c8d..8c10184 100644 Binary files a/assets/uploads/pt-twilightsparkle.png and b/assets/uploads/pt-twilightsparkle.png differ diff --git a/assets/uploads/pt-velvet.png b/assets/uploads/pt-velvet.png index 253f94c..666ed93 100644 Binary files a/assets/uploads/pt-velvet.png and b/assets/uploads/pt-velvet.png differ diff --git a/assets/uploads/pt-violetdawn.png b/assets/uploads/pt-violetdawn.png index adb048b..d12312d 100644 Binary files a/assets/uploads/pt-violetdawn.png and b/assets/uploads/pt-violetdawn.png differ diff --git a/assets/uploads/pt-windy.png b/assets/uploads/pt-windy.png index 83c3dbe..8d01678 100644 Binary files a/assets/uploads/pt-windy.png and b/assets/uploads/pt-windy.png differ diff --git a/assets/uploads/pt-windyleaves.png b/assets/uploads/pt-windyleaves.png index 8eadb40..ef49235 100644 Binary files a/assets/uploads/pt-windyleaves.png and b/assets/uploads/pt-windyleaves.png differ diff --git a/assets/uploads/pt-zippstorm.png b/assets/uploads/pt-zippstorm.png index 94622fc..0cb4b4a 100644 Binary files a/assets/uploads/pt-zippstorm.png and b/assets/uploads/pt-zippstorm.png differ diff --git a/assets/uploads/pt-zoomzephyrwing.png b/assets/uploads/pt-zoomzephyrwing.png index e75a6c3..8ffc3f4 100644 Binary files a/assets/uploads/pt-zoomzephyrwing.png and b/assets/uploads/pt-zoomzephyrwing.png differ diff --git a/auth/callback/index.php b/auth/callback/index.php index 8419364..8d040e9 100644 --- a/auth/callback/index.php +++ b/auth/callback/index.php @@ -56,6 +56,12 @@ if (isset($result["access_token"])) { header("Set-Cookie: PEH2_SESSION_TOKEN=" . $token . "; SameSite=None; Path=/; Secure; HttpOnly; Expires=" . date("r", time() + (86400 * 730))); - header("Location: /"); + if (isset($_COOKIE["PEH2_RETURN_PAGE"])) { + header("Location: " . str_replace("\n", "", str_replace("\r", "", $_COOKIE["PEH2_RETURN_PAGE"]))); + } else { + header("Location: /"); + } + + setcookie("PEH2_RETURN_PAGE", ""); die(); } \ No newline at end of file diff --git a/includes/Parsedown.php b/includes/Parsedown.php deleted file mode 100644 index 3e29589..0000000 --- a/includes/Parsedown.php +++ /dev/null @@ -1,1994 +0,0 @@ -textElements($text); - - # convert to markup - $markup = $this->elements($Elements); - - # trim line breaks - $markup = trim($markup, "\n"); - - return $markup; - } - - protected function textElements($text) - { - # make sure no definitions are set - $this->DefinitionData = array(); - - # standardize line breaks - $text = str_replace(array("\r\n", "\r"), "\n", $text); - - # remove surrounding line breaks - $text = trim($text, "\n"); - - # split text into lines - $lines = explode("\n", $text); - - # iterate through lines to identify blocks - return $this->linesElements($lines); - } - - # - # Setters - # - - function setBreaksEnabled($breaksEnabled) - { - $this->breaksEnabled = $breaksEnabled; - - return $this; - } - - protected $breaksEnabled; - - function setMarkupEscaped($markupEscaped) - { - $this->markupEscaped = $markupEscaped; - - return $this; - } - - protected $markupEscaped; - - function setUrlsLinked($urlsLinked) - { - $this->urlsLinked = $urlsLinked; - - return $this; - } - - protected $urlsLinked = true; - - function setSafeMode($safeMode) - { - $this->safeMode = (bool) $safeMode; - - return $this; - } - - protected $safeMode; - - function setStrictMode($strictMode) - { - $this->strictMode = (bool) $strictMode; - - return $this; - } - - protected $strictMode; - - protected $safeLinksWhitelist = array( - 'http://', - 'https://', - 'ftp://', - 'ftps://', - 'mailto:', - 'tel:', - 'data:image/png;base64,', - 'data:image/gif;base64,', - 'data:image/jpeg;base64,', - 'irc:', - 'ircs:', - 'git:', - 'ssh:', - 'news:', - 'steam:', - ); - - # - # Lines - # - - protected $BlockTypes = array( - '#' => array('Header'), - '*' => array('Rule', 'List'), - '+' => array('List'), - '-' => array('SetextHeader', 'Table', 'Rule', 'List'), - '0' => array('List'), - '1' => array('List'), - '2' => array('List'), - '3' => array('List'), - '4' => array('List'), - '5' => array('List'), - '6' => array('List'), - '7' => array('List'), - '8' => array('List'), - '9' => array('List'), - ':' => array('Table'), - '<' => array('Comment', 'Markup'), - '=' => array('SetextHeader'), - '>' => array('Quote'), - '[' => array('Reference'), - '_' => array('Rule'), - '`' => array('FencedCode'), - '|' => array('Table'), - '~' => array('FencedCode'), - ); - - # ~ - - protected $unmarkedBlockTypes = array( - 'Code', - ); - - # - # Blocks - # - - protected function lines(array $lines) - { - return $this->elements($this->linesElements($lines)); - } - - protected function linesElements(array $lines) - { - $Elements = array(); - $CurrentBlock = null; - - foreach ($lines as $line) - { - if (chop($line) === '') - { - if (isset($CurrentBlock)) - { - $CurrentBlock['interrupted'] = (isset($CurrentBlock['interrupted']) - ? $CurrentBlock['interrupted'] + 1 : 1 - ); - } - - continue; - } - - while (($beforeTab = strstr($line, "\t", true)) !== false) - { - $shortage = 4 - mb_strlen($beforeTab, 'utf-8') % 4; - - $line = $beforeTab - . str_repeat(' ', $shortage) - . substr($line, strlen($beforeTab) + 1) - ; - } - - $indent = strspn($line, ' '); - - $text = $indent > 0 ? substr($line, $indent) : $line; - - # ~ - - $Line = array('body' => $line, 'indent' => $indent, 'text' => $text); - - # ~ - - if (isset($CurrentBlock['continuable'])) - { - $methodName = 'block' . $CurrentBlock['type'] . 'Continue'; - $Block = $this->$methodName($Line, $CurrentBlock); - - if (isset($Block)) - { - $CurrentBlock = $Block; - - continue; - } - else - { - if ($this->isBlockCompletable($CurrentBlock['type'])) - { - $methodName = 'block' . $CurrentBlock['type'] . 'Complete'; - $CurrentBlock = $this->$methodName($CurrentBlock); - } - } - } - - # ~ - - $marker = $text[0]; - - # ~ - - $blockTypes = $this->unmarkedBlockTypes; - - if (isset($this->BlockTypes[$marker])) - { - foreach ($this->BlockTypes[$marker] as $blockType) - { - $blockTypes []= $blockType; - } - } - - # - # ~ - - foreach ($blockTypes as $blockType) - { - $Block = $this->{"block$blockType"}($Line, $CurrentBlock); - - if (isset($Block)) - { - $Block['type'] = $blockType; - - if ( ! isset($Block['identified'])) - { - if (isset($CurrentBlock)) - { - $Elements[] = $this->extractElement($CurrentBlock); - } - - $Block['identified'] = true; - } - - if ($this->isBlockContinuable($blockType)) - { - $Block['continuable'] = true; - } - - $CurrentBlock = $Block; - - continue 2; - } - } - - # ~ - - if (isset($CurrentBlock) and $CurrentBlock['type'] === 'Paragraph') - { - $Block = $this->paragraphContinue($Line, $CurrentBlock); - } - - if (isset($Block)) - { - $CurrentBlock = $Block; - } - else - { - if (isset($CurrentBlock)) - { - $Elements[] = $this->extractElement($CurrentBlock); - } - - $CurrentBlock = $this->paragraph($Line); - - $CurrentBlock['identified'] = true; - } - } - - # ~ - - if (isset($CurrentBlock['continuable']) and $this->isBlockCompletable($CurrentBlock['type'])) - { - $methodName = 'block' . $CurrentBlock['type'] . 'Complete'; - $CurrentBlock = $this->$methodName($CurrentBlock); - } - - # ~ - - if (isset($CurrentBlock)) - { - $Elements[] = $this->extractElement($CurrentBlock); - } - - # ~ - - return $Elements; - } - - protected function extractElement(array $Component) - { - if ( ! isset($Component['element'])) - { - if (isset($Component['markup'])) - { - $Component['element'] = array('rawHtml' => $Component['markup']); - } - elseif (isset($Component['hidden'])) - { - $Component['element'] = array(); - } - } - - return $Component['element']; - } - - protected function isBlockContinuable($Type) - { - return method_exists($this, 'block' . $Type . 'Continue'); - } - - protected function isBlockCompletable($Type) - { - return method_exists($this, 'block' . $Type . 'Complete'); - } - - # - # Code - - protected function blockCode($Line, $Block = null) - { - if (isset($Block) and $Block['type'] === 'Paragraph' and ! isset($Block['interrupted'])) - { - return; - } - - if ($Line['indent'] >= 4) - { - $text = substr($Line['body'], 4); - - $Block = array( - 'element' => array( - 'name' => 'pre', - 'element' => array( - 'name' => 'code', - 'text' => $text, - ), - ), - ); - - return $Block; - } - } - - protected function blockCodeContinue($Line, $Block) - { - if ($Line['indent'] >= 4) - { - if (isset($Block['interrupted'])) - { - $Block['element']['element']['text'] .= str_repeat("\n", $Block['interrupted']); - - unset($Block['interrupted']); - } - - $Block['element']['element']['text'] .= "\n"; - - $text = substr($Line['body'], 4); - - $Block['element']['element']['text'] .= $text; - - return $Block; - } - } - - protected function blockCodeComplete($Block) - { - return $Block; - } - - # - # Comment - - protected function blockComment($Line) - { - if ($this->markupEscaped or $this->safeMode) - { - return; - } - - if (strpos($Line['text'], '') !== false) - { - $Block['closed'] = true; - } - - return $Block; - } - } - - protected function blockCommentContinue($Line, array $Block) - { - if (isset($Block['closed'])) - { - return; - } - - $Block['element']['rawHtml'] .= "\n" . $Line['body']; - - if (strpos($Line['text'], '-->') !== false) - { - $Block['closed'] = true; - } - - return $Block; - } - - # - # Fenced Code - - protected function blockFencedCode($Line) - { - $marker = $Line['text'][0]; - - $openerLength = strspn($Line['text'], $marker); - - if ($openerLength < 3) - { - return; - } - - $infostring = trim(substr($Line['text'], $openerLength), "\t "); - - if (strpos($infostring, '`') !== false) - { - return; - } - - $Element = array( - 'name' => 'code', - 'text' => '', - ); - - if ($infostring !== '') - { - /** - * https://www.w3.org/TR/2011/WD-html5-20110525/elements.html#classes - * Every HTML element may have a class attribute specified. - * The attribute, if specified, must have a value that is a set - * of space-separated tokens representing the various classes - * that the element belongs to. - * [...] - * The space characters, for the purposes of this specification, - * are U+0020 SPACE, U+0009 CHARACTER TABULATION (tab), - * U+000A LINE FEED (LF), U+000C FORM FEED (FF), and - * U+000D CARRIAGE RETURN (CR). - */ - $language = substr($infostring, 0, strcspn($infostring, " \t\n\f\r")); - - $Element['attributes'] = array('class' => "language-$language"); - } - - $Block = array( - 'char' => $marker, - 'openerLength' => $openerLength, - 'element' => array( - 'name' => 'pre', - 'element' => $Element, - ), - ); - - return $Block; - } - - protected function blockFencedCodeContinue($Line, $Block) - { - if (isset($Block['complete'])) - { - return; - } - - if (isset($Block['interrupted'])) - { - $Block['element']['element']['text'] .= str_repeat("\n", $Block['interrupted']); - - unset($Block['interrupted']); - } - - if (($len = strspn($Line['text'], $Block['char'])) >= $Block['openerLength'] - and chop(substr($Line['text'], $len), ' ') === '' - ) { - $Block['element']['element']['text'] = substr($Block['element']['element']['text'], 1); - - $Block['complete'] = true; - - return $Block; - } - - $Block['element']['element']['text'] .= "\n" . $Line['body']; - - return $Block; - } - - protected function blockFencedCodeComplete($Block) - { - return $Block; - } - - # - # Header - - protected function blockHeader($Line) - { - $level = strspn($Line['text'], '#'); - - if ($level > 6) - { - return; - } - - $text = trim($Line['text'], '#'); - - if ($this->strictMode and isset($text[0]) and $text[0] !== ' ') - { - return; - } - - $text = trim($text, ' '); - - $Block = array( - 'element' => array( - 'name' => 'h' . $level, - 'handler' => array( - 'function' => 'lineElements', - 'argument' => $text, - 'destination' => 'elements', - ) - ), - ); - - return $Block; - } - - # - # List - - protected function blockList($Line, array $CurrentBlock = null) - { - list($name, $pattern) = $Line['text'][0] <= '-' ? array('ul', '[*+-]') : array('ol', '[0-9]{1,9}+[.\)]'); - - if (preg_match('/^('.$pattern.'([ ]++|$))(.*+)/', $Line['text'], $matches)) - { - $contentIndent = strlen($matches[2]); - - if ($contentIndent >= 5) - { - $contentIndent -= 1; - $matches[1] = substr($matches[1], 0, -$contentIndent); - $matches[3] = str_repeat(' ', $contentIndent) . $matches[3]; - } - elseif ($contentIndent === 0) - { - $matches[1] .= ' '; - } - - $markerWithoutWhitespace = strstr($matches[1], ' ', true); - - $Block = array( - 'indent' => $Line['indent'], - 'pattern' => $pattern, - 'data' => array( - 'type' => $name, - 'marker' => $matches[1], - 'markerType' => ($name === 'ul' ? $markerWithoutWhitespace : substr($markerWithoutWhitespace, -1)), - ), - 'element' => array( - 'name' => $name, - 'elements' => array(), - ), - ); - $Block['data']['markerTypeRegex'] = preg_quote($Block['data']['markerType'], '/'); - - if ($name === 'ol') - { - $listStart = ltrim(strstr($matches[1], $Block['data']['markerType'], true), '0') ?: '0'; - - if ($listStart !== '1') - { - if ( - isset($CurrentBlock) - and $CurrentBlock['type'] === 'Paragraph' - and ! isset($CurrentBlock['interrupted']) - ) { - return; - } - - $Block['element']['attributes'] = array('start' => $listStart); - } - } - - $Block['li'] = array( - 'name' => 'li', - 'handler' => array( - 'function' => 'li', - 'argument' => !empty($matches[3]) ? array($matches[3]) : array(), - 'destination' => 'elements' - ) - ); - - $Block['element']['elements'] []= & $Block['li']; - - return $Block; - } - } - - protected function blockListContinue($Line, array $Block) - { - if (isset($Block['interrupted']) and empty($Block['li']['handler']['argument'])) - { - return null; - } - - $requiredIndent = ($Block['indent'] + strlen($Block['data']['marker'])); - - if ($Line['indent'] < $requiredIndent - and ( - ( - $Block['data']['type'] === 'ol' - and preg_match('/^[0-9]++'.$Block['data']['markerTypeRegex'].'(?:[ ]++(.*)|$)/', $Line['text'], $matches) - ) or ( - $Block['data']['type'] === 'ul' - and preg_match('/^'.$Block['data']['markerTypeRegex'].'(?:[ ]++(.*)|$)/', $Line['text'], $matches) - ) - ) - ) { - if (isset($Block['interrupted'])) - { - $Block['li']['handler']['argument'] []= ''; - - $Block['loose'] = true; - - unset($Block['interrupted']); - } - - unset($Block['li']); - - $text = isset($matches[1]) ? $matches[1] : ''; - - $Block['indent'] = $Line['indent']; - - $Block['li'] = array( - 'name' => 'li', - 'handler' => array( - 'function' => 'li', - 'argument' => array($text), - 'destination' => 'elements' - ) - ); - - $Block['element']['elements'] []= & $Block['li']; - - return $Block; - } - elseif ($Line['indent'] < $requiredIndent and $this->blockList($Line)) - { - return null; - } - - if ($Line['text'][0] === '[' and $this->blockReference($Line)) - { - return $Block; - } - - if ($Line['indent'] >= $requiredIndent) - { - if (isset($Block['interrupted'])) - { - $Block['li']['handler']['argument'] []= ''; - - $Block['loose'] = true; - - unset($Block['interrupted']); - } - - $text = substr($Line['body'], $requiredIndent); - - $Block['li']['handler']['argument'] []= $text; - - return $Block; - } - - if ( ! isset($Block['interrupted'])) - { - $text = preg_replace('/^[ ]{0,'.$requiredIndent.'}+/', '', $Line['body']); - - $Block['li']['handler']['argument'] []= $text; - - return $Block; - } - } - - protected function blockListComplete(array $Block) - { - if (isset($Block['loose'])) - { - foreach ($Block['element']['elements'] as &$li) - { - if (end($li['handler']['argument']) !== '') - { - $li['handler']['argument'] []= ''; - } - } - } - - return $Block; - } - - # - # Quote - - protected function blockQuote($Line) - { - if (preg_match('/^>[ ]?+(.*+)/', $Line['text'], $matches)) - { - $Block = array( - 'element' => array( - 'name' => 'blockquote', - 'handler' => array( - 'function' => 'linesElements', - 'argument' => (array) $matches[1], - 'destination' => 'elements', - ) - ), - ); - - return $Block; - } - } - - protected function blockQuoteContinue($Line, array $Block) - { - if (isset($Block['interrupted'])) - { - return; - } - - if ($Line['text'][0] === '>' and preg_match('/^>[ ]?+(.*+)/', $Line['text'], $matches)) - { - $Block['element']['handler']['argument'] []= $matches[1]; - - return $Block; - } - - if ( ! isset($Block['interrupted'])) - { - $Block['element']['handler']['argument'] []= $Line['text']; - - return $Block; - } - } - - # - # Rule - - protected function blockRule($Line) - { - $marker = $Line['text'][0]; - - if (substr_count($Line['text'], $marker) >= 3 and chop($Line['text'], " $marker") === '') - { - $Block = array( - 'element' => array( - 'name' => 'hr', - ), - ); - - return $Block; - } - } - - # - # Setext - - protected function blockSetextHeader($Line, array $Block = null) - { - if ( ! isset($Block) or $Block['type'] !== 'Paragraph' or isset($Block['interrupted'])) - { - return; - } - - if ($Line['indent'] < 4 and chop(chop($Line['text'], ' '), $Line['text'][0]) === '') - { - $Block['element']['name'] = $Line['text'][0] === '=' ? 'h1' : 'h2'; - - return $Block; - } - } - - # - # Markup - - protected function blockMarkup($Line) - { - if ($this->markupEscaped or $this->safeMode) - { - return; - } - - if (preg_match('/^<[\/]?+(\w*)(?:[ ]*+'.$this->regexHtmlAttribute.')*+[ ]*+(\/)?>/', $Line['text'], $matches)) - { - $element = strtolower($matches[1]); - - if (in_array($element, $this->textLevelElements)) - { - return; - } - - $Block = array( - 'name' => $matches[1], - 'element' => array( - 'rawHtml' => $Line['text'], - 'autobreak' => true, - ), - ); - - return $Block; - } - } - - protected function blockMarkupContinue($Line, array $Block) - { - if (isset($Block['closed']) or isset($Block['interrupted'])) - { - return; - } - - $Block['element']['rawHtml'] .= "\n" . $Line['body']; - - return $Block; - } - - # - # Reference - - protected function blockReference($Line) - { - if (strpos($Line['text'], ']') !== false - and preg_match('/^\[(.+?)\]:[ ]*+?(?:[ ]+["\'(](.+)["\')])?[ ]*+$/', $Line['text'], $matches) - ) { - $id = strtolower($matches[1]); - - $Data = array( - 'url' => $matches[2], - 'title' => isset($matches[3]) ? $matches[3] : null, - ); - - $this->DefinitionData['Reference'][$id] = $Data; - - $Block = array( - 'element' => array(), - ); - - return $Block; - } - } - - # - # Table - - protected function blockTable($Line, array $Block = null) - { - if ( ! isset($Block) or $Block['type'] !== 'Paragraph' or isset($Block['interrupted'])) - { - return; - } - - if ( - strpos($Block['element']['handler']['argument'], '|') === false - and strpos($Line['text'], '|') === false - and strpos($Line['text'], ':') === false - or strpos($Block['element']['handler']['argument'], "\n") !== false - ) { - return; - } - - if (chop($Line['text'], ' -:|') !== '') - { - return; - } - - $alignments = array(); - - $divider = $Line['text']; - - $divider = trim($divider); - $divider = trim($divider, '|'); - - $dividerCells = explode('|', $divider); - - foreach ($dividerCells as $dividerCell) - { - $dividerCell = trim($dividerCell); - - if ($dividerCell === '') - { - return; - } - - $alignment = null; - - if ($dividerCell[0] === ':') - { - $alignment = 'left'; - } - - if (substr($dividerCell, - 1) === ':') - { - $alignment = $alignment === 'left' ? 'center' : 'right'; - } - - $alignments []= $alignment; - } - - # ~ - - $HeaderElements = array(); - - $header = $Block['element']['handler']['argument']; - - $header = trim($header); - $header = trim($header, '|'); - - $headerCells = explode('|', $header); - - if (count($headerCells) !== count($alignments)) - { - return; - } - - foreach ($headerCells as $index => $headerCell) - { - $headerCell = trim($headerCell); - - $HeaderElement = array( - 'name' => 'th', - 'handler' => array( - 'function' => 'lineElements', - 'argument' => $headerCell, - 'destination' => 'elements', - ) - ); - - if (isset($alignments[$index])) - { - $alignment = $alignments[$index]; - - $HeaderElement['attributes'] = array( - 'style' => "text-align: $alignment;", - ); - } - - $HeaderElements []= $HeaderElement; - } - - # ~ - - $Block = array( - 'alignments' => $alignments, - 'identified' => true, - 'element' => array( - 'name' => 'table', - 'elements' => array(), - ), - ); - - $Block['element']['elements'] []= array( - 'name' => 'thead', - ); - - $Block['element']['elements'] []= array( - 'name' => 'tbody', - 'elements' => array(), - ); - - $Block['element']['elements'][0]['elements'] []= array( - 'name' => 'tr', - 'elements' => $HeaderElements, - ); - - return $Block; - } - - protected function blockTableContinue($Line, array $Block) - { - if (isset($Block['interrupted'])) - { - return; - } - - if (count($Block['alignments']) === 1 or $Line['text'][0] === '|' or strpos($Line['text'], '|')) - { - $Elements = array(); - - $row = $Line['text']; - - $row = trim($row); - $row = trim($row, '|'); - - preg_match_all('/(?:(\\\\[|])|[^|`]|`[^`]++`|`)++/', $row, $matches); - - $cells = array_slice($matches[0], 0, count($Block['alignments'])); - - foreach ($cells as $index => $cell) - { - $cell = trim($cell); - - $Element = array( - 'name' => 'td', - 'handler' => array( - 'function' => 'lineElements', - 'argument' => $cell, - 'destination' => 'elements', - ) - ); - - if (isset($Block['alignments'][$index])) - { - $Element['attributes'] = array( - 'style' => 'text-align: ' . $Block['alignments'][$index] . ';', - ); - } - - $Elements []= $Element; - } - - $Element = array( - 'name' => 'tr', - 'elements' => $Elements, - ); - - $Block['element']['elements'][1]['elements'] []= $Element; - - return $Block; - } - } - - # - # ~ - # - - protected function paragraph($Line) - { - return array( - 'type' => 'Paragraph', - 'element' => array( - 'name' => 'p', - 'handler' => array( - 'function' => 'lineElements', - 'argument' => $Line['text'], - 'destination' => 'elements', - ), - ), - ); - } - - protected function paragraphContinue($Line, array $Block) - { - if (isset($Block['interrupted'])) - { - return; - } - - $Block['element']['handler']['argument'] .= "\n".$Line['text']; - - return $Block; - } - - # - # Inline Elements - # - - protected $InlineTypes = array( - '!' => array('Image'), - '&' => array('SpecialCharacter'), - '*' => array('Emphasis'), - ':' => array('Url'), - '<' => array('UrlTag', 'EmailTag', 'Markup'), - '[' => array('Link'), - '_' => array('Emphasis'), - '`' => array('Code'), - '~' => array('Strikethrough'), - '\\' => array('EscapeSequence'), - ); - - # ~ - - protected $inlineMarkerList = '!*_&[:<`~\\'; - - # - # ~ - # - - public function line($text, $nonNestables = array()) - { - return $this->elements($this->lineElements($text, $nonNestables)); - } - - protected function lineElements($text, $nonNestables = array()) - { - # standardize line breaks - $text = str_replace(array("\r\n", "\r"), "\n", $text); - - $Elements = array(); - - $nonNestables = (empty($nonNestables) - ? array() - : array_combine($nonNestables, $nonNestables) - ); - - # $excerpt is based on the first occurrence of a marker - - while ($excerpt = strpbrk($text, $this->inlineMarkerList)) - { - $marker = $excerpt[0]; - - $markerPosition = strlen($text) - strlen($excerpt); - - $Excerpt = array('text' => $excerpt, 'context' => $text); - - foreach ($this->InlineTypes[$marker] as $inlineType) - { - # check to see if the current inline type is nestable in the current context - - if (isset($nonNestables[$inlineType])) - { - continue; - } - - $Inline = $this->{"inline$inlineType"}($Excerpt); - - if ( ! isset($Inline)) - { - continue; - } - - # makes sure that the inline belongs to "our" marker - - if (isset($Inline['position']) and $Inline['position'] > $markerPosition) - { - continue; - } - - # sets a default inline position - - if ( ! isset($Inline['position'])) - { - $Inline['position'] = $markerPosition; - } - - # cause the new element to 'inherit' our non nestables - - - $Inline['element']['nonNestables'] = isset($Inline['element']['nonNestables']) - ? array_merge($Inline['element']['nonNestables'], $nonNestables) - : $nonNestables - ; - - # the text that comes before the inline - $unmarkedText = substr($text, 0, $Inline['position']); - - # compile the unmarked text - $InlineText = $this->inlineText($unmarkedText); - $Elements[] = $InlineText['element']; - - # compile the inline - $Elements[] = $this->extractElement($Inline); - - # remove the examined text - $text = substr($text, $Inline['position'] + $Inline['extent']); - - continue 2; - } - - # the marker does not belong to an inline - - $unmarkedText = substr($text, 0, $markerPosition + 1); - - $InlineText = $this->inlineText($unmarkedText); - $Elements[] = $InlineText['element']; - - $text = substr($text, $markerPosition + 1); - } - - $InlineText = $this->inlineText($text); - $Elements[] = $InlineText['element']; - - foreach ($Elements as &$Element) - { - if ( ! isset($Element['autobreak'])) - { - $Element['autobreak'] = false; - } - } - - return $Elements; - } - - # - # ~ - # - - protected function inlineText($text) - { - $Inline = array( - 'extent' => strlen($text), - 'element' => array(), - ); - - $Inline['element']['elements'] = self::pregReplaceElements( - $this->breaksEnabled ? '/[ ]*+\n/' : '/(?:[ ]*+\\\\|[ ]{2,}+)\n/', - array( - array('name' => 'br'), - array('text' => "\n"), - ), - $text - ); - - return $Inline; - } - - protected function inlineCode($Excerpt) - { - $marker = $Excerpt['text'][0]; - - if (preg_match('/^(['.$marker.']++)[ ]*+(.+?)[ ]*+(? strlen($matches[0]), - 'element' => array( - 'name' => 'code', - 'text' => $text, - ), - ); - } - } - - protected function inlineEmailTag($Excerpt) - { - $hostnameLabel = '[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?'; - - $commonMarkEmail = '[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]++@' - . $hostnameLabel . '(?:\.' . $hostnameLabel . ')*'; - - if (strpos($Excerpt['text'], '>') !== false - and preg_match("/^<((mailto:)?$commonMarkEmail)>/i", $Excerpt['text'], $matches) - ){ - $url = $matches[1]; - - if ( ! isset($matches[2])) - { - $url = "mailto:$url"; - } - - return array( - 'extent' => strlen($matches[0]), - 'element' => array( - 'name' => 'a', - 'text' => $matches[1], - 'attributes' => array( - 'href' => $url, - ), - ), - ); - } - } - - protected function inlineEmphasis($Excerpt) - { - if ( ! isset($Excerpt['text'][1])) - { - return; - } - - $marker = $Excerpt['text'][0]; - - if ($Excerpt['text'][1] === $marker and preg_match($this->StrongRegex[$marker], $Excerpt['text'], $matches)) - { - $emphasis = 'strong'; - } - elseif (preg_match($this->EmRegex[$marker], $Excerpt['text'], $matches)) - { - $emphasis = 'em'; - } - else - { - return; - } - - return array( - 'extent' => strlen($matches[0]), - 'element' => array( - 'name' => $emphasis, - 'handler' => array( - 'function' => 'lineElements', - 'argument' => $matches[1], - 'destination' => 'elements', - ) - ), - ); - } - - protected function inlineEscapeSequence($Excerpt) - { - if (isset($Excerpt['text'][1]) and in_array($Excerpt['text'][1], $this->specialCharacters)) - { - return array( - 'element' => array('rawHtml' => $Excerpt['text'][1]), - 'extent' => 2, - ); - } - } - - protected function inlineImage($Excerpt) - { - if ( ! isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[') - { - return; - } - - $Excerpt['text']= substr($Excerpt['text'], 1); - - $Link = $this->inlineLink($Excerpt); - - if ($Link === null) - { - return; - } - - $Inline = array( - 'extent' => $Link['extent'] + 1, - 'element' => array( - 'name' => 'img', - 'attributes' => array( - 'src' => $Link['element']['attributes']['href'], - 'alt' => $Link['element']['handler']['argument'], - ), - 'autobreak' => true, - ), - ); - - $Inline['element']['attributes'] += $Link['element']['attributes']; - - unset($Inline['element']['attributes']['href']); - - return $Inline; - } - - protected function inlineLink($Excerpt) - { - $Element = array( - 'name' => 'a', - 'handler' => array( - 'function' => 'lineElements', - 'argument' => null, - 'destination' => 'elements', - ), - 'nonNestables' => array('Url', 'Link'), - 'attributes' => array( - 'href' => null, - 'title' => null, - ), - ); - - $extent = 0; - - $remainder = $Excerpt['text']; - - if (preg_match('/\[((?:[^][]++|(?R))*+)\]/', $remainder, $matches)) - { - $Element['handler']['argument'] = $matches[1]; - - $extent += strlen($matches[0]); - - $remainder = substr($remainder, $extent); - } - else - { - return; - } - - if (preg_match('/^[(]\s*+((?:[^ ()]++|[(][^ )]+[)])++)(?:[ ]+("[^"]*+"|\'[^\']*+\'))?\s*+[)]/', $remainder, $matches)) - { - $Element['attributes']['href'] = $matches[1]; - - if (isset($matches[2])) - { - $Element['attributes']['title'] = substr($matches[2], 1, - 1); - } - - $extent += strlen($matches[0]); - } - else - { - if (preg_match('/^\s*\[(.*?)\]/', $remainder, $matches)) - { - $definition = strlen($matches[1]) ? $matches[1] : $Element['handler']['argument']; - $definition = strtolower($definition); - - $extent += strlen($matches[0]); - } - else - { - $definition = strtolower($Element['handler']['argument']); - } - - if ( ! isset($this->DefinitionData['Reference'][$definition])) - { - return; - } - - $Definition = $this->DefinitionData['Reference'][$definition]; - - $Element['attributes']['href'] = $Definition['url']; - $Element['attributes']['title'] = $Definition['title']; - } - - return array( - 'extent' => $extent, - 'element' => $Element, - ); - } - - protected function inlineMarkup($Excerpt) - { - if ($this->markupEscaped or $this->safeMode or strpos($Excerpt['text'], '>') === false) - { - return; - } - - if ($Excerpt['text'][1] === '/' and preg_match('/^<\/\w[\w-]*+[ ]*+>/s', $Excerpt['text'], $matches)) - { - return array( - 'element' => array('rawHtml' => $matches[0]), - 'extent' => strlen($matches[0]), - ); - } - - if ($Excerpt['text'][1] === '!' and preg_match('/^/s', $Excerpt['text'], $matches)) - { - return array( - 'element' => array('rawHtml' => $matches[0]), - 'extent' => strlen($matches[0]), - ); - } - - if ($Excerpt['text'][1] !== ' ' and preg_match('/^<\w[\w-]*+(?:[ ]*+'.$this->regexHtmlAttribute.')*+[ ]*+\/?>/s', $Excerpt['text'], $matches)) - { - return array( - 'element' => array('rawHtml' => $matches[0]), - 'extent' => strlen($matches[0]), - ); - } - } - - protected function inlineSpecialCharacter($Excerpt) - { - if (substr($Excerpt['text'], 1, 1) !== ' ' and strpos($Excerpt['text'], ';') !== false - and preg_match('/^&(#?+[0-9a-zA-Z]++);/', $Excerpt['text'], $matches) - ) { - return array( - 'element' => array('rawHtml' => '&' . $matches[1] . ';'), - 'extent' => strlen($matches[0]), - ); - } - - return; - } - - protected function inlineStrikethrough($Excerpt) - { - if ( ! isset($Excerpt['text'][1])) - { - return; - } - - if ($Excerpt['text'][1] === '~' and preg_match('/^~~(?=\S)(.+?)(?<=\S)~~/', $Excerpt['text'], $matches)) - { - return array( - 'extent' => strlen($matches[0]), - 'element' => array( - 'name' => 'del', - 'handler' => array( - 'function' => 'lineElements', - 'argument' => $matches[1], - 'destination' => 'elements', - ) - ), - ); - } - } - - protected function inlineUrl($Excerpt) - { - if ($this->urlsLinked !== true or ! isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/') - { - return; - } - - if (strpos($Excerpt['context'], 'http') !== false - and preg_match('/\bhttps?+:[\/]{2}[^\s<]+\b\/*+/ui', $Excerpt['context'], $matches, PREG_OFFSET_CAPTURE) - ) { - $url = $matches[0][0]; - - $Inline = array( - 'extent' => strlen($matches[0][0]), - 'position' => $matches[0][1], - 'element' => array( - 'name' => 'a', - 'text' => $url, - 'attributes' => array( - 'href' => $url, - ), - ), - ); - - return $Inline; - } - } - - protected function inlineUrlTag($Excerpt) - { - if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<(\w++:\/{2}[^ >]++)>/i', $Excerpt['text'], $matches)) - { - $url = $matches[1]; - - return array( - 'extent' => strlen($matches[0]), - 'element' => array( - 'name' => 'a', - 'text' => $url, - 'attributes' => array( - 'href' => $url, - ), - ), - ); - } - } - - # ~ - - protected function unmarkedText($text) - { - $Inline = $this->inlineText($text); - return $this->element($Inline['element']); - } - - # - # Handlers - # - - protected function handle(array $Element) - { - if (isset($Element['handler'])) - { - if (!isset($Element['nonNestables'])) - { - $Element['nonNestables'] = array(); - } - - if (is_string($Element['handler'])) - { - $function = $Element['handler']; - $argument = $Element['text']; - unset($Element['text']); - $destination = 'rawHtml'; - } - else - { - $function = $Element['handler']['function']; - $argument = $Element['handler']['argument']; - $destination = $Element['handler']['destination']; - } - - $Element[$destination] = $this->{$function}($argument, $Element['nonNestables']); - - if ($destination === 'handler') - { - $Element = $this->handle($Element); - } - - unset($Element['handler']); - } - - return $Element; - } - - protected function handleElementRecursive(array $Element) - { - return $this->elementApplyRecursive(array($this, 'handle'), $Element); - } - - protected function handleElementsRecursive(array $Elements) - { - return $this->elementsApplyRecursive(array($this, 'handle'), $Elements); - } - - protected function elementApplyRecursive($closure, array $Element) - { - $Element = call_user_func($closure, $Element); - - if (isset($Element['elements'])) - { - $Element['elements'] = $this->elementsApplyRecursive($closure, $Element['elements']); - } - elseif (isset($Element['element'])) - { - $Element['element'] = $this->elementApplyRecursive($closure, $Element['element']); - } - - return $Element; - } - - protected function elementApplyRecursiveDepthFirst($closure, array $Element) - { - if (isset($Element['elements'])) - { - $Element['elements'] = $this->elementsApplyRecursiveDepthFirst($closure, $Element['elements']); - } - elseif (isset($Element['element'])) - { - $Element['element'] = $this->elementsApplyRecursiveDepthFirst($closure, $Element['element']); - } - - $Element = call_user_func($closure, $Element); - - return $Element; - } - - protected function elementsApplyRecursive($closure, array $Elements) - { - foreach ($Elements as &$Element) - { - $Element = $this->elementApplyRecursive($closure, $Element); - } - - return $Elements; - } - - protected function elementsApplyRecursiveDepthFirst($closure, array $Elements) - { - foreach ($Elements as &$Element) - { - $Element = $this->elementApplyRecursiveDepthFirst($closure, $Element); - } - - return $Elements; - } - - protected function element(array $Element) - { - if ($this->safeMode) - { - $Element = $this->sanitiseElement($Element); - } - - # identity map if element has no handler - $Element = $this->handle($Element); - - $hasName = isset($Element['name']); - - $markup = ''; - - if ($hasName) - { - $markup .= '<' . $Element['name']; - - if (isset($Element['attributes'])) - { - foreach ($Element['attributes'] as $name => $value) - { - if ($value === null) - { - continue; - } - - $markup .= " $name=\"".self::escape($value).'"'; - } - } - } - - $permitRawHtml = false; - - if (isset($Element['text'])) - { - $text = $Element['text']; - } - // very strongly consider an alternative if you're writing an - // extension - elseif (isset($Element['rawHtml'])) - { - $text = $Element['rawHtml']; - - $allowRawHtmlInSafeMode = isset($Element['allowRawHtmlInSafeMode']) && $Element['allowRawHtmlInSafeMode']; - $permitRawHtml = !$this->safeMode || $allowRawHtmlInSafeMode; - } - - $hasContent = isset($text) || isset($Element['element']) || isset($Element['elements']); - - if ($hasContent) - { - $markup .= $hasName ? '>' : ''; - - if (isset($Element['elements'])) - { - $markup .= $this->elements($Element['elements']); - } - elseif (isset($Element['element'])) - { - $markup .= $this->element($Element['element']); - } - else - { - if (!$permitRawHtml) - { - $markup .= self::escape($text, true); - } - else - { - $markup .= $text; - } - } - - $markup .= $hasName ? '' : ''; - } - elseif ($hasName) - { - $markup .= ' />'; - } - - return $markup; - } - - protected function elements(array $Elements) - { - $markup = ''; - - $autoBreak = true; - - foreach ($Elements as $Element) - { - if (empty($Element)) - { - continue; - } - - $autoBreakNext = (isset($Element['autobreak']) - ? $Element['autobreak'] : isset($Element['name']) - ); - // (autobreak === false) covers both sides of an element - $autoBreak = !$autoBreak ? $autoBreak : $autoBreakNext; - - $markup .= ($autoBreak ? "\n" : '') . $this->element($Element); - $autoBreak = $autoBreakNext; - } - - $markup .= $autoBreak ? "\n" : ''; - - return $markup; - } - - # ~ - - protected function li($lines) - { - $Elements = $this->linesElements($lines); - - if ( ! in_array('', $lines) - and isset($Elements[0]) and isset($Elements[0]['name']) - and $Elements[0]['name'] === 'p' - ) { - unset($Elements[0]['name']); - } - - return $Elements; - } - - # - # AST Convenience - # - - /** - * Replace occurrences $regexp with $Elements in $text. Return an array of - * elements representing the replacement. - */ - protected static function pregReplaceElements($regexp, $Elements, $text) - { - $newElements = array(); - - while (preg_match($regexp, $text, $matches, PREG_OFFSET_CAPTURE)) - { - $offset = $matches[0][1]; - $before = substr($text, 0, $offset); - $after = substr($text, $offset + strlen($matches[0][0])); - - $newElements[] = array('text' => $before); - - foreach ($Elements as $Element) - { - $newElements[] = $Element; - } - - $text = $after; - } - - $newElements[] = array('text' => $text); - - return $newElements; - } - - # - # Deprecated Methods - # - - function parse($text) - { - $markup = $this->text($text); - - return $markup; - } - - protected function sanitiseElement(array $Element) - { - static $goodAttribute = '/^[a-zA-Z0-9][a-zA-Z0-9-_]*+$/'; - static $safeUrlNameToAtt = array( - 'a' => 'href', - 'img' => 'src', - ); - - if ( ! isset($Element['name'])) - { - unset($Element['attributes']); - return $Element; - } - - if (isset($safeUrlNameToAtt[$Element['name']])) - { - $Element = $this->filterUnsafeUrlInAttribute($Element, $safeUrlNameToAtt[$Element['name']]); - } - - if ( ! empty($Element['attributes'])) - { - foreach ($Element['attributes'] as $att => $val) - { - # filter out badly parsed attribute - if ( ! preg_match($goodAttribute, $att)) - { - unset($Element['attributes'][$att]); - } - # dump onevent attribute - elseif (self::striAtStart($att, 'on')) - { - unset($Element['attributes'][$att]); - } - } - } - - return $Element; - } - - protected function filterUnsafeUrlInAttribute(array $Element, $attribute) - { - foreach ($this->safeLinksWhitelist as $scheme) - { - if (self::striAtStart($Element['attributes'][$attribute], $scheme)) - { - return $Element; - } - } - - $Element['attributes'][$attribute] = str_replace(':', '%3A', $Element['attributes'][$attribute]); - - return $Element; - } - - # - # Static Methods - # - - protected static function escape($text, $allowQuotes = false) - { - return htmlspecialchars($text, $allowQuotes ? ENT_NOQUOTES : ENT_QUOTES, 'UTF-8'); - } - - protected static function striAtStart($string, $needle) - { - $len = strlen($needle); - - if ($len > strlen($string)) - { - return false; - } - else - { - return strtolower(substr($string, 0, $len)) === strtolower($needle); - } - } - - static function instance($name = 'default') - { - if (isset(self::$instances[$name])) - { - return self::$instances[$name]; - } - - $instance = new static(); - - self::$instances[$name] = $instance; - - return $instance; - } - - private static $instances = array(); - - # - # Fields - # - - protected $DefinitionData; - - # - # Read-Only - - protected $specialCharacters = array( - '\\', '`', '*', '_', '{', '}', '[', ']', '(', ')', '>', '#', '+', '-', '.', '!', '|', '~' - ); - - protected $StrongRegex = array( - '*' => '/^[*]{2}((?:\\\\\*|[^*]|[*][^*]*+[*])+?)[*]{2}(?![*])/s', - '_' => '/^__((?:\\\\_|[^_]|_[^_]*+_)+?)__(?!_)/us', - ); - - protected $EmRegex = array( - '*' => '/^[*]((?:\\\\\*|[^*]|[*][*][^*]+?[*][*])+?)[*](?![*])/s', - '_' => '/^_((?:\\\\_|[^_]|__[^_]*__)+?)_(?!_)\b/us', - ); - - protected $regexHtmlAttribute = '[a-zA-Z_:][\w:.-]*+(?:\s*+=\s*+(?:[^"\'=<>`\s]+|"[^"]*+"|\'[^\']*+\'))?+'; - - protected $voidElements = array( - 'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', - ); - - protected $textLevelElements = array( - 'a', 'br', 'bdo', 'abbr', 'blink', 'nextid', 'acronym', 'basefont', - 'b', 'em', 'big', 'cite', 'small', 'spacer', 'listing', - 'i', 'rp', 'del', 'code', 'strike', 'marquee', - 'q', 'rt', 'ins', 'font', 'strong', - 's', 'tt', 'kbd', 'mark', - 'u', 'xm', 'sub', 'nobr', - 'sup', 'ruby', - 'var', 'span', - 'wbr', 'time', - ); -} \ No newline at end of file diff --git a/includes/agewarning.inc b/includes/agewarning.inc deleted file mode 100644 index 1f51647..0000000 --- a/includes/agewarning.inc +++ /dev/null @@ -1,35 +0,0 @@ - 1677628800) { - file_get_contents('https://' . $ntfy["server"] . '/' . $ntfy['topic'], false, stream_context_create([ - 'http' => [ - 'method' => 'POST', - 'header' => - "Content-Type: text/plain\r\n" . - "Title: ⚠️ $name does not have an age or birth year set\r\n" . - "Priority: max\r\n" . - "Tags: switch\r\n" . - "Actions: view, Edit on Cold Haze, https://ponies.equestria.horse/-/metadata/" . ($system === "gdapd" ? "raindrops" : "cloudburst") . "/" . $id . "/, clear=true\r\n" . - "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => "To make sure they appear on the fronting schedule (and to make sure they can front again), they need to set an age or birth year now." - ] - ])); - } else { - file_get_contents('https://' . $ntfy["server"] . '/' . $ntfy['topic'], false, stream_context_create([ - 'http' => [ - 'method' => 'POST', - 'header' => - "Content-Type: text/plain\r\n" . - "Title: ⚠️ $name does not have an age or birth year set\r\n" . - "Priority: max\r\n" . - "Tags: switch\r\n" . - "Actions: view, Edit on Cold Haze, https://ponies.equestria.horse/-/metadata/" . ($system === "gdapd" ? "raindrops" : "cloudburst") . "/" . $id . "/, clear=true\r\n" . - "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => "To make sure they still appear on the fronting schedule after March 1st, they need to set an age or birth year now." - ] - ])); - } -} \ No newline at end of file diff --git a/includes/assets.inc b/includes/assets.inc deleted file mode 100644 index 3f2d652..0000000 --- a/includes/assets.inc +++ /dev/null @@ -1,86 +0,0 @@ - date('c'), - "files" => [] -]; - -foreach ($root as $file) { - if ($file === "backup.poniesbackup" || $file === "backup.ponieskey" || $file === "encrypted" || str_ends_with($file, ".poniesbackup")) continue; - echo(" /$file\n"); - - if (is_dir("data/$file")) { - foreach (array_filter(scandir("data/$file"), function ($i) { - return !str_starts_with($i, "."); - }) as $dirfile) { - if ($dirfile === "backup.poniesbackup" || $dirfile === "backup.ponieskey" || $dirfile === "encrypted" || str_ends_with($dirfile, ".poniesbackup")) continue; - - echo(" /$dirfile/$file\n"); - $files[] = [ - "dir" => $file, - "file" => $dirfile - ]; - } - } else { - echo(" /$file\n"); - $files[] = [ - "dir" => "", - "file" => $file - ]; - } -} - -echo(" Reading files...\n"); -foreach ($files as $file) { - echo(" /$file[dir]/$file[file]\n"); - $file["mime"] = mime_content_type("data/$file[dir]/$file[file]"); - $file["checksum"] = [ - sha1_file("data/$file[dir]/$file[file]"), - md5_file("data/$file[dir]/$file[file]") - ]; - $file["content"] = base64_encode(file_get_contents("data/$file[dir]/$file[file]")); - - $data["files"][] = $file; -} - -function pkcs7_pad($data, $size) { - $length = $size - strlen($data) % $size; - return $data . str_repeat(chr($length), $length); -} - -if (!file_exists("./data/backup.ponieskey")) { - echo(" Creating encryption key...\n"); - $key = openssl_random_pseudo_bytes(512); - $iv = openssl_random_pseudo_bytes(16); - file_put_contents("./data/backup.ponieskey", base64_encode(json_encode([ - "iv" => bin2hex($iv), - "key" => bin2hex($key) - ]))); -} else { - echo(" Reading encryption key...\n"); - $key_raw = json_decode(base64_decode(file_get_contents("./data/backup.ponieskey")), true); - $key = hex2bin($key_raw["key"]); - $iv = hex2bin($key_raw["iv"]); -} - -echo(" Encrypting...\n"); -$payload = json_encode($data); -$encrypted = openssl_encrypt(pkcs7_pad($payload, 16), 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv); - -echo(" Writing backup...\n"); -file_put_contents("./data/backup.poniesbackup", $encrypted); -@mkdir("./data/encrypted"); - -$id = str_replace(":", "-", date('c')); -copy("./data/backup.poniesbackup", "./data/encrypted/" . $id . ".poniesbackup"); - -echo(" Uploading to servers...\n"); - -echo(" zephyrheights... upload\n"); -exec("scp ./data/encrypted/" . $id . ".poniesbackup root@zephyrheights.equestria.dev:/opt/ponies"); -echo(" zephyrheights... cleaning up\n"); -exec('ssh root@zephyrheights.equestria.dev bash /opt/clean.sh'); - -echo(" canterlot... upload\n"); -exec("scp ./data/encrypted/" . $id . ".poniesbackup root@canterlot.equestria.dev:/opt/ponies"); -echo(" canterlot... cleaning up\n"); -exec('ssh root@canterlot.equestria.dev bash /opt/clean.sh'); - -if (file_exists("/opt/ponies")) { - echo(" bridlewood... copy\n"); - copy("./data/encrypted/" . $id . ".poniesbackup", "/opt/ponies/" . $id . ".poniesbackup"); - echo(" bridlewood... cleaning up\n"); - exec('bash -c "cd /opt/ponies; ls -tp | grep -v \'/$\' | tail -n +20 | xargs -I {} rm -- {}"'); -} - -echo(" Cleaning up...\n"); -unlink("./data/encrypted/" . $id . ".poniesbackup"); \ No newline at end of file diff --git a/includes/banner.inc b/includes/banner.inc deleted file mode 100644 index a95c51d..0000000 --- a/includes/banner.inc +++ /dev/null @@ -1,480 +0,0 @@ - 4196352, - "regression" => null, - "median" => null, - "marefriends" => [], - "sexfriends" => [], - "sisters" => [], - "caretakers" => [] - ]); - - $prefixes = []; - foreach ($member['proxy_tags'] as $proxy) { - if ($travelling[$member['id']]["travelling"]) { - if (isset($travelling[$member['id']]['equestria']) && $travelling[$member['id']]['equestria']) { - $prefixes[] = null; - } else { - $prefixes[] = "+" . $proxy["prefix"] . ($proxy["suffix"] !== "" && $proxy["suffix"] !== null ? "..." . $proxy["suffix"] : ""); - } - } else { - $prefixes[] = $proxy["prefix"] . ($proxy["suffix"] !== "" && $proxy["suffix"] !== null ? "..." . $proxy["suffix"] : ""); - } - } - - $lastFronted = null; - if (!$metadata["median"]) { - $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)) { - $lastFronted = [ - 'now' => true, - 'relative' => timeAgo(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json"), true)["timestamp"]), - 'absolute' => date("D j M Y, G:i:s (e)", strtotime(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json"), true)["timestamp"])), - 'timestamp' => strtotime(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json"), true)["timestamp"]), - 'duration' => [ - 'seconds' => null, - 'pretty' => null - ] - ]; - } else { - $switches = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/switches.json"), true); - - $thisMember = array_filter($switches, function ($item) { - global $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)) { - $seconds = (strtotime($frontingEnd["timestamp"]) - strtotime($frontingStart["timestamp"])); - - $lastFronted = [ - 'now' => false, - 'relative' => timeAgo($frontingEnd["timestamp"]), - 'absolute' => date("D j M Y, G:i:s (e)", strtotime($frontingEnd["timestamp"])), - 'timestamp' => strtotime($frontingEnd["timestamp"]), - 'duration' => [ - 'seconds' => $seconds, - 'pretty' => $seconds . ($french ? " secondes" : " seconds") - ] - ]; - if ($french) { - if ($seconds > 60) { - if ($seconds > 3600) { - $lastFronted['duration']['pretty'] = round($seconds / 3600) . " heures"; - } else { - $lastFronted['duration']['pretty'] = round($seconds / 60) . " minutes"; - } - } - } else { - if ($seconds > 60) { - if ($seconds > 3600) { - $lastFronted['duration']['pretty'] = round($seconds / 3600) . " hours"; - } else { - $lastFronted['duration']['pretty'] = round($seconds / 60) . " minutes"; - } - } - } - } - } - } - - $speciesList = []; - foreach ($metadata["species"] ?? [] as $species) { - if ($french) { - $name = match ($species) { - "earth" => $metadata["robot"] ? "Robot poney terrestre" : (!$metadata["plush"] ? "Poney terrestre" : "Poney terrestre en peluche"), - "alicorn" => $metadata["robot"] ? "Robot alicorne" : (!$metadata["plush"] ? "Alicorne" : "Alicorne en peluche"), - "crystal" => $metadata["robot"] ? "Robot poney de crystal" : (!$metadata["plush"] ? "Poney de crystal" : "Poney de crystal en peluche"), - "pegasus" => $metadata["robot"] ? "Robot pégase" : (!$metadata["plush"] ? "Pégase" : "Pégase en peluche"), - "batpony" => $metadata["robot"] ? "Robot Poney chauve souris" : (!$metadata["plush"] ? "Poney chauve souris" : "Poney chauve souris en peluche"), - "unicorn" => $metadata["robot"] ? "Robot licorne" : (!$metadata["plush"] ? "Licorne" : "Licorne en peluche"), - "changeling" => "Changelin", - default => $species . "_" . $metadata["robot"] - }; - } else { - $name = match ($species) { - "earth" => $metadata["robot"] ? "Robot earth pony" : (!$metadata["plush"] ? "Earth pony" : "Earth pony plush"), - "alicorn" => $metadata["robot"] ? "Robot alicorn" : (!$metadata["plush"] ? "Alicorn" : "Alicorn plush"), - "crystal" => $metadata["robot"] ? "Robot crystal pony" : (!$metadata["plush"] ? "Crystal pony" : "Crystal pony plush"), - "pegasus" => $metadata["robot"] ? "Robot pegasus" : (!$metadata["plush"] ? "Pegasus" : "Pegasus plush"), - "batpony" => $metadata["robot"] ? "Robot bat pony" : (!$metadata["plush"] ? "Bat pony" : "Bat pony plush"), - "unicorn" => $metadata["robot"] ? "Robot unicorn" : (!$metadata["plush"] ? "Unicorn" : "Unicorn plush"), - "changeling" => "Changeling", - default => $species . "_" . $metadata["robot"] - }; - } - - $speciesList[] = [ - "id" => $species, - "name" => $name, - "robot" => $metadata["robot"], - "plush" => $metadata["plush"], - "icon" => $species . ($metadata["robot"] ? "-robot" : ($metadata["plush"] ? "-plush" : "")) . ".png" - ]; - } - - $app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true); - - $systemData = []; - $systemData['page'] = "/" . ($system === "gdapd" ? "raindrops" : ($system === $app["other"]["id"] ? $app["other"]["slug"] : "cloudburst")); - $systemData['icon'] = getAsset($system); - $systemData['name'] = $system === "gdapd" ? "Raindrops" : ($system === $app["other"]["id"] ? $app["other"]["short"] : "Cloudburst"); - $systemData['full_name'] = $system === "gdapd" ? "Raindrops System" : ($system === $app["other"]["id"] ? $app["other"]["name"] : "Cloudburst System"); - $systemData['temporary'] = false; - - if ($travelling[$member['id']]["travelling"] && !$travelling[$member['id']]["equestria"]) { - $systemData['page'] = "/" . ($system === "gdapd" ? "cloudburst" : "raindrops"); - $systemData['icon'] = getAsset($system === "gdapd" ? "ynmuc" : "gdapd"); - $systemData['name'] = $system === "gdapd" ? "Cloudburst" : "Raindrops"; - $systemData['full_name'] = $system === "gdapd" ? "Cloudburst System" : "Raindrops System"; - $systemData['temporary'] = true; - } - - if ($travelling[$member['id']]["travelling"] && $travelling[$member['id']]["equestria"]) { - $systemData['page'] = null; - $systemData['icon'] = "../logo/equestria.png"; - $systemData['name'] = "Equestria"; - $systemData['full_name'] = "Equestria"; - $systemData['temporary'] = true; - } - - $marefriends = []; - foreach ($metadata["marefriends"] as $marefriend) { - $mfSystem = explode("/", $marefriend)[0]; - $mfMemberID = explode("/", $marefriend)[1]; - $mfMember = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$mfSystem/members.json"), true), function ($item) use ($mfMemberID) { - return $item["id"] === $mfMemberID; - }); - sort($mfMember); - $mfMember = $mfMember[0]; - - $marefriends[] = [ - "id" => $marefriend, - "link" => "/" . ($mfMember["name"]), - "icon" => getAsset($mfSystem, $mfMemberID, "heads"), - "name" => $mfMember["display_name"] ?? $mfMember["name"], - "full_name" => $mfMember["display_name"] ?? $mfMember["name"] - ]; - } - - $sexfriends = null; - - if ($isLoggedIn) { - $sexfriends = []; - foreach ($metadata["sexfriends"] as $marefriend) { - $mfSystem = explode("/", $marefriend)[0]; - $mfMemberID = explode("/", $marefriend)[1]; - $mfMember = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$mfSystem/members.json"), true), function ($item) use ($mfMemberID) { - return $item["id"] === $mfMemberID; - }); - sort($mfMember); - $mfMember = $mfMember[0]; - - $sexfriends[] = [ - "id" => $marefriend, - "link" => "/" . ($mfMember["name"]), - "icon" => getAsset($mfSystem, $mfMemberID, "heads"), - "name" => $mfMember["display_name"] ?? $mfMember["name"], - "full_name" => $mfMember["display_name"] ?? $mfMember["name"] - ]; - } - } - - $sisters = []; - foreach ($metadata["sisters"] as $marefriend) { - $mfSystem = explode("/", $marefriend)[0]; - $mfMemberID = explode("/", $marefriend)[1]; - $mfMember = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$mfSystem/members.json"), true), function ($item) use ($mfMemberID) { - return $item["id"] === $mfMemberID; - }); - sort($mfMember); - $mfMember = $mfMember[0]; - - $sisters[] = [ - "id" => $marefriend, - "link" => "/" . ($mfMember["name"]), - "icon" => getAsset($mfSystem, $mfMemberID, "heads"), - "name" => $mfMember["display_name"] ?? $mfMember["name"], - "full_name" => $mfMember["display_name"] ?? $mfMember["name"] - ]; - } - - $caretakers = null; - - if ($metadata["little"] >= 2) { - $caretakers = []; - foreach ($metadata["caretakers"] as $marefriend) { - $mfSystem = explode("/", $marefriend)[0]; - $mfMemberID = explode("/", $marefriend)[1]; - $mfMember = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$mfSystem/members.json"), true), function ($item) use ($mfMemberID) { - return $item["id"] === $mfMemberID; - }); - sort($mfMember); - $mfMember = $mfMember[0]; - - $caretakers[] = [ - "id" => $marefriend, - "link" => "/" . ($mfMember["name"]), - "icon" => getAsset($mfSystem, $mfMemberID, "heads"), - "name" => $mfMember["display_name"] ?? $mfMember["name"], - "full_name" => $mfMember["display_name"] ?? $mfMember["name"] - ]; - } - } - - $badges = []; - - if ($metadata["host"] ?? false) { - if (!$travelling[$member['id']]["travelling"]) { - $badges[] = [ - "id" => "mcf", - "color" => "primary", - "html" => ( - $french - ? - 'Fronteuse la plus présente' - : - 'Most common fronter' - ) - ]; - } - } - - /*if (($metadata["age_spells"] ?? false) && !$french) { - $badges[] = [ - "id" => "age_spells", - "color" => "#6f42c1", - "html" => 'Affected by age spells' - ]; - }*/ - - if ($metadata["fictive"] ?? false) { - $badges[] = [ - "id" => "fictive", - "color" => "info", - "html" => ( - $french - ? - 'Fictive' - : - 'Fictive' - ) - ]; - } - - if ($metadata["persecutor"] ?? false) { - $badges[] = [ - "id" => "persecutor", - "color" => "danger", - "html" => ( - $french - ? - 'Persécutrice' - : - 'Persecutor' - ) - ]; - } - - if ($metadata["less_frequent"] ?? false) { - $badges[] = [ - "id" => "nonverbal", - "color" => "#6610f2", - "html" => ( - $french - ? - 'Fronte moins souvent' - : - 'Fronts less often' - ) - ]; - } - - if ($metadata["nonverbal"] ?? false) { - $badges[] = [ - "id" => "nonverbal", - "color" => "#20c997", - "html" => ( - $french - ? - 'Non verbal IRL' - : - 'Non verbal IRL' - ) - ]; - } - - if ($member["name"] === "fusion") { - $badges[] = [ - "id" => "fusion", - "color" => "d63384", - "html" => 'Fusion' - ]; - } - - if (($metadata["leader"] ?? false)) { - $badges[] = [ - "id" => "leader", - "color" => "d6a833", - "html" => ( - $french - ? - 'Dirigeante' - : - 'Leader' - ) - ]; - } - - if ($metadata["protector"] ?? false) { - $badges[] = [ - "id" => "protector", - "color" => "black", - "html" => ( - $french - ? - '
' . ucfirst(getMemberPronouns($member['pronouns'])["subjective"]) . ' ' . (getMemberPronouns($member['pronouns'])["third"] ? "is" : "are") . ' a protector in the system and will front when somepony cannot handle it anymore." class="badge rounded-pill bg-black">' . (getMemberPronouns($member['pronouns'])["gender"] === "female" ? "Protectrice" : (getMemberPronouns($member['pronouns'])["gender"] === "male" ? "Protecteur" : "Protectrice")) . '
' - : - 'Protector' - ) - ]; - } - - if (($metadata["little"] ?? 0) === 2) { - $badges[] = [ - "id" => "little", - "color" => "success", - "html" => ( - $french - ? - '
' . ucfirst(getMemberPronouns($member['pronouns'])["subjective"]) . ' ' . (getMemberPronouns($member['pronouns'])["third"] ? "is" : "are") . ' mentally younger, and therefore behaves and feels younger than the body is." class="badge rounded-pill bg-success">Petit' . (getMemberPronouns($member['pronouns'])["gender"] === "female" ? "e" : (getMemberPronouns($member['pronouns'])["gender"] === "male" ? "" : "·e")) . '
' - : - 'Little' - ) - ]; - } - - if (($metadata["little"] ?? 0) === 3) { - $badges[] = [ - "id" => "younger", - "color" => "dark", - "html" => ( - $french - ? - 'Plus jeune' - : - 'Younger' - ) - ]; - } - - if (($metadata["age_regressor"] ?? false)) { - if ($metadata["regression"] !== null && $metadata["regression"] !== false) { - $regression = _header_getMember($metadata["regression"], $system); - $badges[] = [ - "id" => "regressor_median", - "color" => "secondary", - "html" => ( - $french - ? - 'Régresse en âge en '. (getMiniName($regression["display_name"] ?? $regression["name"])) . '' - : - 'Age regresses into '. (getMiniName($regression["display_name"] ?? $regression["name"])) . '' - ) - ]; - } - } - - if ($metadata["median"] !== null && $metadata["median"] !== false) { - $source = _header_getMember($metadata["median"], $system); - if ($metadata["little"] > 0) { - $badges[] = [ - "id" => "regressed", - "color" => "warning", - "html" => ( - $french - ? - 'Régressé en âge de ' . (getMiniName($source["display_name"] ?? $source["name"])) . '' - : - 'Age regressed from ' . (getMiniName($source["display_name"] ?? $source["name"])) . '' - ) - ]; - } else { - $badges[] = [ - "id" => "facet", - "color" => "light", - "html" => ( - $french - ? - 'Facette de ' . getMiniName($source["display_name"] ?? $source["name"]) . '' - : - 'Facet of ' . getMiniName($source["display_name"] ?? $source["name"]) . '' - ) - ]; - } - } - - return [ - 'id' => $member['name'], - 'color' => $member["color"] ?? "000000", - 'icon' => [ - "online" => getAsset($system, $member["id"]), - "offline" => "pf-$system-$id.webp" - ], - 'median' => $metadata["median"], - 'little' => $metadata["little"] >= 2, - 'name' => $member["display_name"] ?? $member["name"], - 'badges' => $badges, - 'prefixes' => $prefixes, - 'pronouns' => getTooltipsFromMark($member["pronouns"], $french) ?? "they/them", - 'pronouns_usage' => getMemberPronouns($member['pronouns']), - 'last_fronted' => $lastFronted, - 'species' => $speciesList, - 'system' => $systemData, - 'relations' => [ - 'marefriends' => $marefriends ?? [], - 'sexfriends' => $sexfriends ?? null, - 'sisters' => $sisters ?? [], - 'caretakers' => $caretakers ?? [] - ] - ]; -} \ No newline at end of file diff --git a/includes/bitset.inc b/includes/bitset.inc deleted file mode 100644 index 131cb39..0000000 --- a/includes/bitset.inc +++ /dev/null @@ -1,21 +0,0 @@ - 1990) { - $age = (int)date('Y') - $metadata["birth"]["year"] + (strtotime(date('Y') . "-" . $metadata["birth"]["date"]) <= time() ? 0 : -1); - } - - if ($age > 0 && $age <= 10) { - $metadata["little"] = 2; - } else if ($age > 0 && $age <= 15) { - $metadata["little"] = 3; - } - - return $metadata; -} \ No newline at end of file diff --git a/includes/cleanup.inc b/includes/cleanup.inc deleted file mode 100644 index 1d02081..0000000 --- a/includes/cleanup.inc +++ /dev/null @@ -1,45 +0,0 @@ - +
" style="grid-template-columns: repeat(4, 1fr); background-color: ; margin-left: -20px; margin-right: -20px;"> +
+
+ "" . $lang["details"]["food_states"][0] . "", + 1 => "" . $lang["details"]["food_states"][1] . "", + 2 => "" . $lang["details"]["food_states"][2] . "", + 3 => "" . $lang["details"]["food_states"][3] . "", + } ?> +
+
+
+ "" . $lang["details"]["memory_states"][0] . "", + 1 => "" . $lang["details"]["memory_states"][1] . "", + 2 => "" . $lang["details"]["memory_states"][2] . "", + } ?> +
+ +
+ Age:
+ 0): ?> + INF ?> + Eternal" ?> + + - + + " . $metadata["birth"]["age"] . "* years old" ?> + + Sliding " . explode("-", $metadata["birth"]["age"])[0] . " to " . explode("-", $metadata["birth"]["age"])[1] . "" ?> + + + + - + + + " . $age . " years old" ?> + + +
+ + +
+
+ + + + - + +
+
+ Primary interest:
+ + + + - + +
+ + +
+ + + +
; margin-left: -20px; margin-right: -20px;grid-template-columns: repeat(3, 1fr);"> + + = 16 && $metadata["little"] === 0) || (!isset($age) && $metadata["little"] === 0)) || $metadata["sexual_features"]): ?> + +
+ + Sexual consent:
+ + , however may ask to not have sex at the moment and such request must be honored." data-bs-toggle="tooltip">Preemptive + + ." data-bs-toggle="tooltip">Required + +
+ = 16 && $metadata["little"] === 0) || (!isset($age) && $metadata["little"] === 0))): ?> + + +
+ +
+ Sexual alignmentSex. algn.:
+ (poly) +
+ +
+ +
This member is too young to be in a sexual relationship.
+
+ +
+ Romantic alignmentRom. algn.:
+ (poly) +
+ +
+ Birthday:
+ + + + - + +
+ +
+ diff --git a/includes/components/emergency.inc b/includes/components/emergency.inc new file mode 100644 index 0000000..5490985 --- /dev/null +++ b/includes/components/emergency.inc @@ -0,0 +1,194 @@ +

Emergency alert +
+ + · +
+

+ +Turn ON + +

Sending next notification never

+ + + + + + + + \ No newline at end of file diff --git a/includes/components/footer.inc b/includes/components/footer.inc new file mode 100644 index 0000000..2cef58f --- /dev/null +++ b/includes/components/footer.inc @@ -0,0 +1,42 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/includes/components/fullbanner.inc b/includes/components/fullbanner.inc new file mode 100644 index 0000000..ddd59df --- /dev/null +++ b/includes/components/fullbanner.inc @@ -0,0 +1,28 @@ + + + +
+
+ +
+ +
+ + + + + +
+
+ . +
+
+ +
+
+ is on a trip to Equestria. . +
+
+ \ No newline at end of file diff --git a/includes/components/header.inc b/includes/components/header.inc new file mode 100644 index 0000000..7c4cfc8 --- /dev/null +++ b/includes/components/header.inc @@ -0,0 +1,220 @@ +"> +
+ Error ' . $errno . ': ' . $errstr . ' [' . $file . ':' . $line . '] +
'); + } +} + +if (isset($_GET['errors'])) { + ini_set('display_errors', '1'); + ini_set('display_startup_errors', '1'); + error_reporting(E_ALL); + set_error_handler("error", E_ALL); +} + +global $_MemberName; +global $_MemberPage; +global $_SystemName; +global $_SystemPage; +global $toplevel; + +$pages = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/pages.json"), true); +$page = $pages[$toplevel] ?? [ + "rail" => false +]; + +require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/util/travelling.inc"; global $travelling; +require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/util/score.inc"; +require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/util/pronouns.inc"; +require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/util/bitset.inc"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/banner.inc"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/rainbow.inc"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; + +?> + + + + + + + + + <?= $title && $title !== "-" ? $title . " · " : "" ?>Cold Haze + .png" type="image/png"> + + id="admin-page"> + + + +
+ + + + + + + + + diff --git a/includes/components/mobilenav.inc b/includes/components/mobilenav.inc new file mode 100644 index 0000000..646738c --- /dev/null +++ b/includes/components/mobilenav.inc @@ -0,0 +1,88 @@ + + + + + + + + \ No newline at end of file diff --git a/includes/components/navigation.inc b/includes/components/navigation.inc new file mode 100644 index 0000000..beb92bb --- /dev/null +++ b/includes/components/navigation.inc @@ -0,0 +1,424 @@ + true, + "name" => "Private utilities", + "icon" => "/assets/icons/admin.svg", + "invert" => true, + "items" => [ + "alerts" => [ + "name" => null, + "minimal" => true, + "items" => [ + [ + "name" => $pages["emergency"]["name"][$lang["_name"]], + "icon" => "/assets/icons/emergency.svg", + "invert" => false, + "link" => "/-/emergency", + "stepped" => "rgb(220,53,69)", + "private" => false + ], + [ + "name" => $pages["wakeup"]["name"][$lang["_name"]], + "icon" => "/assets/icons/wakeup.svg", + "invert" => false, + "link" => "/-/wakeup", + "stepped" => "rgb(13,202,240)", + "private" => false + ] + ] + ], + "apps" => [ + "name" => $lang["navigation"]["apps"], + "minimal" => false, + "items" => [ + [ + "name" => $pages["fronting"]["name"][$lang["_name"]], + "icon" => "/assets/icons/fronting.svg", + "invert" => true, + "link" => "/-/fronting", + "stepped" => null, + "private" => false + ], + [ + "name" => $pages["profiles"]["name"][$lang["_name"]], + "icon" => "/assets/icons/profiles.svg", + "invert" => true, + "link" => "/-/profiles", + "stepped" => null, + "private" => false + ], + [ + "name" => $pages["money"]["name"][$lang["_name"]], + "icon" => "/assets/icons/money.svg", + "invert" => true, + "link" => "/-/money", + "stepped" => null, + "private" => true + ], + [ + "name" => $pages["rules"]["name"][$lang["_name"]], + "icon" => "/assets/icons/rules.svg", + "invert" => true, + "link" => "/-/rules", + "stepped" => null, + "private" => true + ], + [ + "name" => $pages["docs"]["name"][$lang["_name"]], + "icon" => "/assets/icons/docs.svg", + "invert" => true, + "link" => "/-/docs", + "stepped" => null, + "private" => true + ], + [ + "name" => $pages["computers"]["name"][$lang["_name"]], + "icon" => "/assets/icons/computers.svg", + "invert" => true, + "link" => "/-/computers", + "stepped" => null, + "private" => true + ], + [ + "name" => $pages["travelling"]["name"][$lang["_name"]], + "icon" => "/assets/icons/travelling.svg", + "invert" => true, + "link" => "/-/travelling", + "stepped" => null, + "private" => false + ], + [ + "name" => $pages["stats"]["name"][$lang["_name"]], + "icon" => "/assets/icons/stats.svg", + "invert" => true, + "link" => "/-/stats", + "stepped" => null, + "private" => true + ], + [ + "name" => $pages["logout"]["name"][$lang["_name"]], + "icon" => "/assets/icons/logout.svg", + "invert" => true, + "link" => "/-/logout", + "stepped" => null, + "private" => false + ] + ] + ], + "sort" => [ + "name" => "Sorted members lists", + "minimal" => false, + "items" => [ + [ + "name" => $pages["splitting"]["name"][$lang["_name"]], + "icon" => "/assets/icons/splitting.svg", + "invert" => true, + "link" => "/-/splitting", + "stepped" => null, + "private" => false + ], + [ + "name" => $pages["byfront"]["name"][$lang["_name"]], + "icon" => "/assets/icons/byfront.svg", + "invert" => true, + "link" => "/-/byfront", + "stepped" => null, + "private" => false + ], + [ + "name" => $pages["alphabet"]["name"][$lang["_name"]], + "icon" => "/assets/icons/alphabet.svg", + "invert" => true, + "link" => "/-/alphabet", + "stepped" => null, + "private" => false + ], + [ + "name" => $pages["s:species"]["name"][$lang["_name"]], + "icon" => "/assets/icons/species.svg", + "invert" => true, + "link" => "/-/byspecies", + "stepped" => null, + "private" => false + ], + ] + ], + /*"debug" => [ + "name" => $lang["navigation"]["debug"], + "minimal" => false, + "items" => [ + [ + "name" => $pages["debug"]["name"][$lang["_name"]], + "icon" => "/assets/icons/debug.svg", + "invert" => true, + "link" => "/-/debug", + "stepped" => null + ], + [ + "name" => $pages["bitset"]["name"][$lang["_name"]], + "icon" => "/assets/icons/bitset.svg", + "invert" => true, + "link" => "/-/bitset", + "stepped" => null + ], + [ + "name" => $pages["score"]["name"][$lang["_name"]], + "icon" => "/assets/icons/score.svg", + "invert" => true, + "link" => "/-/score", + "stepped" => null + ], + [ + "name" => $pages["logout"]["name"][$lang["_name"]], + "icon" => "/assets/icons/logout.svg", + "invert" => true, + "link" => "/-/logout", + "stepped" => null + ] + ] + ]*/ + ] +]; +$navigation_global = [ + "admin" => false, + "name" => $lang["navigation"]["general"], + "icon" => "/assets/icons/global.svg", + "invert" => true, + "items" => [ + "main" => [ + "name" => null, + "minimal" => false, + "items" => [ + [ + "name" => $pages["home"]["name"][$lang["_name"]], + "icon" => "/assets/icons/home.svg", + "invert" => true, + "link" => "/", + "stepped" => null, + "private" => false + ], + [ + "name" => $pages["relations"]["name"][$lang["_name"]], + "icon" => "/assets/icons/relations.svg", + "invert" => true, + "link" => "/-/relations", + "stepped" => null, + "private" => false + ], + [ + "name" => $pages["terminology"]["name"][$lang["_name"]], + "icon" => "/assets/icons/terminology.svg", + "invert" => true, + "link" => "/-/terminology", + "stepped" => null, + "private" => false + ] + ] + ] + ] +]; +$navigation_cloudburst = [ + "admin" => false, + "name" => "Cloudburst System", + "icon" => getAsset("ynmuc"), + "invert" => false, + "items" => [ + "header" => [ + "name" => null, + "minimal" => false, + "items" => [ + [ + "name" => $lang["navigation"]["about"], + "icon" => "/assets/icons/about.svg", + "invert" => true, + "link" => "/cloudburst", + "stepped" => null, + "private" => false + ], + [ + "name" => $pages["s:history"]["name"][$lang["_name"]], + "icon" => "/assets/icons/history.svg", + "invert" => true, + "link" => "/cloudburst/-/history", + "stepped" => null, + "private" => false + ], + [ + "name" => $pages["s:compare"]["name"][$lang["_name"]], + "icon" => "/assets/icons/compare.svg", + "invert" => true, + "link" => "/cloudburst/-/compare", + "stepped" => null, + "private" => false + ] + ] + ], + "members" => [ + "name" => $lang["navigation"]["members"], + "minimal" => false, + "items" => array_map(function ($member) { + return [ + "name" => $member['display_name'] ?? $member['name'], + "icon" => getAsset($member["system"], $member["id"], "heads"), + "invert" => false, + "link" => "/$member[name]", + "stepped" => null, + "private" => false + ]; + }, array_filter(scoreOrder(withTravelers(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/members.json"), true), "ynmuc"), "ynmuc"), function ($member) { + return $member['name'] !== "unknown" && $member['name'] !== "fusion" && $member['name'] !== "new"; + })) + ] + ] +]; +$navigation_other = [ + "admin" => true, + "name" => $app["other"]["name"], + "icon" => getAsset($app["other"]["id"]), + "invert" => false, + "items" => [ + "header" => [ + "name" => null, + "minimal" => false, + "items" => [ + [ + "name" => $lang["navigation"]["about"], + "icon" => "/assets/icons/about.svg", + "invert" => true, + "link" => "/" . $app["other"]["slug"], + "stepped" => null, + "private" => false + ], + [ + "name" => $pages["s:history"]["name"][$lang["_name"]], + "icon" => "/assets/icons/history.svg", + "invert" => true, + "link" => "/" . $app["other"]["slug"] . "/-/history", + "stepped" => null, + "private" => false + ], + [ + "name" => $pages["s:compare"]["name"][$lang["_name"]], + "icon" => "/assets/icons/compare.svg", + "invert" => true, + "link" => "/" . $app["other"]["slug"] . "/-/compare", + "stepped" => null, + "private" => false + ] + ] + ], + "members" => [ + "name" => $lang["navigation"]["members"], + "minimal" => false, + "items" => array_map(function ($member) { + return [ + "name" => $member['display_name'] ?? $member['name'], + "icon" => getAsset($member["system"], $member["id"], "heads"), + "invert" => false, + "link" => "/$member[name]", + "stepped" => null, + "private" => false + ]; + }, array_filter(scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/other/members.json"), true), $app["other"]["id"]), function ($member) { + return $member['name'] !== "unknown" && $member['name'] !== "fusion" && $member['name'] !== "new"; + })) + ] + ] +]; +$navigation_raindrops = [ + "admin" => false, + "name" => "Raindrops System", + "icon" => getAsset("gdapd"), + "invert" => false, + "items" => [ + "header" => [ + "name" => null, + "minimal" => false, + "items" => [ + [ + "name" => $lang["navigation"]["about"], + "icon" => "/assets/icons/about.svg", + "invert" => true, + "link" => "/raindrops", + "stepped" => null, + "private" => false + ], + [ + "name" => $pages["s:history"]["name"][$lang["_name"]], + "icon" => "/assets/icons/history.svg", + "invert" => true, + "link" => "/raindrops/-/history", + "stepped" => null, + "private" => false + ], + [ + "name" => $pages["s:compare"]["name"][$lang["_name"]], + "icon" => "/assets/icons/compare.svg", + "invert" => true, + "link" => "/raindrops/-/compare", + "stepped" => null, + "private" => false + ] + ] + ], + "members" => [ + "name" => $lang["navigation"]["members"], + "minimal" => false, + "items" => array_map(function ($member) { + return [ + "name" => $member['display_name'] ?? $member['name'], + "icon" => getAsset($member["system"], $member["id"], "heads"), + "invert" => false, + "link" => "/$member[name]", + "stepped" => null, + "private" => false + ]; + }, array_filter(scoreOrder(withTravelers(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/members.json"), true), "gdapd"), "gdapd"), function ($member) { + return $member['name'] !== "unknown" && $member['name'] !== "fusion" && $member['name'] !== "new"; + })) + ] + ] +]; + +global $parts; + +if (isset($parts) && isset($parts[0]) && $parts[0] === $app["other"]["slug"]) { + $navigation = [ + "other" => $navigation_other, + "cloudburst" => $navigation_cloudburst, + "raindrops" => $navigation_raindrops, + "admin" => $navigation_admin, + "global" => $navigation_global + ]; +} elseif (isset($parts) && isset($parts[0]) && $parts[0] === "cloudburst") { + $navigation = [ + "cloudburst" => $navigation_cloudburst, + "raindrops" => $navigation_raindrops, + "other" => $navigation_other, + "admin" => $navigation_admin, + "global" => $navigation_global + ]; +} elseif (isset($parts) && isset($parts[0]) && $parts[0] === "raindrops") { + $navigation = [ + "raindrops" => $navigation_raindrops, + "cloudburst" => $navigation_cloudburst, + "other" => $navigation_other, + "admin" => $navigation_admin, + "global" => $navigation_global + ]; +} else { + $navigation = [ + "admin" => $navigation_admin, + "global" => $navigation_global, + "cloudburst" => $navigation_cloudburst, + "raindrops" => $navigation_raindrops, + "other" => $navigation_other, + ]; +} \ No newline at end of file diff --git a/includes/components/pane.inc b/includes/components/pane.inc new file mode 100644 index 0000000..28ccd71 --- /dev/null +++ b/includes/components/pane.inc @@ -0,0 +1,129 @@ + + + + + + + + + + + $item): if (!$item["admin"] || $isLoggedIn || $isLowerLoggedIn): ?> + +
+
+ " class="dropdown-icon" alt="" style=" border-radius: 2px;width:24px;vertical-align: middle;"> + +
+ + + + +
+ + + + \ No newline at end of file diff --git a/includes/components/planner.inc b/includes/components/planner.inc new file mode 100644 index 0000000..a7ec44f --- /dev/null +++ b/includes/components/planner.inc @@ -0,0 +1,1046 @@ +"; + } + + return ""; +} + +foreach ($cloudburst as $id => $day) { + foreach ($day as $index => $fronter) { + if (is_string($fronter)) { + $cloudburst[$id][$index] = [$fronter]; + } else if (is_array($fronter)) { + if (count($fronter) < 2) { + if (!isset($cloudburst[$id][$index][0])) $cloudburst[$id][$index][0] = null; + $cloudburst[$id][$index][1] = null; + } else if (count($fronter) > 2) { + $array = []; + + if (isset($cloudburst[$id][$index][0])) { + $array[0] = $cloudburst[$id][$index][0]; + } else { + $array[0] = null; + } + + if (isset($cloudburst[$id][$index][1])) { + $array[1] = $cloudburst[$id][$index][1]; + } else { + $array[1] = null; + } + + $cloudburst[$id][$index] = $array; + } + } + } +} + +foreach ($raindrops as $id => $day) { + foreach ($day as $index => $fronter) { + if (is_string($fronter)) { + $raindrops[$id][$index] = [$fronter]; + } else if (is_array($fronter)) { + if (count($fronter) < 2) { + if (!isset($raindrops[$id][$index][0])) $raindrops[$id][$index][0] = null; + $raindrops[$id][$index][1] = null; + } else if (count($fronter) > 2) { + $array = []; + + if (isset($raindrops[$id][$index][0])) { + $array[0] = $raindrops[$id][$index][0]; + } else { + $array[0] = null; + } + + if (isset($raindrops[$id][$index][1])) { + $array[1] = $raindrops[$id][$index][1]; + } else { + $array[1] = null; + } + + $raindrops[$id][$index] = $array; + } + } + } +} + +$school = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/school.json"), true); + +function formatTime($time) { + if ($time === "0:00") return "midnight"; + if ($time === "12:00") return "noon"; + + $parts = explode(":", $time); + $hours = (int)$parts[0]; + $ampm = ""; + + if ($hours === 0 || $hours === 12) { + $ampm = ($hours === 0 ? "am" : "pm"); + $hours = 12; + } else { + if ($hours > 12) { + $ampm = "pm"; + $hours = $hours - 12; + } else { + $ampm = "am"; + } + } + + if ((int)$parts[1] > 0) { + return $hours . ":" . $parts[1] . $ampm; + } else { + return $hours . $ampm; + } +} + +function school($time, $first = false) { + global $school; + global $_PROFILE; + global $isLowerLoggedIn; + + $day = date('Y-m-d', $time); + $parts = []; + + if (isset($school[$day])) { + if (isset($school[$day]["wakeUp"]["timestamp"])) { + $parts[] = "waking up at " . formatTime($school[$day]["wakeUp"][$_PROFILE["login"]]) . " (your time)"; + } + + if (isset($school[$day]["sleep"]["timestamp"])) { + $parts[] = "sleeping at " . formatTime($school[$day]["sleep"][$_PROFILE["login"]]) . " (your time)"; + } + } + + if ($isLowerLoggedIn) $parts = []; + + if (count($parts) > 0) { + if ($first) { + return ucfirst(implode(", ", $parts)); + } else { + return " · " . implode(", ", $parts); + } + } else { + if ($first) { + return "-"; + } else { + return ""; + } + } +} + +function day($display, $diff): void { if ($diff < 0) $disabled = true; else $disabled = false; global $cloudburst; global $raindrops; global $isLowerLoggedIn; ?> + + style="opacity: .75; pointer-events: none;"> + +
+ + + + style="opacity: .75; pointer-events: none;"> + Cloudburst System + Raindrops System + + + style="opacity: .75; pointer-events: none;"> + + + + + colspan="3" colspan="2"> + + + Multiple merged members + + Other/unknown/fallback pony + + " style="width:24px;"> + + + + + + + + + + + + + Multiple merged members + + Other/unknown/fallback pony + + " style="width:24px;"> + + + + + + + + + + + + + + + + + + colspan="3" colspan="2"> + + Multiple merged members + + Other/unknown/fallback pony + + " style="width:24px;"> + + + + + + + + + + + + + Multiple merged members + + Other/unknown/fallback pony + + " style="width:24px;"> + + + + + + + + + + + + + + + style="opacity: .75; pointer-events: none;"> + +
+ 0 && count($dayRaindrops) > 0): ?> + will sleep with + + + +
+ + + + + +

Front planner

+ + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/includes/components/search.inc b/includes/components/search.inc new file mode 100644 index 0000000..278ec41 --- /dev/null +++ b/includes/components/search.inc @@ -0,0 +1,534 @@ + + + + + + + + + + \ No newline at end of file diff --git a/includes/components/sysbanner.inc b/includes/components/sysbanner.inc new file mode 100644 index 0000000..8819617 --- /dev/null +++ b/includes/components/sysbanner.inc @@ -0,0 +1,96 @@ + + + + + \ No newline at end of file diff --git a/includes/components/wakeup.inc b/includes/components/wakeup.inc new file mode 100644 index 0000000..587e705 --- /dev/null +++ b/includes/components/wakeup.inc @@ -0,0 +1,114 @@ +

Wake-up alert +
+ + · +
+

+ +Turn ON + +

Sending next notification never

+ + + + + + \ No newline at end of file diff --git a/includes/details.inc b/includes/details.inc deleted file mode 100644 index 7f96884..0000000 --- a/includes/details.inc +++ /dev/null @@ -1,166 +0,0 @@ - -
" style="grid-template-columns: repeat(4, 1fr); background-color: ; margin-left: -20px; margin-right: -20px;"> -
-
- "" . $lang["details"]["food_states"][0] . "", - 1 => "" . $lang["details"]["food_states"][1] . "", - 2 => "" . $lang["details"]["food_states"][2] . "", - 3 => "" . $lang["details"]["food_states"][3] . "", - } ?> -
-
-
- "" . $lang["details"]["memory_states"][0] . "", - 1 => "" . $lang["details"]["memory_states"][1] . "", - 2 => "" . $lang["details"]["memory_states"][2] . "", - } ?> -
- - -
- Age:
- 0): ?> - INF ?> - Eternal" ?> - - - - - " . $metadata["birth"]["age"] . "* years old" ?> - - Sliding " . explode("-", $metadata["birth"]["age"])[0] . " to " . explode("-", $metadata["birth"]["age"])[1] . "" ?> - - - - - - - - " . $age . " years old" ?> - - -
- -
-
- - - - - - -
-
- Primary interest:
- - - - - - -
- - -
- - - -
; margin-left: -20px; margin-right: -20px;grid-template-columns: repeat(3, 1fr);"> - - = 16 && $metadata["little"] === 0) || (!isset($age) && $metadata["little"] === 0)) || $metadata["sexual_features"]): ?> - -
- - Sexual consent:
- - , however may ask to not have sex at the moment and such request must be honored." data-bs-toggle="tooltip">Preemptive - - ." data-bs-toggle="tooltip">Required - -
- = 16 && $metadata["little"] === 0) || (!isset($age) && $metadata["little"] === 0))): ?> - - -
- -
- Sexual alignmentSex. algn.:
- (poly) -
- -
- -
This member is too young to be in a sexual relationship.
-
- -
- Romantic alignmentRom. algn.:
- (poly) -
- -
- Birthday:
- - - - - - -
- -
- diff --git a/includes/edit-private.inc b/includes/edit-private.inc deleted file mode 100644 index 69f50d8..0000000 --- a/includes/edit-private.inc +++ /dev/null @@ -1,142 +0,0 @@ - - -
-
- - -

- Saved · bytes · ">View page -

- - - - - - - - -
- - \ No newline at end of file diff --git a/includes/edit.inc b/includes/edit.inc deleted file mode 100644 index 61e9f29..0000000 --- a/includes/edit.inc +++ /dev/null @@ -1,142 +0,0 @@ - - -
-
- - -

- Saved · bytes · ">View page -

- - - - - - - - -
- - \ No newline at end of file diff --git a/includes/emergency.inc b/includes/emergency.inc deleted file mode 100644 index 5490985..0000000 --- a/includes/emergency.inc +++ /dev/null @@ -1,194 +0,0 @@ -

Emergency alert -
- - · -
-

- -Turn ON - -

Sending next notification never

- - - - - - - - \ No newline at end of file diff --git a/includes/exchange.txt b/includes/exchange.txt index 79156ae..07cccdc 100644 --- a/includes/exchange.txt +++ b/includes/exchange.txt @@ -1 +1 @@ -0.88 \ No newline at end of file +0.89 \ No newline at end of file diff --git a/includes/footer.inc b/includes/footer.inc deleted file mode 100644 index b2fb277..0000000 --- a/includes/footer.inc +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/includes/fragments/edit-private.inc b/includes/fragments/edit-private.inc new file mode 100644 index 0000000..998dfdd --- /dev/null +++ b/includes/fragments/edit-private.inc @@ -0,0 +1,142 @@ + + +
+
+ + +

+ Saved · bytes · ">View page +

+ + + + + + + + +
+ + \ No newline at end of file diff --git a/includes/fragments/edit.inc b/includes/fragments/edit.inc new file mode 100644 index 0000000..b5617f2 --- /dev/null +++ b/includes/fragments/edit.inc @@ -0,0 +1,142 @@ + + +
+
+ + +

+ Saved · bytes · ">View page +

+ + + + + + + + +
+ + \ No newline at end of file diff --git a/includes/fragments/member.inc b/includes/fragments/member.inc new file mode 100644 index 0000000..4eed308 --- /dev/null +++ b/includes/fragments/member.inc @@ -0,0 +1,150 @@ + + +
;position: fixed;background-image: url('');background-size: cover;background-position: center; top: 0;"> +
">
+
+ + + +
+
+
; padding-bottom: 0 !important;"> + + +
+ +
+
+

Hello there!

+

I'm currently not totally sure who I am (it's a thing that can happen with plurality), but I am using this pony as a temporary identity to stay calm and not panic while I figure out what is going on and who I am.

+

I can either be an existing headmate who cannot work out they are fronting (this can sometimes happen when one of us gets pushed out of front), multiple headmates blurring who cannot work out who we are, a new pony trying to figure out their identity (this can sometimes take a while), or some other plurality shenanigans.

+ In all cases, feel free to ask! +
+
+ +
+ +
+ + +
+ +
+ + + + "); ?> + + + +
+
+
+ +
+ +
+ +
+ + + (edit: metadata, pony town, page) + + (edit: metadata, pony town, public, private) + + +
+
    +
  • ID: (, )
  • +
  • Files: +
      +
    • ()
    • +
    • ()
    • +
    • ()
    • +
    +
  • +
  • Date added: (, )
  • +
  • Pronouns:
  • +
  • Pronouns usage:
      $usage) { + if (is_string($usage) && $type !== "color") { + echo("
    • " . $type . ": " . $usage . "
    • "); + } + } + + ?>
  • +
  • Color: ;display:inline-block;width:16px;height:16px;border-radius:5px;vertical-align: middle;filter: invert(1) hue-rotate(180deg);"> # +
  • Bitset: (0x, )
  • Not using bitset; please update. +
  • Reduced name:
  • +
  • Shared memory access: ()
  • +
  • Protector: ()
  • +
  • Little: ()
  • +
  • Relations count:
  • + +
  • + Score breakdown: - +
    • -
  • +
+
+
+ +
+ + \ No newline at end of file diff --git a/includes/fragments/metadata.inc b/includes/fragments/metadata.inc new file mode 100644 index 0000000..e143153 --- /dev/null +++ b/includes/fragments/metadata.inc @@ -0,0 +1,169 @@ + + +
+
+

">

+ +
+ +

+ File
+ +

+ +
+ +

General information

+ +
+ General:
+
+ + +
+
+
+ Species
+
+ + +
+
+
+ Alignment
+
+ + +
+
+ +
+ +

Relationships

+ + +

+ Sexfriends (full IDs, comma-separated)
+ "> +

+ +

+ Marefriends (full IDs, comma-separated)
+ "> +

+

+ Sisters (full IDs, comma-separated)
+ "> +

+

+ Caretakers (full IDs, comma-separated)
+ "> +

+ + +
+ +

Technical details

+ +

+ Primary interest (keep it short)
+ "> +

+

+ Member code
+ "> +

+ + +
+ +

Age information

+ +

+ Birth date (use January 1st for none)
+ -"> +

+

+ Age (for ponies with fixed age)
+ "> +

+ +
+ +

Toggleable flags

+ + $name): if (!is_array($name) && !is_null($name)): if (($systemID === $app["other"]["id"] && str_starts_with($name, "!!")) || $systemID !== $app["other"]["id"]): ?> +
+ $name2): ?> +
+ + +
+ + +
+ +
+ This member does not have a metadata file. This file needs to be initially created by an administrator before it can be edited using this page. +
+ +
+ + \ No newline at end of file diff --git a/includes/fragments/sysedit.inc b/includes/fragments/sysedit.inc new file mode 100644 index 0000000..1b341b0 --- /dev/null +++ b/includes/fragments/sysedit.inc @@ -0,0 +1,153 @@ + + +
');background-size: cover;background-position: center; top: 0;"> +
+
+ +
+
+
+ +
+ +
+ +

+ Saved · bytes +

+ + + + + + + + +
+
+ +
+ + \ No newline at end of file diff --git a/includes/fragments/system.inc b/includes/fragments/system.inc new file mode 100644 index 0000000..030c743 --- /dev/null +++ b/includes/fragments/system.inc @@ -0,0 +1,52 @@ + + +
');background-size: cover;background-position: center; top: 0;"> +
+
+ + + +
+
+ +
+ +
+ +
+ +
+ +
+
+ +
+
+ + (edit: ) + +
+ + + + \ No newline at end of file diff --git a/includes/fullbanner.inc b/includes/fullbanner.inc deleted file mode 100644 index 4f78101..0000000 --- a/includes/fullbanner.inc +++ /dev/null @@ -1,28 +0,0 @@ - - - -
-
- -
- -
- - - - - -
-
- . -
-
- -
-
- is on a trip to Equestria. . -
-
- \ No newline at end of file diff --git a/includes/functions.inc b/includes/functions.inc deleted file mode 100644 index e9024d1..0000000 --- a/includes/functions.inc +++ /dev/null @@ -1,551 +0,0 @@ - $g) { - $h += 360; - } - break; - - case $g: - $h = 60 * (($b - $r) / $d + 2); - break; - - case $b: - $h = 60 * (($r - $g) / $d + 4); - break; - } - } - - return array(round($h, 2), round($s, 2), round($l, 2)); - } -} - -if (!function_exists("imageCreateCorners")) { - function imageCreateCorners($sourceImageFile, $radius) { - # test source image - if (file_exists($sourceImageFile)) { - $res = is_array($info = getimagesize($sourceImageFile)); - } - else $res = false; - - # open image - if ($res) { - $w = $info[0]; - $h = $info[1]; - switch ($info['mime']) { - case 'image/jpeg': $src = imagecreatefromjpeg($sourceImageFile); - break; - case 'image/gif': $src = imagecreatefromgif($sourceImageFile); - break; - case 'image/png': $src = imagecreatefrompng($sourceImageFile); - break; - default: - $res = false; - } - } - - # create corners - if ($res) { - - $q = 10; # change this if you want - $radius *= $q; - - # find unique color - do { - $r = rand(0, 255); - $g = rand(0, 255); - $b = rand(0, 255); - } - while (imagecolorexact($src, $r, $g, $b) < 0); - - $nw = $w*$q; - $nh = $h*$q; - - $img = imagecreatetruecolor($nw, $nh); - $alphacolor = imagecolorallocatealpha($img, $r, $g, $b, 127); - imagealphablending($img, false); - imagesavealpha($img, true); - imagefilledrectangle($img, 0, 0, $nw, $nh, $alphacolor); - - imagefill($img, 0, 0, $alphacolor); - imagecopyresampled($img, $src, 0, 0, 0, 0, $nw, $nh, $w, $h); - - imagearc($img, $radius-1, $radius-1, $radius*2, $radius*2, 180, 270, $alphacolor); - imagefilltoborder($img, 0, 0, $alphacolor, $alphacolor); - imagearc($img, $nw-$radius, $radius-1, $radius*2, $radius*2, 270, 0, $alphacolor); - imagefilltoborder($img, $nw-1, 0, $alphacolor, $alphacolor); - imagearc($img, $radius-1, $nh-$radius, $radius*2, $radius*2, 90, 180, $alphacolor); - imagefilltoborder($img, 0, $nh-1, $alphacolor, $alphacolor); - imagearc($img, $nw-$radius, $nh-$radius, $radius*2, $radius*2, 0, 90, $alphacolor); - imagefilltoborder($img, $nw-1, $nh-1, $alphacolor, $alphacolor); - imagealphablending($img, true); - imagecolortransparent($img, $alphacolor); - - # resize image down - $dest = imagecreatetruecolor($w, $h); - imagealphablending($dest, false); - imagesavealpha($dest, true); - imagefilledrectangle($dest, 0, 0, $w, $h, $alphacolor); - imagecopyresampled($dest, $img, 0, 0, 0, 0, $w, $h, $nw, $nh); - - # output image - $res = $dest; - imagedestroy($src); - imagedestroy($img); - } - - return $res; - } -} - -if (!function_exists("getMiniName")) { - function getMiniName(string $name) { - $parts = explode(" ", $name); - - if (strlen($parts[0]) > 3 && $parts[0] !== "Sweetie" && $parts[0] !== "Filly" && $parts[0] !== "Windy" && (isset($parts[1]) && $parts[1] !== "Brightdawn" && $parts[1] !== "Fizz")) { - if ($parts[0] === "Princess") { - array_shift($parts); - } - - if (str_contains($parts[0], "/")) { - return explode("/", $parts[0])[0]; - } else { - return $parts[0]; - } - } else { - return $name; - } - } -} - -if (!function_exists("withCaretakersDown")) { - function withCaretakersDown(array $ordered): array { - return $ordered; - } -} - -if (!function_exists("getSystemMember")) { - function getSystemMember(string $system, string $id) { - $app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true); - $systemID = $system; - - $members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($systemID === $app["other"]["id"] ? "other" : $systemID) . "/members.json"), true); - $member = null; - - foreach ($members as $m) { - if ($m["id"] === $id) $member = $m; - } - - $member["system"] = $member["_system"] = $system; - - return $member; - } -} - -if (!function_exists("getMemberWithoutSystem")) { - function getMemberWithoutSystem(string $id) { - global $isLowerLoggedIn; global $isLoggedIn; - $member = null; - - $members1 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/members.json"), true); - foreach ($members1 as $m) { - $m["_system"] = "ynmuc"; - $m["system"] = "ynmuc"; - if ($m["id"] === $id) $member = $m; - } - - $members2 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/members.json"), true); - foreach ($members2 as $m) { - $m["_system"] = "gdapd"; - $m["system"] = "gdapd"; - if ($m["id"] === $id) $member = $m; - } - - if ($isLowerLoggedIn || $isLoggedIn) { - $app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true); - $members3 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/other/members.json"), true); - - foreach ($members3 as $m) { - $m["_system"] = $app["other"]["id"]; - $m["system"] = $app["other"]["id"]; - if ($m["id"] === $id) $member = $m; - } - } - - return $member; - } -} - -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']) . '
-
' . (isset($member['travelling']) && $member['travelling'] ? "+" . ($member['proxy_tags'][0]['prefix'] ?? " ") : ($member['proxy_tags'][0]['prefix'] ?? " ")) . '
-
'); - }} - } -} - -if (!function_exists("prettySize")) { - function prettySize($bytes) { - if ($bytes > 1024) { - if ($bytes > 1024**2) { - if ($bytes > 1024**3) { - return round($bytes / 1024**3, 1) . " GB"; - } else { - return round($bytes / 1024**2, 1) . " MB"; - } - } else { - return round($bytes / 1024, 1) . " KB"; - } - } else { - return $bytes . " B"; - } - } -} - -if (!function_exists("showSystem")) { - function showSystem(string $id, string $name, string $color, bool $hideTitle) { - $app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true); - global $travelling; - - $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('
'); - } else { - echo('
'); - } - if (!$hideTitle) echo(' -

' . $name . '
-
'); - - if ($hideTitle) { - echo('
'); - } else { - echo('
'); - } - - if ($id === $app["other"]["id"]) { - showMembersFromList(scoreOrder([...array_map(function ($i) use ($id, $travelling) { - $i["travelling"] = false; - $i["system"] = $id; - $i["equestria"] = false; - return $i; - }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . (isset($app["other"]) && $id === $app["other"]["id"] ? "other" : $id) . "/members.json"), true))], $id)); - } else { - showMembersFromList(scoreOrder([...array_map(function ($i) use ($id, $travelling) { - $i["travelling"] = false; - $i["system"] = $id; - $i["equestria"] = $travelling[$i['id']]['travelling'] && $travelling[$i['id']]['equestria']; - return $i; - }, array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . (isset($app["other"]) && $id === $app["other"]["id"] ? "other" : $id) . "/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'])); - })), ...array_map(function ($i) use ($id) { - $i["travelling"] = true; - $i["system"] = ($id === "gdapd" ? "ynmuc" : "gdapd"); - return $i; - }, array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($id === "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']); - }))], $id)); - } - - echo('
- -
'); - } -} - -if (!function_exists("cloudburst")) { - function cloudburst(bool $hideTitle): void { - showSystem("ynmuc", "Cloudburst System", "#5f08a9a6", $hideTitle); - } -} - - -if (!function_exists("raindrops")) { - function raindrops(bool $hideTitle): void { - showSystem("gdapd", "Raindrops System", "#a95f08a6", $hideTitle); - } -} - -if (!function_exists("other")) { - function other(bool $hideTitle): void { - $app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true); - showSystem($app["other"]["id"], $app["other"]["name"], "#" . $app["other"]["color"] . "a6", $hideTitle); - } -} - -if (!function_exists("getMember")) { - function getMember(string $id) { - global $systemID; - - $members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/members.json"), true); - $member = null; - - foreach ($members as $m) { - if ($m["id"] === $id) $member = $m; - } - - return $member; - } -} - -if (!function_exists("timeAgo")) { - function timeAgo($time, $french = false): string { - if (!is_numeric($time)) { - $time = strtotime($time); - } - - $periods = ["sec", "min", "hr", "d", "wk", "mo", "y", "ages"]; - $periods_fr = $periods; - $lengths = array("60", "60", "24", "7", "4.35", "12", "100"); - - $now = time(); - - $difference = $now - $time; - if ($difference <= 10 && $difference >= 0) { - return $tense = "now"; - } elseif ($difference > 0) { - $tense = "ago"; - } else { - $tense = "later"; - } - - for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) { - $difference /= $lengths[$j]; - } - - $difference = round($difference); - - $period = $periods[$j]; - return "{$difference} {$period} {$tense}"; - } -} - -if (!function_exists("timeIn")) { - function timeIn($time): string { - if (!is_numeric($time)) { - $time = strtotime($time); - } - - $periods = ["second", "minute", "hour", "day", "week", "month", "year", "age"]; - $lengths = array("60", "60", "24", "7", "4.35", "12", "100"); - - $now = time(); - - $difference = $time - $now; - if ($difference <= 10 && $difference >= 0) { - return $tense = "now"; - } elseif ($difference > 0) { - $tense = "in"; - } else { - $tense = "ago"; - } - - for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) { - $difference /= $lengths[$j]; - } - - $difference = round($difference); - - $period = $periods[$j] . ($difference >1 ? "s" :''); - return "{$tense} {$difference} {$period}"; - } -} - -if (!function_exists("duration")) { - function duration($seconds) { - global $lang; global $pages; - - if ($seconds >= 60) { - if (floor($seconds / 60) >= 60) { - if (floor($seconds / 3600) >= 24) { - $days = floor($seconds / 86400); - - if ($lang["_french"]) { - return $days . " jour" . ($days > 1 ? "s" : ""); - } else { - return $days . " day" . ($days > 1 ? "s" : ""); - } - } else { - $hours = floor($seconds / 3600); - - if ($lang["_french"]) { - return $hours . " heure" . ($hours > 1 ? "s" : ""); - } else { - return $hours . " hour" . ($hours > 1 ? "s" : ""); - } - } - } else { - $minutes = floor($seconds / 60); - return $minutes . " minute" . ($minutes > 1 ? "s" : ""); - } - } else { - if ($lang["_french"]) { - return $seconds . " secondes"; - } else { - return $seconds . " seconds"; - } - } - } -} - -if (!function_exists("relativeDate")) { - function relativeDate($date, $showTime = true) { - if (!is_numeric($date)) $date = strtotime($date); - - if (!$showTime) { - if (date('Y-m-d', $date) === date('Y-m-d')) { - return "today"; - } elseif (date('Y-m-d', $date) === date('Y-m-d', time() + 86400)) { - return "tomorrow"; - } elseif ($date < time() + 518400) { - return date('l', $date); - } else { - return date('D j M', $date); - } - } else { - if (date('Y-m-d', $date) === date('Y-m-d')) { - return "today, " . date('H:i', $date) . ""; - } elseif (date('Y-m-d', $date) === date('Y-m-d', time() + 86400)) { - return "tomorrow, " . date('H:i', $date) . ""; - } elseif ($date < time() + 518400) { - return date('l', $date) . ", " . date('H:i', $date) . ""; - } else { - return date('D j M', $date) . ", " . date('H:i', $date) . ""; - } - } - } -} - -if (!function_exists("getMemberSystem")) { - function getMemberSystem(string $id) { - $list = scoreOrderGlobal(); - - foreach ($list as $item) { - if ($item["id"] === $id) return $item["_system"]; - } - } -} - -if (!function_exists("getMemberFromName")) { - function getMemberFromName(string $name) { - $list = [...json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/members.json"), true), ...json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/members.json"), true), ...json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/other/members.json"), true)]; - - foreach ($list as $item) { - if ($item["name"] === $name) return getMemberWithoutSystem($item["id"]); - } - } -} - -if (!function_exists("resolveMember")) { - function resolveMember(mixed $name) { - if (is_string($name)) { - if (str_ends_with($name, "-travelling")) { - return substr($name, 0, strlen($name) - 11); - } else { - return $name; - } - } else { - return $name; - } - } -} \ No newline at end of file diff --git a/includes/header.inc b/includes/header.inc deleted file mode 100644 index 02cb190..0000000 --- a/includes/header.inc +++ /dev/null @@ -1,231 +0,0 @@ -"> -
- Error ' . $errno . ': ' . $errstr . ' [' . $file . ':' . $line . '] -
'); - } -} - -if (isset($_GET['errors'])) { - ini_set('display_errors', '1'); - ini_set('display_startup_errors', '1'); - error_reporting(E_ALL); - set_error_handler("error", E_ALL); -} - -global $_MemberName; -global $_MemberPage; -global $_SystemName; -global $_SystemPage; -global $toplevel; - -$pages = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/pages.json"), true); -$page = $pages[$toplevel] ?? [ - "rail" => false -]; - -require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/travelling.inc"; global $travelling; -require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/score.inc"; -require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/pronouns.inc"; -require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/bitset.inc"; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/banner.inc"; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/rainbow.inc"; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.inc"; - -?> - - - - - - - - - <?= $title && $title !== "-" ? $title . " · " : "" ?>Cold Haze - .png" type="image/png"> - - id="admin-page"> - - - -
- - - - - -
- -
- - - -
- - - - - - - diff --git a/includes/homepage.inc b/includes/homepage.inc deleted file mode 100644 index 900d8f1..0000000 --- a/includes/homepage.inc +++ /dev/null @@ -1,36 +0,0 @@ - - -= $columns) { - $packs[] = $currentPack; - $currentPack = []; - } - - $currentPack[] = $member["color"]; -} - -if (count($currentPack) > 0) $packs[] = $currentPack; - -$newPacks = []; -foreach ($packs as $pack) { - usort($pack, function ($a, $b) { - $vra = hexdec(substr($a, 0, 2)); - $vga = hexdec(substr($a, 2, 2)); - $vba = hexdec(substr($a, 4, 2)); - - $hsla = rgbToHsl($vra, $vga, $vba); - $ra = $hsla[2] * $hsla[1]; - - $vrb = hexdec(substr($b, 0, 2)); - $vgb = hexdec(substr($b, 2, 2)); - $vbb = hexdec(substr($b, 4, 2)); - - $hslb = rgbToHsl($vrb, $vgb, $vbb); - $rb = $hslb[2] * $hslb[1]; - - return $rb < $ra; - }); - - while (count($pack) < $columns) $pack[] = "ffffff"; - - $newPacks[] = $pack; -} - -$img = imagecreatetruecolor($columns, $columns); -$factor = 64; - -for ($y = 0; $y < $columns; ++$y) { - for ($x = 0; $x < $columns; ++$x) { - if (isset($newPacks[$y][$x])) { - imagesetpixel($img, $x, $y, imagecolorallocate($img, hexdec(substr($newPacks[$y][$x], 0, 2)), hexdec(substr($newPacks[$y][$x], 2, 2)), hexdec(substr($newPacks[$y][$x], 4, 2)))); - } else { - imagesetpixel($img, $x, $y, imagecolorallocate($img, 255, 255, 255)); - } - } -} - -$img2 = imagecreatetruecolor($columns * $factor, $columns * $factor); -imagecopyresampled($img2, $img, 0, 0, 0, 0, $columns * $factor, $columns * $factor, $columns, $columns); - -imagepng($img2, "/tmp/image.png"); -$img3 = imageCreateCorners("/tmp/image.png", $columns * 10); -unlink("/tmp/image.png"); - -imagepng($img3, $_SERVER['DOCUMENT_ROOT'] . "/assets/logo/newlogo.png"); -imagepng($img3, "/tmp/ponieslogo1.png"); - -for ($x = 1; $x <= 120; $x++) { - imagefilter($img2, IMG_FILTER_GAUSSIAN_BLUR); -} - -imagefilter($img2, IMG_FILTER_BRIGHTNESS, -100); - -imagepng($img2, "/tmp/image.png"); -$img3 = imageCreateCorners("/tmp/image.png", $columns * 10); -unlink("/tmp/image.png"); - -imagepng($img3, $_SERVER['DOCUMENT_ROOT'] . "/assets/logo/newlogo-template.png"); -imagepng($img3, "/tmp/ponieslogo2.png"); - -// -------------------------- - -/*$columns = ceil(sqrt(count(array_filter(scoreOrderGlobal(), function ($i) { - return $i["_system"] === "gdapd"; -})))); -echo(" Using " . $columns . " columns\n"); - -$members = array_values(array_filter(scoreOrderGlobal(), function ($i) { - return $i["_system"] === "gdapd"; -})); - -usort($members, function ($a, $b) { - $vr = hexdec(substr($a["color"], 0, 2)); - $vg = hexdec(substr($a["color"], 2, 2)); - $vb = hexdec(substr($a["color"], 4, 2)); - - $hsl = rgbToHsl($vr, $vg, $vb); - if ($hsl[0] == 0) $hsl[0] = 360; - $ra = $hsl[0]; - - $vr = hexdec(substr($b["color"], 0, 2)); - $vg = hexdec(substr($b["color"], 2, 2)); - $vb = hexdec(substr($b["color"], 4, 2)); - - $hsl = rgbToHsl($vr, $vg, $vb); - if ($hsl[0] == 0) $hsl[0] = 360; - $rb = $hsl[0]; - - return $ra - $rb; -}); - -echo(" " . count($members) . " members\n"); - -$packs = []; -$currentPack = []; - -foreach ($members as $member) { - if (count($currentPack) >= $columns) { - $packs[] = $currentPack; - $currentPack = []; - } - - $currentPack[] = $member["color"]; -} - -if (count($currentPack) > 0) $packs[] = $currentPack; - -$newPacks = []; -foreach ($packs as $pack) { - usort($pack, function ($a, $b) { - $vra = hexdec(substr($a, 0, 2)); - $vga = hexdec(substr($a, 2, 2)); - $vba = hexdec(substr($a, 4, 2)); - - $hsla = rgbToHsl($vra, $vga, $vba); - $ra = $hsla[2] * $hsla[1]; - - $vrb = hexdec(substr($b, 0, 2)); - $vgb = hexdec(substr($b, 2, 2)); - $vbb = hexdec(substr($b, 4, 2)); - - $hslb = rgbToHsl($vrb, $vgb, $vbb); - $rb = $hslb[2] * $hslb[1]; - - return $rb < $ra; - }); - - while (count($pack) < $columns) $pack[] = "ffffff"; - - $newPacks[] = $pack; -} - -$img = imagecreatetruecolor($columns, $columns); -$factor = 64; - -for ($y = 0; $y < $columns; ++$y) { - for ($x = 0; $x < $columns; ++$x) { - if (isset($newPacks[$y][$x])) { - imagesetpixel($img, $x, $y, imagecolorallocate($img, hexdec(substr($newPacks[$y][$x], 0, 2)), hexdec(substr($newPacks[$y][$x], 2, 2)), hexdec(substr($newPacks[$y][$x], 4, 2)))); - } else { - imagesetpixel($img, $x, $y, imagecolorallocate($img, 255, 255, 255)); - } - } -} - -$img2 = imagecreatetruecolor($columns * $factor, $columns * $factor); -imagecopyresampled($img2, $img, 0, 0, 0, 0, $columns * $factor, $columns * $factor, $columns, $columns); - -imagepng($img2, "/tmp/image.png"); -$img3 = imageCreateCorners("/tmp/image.png", $columns * 10); -unlink("/tmp/image.png"); - -imagepng($img3, $_SERVER['DOCUMENT_ROOT'] . "/assets/logo/newlogo2.png"); -imagepng($img3, "/tmp/ponieslogo1a.png"); - -for ($x = 1; $x <= 120; $x++) { - imagefilter($img2, IMG_FILTER_GAUSSIAN_BLUR); -} - -imagefilter($img2, IMG_FILTER_BRIGHTNESS, -100); - -imagepng($img2, "/tmp/image.png"); -$img3 = imageCreateCorners("/tmp/image.png", $columns * 10); -unlink("/tmp/image.png"); - -imagepng($img3, $_SERVER['DOCUMENT_ROOT'] . "/assets/logo/newlogo2-template.png"); -imagepng($img3, "/tmp/ponieslogo2a.png");*/ - -// -------------------------- - -$isLoggedIn = true; -$isLowerLoggedIn = false; - -$columns = ceil(sqrt(count(array_filter(scoreOrderGlobal())))); -echo(" Using " . $columns . " columns\n"); - -$members = array_values(array_filter(scoreOrderGlobal())); - -usort($members, function ($a, $b) { - $vr = hexdec(substr($a["color"], 0, 2)); - $vg = hexdec(substr($a["color"], 2, 2)); - $vb = hexdec(substr($a["color"], 4, 2)); - - $hsl = rgbToHsl($vr, $vg, $vb); - if ($hsl[0] == 0) $hsl[0] = 360; - $ra = $hsl[0]; - - $vr = hexdec(substr($b["color"], 0, 2)); - $vg = hexdec(substr($b["color"], 2, 2)); - $vb = hexdec(substr($b["color"], 4, 2)); - - $hsl = rgbToHsl($vr, $vg, $vb); - if ($hsl[0] == 0) $hsl[0] = 360; - $rb = $hsl[0]; - - return $ra - $rb; -}); - -echo(" " . count($members) . " members\n"); - -$packs = []; -$currentPack = []; - -foreach ($members as $member) { - if (count($currentPack) >= $columns) { - $packs[] = $currentPack; - $currentPack = []; - } - - $currentPack[] = $member["color"]; -} - -if (count($currentPack) > 0) $packs[] = $currentPack; - -$newPacks = []; -foreach ($packs as $pack) { - usort($pack, function ($a, $b) { - $vra = hexdec(substr($a, 0, 2)); - $vga = hexdec(substr($a, 2, 2)); - $vba = hexdec(substr($a, 4, 2)); - - $hsla = rgbToHsl($vra, $vga, $vba); - $ra = $hsla[2] * $hsla[1]; - - $vrb = hexdec(substr($b, 0, 2)); - $vgb = hexdec(substr($b, 2, 2)); - $vbb = hexdec(substr($b, 4, 2)); - - $hslb = rgbToHsl($vrb, $vgb, $vbb); - $rb = $hslb[2] * $hslb[1]; - - return $rb < $ra; - }); - - while (count($pack) < $columns) $pack[] = "ffffff"; - - $newPacks[] = $pack; -} - -$img = imagecreatetruecolor($columns, $columns); -$factor = 64; - -for ($y = 0; $y < $columns; ++$y) { - for ($x = 0; $x < $columns; ++$x) { - if (isset($newPacks[$y][$x])) { - imagesetpixel($img, $x, $y, imagecolorallocate($img, hexdec(substr($newPacks[$y][$x], 0, 2)), hexdec(substr($newPacks[$y][$x], 2, 2)), hexdec(substr($newPacks[$y][$x], 4, 2)))); - } else { - imagesetpixel($img, $x, $y, imagecolorallocate($img, 255, 255, 255)); - } - } -} - -$img2 = imagecreatetruecolor($columns * $factor, $columns * $factor); -imagecopyresampled($img2, $img, 0, 0, 0, 0, $columns * $factor, $columns * $factor, $columns, $columns); - -imagepng($img2, "/tmp/image.png"); -$img3 = imageCreateCorners("/tmp/image.png", $columns * 10); -unlink("/tmp/image.png"); - -imagepng($img3, $_SERVER['DOCUMENT_ROOT'] . "/assets/logo/newlogo3.png"); -imagepng($img3, "/tmp/ponieslogo1b.png"); - -for ($x = 1; $x <= 120; $x++) { - imagefilter($img2, IMG_FILTER_GAUSSIAN_BLUR); -} - -imagefilter($img2, IMG_FILTER_BRIGHTNESS, -100); - -imagepng($img2, "/tmp/image.png"); -$img3 = imageCreateCorners("/tmp/image.png", $columns * 10); -unlink("/tmp/image.png"); - -imagepng($img3, $_SERVER['DOCUMENT_ROOT'] . "/assets/logo/newlogo3-template.png"); -imagepng($img3, "/tmp/ponieslogo2b.png"); \ No newline at end of file diff --git a/includes/member.inc b/includes/member.inc deleted file mode 100644 index b98d0f5..0000000 --- a/includes/member.inc +++ /dev/null @@ -1,150 +0,0 @@ - - -
;position: fixed;background-image: url('');background-size: cover;background-position: center; top: 0;"> -
">
-
- - - -
-
-
; padding-bottom: 0 !important;"> - - -
- -
-
-

Hello there!

-

I'm currently not totally sure who I am (it's a thing that can happen with plurality), but I am using this pony as a temporary identity to stay calm and not panic while I figure out what is going on and who I am.

-

I can either be an existing headmate who cannot work out they are fronting (this can sometimes happen when one of us gets pushed out of front), multiple headmates blurring who cannot work out who we are, a new pony trying to figure out their identity (this can sometimes take a while), or some other plurality shenanigans.

- In all cases, feel free to ask! -
-
- -
- -
- - -
- -
- - - - "); ?> - - - -
-
-
- -
- -
- -
- - - (edit: metadata, pony town, page) - - (edit: metadata, pony town, public, private) - - -
-
    -
  • ID: (, )
  • -
  • Files: -
      -
    • ()
    • -
    • ()
    • -
    • ()
    • -
    -
  • -
  • Date added: (, )
  • -
  • Pronouns:
  • -
  • Pronouns usage:
      $usage) { - if (is_string($usage) && $type !== "color") { - echo("
    • " . $type . ": " . $usage . "
    • "); - } - } - - ?>
  • -
  • Color: ;display:inline-block;width:16px;height:16px;border-radius:5px;vertical-align: middle;filter: invert(1) hue-rotate(180deg);"> # -
  • Bitset: (0x, )
  • Not using bitset; please update. -
  • Reduced name:
  • -
  • Shared memory access: ()
  • -
  • Protector: ()
  • -
  • Little: ()
  • -
  • Relations count:
  • - -
  • - Score breakdown: - -
    • -
  • -
-
-
- -
- - \ No newline at end of file diff --git a/includes/metadata.inc b/includes/metadata.inc deleted file mode 100644 index 485666a..0000000 --- a/includes/metadata.inc +++ /dev/null @@ -1,169 +0,0 @@ - - -
-
-

">

- -
- -

- File
- -

- -
- -

General information

- -
- General:
-
- - -
-
-
- Species
-
- - -
-
-
- Alignment
-
- - -
-
- -
- -

Relationships

- - -

- Sexfriends (full IDs, comma-separated)
- "> -

- -

- Marefriends (full IDs, comma-separated)
- "> -

-

- Sisters (full IDs, comma-separated)
- "> -

-

- Caretakers (full IDs, comma-separated)
- "> -

- - -
- -

Technical details

- -

- Primary interest (keep it short)
- "> -

-

- Member code
- "> -

- -
- -

Age information

- -

- Birth date (use January 1st for none)
- -"> -

-

- Age (for ponies with fixed age)
- "> -

- - -
- -

Toggleable flags

- - $name): if (!is_array($name) && !is_null($name)): if (($systemID === $app["other"]["id"] && str_starts_with($name, "!!")) || $systemID !== $app["other"]["id"]): ?> -
- $name2): ?> -
- - -
- - -
- -
- This member does not have a metadata file. This file needs to be initially created by an administrator before it can be edited using this page. -
- -
- - \ No newline at end of file diff --git a/includes/mobilenav.inc b/includes/mobilenav.inc deleted file mode 100644 index ed778ec..0000000 --- a/includes/mobilenav.inc +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/includes/navigation.inc b/includes/navigation.inc deleted file mode 100644 index 976cfff..0000000 --- a/includes/navigation.inc +++ /dev/null @@ -1,432 +0,0 @@ - true, - "name" => "Private utilities", - "icon" => "/assets/icons/admin.svg", - "invert" => true, - "items" => [ - "alerts" => [ - "name" => null, - "minimal" => true, - "items" => [ - [ - "name" => $pages["emergency"]["name"][$lang["_name"]], - "icon" => "/assets/icons/emergency.svg", - "invert" => false, - "link" => "/-/emergency", - "stepped" => "rgb(220,53,69)", - "private" => false - ], - [ - "name" => $pages["wakeup"]["name"][$lang["_name"]], - "icon" => "/assets/icons/wakeup.svg", - "invert" => false, - "link" => "/-/wakeup", - "stepped" => "rgb(13,202,240)", - "private" => false - ] - ] - ], - "apps" => [ - "name" => $lang["navigation"]["apps"], - "minimal" => false, - "items" => [ - [ - "name" => $pages["about"]["name"][$lang["_name"]], - "icon" => "/assets/icons/about.svg", - "invert" => true, - "link" => "/-/about", - "stepped" => null, - "private" => false - ], - [ - "name" => $pages["fronting"]["name"][$lang["_name"]], - "icon" => "/assets/icons/fronting.svg", - "invert" => true, - "link" => "/-/fronting", - "stepped" => null, - "private" => false - ], - [ - "name" => $pages["profiles"]["name"][$lang["_name"]], - "icon" => "/assets/icons/profiles.svg", - "invert" => true, - "link" => "/-/profiles", - "stepped" => null, - "private" => false - ], - [ - "name" => $pages["money"]["name"][$lang["_name"]], - "icon" => "/assets/icons/money.svg", - "invert" => true, - "link" => "/-/money", - "stepped" => null, - "private" => true - ], - [ - "name" => $pages["rules"]["name"][$lang["_name"]], - "icon" => "/assets/icons/rules.svg", - "invert" => true, - "link" => "/-/rules", - "stepped" => null, - "private" => true - ], - [ - "name" => $pages["docs"]["name"][$lang["_name"]], - "icon" => "/assets/icons/docs.svg", - "invert" => true, - "link" => "/-/docs", - "stepped" => null, - "private" => true - ], - [ - "name" => $pages["computers"]["name"][$lang["_name"]], - "icon" => "/assets/icons/computers.svg", - "invert" => true, - "link" => "/-/computers", - "stepped" => null, - "private" => true - ], - [ - "name" => $pages["travelling"]["name"][$lang["_name"]], - "icon" => "/assets/icons/travelling.svg", - "invert" => true, - "link" => "/-/travelling", - "stepped" => null, - "private" => false - ], - [ - "name" => $pages["stats"]["name"][$lang["_name"]], - "icon" => "/assets/icons/stats.svg", - "invert" => true, - "link" => "/-/stats", - "stepped" => null, - "private" => true - ], - [ - "name" => $pages["logout"]["name"][$lang["_name"]], - "icon" => "/assets/icons/logout.svg", - "invert" => true, - "link" => "/-/logout", - "stepped" => null, - "private" => false - ] - ] - ], - "sort" => [ - "name" => "Sorted members lists", - "minimal" => false, - "items" => [ - [ - "name" => $pages["splitting"]["name"][$lang["_name"]], - "icon" => "/assets/icons/splitting.svg", - "invert" => true, - "link" => "/-/splitting", - "stepped" => null, - "private" => false - ], - [ - "name" => $pages["byfront"]["name"][$lang["_name"]], - "icon" => "/assets/icons/byfront.svg", - "invert" => true, - "link" => "/-/byfront", - "stepped" => null, - "private" => false - ], - [ - "name" => $pages["alphabet"]["name"][$lang["_name"]], - "icon" => "/assets/icons/alphabet.svg", - "invert" => true, - "link" => "/-/alphabet", - "stepped" => null, - "private" => false - ], - [ - "name" => $pages["s:species"]["name"][$lang["_name"]], - "icon" => "/assets/icons/species.svg", - "invert" => true, - "link" => "/-/byspecies", - "stepped" => null, - "private" => false - ], - ] - ], - /*"debug" => [ - "name" => $lang["navigation"]["debug"], - "minimal" => false, - "items" => [ - [ - "name" => $pages["debug"]["name"][$lang["_name"]], - "icon" => "/assets/icons/debug.svg", - "invert" => true, - "link" => "/-/debug", - "stepped" => null - ], - [ - "name" => $pages["bitset"]["name"][$lang["_name"]], - "icon" => "/assets/icons/bitset.svg", - "invert" => true, - "link" => "/-/bitset", - "stepped" => null - ], - [ - "name" => $pages["score"]["name"][$lang["_name"]], - "icon" => "/assets/icons/score.svg", - "invert" => true, - "link" => "/-/score", - "stepped" => null - ], - [ - "name" => $pages["logout"]["name"][$lang["_name"]], - "icon" => "/assets/icons/logout.svg", - "invert" => true, - "link" => "/-/logout", - "stepped" => null - ] - ] - ]*/ - ] -]; -$navigation_global = [ - "admin" => false, - "name" => $lang["navigation"]["general"], - "icon" => "/assets/icons/global.svg", - "invert" => true, - "items" => [ - "main" => [ - "name" => null, - "minimal" => false, - "items" => [ - [ - "name" => $pages["home"]["name"][$lang["_name"]], - "icon" => "/assets/icons/home.svg", - "invert" => true, - "link" => "/", - "stepped" => null, - "private" => false - ], - [ - "name" => $pages["relations"]["name"][$lang["_name"]], - "icon" => "/assets/icons/relations.svg", - "invert" => true, - "link" => "/-/relations", - "stepped" => null, - "private" => false - ], - [ - "name" => $pages["terminology"]["name"][$lang["_name"]], - "icon" => "/assets/icons/terminology.svg", - "invert" => true, - "link" => "/-/terminology", - "stepped" => null, - "private" => false - ] - ] - ] - ] -]; -$navigation_cloudburst = [ - "admin" => $_SERVER['HTTP_HOST'] === "fr.equestria.horse", - "name" => "Cloudburst System", - "icon" => getAsset("ynmuc"), - "invert" => false, - "items" => [ - "header" => [ - "name" => null, - "minimal" => false, - "items" => [ - [ - "name" => $lang["navigation"]["about"], - "icon" => "/assets/icons/about.svg", - "invert" => true, - "link" => "/cloudburst", - "stepped" => null, - "private" => false - ], - [ - "name" => $pages["s:history"]["name"][$lang["_name"]], - "icon" => "/assets/icons/history.svg", - "invert" => true, - "link" => "/cloudburst/-/history", - "stepped" => null, - "private" => false - ], - [ - "name" => $pages["s:compare"]["name"][$lang["_name"]], - "icon" => "/assets/icons/compare.svg", - "invert" => true, - "link" => "/cloudburst/-/compare", - "stepped" => null, - "private" => false - ] - ] - ], - "members" => [ - "name" => $lang["navigation"]["members"], - "minimal" => false, - "items" => array_map(function ($member) { - return [ - "name" => $member['display_name'] ?? $member['name'], - "icon" => getAsset($member["system"], $member["id"], "heads"), - "invert" => false, - "link" => "/$member[name]", - "stepped" => null, - "private" => false - ]; - }, array_filter(scoreOrder(withTravelers(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/members.json"), true), "ynmuc"), "ynmuc"), function ($member) { - return $member['name'] !== "unknown" && $member['name'] !== "fusion" && $member['name'] !== "new"; - })) - ] - ] -]; -$navigation_other = [ - "admin" => true, - "name" => $app["other"]["name"], - "icon" => getAsset($app["other"]["id"]), - "invert" => false, - "items" => [ - "header" => [ - "name" => null, - "minimal" => false, - "items" => [ - [ - "name" => $lang["navigation"]["about"], - "icon" => "/assets/icons/about.svg", - "invert" => true, - "link" => "/" . $app["other"]["slug"], - "stepped" => null, - "private" => false - ], - [ - "name" => $pages["s:history"]["name"][$lang["_name"]], - "icon" => "/assets/icons/history.svg", - "invert" => true, - "link" => "/" . $app["other"]["slug"] . "/-/history", - "stepped" => null, - "private" => false - ], - [ - "name" => $pages["s:compare"]["name"][$lang["_name"]], - "icon" => "/assets/icons/compare.svg", - "invert" => true, - "link" => "/" . $app["other"]["slug"] . "/-/compare", - "stepped" => null, - "private" => false - ] - ] - ], - "members" => [ - "name" => $lang["navigation"]["members"], - "minimal" => false, - "items" => array_map(function ($member) { - return [ - "name" => $member['display_name'] ?? $member['name'], - "icon" => getAsset($member["system"], $member["id"], "heads"), - "invert" => false, - "link" => "/$member[name]", - "stepped" => null, - "private" => false - ]; - }, array_filter(scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/other/members.json"), true), $app["other"]["id"]), function ($member) { - return $member['name'] !== "unknown" && $member['name'] !== "fusion" && $member['name'] !== "new"; - })) - ] - ] -]; -$navigation_raindrops = [ - "admin" => false, - "name" => "Raindrops System", - "icon" => getAsset("gdapd"), - "invert" => false, - "items" => [ - "header" => [ - "name" => null, - "minimal" => false, - "items" => [ - [ - "name" => $lang["navigation"]["about"], - "icon" => "/assets/icons/about.svg", - "invert" => true, - "link" => "/raindrops", - "stepped" => null, - "private" => false - ], - [ - "name" => $pages["s:history"]["name"][$lang["_name"]], - "icon" => "/assets/icons/history.svg", - "invert" => true, - "link" => "/raindrops/-/history", - "stepped" => null, - "private" => false - ], - [ - "name" => $pages["s:compare"]["name"][$lang["_name"]], - "icon" => "/assets/icons/compare.svg", - "invert" => true, - "link" => "/raindrops/-/compare", - "stepped" => null, - "private" => false - ] - ] - ], - "members" => [ - "name" => $lang["navigation"]["members"], - "minimal" => false, - "items" => array_map(function ($member) { - return [ - "name" => $member['display_name'] ?? $member['name'], - "icon" => getAsset($member["system"], $member["id"], "heads"), - "invert" => false, - "link" => "/$member[name]", - "stepped" => null, - "private" => false - ]; - }, array_filter(scoreOrder(withTravelers(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/members.json"), true), "gdapd"), "gdapd"), function ($member) { - return $member['name'] !== "unknown" && $member['name'] !== "fusion" && $member['name'] !== "new"; - })) - ] - ] -]; - -global $parts; - -if (isset($parts) && isset($parts[0]) && $parts[0] === $app["other"]["slug"]) { - $navigation = [ - "other" => $navigation_other, - "cloudburst" => $navigation_cloudburst, - "raindrops" => $navigation_raindrops, - "admin" => $navigation_admin, - "global" => $navigation_global - ]; -} elseif (isset($parts) && isset($parts[0]) && $parts[0] === "cloudburst") { - $navigation = [ - "cloudburst" => $navigation_cloudburst, - "raindrops" => $navigation_raindrops, - "other" => $navigation_other, - "admin" => $navigation_admin, - "global" => $navigation_global - ]; -} elseif (isset($parts) && isset($parts[0]) && $parts[0] === "raindrops") { - $navigation = [ - "raindrops" => $navigation_raindrops, - "cloudburst" => $navigation_cloudburst, - "other" => $navigation_other, - "admin" => $navigation_admin, - "global" => $navigation_global - ]; -} else { - $navigation = [ - "admin" => $navigation_admin, - "global" => $navigation_global, - "cloudburst" => $navigation_cloudburst, - "raindrops" => $navigation_raindrops, - "other" => $navigation_other, - ]; -} \ No newline at end of file diff --git a/includes/pages.json b/includes/pages.json index 8e21cc9..f5e665f 100644 --- a/includes/pages.json +++ b/includes/pages.json @@ -206,7 +206,7 @@ }, "short": "Metadata", "admin": true, - "limited": false, + "limited": true, "rail": false }, "money": { diff --git a/includes/pane.inc b/includes/pane.inc deleted file mode 100644 index d135eac..0000000 --- a/includes/pane.inc +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - $item): if (!$item["admin"] || $isLoggedIn || $isLowerLoggedIn): ?> - -
-
- " class="dropdown-icon" alt="" style="width:24px;vertical-align: middle;"> - -
- - - - -
- - - - \ No newline at end of file diff --git a/includes/planner.inc b/includes/planner.inc deleted file mode 100644 index e553627..0000000 --- a/includes/planner.inc +++ /dev/null @@ -1,1046 +0,0 @@ -"; - } - - return ""; -} - -foreach ($cloudburst as $id => $day) { - foreach ($day as $index => $fronter) { - if (is_string($fronter)) { - $cloudburst[$id][$index] = [$fronter]; - } else if (is_array($fronter)) { - if (count($fronter) < 2) { - if (!isset($cloudburst[$id][$index][0])) $cloudburst[$id][$index][0] = null; - $cloudburst[$id][$index][1] = null; - } else if (count($fronter) > 2) { - $array = []; - - if (isset($cloudburst[$id][$index][0])) { - $array[0] = $cloudburst[$id][$index][0]; - } else { - $array[0] = null; - } - - if (isset($cloudburst[$id][$index][1])) { - $array[1] = $cloudburst[$id][$index][1]; - } else { - $array[1] = null; - } - - $cloudburst[$id][$index] = $array; - } - } - } -} - -foreach ($raindrops as $id => $day) { - foreach ($day as $index => $fronter) { - if (is_string($fronter)) { - $raindrops[$id][$index] = [$fronter]; - } else if (is_array($fronter)) { - if (count($fronter) < 2) { - if (!isset($raindrops[$id][$index][0])) $raindrops[$id][$index][0] = null; - $raindrops[$id][$index][1] = null; - } else if (count($fronter) > 2) { - $array = []; - - if (isset($raindrops[$id][$index][0])) { - $array[0] = $raindrops[$id][$index][0]; - } else { - $array[0] = null; - } - - if (isset($raindrops[$id][$index][1])) { - $array[1] = $raindrops[$id][$index][1]; - } else { - $array[1] = null; - } - - $raindrops[$id][$index] = $array; - } - } - } -} - -$school = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/school.json"), true); - -function formatTime($time) { - if ($time === "0:00") return "midnight"; - if ($time === "12:00") return "noon"; - - $parts = explode(":", $time); - $hours = (int)$parts[0]; - $ampm = ""; - - if ($hours === 0 || $hours === 12) { - $ampm = ($hours === 0 ? "am" : "pm"); - $hours = 12; - } else { - if ($hours > 12) { - $ampm = "pm"; - $hours = $hours - 12; - } else { - $ampm = "am"; - } - } - - if ((int)$parts[1] > 0) { - return $hours . ":" . $parts[1] . $ampm; - } else { - return $hours . $ampm; - } -} - -function school($time, $first = false) { - global $school; - global $_PROFILE; - global $isLowerLoggedIn; - - $day = date('Y-m-d', $time); - $parts = []; - - if (isset($school[$day])) { - if (isset($school[$day]["wakeUp"]["timestamp"])) { - $parts[] = "waking up at " . formatTime($school[$day]["wakeUp"][$_PROFILE["login"]]) . " (your time)"; - } - - if (isset($school[$day]["sleep"]["timestamp"])) { - $parts[] = "sleeping at " . formatTime($school[$day]["sleep"][$_PROFILE["login"]]) . " (your time)"; - } - } - - if ($isLowerLoggedIn) $parts = []; - - if (count($parts) > 0) { - if ($first) { - return ucfirst(implode(", ", $parts)); - } else { - return " · " . implode(", ", $parts); - } - } else { - if ($first) { - return "-"; - } else { - return ""; - } - } -} - -function day($display, $diff): void { if ($diff < 0) $disabled = true; else $disabled = false; global $cloudburst; global $raindrops; global $isLowerLoggedIn; ?> - - style="opacity: .75; pointer-events: none;"> - -
- - - - style="opacity: .75; pointer-events: none;"> - Cloudburst System - Raindrops System - - - style="opacity: .75; pointer-events: none;"> - - - - - colspan="3" colspan="2"> - - - Multiple merged members - - Other/unknown/fallback pony - - " style="width:24px;"> - - - - - - - - - - - - - Multiple merged members - - Other/unknown/fallback pony - - " style="width:24px;"> - - - - - - - - - - - - - - - - - - colspan="3" colspan="2"> - - Multiple merged members - - Other/unknown/fallback pony - - " style="width:24px;"> - - - - - - - - - - - - - Multiple merged members - - Other/unknown/fallback pony - - " style="width:24px;"> - - - - - - - - - - - - - - - style="opacity: .75; pointer-events: none;"> - -
- 0 && count($dayRaindrops) > 0): ?> - will sleep with - - - -
- - - - - -

Front planner

- - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/includes/profiles.inc b/includes/profiles.inc deleted file mode 100644 index 66274c7..0000000 --- a/includes/profiles.inc +++ /dev/null @@ -1,97 +0,0 @@ - 0) || isset($member["_metadata"]["birth"]["year"]) && $member["_metadata"]["birth"]["year"] > 1900) || ((isset($member["_metadata"]["birth"]["age"]) && $member["_metadata"]["birth"]["age"] === -1) && in_array("alicorn", $member["_metadata"]["species"])), - isset($member["_metadata"]["birth"]["date"]) && trim($member["_metadata"]["birth"]["date"]) !== "" && $member["_metadata"]["birth"]["date"] !== "01-01", - file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . ".html") && strlen(preg_replace("/[^a-zA-Z0-9]/m", "", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . ".html"))) > 200, - file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . "-private.html") && strlen(preg_replace("/[^a-zA-Z0-9]/m", "", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . "-private.html"))) > 200, - isset($member["banner"]), - file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $member["name"] . ".png"), - isset($member["color"]) - ]; - - $result = [ - "values" => $values, - "pages" => [], - "characters" => [], - "score" => (float)array_reduce($values, function ($a, $b) { - return $a + $b; - }), - "score2" => (float)array_reduce($values, function ($a, $b) { - return $a + $b; - }), - "actions" => [] - ]; - - if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . ".html") && strlen(preg_replace("/[^a-zA-Z0-9]/m", "", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . ".html"))) <= 200) { - $result["pages"][] = true; - $result["score"] += strlen(preg_replace("/[^a-zA-Z0-9]/m", "", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . ".html"))) / 201; - } else { - $result["pages"][] = false; - } - - if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . "-private.html") && strlen(preg_replace("/[^a-zA-Z0-9]/m", "", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . "-private.html"))) <= 200) { - $result["pages"][] = true; - $result["score"] += strlen(preg_replace("/[^a-zA-Z0-9]/m", "", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . "-private.html"))) / 201; - } else { - $result["pages"][] = false; - } - - if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . ".html")) { - $result["characters"][] = strlen(preg_replace("/[^a-zA-Z0-9]/m", "", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . ".html"))); - } else { - $result["characters"][] = -1; - } - - if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . "-private.html")) { - $result["characters"][] = strlen(preg_replace("/[^a-zA-Z0-9]/m", "", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . "-private.html"))); - } else { - $result["characters"][] = -1; - } - - if (!((isset($member["_metadata"]["birth"]["age"]) && $member["_metadata"]["birth"]["age"] > 0) || isset($member["_metadata"]["birth"]["year"]) && $member["_metadata"]["birth"]["year"] > 1900) && !(isset($member["_metadata"]["birth"]["age"]) && $member["_metadata"]["birth"]["age"] === -1) && in_array("alicorn", $member["_metadata"]["species"])) { - $result["score"] += 0.5; - } - - $result["progress"] = $result["score"] / 7; - $result["sortable"] = (int)($result["progress"] * 100000000000000); - - if (!$result["values"][5]) { - $result["actions"][] = "a Pony Town character"; - } - - if (!$result["values"][6]) { - $result["actions"][] = "a color"; - } - - if (!$result["values"][2]) { - if ($result["characters"][0] === -1) { - $result["actions"][] = "a public page"; - } else { - $result["actions"][] = (200 - $result["characters"][0]) . " characters to the public page"; - } - } - - if (!$result["values"][3]) { - if ($result["characters"][1] === -1) { - $result["actions"][] = "a private page"; - } else { - $result["actions"][] = (200 - $result["characters"][1]) . " characters to the private page"; - } - } - - if (!$result["values"][4]) { - $result["actions"][] = "a banner"; - } - - if (!$result["values"][0]) { - $result["actions"][] = "an age"; - } - - if (!$result["values"][1]) { - $result["actions"][] = "a birthdate"; - } - - return $result; -} \ No newline at end of file diff --git a/includes/pronouns.inc b/includes/pronouns.inc deleted file mode 100644 index 6ab2487..0000000 --- a/includes/pronouns.inc +++ /dev/null @@ -1,149 +0,0 @@ - [ - "gender" => "ponygender", - "gender:fr" => "poneygenre", - "object" => "pony", - "person" => "pony", - "possessive_det" => "pony's", - "possessive_pro" => "pony's", - "reflexive" => "ponyself", - "subjective" => "pony", - "third" => true, - "color" => "warning" - ], - "she" => [ - "gender" => "female", - "gender:fr" => "fille", - "object" => "her", - "person" => "girl", - "possessive_det" => "her", - "possessive_pro" => "hers", - "reflexive" => "herself", - "subjective" => "she", - "third" => true, - "color" => "success" - ], - "he" => [ - "gender" => "male", - "gender:fr" => "garçon", - "object" => "him", - "person" => "boy", - "possessive_det" => "his", - "possessive_pro" => "his", - "reflexive" => "himself", - "subjective" => "he", - "third" => true, - "color" => "info" - ], - "it" => [ - "gender" => "agender", - "gender:fr" => "agenre", - "object" => "it", - "person" => "person", - "possessive_det" => "its", - "possessive_pro" => "its", - "reflexive" => "itself", - "subjective" => "it", - "third" => true, - "color" => "light" - ], - "they" => [ - "gender" => "non binary", - "gender:fr" => "non binaire", - "object" => "them", - "person" => "person", - "possessive_det" => "their", - "possessive_pro" => "theirs", - "reflexive" => "themself", - "subjective" => "they", - "third" => false, - "color" => "primary" - ] -]; - -$pronounGetCount = 0; - -$possibilitiesPerSet = []; -foreach ($pronounsSets as $name => $set) { - if (!isset($possibilitiesPerSet[$name])) $possibilitiesPerSet[$name] = []; - $possibilitiesPerSet[$name][] = $name; - - foreach ($set as $category => $value) { - if (is_string($value)) $possibilitiesPerSet[$name][] = $value; - } -} - -function getSetFromValue(string $value) { - global $possibilitiesPerSet; - - foreach ($possibilitiesPerSet as $name => $set) { - if (in_array($value, $set)) { - return $name; - } - } - - return null; -} - -function getPronounsFromMark(?string $mark = null): array { - if (!isset($mark) || trim($mark) === "") { - return ["they"]; - } else { - $parts = array_unique(array_map(function ($i) { - return getSetFromValue($i); - }, explode("/", $mark))); - return $parts; - } -} - -function getMemberPronouns(?string $pronouns): ?array { - global $pronounsSets; - $list = getPronounsFromMark($pronouns); - return $pronounsSets[$list[array_rand($list)]] ?? $pronounsSets["she"]; -} - -function getGenderFromPronoun(string $pronoun, bool $french = false) { - global $pronounsSets; - $set = getPronounsFromMark($pronoun)[0]; - - if ($french) { - return ($pronounsSets[$set] ?? $pronounsSets["they"])["gender:fr"]; - } else { - return ($pronounsSets[$set] ?? $pronounsSets["they"])["gender"]; - } -} - -function pronounInFrench(string $pronoun): string { - return match ($pronoun) { - "she" => "elle", - "her" => "elle", - "he" => "il", - "him" => "lui", - "they" => "iel", - "them" => "iel", - "it" => "iel", - "its" => "iel", - "pony" => "poney", - "pony's" => "à poney", - "ponys" => "à poney", - default => $pronoun, - }; -} - -function getTooltipsFromMark(string $mark = null, bool $french = false): ?string { - if (!isset($mark)) { - return null; - } else { - if ($french) { - return implode("/", array_map(function ($i) { - return "" . pronounInFrench($i) . ""; - }, explode("/", $mark))); - } else { - return implode("/", array_map(function ($i) { - return "" . $i . ""; - }, explode("/", $mark))); - } - } -} \ No newline at end of file diff --git a/includes/rail.inc b/includes/rail.inc deleted file mode 100644 index e78815e..0000000 --- a/includes/rail.inc +++ /dev/null @@ -1,167 +0,0 @@ - - -
-
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
-
-
- -
-
- -
-
-
- - - - \ No newline at end of file diff --git a/includes/rainbow.inc b/includes/rainbow.inc deleted file mode 100644 index 01b234c..0000000 --- a/includes/rainbow.inc +++ /dev/null @@ -1,56 +0,0 @@ - $member - ]; - - if (isset($member["color"])) { - $data[$member["name"]]["rgb"] = [ - hexdec(substr($member["color"], 0, 2)), - hexdec(substr($member["color"], 2, 2)), - hexdec(substr($member["color"], 4, 2)) - ]; - $data[$member["name"]]["hsl"] = rgbToHsl( - $data[$member["name"]]["rgb"][0], - $data[$member["name"]]["rgb"][1], - $data[$member["name"]]["rgb"][2] - ); - } else { - $data[$member["name"]]["rgb"] = [255, 255, 255]; - $data[$member["name"]]["hsl"] = rgbToHsl(255, 255, 255); - } - } - - return $data; -} - -function getMembersByColor($hideCloudburst = false): array { - $members = rainbow($hideCloudburst); - uasort($members, function ($a, $b) { - return $a['hsl'][0] - $b['hsl'][0]; - }); - - $sorted = []; - foreach ($members as $data) { - $data["_data"]["hue"] = $data["hsl"][0]; - $sorted[] = $data["_data"]; - } - - return $sorted; -} \ No newline at end of file diff --git a/includes/random.inc b/includes/random.inc deleted file mode 100644 index b6e7905..0000000 --- a/includes/random.inc +++ /dev/null @@ -1,15 +0,0 @@ -= 3600) { - require_once "./backup.inc"; + require_once "./refresh/backup.inc"; file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/backup.txt", time()); echo("Backup completed\n"); } else { @@ -260,7 +260,7 @@ if (time() - $lastBackup >= 3600) { echo("Generating logo...\n"); $currentOpStart = microtime(true); -require_once "./logo.inc"; +require_once "./refresh/logo.inc"; $times["logo"] = microtime(true) - $currentOpStart; echo("Generated logo\n"); @@ -279,7 +279,7 @@ echo("Fetched school information\n"); echo("Downloading assets...\n"); $currentOpStart = microtime(true); -require_once "./assets.inc"; +require_once "./refresh/assets.inc"; $times["assets"] = microtime(true) - $currentOpStart; echo("Downloading assets\n"); diff --git a/includes/refresh/assets.inc b/includes/refresh/assets.inc new file mode 100644 index 0000000..b27840a --- /dev/null +++ b/includes/refresh/assets.inc @@ -0,0 +1,86 @@ + date('c'), + "files" => [] +]; + +foreach ($root as $file) { + if ($file === "backup.poniesbackup" || $file === "backup.ponieskey" || $file === "encrypted" || str_ends_with($file, ".poniesbackup")) continue; + echo(" /$file\n"); + + if (is_dir("data/$file")) { + foreach (array_filter(scandir("data/$file"), function ($i) { + return !str_starts_with($i, "."); + }) as $dirfile) { + if ($dirfile === "backup.poniesbackup" || $dirfile === "backup.ponieskey" || $dirfile === "encrypted" || str_ends_with($dirfile, ".poniesbackup")) continue; + + echo(" /$dirfile/$file\n"); + $files[] = [ + "dir" => $file, + "file" => $dirfile + ]; + } + } else { + echo(" /$file\n"); + $files[] = [ + "dir" => "", + "file" => $file + ]; + } +} + +echo(" Reading files...\n"); +foreach ($files as $file) { + echo(" /$file[dir]/$file[file]\n"); + $file["mime"] = mime_content_type("data/$file[dir]/$file[file]"); + $file["checksum"] = [ + sha1_file("data/$file[dir]/$file[file]"), + md5_file("data/$file[dir]/$file[file]") + ]; + $file["content"] = base64_encode(file_get_contents("data/$file[dir]/$file[file]")); + + $data["files"][] = $file; +} + +function pkcs7_pad($data, $size) { + $length = $size - strlen($data) % $size; + return $data . str_repeat(chr($length), $length); +} + +if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/backup.ponieskey")) { + echo(" Creating encryption key...\n"); + $key = openssl_random_pseudo_bytes(512); + $iv = openssl_random_pseudo_bytes(16); + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/backup.ponieskey", base64_encode(json_encode([ + "iv" => bin2hex($iv), + "key" => bin2hex($key) + ]))); +} else { + echo(" Reading encryption key...\n"); + $key_raw = json_decode(base64_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/backup.ponieskey")), true); + $key = hex2bin($key_raw["key"]); + $iv = hex2bin($key_raw["iv"]); +} + +echo(" Encrypting...\n"); +$payload = json_encode($data); +$encrypted = openssl_encrypt(pkcs7_pad($payload, 16), 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv); + +echo(" Writing backup...\n"); +file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/backup.poniesbackup", $encrypted); +@mkdir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/encrypted"); + +$id = str_replace(":", "-", date('c')); +copy($_SERVER['DOCUMENT_ROOT'] . "/includes/data/backup.poniesbackup", $_SERVER['DOCUMENT_ROOT'] . "/includes/data/encrypted/" . $id . ".poniesbackup"); + +echo(" Uploading to servers...\n"); + +echo(" zephyrheights... upload\n"); +exec("scp -P 2222 " . $_SERVER['DOCUMENT_ROOT'] . "/includes/data/encrypted/" . $id . ".poniesbackup root@zephyrheights.equestria.dev:/opt/ponies"); +echo(" zephyrheights... cleaning up\n"); +exec('ssh -p 2222 root@zephyrheights.equestria.dev bash -c "cd /opt/ponies; ls -tp | grep -v \'/$\' | tail -n +20 | xargs -I {} rm -- {}"'); + +if (file_exists("/opt/ponies")) { + echo(" bridlewood... copy\n"); + copy($_SERVER['DOCUMENT_ROOT'] . "/includes/data/encrypted/" . $id . ".poniesbackup", "/opt/ponies/" . $id . ".poniesbackup"); + echo(" bridlewood... cleaning up\n"); + exec('bash -c "cd /opt/ponies; ls -tp | grep -v \'/$\' | tail -n +20 | xargs -I {} rm -- {}"'); +} + +echo(" Cleaning up...\n"); +unlink($_SERVER['DOCUMENT_ROOT'] . "/includes/data/encrypted/" . $id . ".poniesbackup"); \ No newline at end of file diff --git a/includes/refresh/cleanup.inc b/includes/refresh/cleanup.inc new file mode 100644 index 0000000..39ec41a --- /dev/null +++ b/includes/refresh/cleanup.inc @@ -0,0 +1,24 @@ += $columns) { + $packs[] = $currentPack; + $currentPack = []; + } + + $currentPack[] = $member["color"]; +} + +if (count($currentPack) > 0) $packs[] = $currentPack; + +$newPacks = []; +foreach ($packs as $pack) { + usort($pack, function ($a, $b) { + $vra = hexdec(substr($a, 0, 2)); + $vga = hexdec(substr($a, 2, 2)); + $vba = hexdec(substr($a, 4, 2)); + + $hsla = rgbToHsl($vra, $vga, $vba); + $ra = $hsla[2] * $hsla[1]; + + $vrb = hexdec(substr($b, 0, 2)); + $vgb = hexdec(substr($b, 2, 2)); + $vbb = hexdec(substr($b, 4, 2)); + + $hslb = rgbToHsl($vrb, $vgb, $vbb); + $rb = $hslb[2] * $hslb[1]; + + return $rb < $ra; + }); + + while (count($pack) < $columns) $pack[] = "ffffff"; + + $newPacks[] = $pack; +} + +$img = imagecreatetruecolor($columns, $columns); +$factor = 64; + +for ($y = 0; $y < $columns; ++$y) { + for ($x = 0; $x < $columns; ++$x) { + if (isset($newPacks[$y][$x])) { + imagesetpixel($img, $x, $y, imagecolorallocate($img, hexdec(substr($newPacks[$y][$x], 0, 2)), hexdec(substr($newPacks[$y][$x], 2, 2)), hexdec(substr($newPacks[$y][$x], 4, 2)))); + } else { + imagesetpixel($img, $x, $y, imagecolorallocate($img, 255, 255, 255)); + } + } +} + +$img2 = imagecreatetruecolor($columns * $factor, $columns * $factor); +imagecopyresampled($img2, $img, 0, 0, 0, 0, $columns * $factor, $columns * $factor, $columns, $columns); + +imagepng($img2, "/tmp/image.png"); +$img3 = imageCreateCorners("/tmp/image.png", $columns * 10); +unlink("/tmp/image.png"); + +imagepng($img3, $_SERVER['DOCUMENT_ROOT'] . "/assets/logo/newlogo.png"); +imagepng($img3, "/tmp/ponieslogo1.png"); + +for ($x = 1; $x <= 120; $x++) { + imagefilter($img2, IMG_FILTER_GAUSSIAN_BLUR); +} + +imagefilter($img2, IMG_FILTER_BRIGHTNESS, -100); + +imagepng($img2, "/tmp/image.png"); +$img3 = imageCreateCorners("/tmp/image.png", $columns * 10); +unlink("/tmp/image.png"); + +imagepng($img3, $_SERVER['DOCUMENT_ROOT'] . "/assets/logo/newlogo-template.png"); +imagepng($img3, "/tmp/ponieslogo2.png"); + +// -------------------------- + +/*$columns = ceil(sqrt(count(array_filter(scoreOrderGlobal(), function ($i) { + return $i["_system"] === "gdapd"; +})))); +echo(" Using " . $columns . " columns\n"); + +$members = array_values(array_filter(scoreOrderGlobal(), function ($i) { + return $i["_system"] === "gdapd"; +})); + +usort($members, function ($a, $b) { + $vr = hexdec(substr($a["color"], 0, 2)); + $vg = hexdec(substr($a["color"], 2, 2)); + $vb = hexdec(substr($a["color"], 4, 2)); + + $hsl = rgbToHsl($vr, $vg, $vb); + if ($hsl[0] == 0) $hsl[0] = 360; + $ra = $hsl[0]; + + $vr = hexdec(substr($b["color"], 0, 2)); + $vg = hexdec(substr($b["color"], 2, 2)); + $vb = hexdec(substr($b["color"], 4, 2)); + + $hsl = rgbToHsl($vr, $vg, $vb); + if ($hsl[0] == 0) $hsl[0] = 360; + $rb = $hsl[0]; + + return $ra - $rb; +}); + +echo(" " . count($members) . " members\n"); + +$packs = []; +$currentPack = []; + +foreach ($members as $member) { + if (count($currentPack) >= $columns) { + $packs[] = $currentPack; + $currentPack = []; + } + + $currentPack[] = $member["color"]; +} + +if (count($currentPack) > 0) $packs[] = $currentPack; + +$newPacks = []; +foreach ($packs as $pack) { + usort($pack, function ($a, $b) { + $vra = hexdec(substr($a, 0, 2)); + $vga = hexdec(substr($a, 2, 2)); + $vba = hexdec(substr($a, 4, 2)); + + $hsla = rgbToHsl($vra, $vga, $vba); + $ra = $hsla[2] * $hsla[1]; + + $vrb = hexdec(substr($b, 0, 2)); + $vgb = hexdec(substr($b, 2, 2)); + $vbb = hexdec(substr($b, 4, 2)); + + $hslb = rgbToHsl($vrb, $vgb, $vbb); + $rb = $hslb[2] * $hslb[1]; + + return $rb < $ra; + }); + + while (count($pack) < $columns) $pack[] = "ffffff"; + + $newPacks[] = $pack; +} + +$img = imagecreatetruecolor($columns, $columns); +$factor = 64; + +for ($y = 0; $y < $columns; ++$y) { + for ($x = 0; $x < $columns; ++$x) { + if (isset($newPacks[$y][$x])) { + imagesetpixel($img, $x, $y, imagecolorallocate($img, hexdec(substr($newPacks[$y][$x], 0, 2)), hexdec(substr($newPacks[$y][$x], 2, 2)), hexdec(substr($newPacks[$y][$x], 4, 2)))); + } else { + imagesetpixel($img, $x, $y, imagecolorallocate($img, 255, 255, 255)); + } + } +} + +$img2 = imagecreatetruecolor($columns * $factor, $columns * $factor); +imagecopyresampled($img2, $img, 0, 0, 0, 0, $columns * $factor, $columns * $factor, $columns, $columns); + +imagepng($img2, "/tmp/image.png"); +$img3 = imageCreateCorners("/tmp/image.png", $columns * 10); +unlink("/tmp/image.png"); + +imagepng($img3, $_SERVER['DOCUMENT_ROOT'] . "/assets/logo/newlogo2.png"); +imagepng($img3, "/tmp/ponieslogo1a.png"); + +for ($x = 1; $x <= 120; $x++) { + imagefilter($img2, IMG_FILTER_GAUSSIAN_BLUR); +} + +imagefilter($img2, IMG_FILTER_BRIGHTNESS, -100); + +imagepng($img2, "/tmp/image.png"); +$img3 = imageCreateCorners("/tmp/image.png", $columns * 10); +unlink("/tmp/image.png"); + +imagepng($img3, $_SERVER['DOCUMENT_ROOT'] . "/assets/logo/newlogo2-template.png"); +imagepng($img3, "/tmp/ponieslogo2a.png");*/ + +// -------------------------- + +$isLoggedIn = true; +$isLowerLoggedIn = false; + +$columns = ceil(sqrt(count(array_filter(scoreOrderGlobal())))); +echo(" Using " . $columns . " columns\n"); + +$members = array_values(array_filter(scoreOrderGlobal())); + +usort($members, function ($a, $b) { + $vr = hexdec(substr($a["color"], 0, 2)); + $vg = hexdec(substr($a["color"], 2, 2)); + $vb = hexdec(substr($a["color"], 4, 2)); + + $hsl = rgbToHsl($vr, $vg, $vb); + if ($hsl[0] == 0) $hsl[0] = 360; + $ra = $hsl[0]; + + $vr = hexdec(substr($b["color"], 0, 2)); + $vg = hexdec(substr($b["color"], 2, 2)); + $vb = hexdec(substr($b["color"], 4, 2)); + + $hsl = rgbToHsl($vr, $vg, $vb); + if ($hsl[0] == 0) $hsl[0] = 360; + $rb = $hsl[0]; + + return $ra - $rb; +}); + +echo(" " . count($members) . " members\n"); + +$packs = []; +$currentPack = []; + +foreach ($members as $member) { + if (count($currentPack) >= $columns) { + $packs[] = $currentPack; + $currentPack = []; + } + + $currentPack[] = $member["color"]; +} + +if (count($currentPack) > 0) $packs[] = $currentPack; + +$newPacks = []; +foreach ($packs as $pack) { + usort($pack, function ($a, $b) { + $vra = hexdec(substr($a, 0, 2)); + $vga = hexdec(substr($a, 2, 2)); + $vba = hexdec(substr($a, 4, 2)); + + $hsla = rgbToHsl($vra, $vga, $vba); + $ra = $hsla[2] * $hsla[1]; + + $vrb = hexdec(substr($b, 0, 2)); + $vgb = hexdec(substr($b, 2, 2)); + $vbb = hexdec(substr($b, 4, 2)); + + $hslb = rgbToHsl($vrb, $vgb, $vbb); + $rb = $hslb[2] * $hslb[1]; + + return $rb < $ra; + }); + + while (count($pack) < $columns) $pack[] = "ffffff"; + + $newPacks[] = $pack; +} + +$img = imagecreatetruecolor($columns, $columns); +$factor = 64; + +for ($y = 0; $y < $columns; ++$y) { + for ($x = 0; $x < $columns; ++$x) { + if (isset($newPacks[$y][$x])) { + imagesetpixel($img, $x, $y, imagecolorallocate($img, hexdec(substr($newPacks[$y][$x], 0, 2)), hexdec(substr($newPacks[$y][$x], 2, 2)), hexdec(substr($newPacks[$y][$x], 4, 2)))); + } else { + imagesetpixel($img, $x, $y, imagecolorallocate($img, 255, 255, 255)); + } + } +} + +$img2 = imagecreatetruecolor($columns * $factor, $columns * $factor); +imagecopyresampled($img2, $img, 0, 0, 0, 0, $columns * $factor, $columns * $factor, $columns, $columns); + +imagepng($img2, "/tmp/image.png"); +$img3 = imageCreateCorners("/tmp/image.png", $columns * 10); +unlink("/tmp/image.png"); + +imagepng($img3, $_SERVER['DOCUMENT_ROOT'] . "/assets/logo/newlogo3.png"); +imagepng($img3, "/tmp/ponieslogo1b.png"); + +for ($x = 1; $x <= 120; $x++) { + imagefilter($img2, IMG_FILTER_GAUSSIAN_BLUR); +} + +imagefilter($img2, IMG_FILTER_BRIGHTNESS, -100); + +imagepng($img2, "/tmp/image.png"); +$img3 = imageCreateCorners("/tmp/image.png", $columns * 10); +unlink("/tmp/image.png"); + +imagepng($img3, $_SERVER['DOCUMENT_ROOT'] . "/assets/logo/newlogo3-template.png"); +imagepng($img3, "/tmp/ponieslogo2b.png"); \ No newline at end of file diff --git a/includes/score.inc b/includes/score.inc deleted file mode 100644 index 57c7a75..0000000 --- a/includes/score.inc +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/includes/session.inc b/includes/session.inc deleted file mode 100644 index b99cc81..0000000 --- a/includes/session.inc +++ /dev/null @@ -1,29 +0,0 @@ - "/raindrops", - "cb" => "/cloudburst", - "minty" => "/cloudydreams", - "twilight" => "/twi", - "luna" => "/princessluna", - "cloudy" => "/cloudydreams", - "zipp" => "/zippstorm", - "babs" => "/babsseed", - "frost" => "/frostcrystals", - "violet" => "/violetdawn" -]; - -foreach ($members as $member) { - for ($i = 1; $i < strlen($member["name"]); $i++) { - $part = substr($member["name"], 0, $i); - - if (in_array($part, array_keys($list))) { - $list[$part] = false; - } else { - $list[$part] = "/" . $member["name"]; - } - } - - foreach ($member["proxy_tags"] as $proxy) { - $system = $member["_system"] === "gdapd" ? "rd" : "cb"; - $list[$system . preg_replace("/[^a-z]/m", "", $proxy["prefix"])] = "/" . $member["name"]; - } - - $list[$member["id"]] = "/" . $member["name"]; - $list[$member["uuid"]] = "/" . $member["name"]; -} - -$list["minty"] = "/cloudydreams"; -$list["twilight"] = "/twi"; - -if (in_array($toplevel, array_keys($list)) && $list[$toplevel]) { - if ($toplevel !== "unknown") { - header("Location: " . $list[$toplevel]); - } else { - peh_error("Page not found: " . strip_tags($toplevel), 404); - } -} else { - peh_error("Page not found: " . strip_tags($toplevel), 404); -} \ No newline at end of file diff --git a/includes/sysbanner.inc b/includes/sysbanner.inc deleted file mode 100644 index 763c961..0000000 --- a/includes/sysbanner.inc +++ /dev/null @@ -1,96 +0,0 @@ - - - - - \ No newline at end of file diff --git a/includes/sysedit.inc b/includes/sysedit.inc deleted file mode 100644 index 22ec670..0000000 --- a/includes/sysedit.inc +++ /dev/null @@ -1,153 +0,0 @@ - - -
');background-size: cover;background-position: center; top: 0;"> -
-
- -
-
-
- -
- -
- -

- Saved · bytes -

- - - - - - - - -
-
- -
- - \ No newline at end of file diff --git a/includes/system.inc b/includes/system.inc deleted file mode 100644 index ae624f9..0000000 --- a/includes/system.inc +++ /dev/null @@ -1,52 +0,0 @@ - - -
');background-size: cover;background-position: center; top: 0;"> -
-
- - - -
-
- -
- -
- -
- -
- -
-
- -
-
- - (edit: ) - -
- - - - \ No newline at end of file diff --git a/includes/system/compare.inc b/includes/system/compare.inc index 768522f..7e683fa 100644 --- a/includes/system/compare.inc +++ b/includes/system/compare.inc @@ -1,4 +1,4 @@ -
- \ No newline at end of file + \ No newline at end of file diff --git a/includes/system/history.inc b/includes/system/history.inc index 199f0ba..281e62d 100644 --- a/includes/system/history.inc +++ b/includes/system/history.inc @@ -1,4 +1,4 @@ - @@ -159,4 +159,4 @@ document.getElementById("timezone").style.display = ""; - \ No newline at end of file + \ No newline at end of file diff --git a/includes/titlebar.inc b/includes/titlebar.inc deleted file mode 100644 index e941179..0000000 --- a/includes/titlebar.inc +++ /dev/null @@ -1,606 +0,0 @@ - - - "; -$part2 = null; -$part3 = null; - -if (isset($pages[$name])) { - if (($name === "docs" || $name === "toys" || $name === "actions" || $name === "computers") && isset($parts[2])) { - $part3 = "Dashboard"; - $part2 = "" . $pages[$name]['name'][$lang["_name"]] . ""; - - if ($name === "docs") { - $actionsProfile = "docs-item"; - $part1 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/docs/" . $parts[2] . ".json"), true)["name"]; - } elseif ($name === "computers") { - $part1 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/metadata/" . $parts[2] . ".json"), true)["host"]; - } else { - $actionsProfile = "$name-item"; - $list = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($name === "toys" ? "toys/toys" : "actions/actions") . ".json"), true); - $part1 = array_values(array_filter($list, function ($i) use ($parts) { - return $i["id"] === $parts[2]; - }))[0]["name"]; - } - } else { - if ($pages[$name]["admin"]) { - $part1 = $pages[$name]['name'][$lang["_name"]]; - $part2 = "Dashboard"; - } else { - $part1 = $pages[$name]['name'][$lang["_name"]]; - } - } -} elseif ($name === "cloudburst") { - if (isset($parts[2])) { - $part2 = "Cloudburst System"; - - $part1 = $pages["s:" . $parts[2]]['name'][$lang["_name"]] ?? $parts[2]; - } else { - $actionsProfile = "system"; - $part1 = "Cloudburst System"; - } -} elseif ($name === "raindrops") { - if (isset($parts[2])) { - $part2 = "Raindrops System"; - - $part1 = $pages["s:" . $parts[2]]['name'][$lang["_name"]] ?? $parts[2]; - } else { - $actionsProfile = "system"; - $part1 = "Raindrops System"; - } -} elseif ($name === $app["other"]["slug"]) { - if (isset($parts[2])) { - $part2 = "" . $app["other"]["name"] . ""; - - $part1 = $pages["s:" . $parts[2]]['name'][$lang["_name"]] ?? $parts[2]; - } else { - $actionsProfile = "system"; - $part1 = $app["other"]["name"]; - } -} else { - $member = getMemberFromName($name); - $actionsProfile = "member"; - - if ($member["_system"] === $app["other"]["id"]) { - $actionsProfile = "member-other"; - } - - if (isset($member)) { - $memberName = $member["display_name"] ?? $member["name"]; - $part1 = "$memberName"; - - if ($member["_system"] === "gdapd") { - $part2 = "Raindrops System"; - } elseif ($member["_system"] === "ynmuc") { - $part2 = "Cloudburst System"; - } else { - $part2 = "" . $app["other"]["name"] . ""; - } - } else { - $part1 = "$name"; - } -} - -if ($actionsProfile === "default") { - switch ($name) { - case "home": - $actionsProfile = "home"; - break; - - case "emergency": - case "wakeup": - case "pleasure": - $actionsProfile = "alert"; - break; - - case "fronting": - $actionsProfile = "planner"; - break; - - case "actions": - case "toys": - $actionsProfile = "actions-or-toys"; - break; - - case "docs": - $actionsProfile = "docs"; - break; - - case "edit": - case "edit-private": - if (count($parts) === 3) $actionsProfile = "editor-system"; - if (count($parts) > 3 && in_array($parts[3], $membersNames)) $actionsProfile = "editor-member"; - break; - - case "debug": - $actionsProfile = "debug"; - break; - - case "bitset": - $actionsProfile = "bitset"; - break; - - case "computers": - if (count($parts) === 3) $actionsProfile = "computers"; - if (count($parts) === 4) $actionsProfile = "computers-remote"; - break; - } -} - -echo(""); -if (isset($part3)) { - echo "$part3 > $part2 > $part1"; -} elseif (isset($part2)) { - echo "$part2 > $part1"; -} else { - echo "$part1"; -} -echo(""); -echo(""); - -$links = [ - "default" => [ - [ - "name" => $lang["titlebar"]["top"], - "link" => [ - "type" => "js", - "text" => "document.body.scrollTop = 0; document.documentElement.scrollTop = 0;" - ], - "icon" => "/assets/icons/up.svg", - "invert" => true - ] - ], - "computers" => [ - [ - "name" => "Remote control", - "link" => [ - "type" => "url", - "text" => "/-/computers/" . ($parts[2] ?? null) . "/control" - ], - "icon" => "/assets/icons/computers-remote.svg", - "invert" => true - ], - [ - "name" => $lang["titlebar"]["top"], - "link" => [ - "type" => "js", - "text" => "document.body.scrollTop = 0; document.documentElement.scrollTop = 0;" - ], - "icon" => "/assets/icons/up.svg", - "invert" => true - ] - ], - "computers-remote" => [ - [ - "name" => "Enable controlling", - "link" => [ - "type" => "js", - "text" => "enableControl();" - ], - "icon" => "/assets/icons/computers-on.svg", - "invert" => true - ], - [ - "name" => "Disable controlling", - "link" => [ - "type" => "js", - "text" => "disableControl();" - ], - "icon" => "/assets/icons/computers-off.svg", - "invert" => true - ], - [ - "name" => "Back to computer info", - "link" => [ - "type" => "url", - "text" => "/-/computers/" . ($parts[2] ?? null) - ], - "icon" => "/assets/icons/up.svg", - "invert" => true - ] - ], - "editor-member" => [ - [ - "name" => "View page", - "link" => [ - "type" => "url", - "text" => "/" . ($parts[3] ?? null) - ], - "icon" => "/assets/icons/view.svg", - "invert" => true - ], - [ - "name" => $lang["titlebar"]["top"], - "link" => [ - "type" => "js", - "text" => "document.body.scrollTop = 0; document.documentElement.scrollTop = 0;" - ], - "icon" => "/assets/icons/up.svg", - "invert" => true - ] - ], - "editor-system" => [ - [ - "name" => "View page", - "link" => [ - "type" => "url", - "text" => "/" . ($parts[2] ?? null) - ], - "icon" => "/assets/icons/view.svg", - "invert" => true - ], - [ - "name" => $lang["titlebar"]["top"], - "link" => [ - "type" => "js", - "text" => "document.body.scrollTop = 0; document.documentElement.scrollTop = 0;" - ], - "icon" => "/assets/icons/up.svg", - "invert" => true - ] - ], - "member" => [ - [ - "name" => $lang["titlebar"]["member"], - "link" => [ - "type" => "url", - "text" => "/$system" - ], - "icon" => "/assets/icons/parent.svg", - "invert" => true - ], - [ - "name" => $pages["edit-private"]["name"][$lang["_name"]], - "link" => [ - "type" => "url", - "text" => "/-/edit-private/$system/$name" - ], - "icon" => "/assets/icons/edit-private.svg", - "invert" => true, - "show" => $isLoggedIn - ], - [ - "name" => $pages["edit"]["name"][$lang["_name"]], - "link" => [ - "type" => "url", - "text" => "/-/edit/$system/$name" - ], - "icon" => "/assets/icons/edit.svg", - "invert" => true, - "show" => $isLoggedIn - ], - [ - "name" => $lang["titlebar"]["top"], - "link" => [ - "type" => "js", - "text" => "document.body.scrollTop = 0; document.documentElement.scrollTop = 0;" - ], - "icon" => "/assets/icons/up.svg", - "invert" => true - ] - ], - "member-other" => [ - [ - "name" => $lang["titlebar"]["member"], - "link" => [ - "type" => "url", - "text" => "/$system" - ], - "icon" => "/assets/icons/parent.svg", - "invert" => true - ], - [ - "name" => $pages["edit"]["name"][$lang["_name"]], - "link" => [ - "type" => "url", - "text" => "/-/edit/$system/$name" - ], - "icon" => "/assets/icons/edit.svg", - "invert" => true, - "show" => $isLoggedIn - ], - [ - "name" => $lang["titlebar"]["top"], - "link" => [ - "type" => "js", - "text" => "document.body.scrollTop = 0; document.documentElement.scrollTop = 0;" - ], - "icon" => "/assets/icons/up.svg", - "invert" => true - ] - ], - "home" => [ - [ - "name" => "Raindrops System", - "link" => [ - "type" => "url", - "text" => "/raindrops" - ], - "icon" => "/assets/avatars/7d9f543ef74240f69d0786c3f2983124.webp", - "invert" => false - ], - [ - "name" => $lang["titlebar"]["top"], - "link" => [ - "type" => "js", - "text" => "document.body.scrollTop = 0; document.documentElement.scrollTop = 0;" - ], - "icon" => "/assets/icons/up.svg", - "invert" => true - ] - ], - "planner" => [ - [ - "name" => "Add in the Cloudburst System", - "link" => [ - "type" => "js", - "text" => "document.getElementById('planner-add-link-cloudburst-0').click()" - ], - "icon" => "/assets/icons/add-cloudburst.svg", - "invert" => false - ], - [ - "name" => "Add in the Raindrops System", - "link" => [ - "type" => "js", - "text" => "document.getElementById('planner-add-link-raindrops-0').click()" - ], - "icon" => "/assets/icons/add-raindrops.svg", - "invert" => false - ] - ], - "actions-or-toys" => [ - [ - "name" => "Search", - "link" => [ - "type" => "js", - "text" => "document.body.scrollTop = 0; document.documentElement.scrollTop = 0; document.getElementById('search').focus();" - ], - "icon" => "/assets/icons/search.svg", - "invert" => true - ], - [ - "name" => "Add", - "link" => [ - "type" => "js", - "text" => "(new bootstrap.Modal(document.getElementById('creator'))).show(); setInterval(() => { document.getElementById('creator-title').focus(); }, 500);" - ], - "icon" => "/assets/icons/add.svg", - "invert" => true - ] - ], - "docs" => [ - [ - "name" => "Marked for deletion", - "link" => [ - "type" => "url", - "text" => "#deletable" - ], - "icon" => "/assets/icons/delete.svg", - "invert" => true - ], - [ - "name" => "Create new", - "link" => [ - "type" => "url", - "text" => "/-/docs/add" - ], - "icon" => "/assets/icons/add.svg", - "invert" => true - ], - [ - "name" => $lang["titlebar"]["top"], - "link" => [ - "type" => "js", - "text" => "document.body.scrollTop = 0; document.documentElement.scrollTop = 0;" - ], - "icon" => "/assets/icons/up.svg", - "invert" => true - ] - ], - "docs-item" => [ - [ - "name" => "Save", - "link" => [ - "type" => "js", - "text" => "save();" - ], - "icon" => "/assets/icons/save.svg", - "invert" => true - ], - [ - "name" => $lang["titlebar"]["top"], - "link" => [ - "type" => "js", - "text" => "document.body.scrollTop = 0; document.documentElement.scrollTop = 0;" - ], - "icon" => "/assets/icons/up.svg", - "invert" => true - ] - ], - "debug" => [ - [ - "name" => $lang["titlebar"]["debug"][0], - "link" => [ - "type" => "url", - "text" => "#failures" - ], - "icon" => "/assets/icons/failures.svg", - "invert" => true - ], - [ - "name" => $lang["titlebar"]["debug"][1], - "link" => [ - "type" => "url", - "text" => "#times" - ], - "icon" => "/assets/icons/time.svg", - "invert" => true - ], - [ - "name" => $lang["titlebar"]["top"], - "link" => [ - "type" => "js", - "text" => "document.body.scrollTop = 0; document.documentElement.scrollTop = 0;" - ], - "icon" => "/assets/icons/up.svg", - "invert" => true - ] - ], - "bitset" => [ - [ - "name" => "Copy bitset", - "link" => [ - "type" => "js", - "text" => "navigator.clipboard.writeText(document.getElementById('input').value);" - ], - "icon" => "/assets/icons/copy.svg", - "invert" => true - ], - [ - "name" => "Reset", - "link" => [ - "type" => "js", - "text" => "document.getElementById('input').value = '2048'; calculateInput();" - ], - "icon" => "/assets/icons/reset.svg", - "invert" => true - ] - ], - "alert" => [ - [ - "name" => "Turn alert on", - "link" => [ - "type" => "js", - "text" => "if (document.getElementById('btn-on').style.display === 'block') (new bootstrap.Modal(document.getElementById('turn-on'))).show();" - ], - "icon" => "/assets/icons/alert-on.svg", - "invert" => true - ], - [ - "name" => "Turn alert off", - "link" => [ - "type" => "js", - "text" => "if (document.getElementById('btn-off').style.display === 'block') (new bootstrap.Modal(document.getElementById('turn-off'))).show();" - ], - "icon" => "/assets/icons/alert-off.svg", - "invert" => true - ] - ], - "system" => [ - [ - "name" => $pages["s:history"]["name"][$lang["_name"]], - "link" => [ - "type" => "url", - "text" => "/$name/-/history" - ], - "icon" => "/assets/icons/history.svg", - "invert" => true - ], - [ - "name" => $pages["s:compare"]["name"][$lang["_name"]], - "link" => [ - "type" => "url", - "text" => "/$name/-/compare" - ], - "icon" => "/assets/icons/compare.svg", - "invert" => true - ], - [ - "name" => $pages["edit"]["name"][$lang["_name"]], - "link" => [ - "type" => "url", - "text" => "/-/edit/$name" - ], - "icon" => "/assets/icons/edit.svg", - "invert" => true, - "show" => $isLoggedIn - ], - [ - "name" => $lang["titlebar"]["top"], - "link" => [ - "type" => "js", - "text" => "document.body.scrollTop = 0; document.documentElement.scrollTop = 0;" - ], - "icon" => "/assets/icons/up.svg", - "invert" => true - ] - ] -]; - -if ($_SERVER['HTTP_HOST'] !== "fr.equestria.horse") { - array_unshift($links["home"], [ - "name" => "Cloudburst System", - "link" => [ - "type" => "url", - "text" => "/cloudburst" - ], - "icon" => "/assets/avatars/ade46823206b4b0cad3ccaae934a5f3b.webp", - "invert" => false - ]); -} - -if ($isLowerLoggedIn || $isLoggedIn) { - $links["home"][] = [ - "name" => $app["other"]["name"], - "link" => [ - "type" => "url", - "text" => "/" . $app["other"]["slug"] - ], - "icon" => "/assets/avatars/" . str_replace("-", "", $app["other"]["uuid"]) . ".webp", - "invert" => false - ]; - - $links["home"] = [ - array_values(array_filter($links["home"], function ($i) { return $i["name"] === "Cloudburst System"; }))[0], - array_values(array_filter($links["home"], function ($i) { return $i["name"] === "Raindrops System"; }))[0], - array_values(array_filter($links["home"], function ($i) use ($app) { return $i["name"] === $app["other"]["name"]; }))[0], - array_values(array_filter($links["home"], function ($i) { return $i["link"]["type"] === "js"; }))[0] - ]; -} - -$linksList = $links[isset($links[$actionsProfile]) ? $actionsProfile : "default"]; - -?> - - $link): if (!(isset($link["show"]) && !$link["show"])): ?>hrefonclick="" title="" data-bs-toggle="tooltip" class="title-bar-action tooltip-nohelp">" class="dropdown-icon" alt="" style="width:24px;vertical-align: middle;"> - - - - \ No newline at end of file diff --git a/includes/travelling.inc b/includes/travelling.inc deleted file mode 100644 index 0d1696a..0000000 --- a/includes/travelling.inc +++ /dev/null @@ -1,62 +0,0 @@ - false, - "history" => [] - ]; - - @file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling/travelling.json", utf8_encode(json_encode($travelling, JSON_PRETTY_PRINT))); - } - - if (!isset($travelling[$member["id"]]["equestria"])) { - $travelling[$member["id"]]["equestria"] = false; - } -} - -function withTravelers(array $members, string $system): array { - global $travelling; - 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/includes/util/Parsedown.php b/includes/util/Parsedown.php new file mode 100644 index 0000000..3e29589 --- /dev/null +++ b/includes/util/Parsedown.php @@ -0,0 +1,1994 @@ +textElements($text); + + # convert to markup + $markup = $this->elements($Elements); + + # trim line breaks + $markup = trim($markup, "\n"); + + return $markup; + } + + protected function textElements($text) + { + # make sure no definitions are set + $this->DefinitionData = array(); + + # standardize line breaks + $text = str_replace(array("\r\n", "\r"), "\n", $text); + + # remove surrounding line breaks + $text = trim($text, "\n"); + + # split text into lines + $lines = explode("\n", $text); + + # iterate through lines to identify blocks + return $this->linesElements($lines); + } + + # + # Setters + # + + function setBreaksEnabled($breaksEnabled) + { + $this->breaksEnabled = $breaksEnabled; + + return $this; + } + + protected $breaksEnabled; + + function setMarkupEscaped($markupEscaped) + { + $this->markupEscaped = $markupEscaped; + + return $this; + } + + protected $markupEscaped; + + function setUrlsLinked($urlsLinked) + { + $this->urlsLinked = $urlsLinked; + + return $this; + } + + protected $urlsLinked = true; + + function setSafeMode($safeMode) + { + $this->safeMode = (bool) $safeMode; + + return $this; + } + + protected $safeMode; + + function setStrictMode($strictMode) + { + $this->strictMode = (bool) $strictMode; + + return $this; + } + + protected $strictMode; + + protected $safeLinksWhitelist = array( + 'http://', + 'https://', + 'ftp://', + 'ftps://', + 'mailto:', + 'tel:', + 'data:image/png;base64,', + 'data:image/gif;base64,', + 'data:image/jpeg;base64,', + 'irc:', + 'ircs:', + 'git:', + 'ssh:', + 'news:', + 'steam:', + ); + + # + # Lines + # + + protected $BlockTypes = array( + '#' => array('Header'), + '*' => array('Rule', 'List'), + '+' => array('List'), + '-' => array('SetextHeader', 'Table', 'Rule', 'List'), + '0' => array('List'), + '1' => array('List'), + '2' => array('List'), + '3' => array('List'), + '4' => array('List'), + '5' => array('List'), + '6' => array('List'), + '7' => array('List'), + '8' => array('List'), + '9' => array('List'), + ':' => array('Table'), + '<' => array('Comment', 'Markup'), + '=' => array('SetextHeader'), + '>' => array('Quote'), + '[' => array('Reference'), + '_' => array('Rule'), + '`' => array('FencedCode'), + '|' => array('Table'), + '~' => array('FencedCode'), + ); + + # ~ + + protected $unmarkedBlockTypes = array( + 'Code', + ); + + # + # Blocks + # + + protected function lines(array $lines) + { + return $this->elements($this->linesElements($lines)); + } + + protected function linesElements(array $lines) + { + $Elements = array(); + $CurrentBlock = null; + + foreach ($lines as $line) + { + if (chop($line) === '') + { + if (isset($CurrentBlock)) + { + $CurrentBlock['interrupted'] = (isset($CurrentBlock['interrupted']) + ? $CurrentBlock['interrupted'] + 1 : 1 + ); + } + + continue; + } + + while (($beforeTab = strstr($line, "\t", true)) !== false) + { + $shortage = 4 - mb_strlen($beforeTab, 'utf-8') % 4; + + $line = $beforeTab + . str_repeat(' ', $shortage) + . substr($line, strlen($beforeTab) + 1) + ; + } + + $indent = strspn($line, ' '); + + $text = $indent > 0 ? substr($line, $indent) : $line; + + # ~ + + $Line = array('body' => $line, 'indent' => $indent, 'text' => $text); + + # ~ + + if (isset($CurrentBlock['continuable'])) + { + $methodName = 'block' . $CurrentBlock['type'] . 'Continue'; + $Block = $this->$methodName($Line, $CurrentBlock); + + if (isset($Block)) + { + $CurrentBlock = $Block; + + continue; + } + else + { + if ($this->isBlockCompletable($CurrentBlock['type'])) + { + $methodName = 'block' . $CurrentBlock['type'] . 'Complete'; + $CurrentBlock = $this->$methodName($CurrentBlock); + } + } + } + + # ~ + + $marker = $text[0]; + + # ~ + + $blockTypes = $this->unmarkedBlockTypes; + + if (isset($this->BlockTypes[$marker])) + { + foreach ($this->BlockTypes[$marker] as $blockType) + { + $blockTypes []= $blockType; + } + } + + # + # ~ + + foreach ($blockTypes as $blockType) + { + $Block = $this->{"block$blockType"}($Line, $CurrentBlock); + + if (isset($Block)) + { + $Block['type'] = $blockType; + + if ( ! isset($Block['identified'])) + { + if (isset($CurrentBlock)) + { + $Elements[] = $this->extractElement($CurrentBlock); + } + + $Block['identified'] = true; + } + + if ($this->isBlockContinuable($blockType)) + { + $Block['continuable'] = true; + } + + $CurrentBlock = $Block; + + continue 2; + } + } + + # ~ + + if (isset($CurrentBlock) and $CurrentBlock['type'] === 'Paragraph') + { + $Block = $this->paragraphContinue($Line, $CurrentBlock); + } + + if (isset($Block)) + { + $CurrentBlock = $Block; + } + else + { + if (isset($CurrentBlock)) + { + $Elements[] = $this->extractElement($CurrentBlock); + } + + $CurrentBlock = $this->paragraph($Line); + + $CurrentBlock['identified'] = true; + } + } + + # ~ + + if (isset($CurrentBlock['continuable']) and $this->isBlockCompletable($CurrentBlock['type'])) + { + $methodName = 'block' . $CurrentBlock['type'] . 'Complete'; + $CurrentBlock = $this->$methodName($CurrentBlock); + } + + # ~ + + if (isset($CurrentBlock)) + { + $Elements[] = $this->extractElement($CurrentBlock); + } + + # ~ + + return $Elements; + } + + protected function extractElement(array $Component) + { + if ( ! isset($Component['element'])) + { + if (isset($Component['markup'])) + { + $Component['element'] = array('rawHtml' => $Component['markup']); + } + elseif (isset($Component['hidden'])) + { + $Component['element'] = array(); + } + } + + return $Component['element']; + } + + protected function isBlockContinuable($Type) + { + return method_exists($this, 'block' . $Type . 'Continue'); + } + + protected function isBlockCompletable($Type) + { + return method_exists($this, 'block' . $Type . 'Complete'); + } + + # + # Code + + protected function blockCode($Line, $Block = null) + { + if (isset($Block) and $Block['type'] === 'Paragraph' and ! isset($Block['interrupted'])) + { + return; + } + + if ($Line['indent'] >= 4) + { + $text = substr($Line['body'], 4); + + $Block = array( + 'element' => array( + 'name' => 'pre', + 'element' => array( + 'name' => 'code', + 'text' => $text, + ), + ), + ); + + return $Block; + } + } + + protected function blockCodeContinue($Line, $Block) + { + if ($Line['indent'] >= 4) + { + if (isset($Block['interrupted'])) + { + $Block['element']['element']['text'] .= str_repeat("\n", $Block['interrupted']); + + unset($Block['interrupted']); + } + + $Block['element']['element']['text'] .= "\n"; + + $text = substr($Line['body'], 4); + + $Block['element']['element']['text'] .= $text; + + return $Block; + } + } + + protected function blockCodeComplete($Block) + { + return $Block; + } + + # + # Comment + + protected function blockComment($Line) + { + if ($this->markupEscaped or $this->safeMode) + { + return; + } + + if (strpos($Line['text'], '') !== false) + { + $Block['closed'] = true; + } + + return $Block; + } + } + + protected function blockCommentContinue($Line, array $Block) + { + if (isset($Block['closed'])) + { + return; + } + + $Block['element']['rawHtml'] .= "\n" . $Line['body']; + + if (strpos($Line['text'], '-->') !== false) + { + $Block['closed'] = true; + } + + return $Block; + } + + # + # Fenced Code + + protected function blockFencedCode($Line) + { + $marker = $Line['text'][0]; + + $openerLength = strspn($Line['text'], $marker); + + if ($openerLength < 3) + { + return; + } + + $infostring = trim(substr($Line['text'], $openerLength), "\t "); + + if (strpos($infostring, '`') !== false) + { + return; + } + + $Element = array( + 'name' => 'code', + 'text' => '', + ); + + if ($infostring !== '') + { + /** + * https://www.w3.org/TR/2011/WD-html5-20110525/elements.html#classes + * Every HTML element may have a class attribute specified. + * The attribute, if specified, must have a value that is a set + * of space-separated tokens representing the various classes + * that the element belongs to. + * [...] + * The space characters, for the purposes of this specification, + * are U+0020 SPACE, U+0009 CHARACTER TABULATION (tab), + * U+000A LINE FEED (LF), U+000C FORM FEED (FF), and + * U+000D CARRIAGE RETURN (CR). + */ + $language = substr($infostring, 0, strcspn($infostring, " \t\n\f\r")); + + $Element['attributes'] = array('class' => "language-$language"); + } + + $Block = array( + 'char' => $marker, + 'openerLength' => $openerLength, + 'element' => array( + 'name' => 'pre', + 'element' => $Element, + ), + ); + + return $Block; + } + + protected function blockFencedCodeContinue($Line, $Block) + { + if (isset($Block['complete'])) + { + return; + } + + if (isset($Block['interrupted'])) + { + $Block['element']['element']['text'] .= str_repeat("\n", $Block['interrupted']); + + unset($Block['interrupted']); + } + + if (($len = strspn($Line['text'], $Block['char'])) >= $Block['openerLength'] + and chop(substr($Line['text'], $len), ' ') === '' + ) { + $Block['element']['element']['text'] = substr($Block['element']['element']['text'], 1); + + $Block['complete'] = true; + + return $Block; + } + + $Block['element']['element']['text'] .= "\n" . $Line['body']; + + return $Block; + } + + protected function blockFencedCodeComplete($Block) + { + return $Block; + } + + # + # Header + + protected function blockHeader($Line) + { + $level = strspn($Line['text'], '#'); + + if ($level > 6) + { + return; + } + + $text = trim($Line['text'], '#'); + + if ($this->strictMode and isset($text[0]) and $text[0] !== ' ') + { + return; + } + + $text = trim($text, ' '); + + $Block = array( + 'element' => array( + 'name' => 'h' . $level, + 'handler' => array( + 'function' => 'lineElements', + 'argument' => $text, + 'destination' => 'elements', + ) + ), + ); + + return $Block; + } + + # + # List + + protected function blockList($Line, array $CurrentBlock = null) + { + list($name, $pattern) = $Line['text'][0] <= '-' ? array('ul', '[*+-]') : array('ol', '[0-9]{1,9}+[.\)]'); + + if (preg_match('/^('.$pattern.'([ ]++|$))(.*+)/', $Line['text'], $matches)) + { + $contentIndent = strlen($matches[2]); + + if ($contentIndent >= 5) + { + $contentIndent -= 1; + $matches[1] = substr($matches[1], 0, -$contentIndent); + $matches[3] = str_repeat(' ', $contentIndent) . $matches[3]; + } + elseif ($contentIndent === 0) + { + $matches[1] .= ' '; + } + + $markerWithoutWhitespace = strstr($matches[1], ' ', true); + + $Block = array( + 'indent' => $Line['indent'], + 'pattern' => $pattern, + 'data' => array( + 'type' => $name, + 'marker' => $matches[1], + 'markerType' => ($name === 'ul' ? $markerWithoutWhitespace : substr($markerWithoutWhitespace, -1)), + ), + 'element' => array( + 'name' => $name, + 'elements' => array(), + ), + ); + $Block['data']['markerTypeRegex'] = preg_quote($Block['data']['markerType'], '/'); + + if ($name === 'ol') + { + $listStart = ltrim(strstr($matches[1], $Block['data']['markerType'], true), '0') ?: '0'; + + if ($listStart !== '1') + { + if ( + isset($CurrentBlock) + and $CurrentBlock['type'] === 'Paragraph' + and ! isset($CurrentBlock['interrupted']) + ) { + return; + } + + $Block['element']['attributes'] = array('start' => $listStart); + } + } + + $Block['li'] = array( + 'name' => 'li', + 'handler' => array( + 'function' => 'li', + 'argument' => !empty($matches[3]) ? array($matches[3]) : array(), + 'destination' => 'elements' + ) + ); + + $Block['element']['elements'] []= & $Block['li']; + + return $Block; + } + } + + protected function blockListContinue($Line, array $Block) + { + if (isset($Block['interrupted']) and empty($Block['li']['handler']['argument'])) + { + return null; + } + + $requiredIndent = ($Block['indent'] + strlen($Block['data']['marker'])); + + if ($Line['indent'] < $requiredIndent + and ( + ( + $Block['data']['type'] === 'ol' + and preg_match('/^[0-9]++'.$Block['data']['markerTypeRegex'].'(?:[ ]++(.*)|$)/', $Line['text'], $matches) + ) or ( + $Block['data']['type'] === 'ul' + and preg_match('/^'.$Block['data']['markerTypeRegex'].'(?:[ ]++(.*)|$)/', $Line['text'], $matches) + ) + ) + ) { + if (isset($Block['interrupted'])) + { + $Block['li']['handler']['argument'] []= ''; + + $Block['loose'] = true; + + unset($Block['interrupted']); + } + + unset($Block['li']); + + $text = isset($matches[1]) ? $matches[1] : ''; + + $Block['indent'] = $Line['indent']; + + $Block['li'] = array( + 'name' => 'li', + 'handler' => array( + 'function' => 'li', + 'argument' => array($text), + 'destination' => 'elements' + ) + ); + + $Block['element']['elements'] []= & $Block['li']; + + return $Block; + } + elseif ($Line['indent'] < $requiredIndent and $this->blockList($Line)) + { + return null; + } + + if ($Line['text'][0] === '[' and $this->blockReference($Line)) + { + return $Block; + } + + if ($Line['indent'] >= $requiredIndent) + { + if (isset($Block['interrupted'])) + { + $Block['li']['handler']['argument'] []= ''; + + $Block['loose'] = true; + + unset($Block['interrupted']); + } + + $text = substr($Line['body'], $requiredIndent); + + $Block['li']['handler']['argument'] []= $text; + + return $Block; + } + + if ( ! isset($Block['interrupted'])) + { + $text = preg_replace('/^[ ]{0,'.$requiredIndent.'}+/', '', $Line['body']); + + $Block['li']['handler']['argument'] []= $text; + + return $Block; + } + } + + protected function blockListComplete(array $Block) + { + if (isset($Block['loose'])) + { + foreach ($Block['element']['elements'] as &$li) + { + if (end($li['handler']['argument']) !== '') + { + $li['handler']['argument'] []= ''; + } + } + } + + return $Block; + } + + # + # Quote + + protected function blockQuote($Line) + { + if (preg_match('/^>[ ]?+(.*+)/', $Line['text'], $matches)) + { + $Block = array( + 'element' => array( + 'name' => 'blockquote', + 'handler' => array( + 'function' => 'linesElements', + 'argument' => (array) $matches[1], + 'destination' => 'elements', + ) + ), + ); + + return $Block; + } + } + + protected function blockQuoteContinue($Line, array $Block) + { + if (isset($Block['interrupted'])) + { + return; + } + + if ($Line['text'][0] === '>' and preg_match('/^>[ ]?+(.*+)/', $Line['text'], $matches)) + { + $Block['element']['handler']['argument'] []= $matches[1]; + + return $Block; + } + + if ( ! isset($Block['interrupted'])) + { + $Block['element']['handler']['argument'] []= $Line['text']; + + return $Block; + } + } + + # + # Rule + + protected function blockRule($Line) + { + $marker = $Line['text'][0]; + + if (substr_count($Line['text'], $marker) >= 3 and chop($Line['text'], " $marker") === '') + { + $Block = array( + 'element' => array( + 'name' => 'hr', + ), + ); + + return $Block; + } + } + + # + # Setext + + protected function blockSetextHeader($Line, array $Block = null) + { + if ( ! isset($Block) or $Block['type'] !== 'Paragraph' or isset($Block['interrupted'])) + { + return; + } + + if ($Line['indent'] < 4 and chop(chop($Line['text'], ' '), $Line['text'][0]) === '') + { + $Block['element']['name'] = $Line['text'][0] === '=' ? 'h1' : 'h2'; + + return $Block; + } + } + + # + # Markup + + protected function blockMarkup($Line) + { + if ($this->markupEscaped or $this->safeMode) + { + return; + } + + if (preg_match('/^<[\/]?+(\w*)(?:[ ]*+'.$this->regexHtmlAttribute.')*+[ ]*+(\/)?>/', $Line['text'], $matches)) + { + $element = strtolower($matches[1]); + + if (in_array($element, $this->textLevelElements)) + { + return; + } + + $Block = array( + 'name' => $matches[1], + 'element' => array( + 'rawHtml' => $Line['text'], + 'autobreak' => true, + ), + ); + + return $Block; + } + } + + protected function blockMarkupContinue($Line, array $Block) + { + if (isset($Block['closed']) or isset($Block['interrupted'])) + { + return; + } + + $Block['element']['rawHtml'] .= "\n" . $Line['body']; + + return $Block; + } + + # + # Reference + + protected function blockReference($Line) + { + if (strpos($Line['text'], ']') !== false + and preg_match('/^\[(.+?)\]:[ ]*+?(?:[ ]+["\'(](.+)["\')])?[ ]*+$/', $Line['text'], $matches) + ) { + $id = strtolower($matches[1]); + + $Data = array( + 'url' => $matches[2], + 'title' => isset($matches[3]) ? $matches[3] : null, + ); + + $this->DefinitionData['Reference'][$id] = $Data; + + $Block = array( + 'element' => array(), + ); + + return $Block; + } + } + + # + # Table + + protected function blockTable($Line, array $Block = null) + { + if ( ! isset($Block) or $Block['type'] !== 'Paragraph' or isset($Block['interrupted'])) + { + return; + } + + if ( + strpos($Block['element']['handler']['argument'], '|') === false + and strpos($Line['text'], '|') === false + and strpos($Line['text'], ':') === false + or strpos($Block['element']['handler']['argument'], "\n") !== false + ) { + return; + } + + if (chop($Line['text'], ' -:|') !== '') + { + return; + } + + $alignments = array(); + + $divider = $Line['text']; + + $divider = trim($divider); + $divider = trim($divider, '|'); + + $dividerCells = explode('|', $divider); + + foreach ($dividerCells as $dividerCell) + { + $dividerCell = trim($dividerCell); + + if ($dividerCell === '') + { + return; + } + + $alignment = null; + + if ($dividerCell[0] === ':') + { + $alignment = 'left'; + } + + if (substr($dividerCell, - 1) === ':') + { + $alignment = $alignment === 'left' ? 'center' : 'right'; + } + + $alignments []= $alignment; + } + + # ~ + + $HeaderElements = array(); + + $header = $Block['element']['handler']['argument']; + + $header = trim($header); + $header = trim($header, '|'); + + $headerCells = explode('|', $header); + + if (count($headerCells) !== count($alignments)) + { + return; + } + + foreach ($headerCells as $index => $headerCell) + { + $headerCell = trim($headerCell); + + $HeaderElement = array( + 'name' => 'th', + 'handler' => array( + 'function' => 'lineElements', + 'argument' => $headerCell, + 'destination' => 'elements', + ) + ); + + if (isset($alignments[$index])) + { + $alignment = $alignments[$index]; + + $HeaderElement['attributes'] = array( + 'style' => "text-align: $alignment;", + ); + } + + $HeaderElements []= $HeaderElement; + } + + # ~ + + $Block = array( + 'alignments' => $alignments, + 'identified' => true, + 'element' => array( + 'name' => 'table', + 'elements' => array(), + ), + ); + + $Block['element']['elements'] []= array( + 'name' => 'thead', + ); + + $Block['element']['elements'] []= array( + 'name' => 'tbody', + 'elements' => array(), + ); + + $Block['element']['elements'][0]['elements'] []= array( + 'name' => 'tr', + 'elements' => $HeaderElements, + ); + + return $Block; + } + + protected function blockTableContinue($Line, array $Block) + { + if (isset($Block['interrupted'])) + { + return; + } + + if (count($Block['alignments']) === 1 or $Line['text'][0] === '|' or strpos($Line['text'], '|')) + { + $Elements = array(); + + $row = $Line['text']; + + $row = trim($row); + $row = trim($row, '|'); + + preg_match_all('/(?:(\\\\[|])|[^|`]|`[^`]++`|`)++/', $row, $matches); + + $cells = array_slice($matches[0], 0, count($Block['alignments'])); + + foreach ($cells as $index => $cell) + { + $cell = trim($cell); + + $Element = array( + 'name' => 'td', + 'handler' => array( + 'function' => 'lineElements', + 'argument' => $cell, + 'destination' => 'elements', + ) + ); + + if (isset($Block['alignments'][$index])) + { + $Element['attributes'] = array( + 'style' => 'text-align: ' . $Block['alignments'][$index] . ';', + ); + } + + $Elements []= $Element; + } + + $Element = array( + 'name' => 'tr', + 'elements' => $Elements, + ); + + $Block['element']['elements'][1]['elements'] []= $Element; + + return $Block; + } + } + + # + # ~ + # + + protected function paragraph($Line) + { + return array( + 'type' => 'Paragraph', + 'element' => array( + 'name' => 'p', + 'handler' => array( + 'function' => 'lineElements', + 'argument' => $Line['text'], + 'destination' => 'elements', + ), + ), + ); + } + + protected function paragraphContinue($Line, array $Block) + { + if (isset($Block['interrupted'])) + { + return; + } + + $Block['element']['handler']['argument'] .= "\n".$Line['text']; + + return $Block; + } + + # + # Inline Elements + # + + protected $InlineTypes = array( + '!' => array('Image'), + '&' => array('SpecialCharacter'), + '*' => array('Emphasis'), + ':' => array('Url'), + '<' => array('UrlTag', 'EmailTag', 'Markup'), + '[' => array('Link'), + '_' => array('Emphasis'), + '`' => array('Code'), + '~' => array('Strikethrough'), + '\\' => array('EscapeSequence'), + ); + + # ~ + + protected $inlineMarkerList = '!*_&[:<`~\\'; + + # + # ~ + # + + public function line($text, $nonNestables = array()) + { + return $this->elements($this->lineElements($text, $nonNestables)); + } + + protected function lineElements($text, $nonNestables = array()) + { + # standardize line breaks + $text = str_replace(array("\r\n", "\r"), "\n", $text); + + $Elements = array(); + + $nonNestables = (empty($nonNestables) + ? array() + : array_combine($nonNestables, $nonNestables) + ); + + # $excerpt is based on the first occurrence of a marker + + while ($excerpt = strpbrk($text, $this->inlineMarkerList)) + { + $marker = $excerpt[0]; + + $markerPosition = strlen($text) - strlen($excerpt); + + $Excerpt = array('text' => $excerpt, 'context' => $text); + + foreach ($this->InlineTypes[$marker] as $inlineType) + { + # check to see if the current inline type is nestable in the current context + + if (isset($nonNestables[$inlineType])) + { + continue; + } + + $Inline = $this->{"inline$inlineType"}($Excerpt); + + if ( ! isset($Inline)) + { + continue; + } + + # makes sure that the inline belongs to "our" marker + + if (isset($Inline['position']) and $Inline['position'] > $markerPosition) + { + continue; + } + + # sets a default inline position + + if ( ! isset($Inline['position'])) + { + $Inline['position'] = $markerPosition; + } + + # cause the new element to 'inherit' our non nestables + + + $Inline['element']['nonNestables'] = isset($Inline['element']['nonNestables']) + ? array_merge($Inline['element']['nonNestables'], $nonNestables) + : $nonNestables + ; + + # the text that comes before the inline + $unmarkedText = substr($text, 0, $Inline['position']); + + # compile the unmarked text + $InlineText = $this->inlineText($unmarkedText); + $Elements[] = $InlineText['element']; + + # compile the inline + $Elements[] = $this->extractElement($Inline); + + # remove the examined text + $text = substr($text, $Inline['position'] + $Inline['extent']); + + continue 2; + } + + # the marker does not belong to an inline + + $unmarkedText = substr($text, 0, $markerPosition + 1); + + $InlineText = $this->inlineText($unmarkedText); + $Elements[] = $InlineText['element']; + + $text = substr($text, $markerPosition + 1); + } + + $InlineText = $this->inlineText($text); + $Elements[] = $InlineText['element']; + + foreach ($Elements as &$Element) + { + if ( ! isset($Element['autobreak'])) + { + $Element['autobreak'] = false; + } + } + + return $Elements; + } + + # + # ~ + # + + protected function inlineText($text) + { + $Inline = array( + 'extent' => strlen($text), + 'element' => array(), + ); + + $Inline['element']['elements'] = self::pregReplaceElements( + $this->breaksEnabled ? '/[ ]*+\n/' : '/(?:[ ]*+\\\\|[ ]{2,}+)\n/', + array( + array('name' => 'br'), + array('text' => "\n"), + ), + $text + ); + + return $Inline; + } + + protected function inlineCode($Excerpt) + { + $marker = $Excerpt['text'][0]; + + if (preg_match('/^(['.$marker.']++)[ ]*+(.+?)[ ]*+(? strlen($matches[0]), + 'element' => array( + 'name' => 'code', + 'text' => $text, + ), + ); + } + } + + protected function inlineEmailTag($Excerpt) + { + $hostnameLabel = '[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?'; + + $commonMarkEmail = '[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]++@' + . $hostnameLabel . '(?:\.' . $hostnameLabel . ')*'; + + if (strpos($Excerpt['text'], '>') !== false + and preg_match("/^<((mailto:)?$commonMarkEmail)>/i", $Excerpt['text'], $matches) + ){ + $url = $matches[1]; + + if ( ! isset($matches[2])) + { + $url = "mailto:$url"; + } + + return array( + 'extent' => strlen($matches[0]), + 'element' => array( + 'name' => 'a', + 'text' => $matches[1], + 'attributes' => array( + 'href' => $url, + ), + ), + ); + } + } + + protected function inlineEmphasis($Excerpt) + { + if ( ! isset($Excerpt['text'][1])) + { + return; + } + + $marker = $Excerpt['text'][0]; + + if ($Excerpt['text'][1] === $marker and preg_match($this->StrongRegex[$marker], $Excerpt['text'], $matches)) + { + $emphasis = 'strong'; + } + elseif (preg_match($this->EmRegex[$marker], $Excerpt['text'], $matches)) + { + $emphasis = 'em'; + } + else + { + return; + } + + return array( + 'extent' => strlen($matches[0]), + 'element' => array( + 'name' => $emphasis, + 'handler' => array( + 'function' => 'lineElements', + 'argument' => $matches[1], + 'destination' => 'elements', + ) + ), + ); + } + + protected function inlineEscapeSequence($Excerpt) + { + if (isset($Excerpt['text'][1]) and in_array($Excerpt['text'][1], $this->specialCharacters)) + { + return array( + 'element' => array('rawHtml' => $Excerpt['text'][1]), + 'extent' => 2, + ); + } + } + + protected function inlineImage($Excerpt) + { + if ( ! isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[') + { + return; + } + + $Excerpt['text']= substr($Excerpt['text'], 1); + + $Link = $this->inlineLink($Excerpt); + + if ($Link === null) + { + return; + } + + $Inline = array( + 'extent' => $Link['extent'] + 1, + 'element' => array( + 'name' => 'img', + 'attributes' => array( + 'src' => $Link['element']['attributes']['href'], + 'alt' => $Link['element']['handler']['argument'], + ), + 'autobreak' => true, + ), + ); + + $Inline['element']['attributes'] += $Link['element']['attributes']; + + unset($Inline['element']['attributes']['href']); + + return $Inline; + } + + protected function inlineLink($Excerpt) + { + $Element = array( + 'name' => 'a', + 'handler' => array( + 'function' => 'lineElements', + 'argument' => null, + 'destination' => 'elements', + ), + 'nonNestables' => array('Url', 'Link'), + 'attributes' => array( + 'href' => null, + 'title' => null, + ), + ); + + $extent = 0; + + $remainder = $Excerpt['text']; + + if (preg_match('/\[((?:[^][]++|(?R))*+)\]/', $remainder, $matches)) + { + $Element['handler']['argument'] = $matches[1]; + + $extent += strlen($matches[0]); + + $remainder = substr($remainder, $extent); + } + else + { + return; + } + + if (preg_match('/^[(]\s*+((?:[^ ()]++|[(][^ )]+[)])++)(?:[ ]+("[^"]*+"|\'[^\']*+\'))?\s*+[)]/', $remainder, $matches)) + { + $Element['attributes']['href'] = $matches[1]; + + if (isset($matches[2])) + { + $Element['attributes']['title'] = substr($matches[2], 1, - 1); + } + + $extent += strlen($matches[0]); + } + else + { + if (preg_match('/^\s*\[(.*?)\]/', $remainder, $matches)) + { + $definition = strlen($matches[1]) ? $matches[1] : $Element['handler']['argument']; + $definition = strtolower($definition); + + $extent += strlen($matches[0]); + } + else + { + $definition = strtolower($Element['handler']['argument']); + } + + if ( ! isset($this->DefinitionData['Reference'][$definition])) + { + return; + } + + $Definition = $this->DefinitionData['Reference'][$definition]; + + $Element['attributes']['href'] = $Definition['url']; + $Element['attributes']['title'] = $Definition['title']; + } + + return array( + 'extent' => $extent, + 'element' => $Element, + ); + } + + protected function inlineMarkup($Excerpt) + { + if ($this->markupEscaped or $this->safeMode or strpos($Excerpt['text'], '>') === false) + { + return; + } + + if ($Excerpt['text'][1] === '/' and preg_match('/^<\/\w[\w-]*+[ ]*+>/s', $Excerpt['text'], $matches)) + { + return array( + 'element' => array('rawHtml' => $matches[0]), + 'extent' => strlen($matches[0]), + ); + } + + if ($Excerpt['text'][1] === '!' and preg_match('/^/s', $Excerpt['text'], $matches)) + { + return array( + 'element' => array('rawHtml' => $matches[0]), + 'extent' => strlen($matches[0]), + ); + } + + if ($Excerpt['text'][1] !== ' ' and preg_match('/^<\w[\w-]*+(?:[ ]*+'.$this->regexHtmlAttribute.')*+[ ]*+\/?>/s', $Excerpt['text'], $matches)) + { + return array( + 'element' => array('rawHtml' => $matches[0]), + 'extent' => strlen($matches[0]), + ); + } + } + + protected function inlineSpecialCharacter($Excerpt) + { + if (substr($Excerpt['text'], 1, 1) !== ' ' and strpos($Excerpt['text'], ';') !== false + and preg_match('/^&(#?+[0-9a-zA-Z]++);/', $Excerpt['text'], $matches) + ) { + return array( + 'element' => array('rawHtml' => '&' . $matches[1] . ';'), + 'extent' => strlen($matches[0]), + ); + } + + return; + } + + protected function inlineStrikethrough($Excerpt) + { + if ( ! isset($Excerpt['text'][1])) + { + return; + } + + if ($Excerpt['text'][1] === '~' and preg_match('/^~~(?=\S)(.+?)(?<=\S)~~/', $Excerpt['text'], $matches)) + { + return array( + 'extent' => strlen($matches[0]), + 'element' => array( + 'name' => 'del', + 'handler' => array( + 'function' => 'lineElements', + 'argument' => $matches[1], + 'destination' => 'elements', + ) + ), + ); + } + } + + protected function inlineUrl($Excerpt) + { + if ($this->urlsLinked !== true or ! isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/') + { + return; + } + + if (strpos($Excerpt['context'], 'http') !== false + and preg_match('/\bhttps?+:[\/]{2}[^\s<]+\b\/*+/ui', $Excerpt['context'], $matches, PREG_OFFSET_CAPTURE) + ) { + $url = $matches[0][0]; + + $Inline = array( + 'extent' => strlen($matches[0][0]), + 'position' => $matches[0][1], + 'element' => array( + 'name' => 'a', + 'text' => $url, + 'attributes' => array( + 'href' => $url, + ), + ), + ); + + return $Inline; + } + } + + protected function inlineUrlTag($Excerpt) + { + if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<(\w++:\/{2}[^ >]++)>/i', $Excerpt['text'], $matches)) + { + $url = $matches[1]; + + return array( + 'extent' => strlen($matches[0]), + 'element' => array( + 'name' => 'a', + 'text' => $url, + 'attributes' => array( + 'href' => $url, + ), + ), + ); + } + } + + # ~ + + protected function unmarkedText($text) + { + $Inline = $this->inlineText($text); + return $this->element($Inline['element']); + } + + # + # Handlers + # + + protected function handle(array $Element) + { + if (isset($Element['handler'])) + { + if (!isset($Element['nonNestables'])) + { + $Element['nonNestables'] = array(); + } + + if (is_string($Element['handler'])) + { + $function = $Element['handler']; + $argument = $Element['text']; + unset($Element['text']); + $destination = 'rawHtml'; + } + else + { + $function = $Element['handler']['function']; + $argument = $Element['handler']['argument']; + $destination = $Element['handler']['destination']; + } + + $Element[$destination] = $this->{$function}($argument, $Element['nonNestables']); + + if ($destination === 'handler') + { + $Element = $this->handle($Element); + } + + unset($Element['handler']); + } + + return $Element; + } + + protected function handleElementRecursive(array $Element) + { + return $this->elementApplyRecursive(array($this, 'handle'), $Element); + } + + protected function handleElementsRecursive(array $Elements) + { + return $this->elementsApplyRecursive(array($this, 'handle'), $Elements); + } + + protected function elementApplyRecursive($closure, array $Element) + { + $Element = call_user_func($closure, $Element); + + if (isset($Element['elements'])) + { + $Element['elements'] = $this->elementsApplyRecursive($closure, $Element['elements']); + } + elseif (isset($Element['element'])) + { + $Element['element'] = $this->elementApplyRecursive($closure, $Element['element']); + } + + return $Element; + } + + protected function elementApplyRecursiveDepthFirst($closure, array $Element) + { + if (isset($Element['elements'])) + { + $Element['elements'] = $this->elementsApplyRecursiveDepthFirst($closure, $Element['elements']); + } + elseif (isset($Element['element'])) + { + $Element['element'] = $this->elementsApplyRecursiveDepthFirst($closure, $Element['element']); + } + + $Element = call_user_func($closure, $Element); + + return $Element; + } + + protected function elementsApplyRecursive($closure, array $Elements) + { + foreach ($Elements as &$Element) + { + $Element = $this->elementApplyRecursive($closure, $Element); + } + + return $Elements; + } + + protected function elementsApplyRecursiveDepthFirst($closure, array $Elements) + { + foreach ($Elements as &$Element) + { + $Element = $this->elementApplyRecursiveDepthFirst($closure, $Element); + } + + return $Elements; + } + + protected function element(array $Element) + { + if ($this->safeMode) + { + $Element = $this->sanitiseElement($Element); + } + + # identity map if element has no handler + $Element = $this->handle($Element); + + $hasName = isset($Element['name']); + + $markup = ''; + + if ($hasName) + { + $markup .= '<' . $Element['name']; + + if (isset($Element['attributes'])) + { + foreach ($Element['attributes'] as $name => $value) + { + if ($value === null) + { + continue; + } + + $markup .= " $name=\"".self::escape($value).'"'; + } + } + } + + $permitRawHtml = false; + + if (isset($Element['text'])) + { + $text = $Element['text']; + } + // very strongly consider an alternative if you're writing an + // extension + elseif (isset($Element['rawHtml'])) + { + $text = $Element['rawHtml']; + + $allowRawHtmlInSafeMode = isset($Element['allowRawHtmlInSafeMode']) && $Element['allowRawHtmlInSafeMode']; + $permitRawHtml = !$this->safeMode || $allowRawHtmlInSafeMode; + } + + $hasContent = isset($text) || isset($Element['element']) || isset($Element['elements']); + + if ($hasContent) + { + $markup .= $hasName ? '>' : ''; + + if (isset($Element['elements'])) + { + $markup .= $this->elements($Element['elements']); + } + elseif (isset($Element['element'])) + { + $markup .= $this->element($Element['element']); + } + else + { + if (!$permitRawHtml) + { + $markup .= self::escape($text, true); + } + else + { + $markup .= $text; + } + } + + $markup .= $hasName ? '' : ''; + } + elseif ($hasName) + { + $markup .= ' />'; + } + + return $markup; + } + + protected function elements(array $Elements) + { + $markup = ''; + + $autoBreak = true; + + foreach ($Elements as $Element) + { + if (empty($Element)) + { + continue; + } + + $autoBreakNext = (isset($Element['autobreak']) + ? $Element['autobreak'] : isset($Element['name']) + ); + // (autobreak === false) covers both sides of an element + $autoBreak = !$autoBreak ? $autoBreak : $autoBreakNext; + + $markup .= ($autoBreak ? "\n" : '') . $this->element($Element); + $autoBreak = $autoBreakNext; + } + + $markup .= $autoBreak ? "\n" : ''; + + return $markup; + } + + # ~ + + protected function li($lines) + { + $Elements = $this->linesElements($lines); + + if ( ! in_array('', $lines) + and isset($Elements[0]) and isset($Elements[0]['name']) + and $Elements[0]['name'] === 'p' + ) { + unset($Elements[0]['name']); + } + + return $Elements; + } + + # + # AST Convenience + # + + /** + * Replace occurrences $regexp with $Elements in $text. Return an array of + * elements representing the replacement. + */ + protected static function pregReplaceElements($regexp, $Elements, $text) + { + $newElements = array(); + + while (preg_match($regexp, $text, $matches, PREG_OFFSET_CAPTURE)) + { + $offset = $matches[0][1]; + $before = substr($text, 0, $offset); + $after = substr($text, $offset + strlen($matches[0][0])); + + $newElements[] = array('text' => $before); + + foreach ($Elements as $Element) + { + $newElements[] = $Element; + } + + $text = $after; + } + + $newElements[] = array('text' => $text); + + return $newElements; + } + + # + # Deprecated Methods + # + + function parse($text) + { + $markup = $this->text($text); + + return $markup; + } + + protected function sanitiseElement(array $Element) + { + static $goodAttribute = '/^[a-zA-Z0-9][a-zA-Z0-9-_]*+$/'; + static $safeUrlNameToAtt = array( + 'a' => 'href', + 'img' => 'src', + ); + + if ( ! isset($Element['name'])) + { + unset($Element['attributes']); + return $Element; + } + + if (isset($safeUrlNameToAtt[$Element['name']])) + { + $Element = $this->filterUnsafeUrlInAttribute($Element, $safeUrlNameToAtt[$Element['name']]); + } + + if ( ! empty($Element['attributes'])) + { + foreach ($Element['attributes'] as $att => $val) + { + # filter out badly parsed attribute + if ( ! preg_match($goodAttribute, $att)) + { + unset($Element['attributes'][$att]); + } + # dump onevent attribute + elseif (self::striAtStart($att, 'on')) + { + unset($Element['attributes'][$att]); + } + } + } + + return $Element; + } + + protected function filterUnsafeUrlInAttribute(array $Element, $attribute) + { + foreach ($this->safeLinksWhitelist as $scheme) + { + if (self::striAtStart($Element['attributes'][$attribute], $scheme)) + { + return $Element; + } + } + + $Element['attributes'][$attribute] = str_replace(':', '%3A', $Element['attributes'][$attribute]); + + return $Element; + } + + # + # Static Methods + # + + protected static function escape($text, $allowQuotes = false) + { + return htmlspecialchars($text, $allowQuotes ? ENT_NOQUOTES : ENT_QUOTES, 'UTF-8'); + } + + protected static function striAtStart($string, $needle) + { + $len = strlen($needle); + + if ($len > strlen($string)) + { + return false; + } + else + { + return strtolower(substr($string, 0, $len)) === strtolower($needle); + } + } + + static function instance($name = 'default') + { + if (isset(self::$instances[$name])) + { + return self::$instances[$name]; + } + + $instance = new static(); + + self::$instances[$name] = $instance; + + return $instance; + } + + private static $instances = array(); + + # + # Fields + # + + protected $DefinitionData; + + # + # Read-Only + + protected $specialCharacters = array( + '\\', '`', '*', '_', '{', '}', '[', ']', '(', ')', '>', '#', '+', '-', '.', '!', '|', '~' + ); + + protected $StrongRegex = array( + '*' => '/^[*]{2}((?:\\\\\*|[^*]|[*][^*]*+[*])+?)[*]{2}(?![*])/s', + '_' => '/^__((?:\\\\_|[^_]|_[^_]*+_)+?)__(?!_)/us', + ); + + protected $EmRegex = array( + '*' => '/^[*]((?:\\\\\*|[^*]|[*][*][^*]+?[*][*])+?)[*](?![*])/s', + '_' => '/^_((?:\\\\_|[^_]|__[^_]*__)+?)_(?!_)\b/us', + ); + + protected $regexHtmlAttribute = '[a-zA-Z_:][\w:.-]*+(?:\s*+=\s*+(?:[^"\'=<>`\s]+|"[^"]*+"|\'[^\']*+\'))?+'; + + protected $voidElements = array( + 'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', + ); + + protected $textLevelElements = array( + 'a', 'br', 'bdo', 'abbr', 'blink', 'nextid', 'acronym', 'basefont', + 'b', 'em', 'big', 'cite', 'small', 'spacer', 'listing', + 'i', 'rp', 'del', 'code', 'strike', 'marquee', + 'q', 'rt', 'ins', 'font', 'strong', + 's', 'tt', 'kbd', 'mark', + 'u', 'xm', 'sub', 'nobr', + 'sup', 'ruby', + 'var', 'span', + 'wbr', 'time', + ); +} \ No newline at end of file diff --git a/includes/util/agewarning.inc b/includes/util/agewarning.inc new file mode 100644 index 0000000..1f51647 --- /dev/null +++ b/includes/util/agewarning.inc @@ -0,0 +1,35 @@ + 1677628800) { + file_get_contents('https://' . $ntfy["server"] . '/' . $ntfy['topic'], false, stream_context_create([ + 'http' => [ + 'method' => 'POST', + 'header' => + "Content-Type: text/plain\r\n" . + "Title: ⚠️ $name does not have an age or birth year set\r\n" . + "Priority: max\r\n" . + "Tags: switch\r\n" . + "Actions: view, Edit on Cold Haze, https://ponies.equestria.horse/-/metadata/" . ($system === "gdapd" ? "raindrops" : "cloudburst") . "/" . $id . "/, clear=true\r\n" . + "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), + 'content' => "To make sure they appear on the fronting schedule (and to make sure they can front again), they need to set an age or birth year now." + ] + ])); + } else { + file_get_contents('https://' . $ntfy["server"] . '/' . $ntfy['topic'], false, stream_context_create([ + 'http' => [ + 'method' => 'POST', + 'header' => + "Content-Type: text/plain\r\n" . + "Title: ⚠️ $name does not have an age or birth year set\r\n" . + "Priority: max\r\n" . + "Tags: switch\r\n" . + "Actions: view, Edit on Cold Haze, https://ponies.equestria.horse/-/metadata/" . ($system === "gdapd" ? "raindrops" : "cloudburst") . "/" . $id . "/, clear=true\r\n" . + "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), + 'content' => "To make sure they still appear on the fronting schedule after March 1st, they need to set an age or birth year now." + ] + ])); + } +} \ No newline at end of file diff --git a/includes/util/banner.inc b/includes/util/banner.inc new file mode 100644 index 0000000..46d9ce5 --- /dev/null +++ b/includes/util/banner.inc @@ -0,0 +1,480 @@ + 4196352, + "regression" => null, + "median" => null, + "marefriends" => [], + "sexfriends" => [], + "sisters" => [], + "caretakers" => [] + ]); + + $prefixes = []; + foreach ($member['proxy_tags'] as $proxy) { + if ($travelling[$member['id']]["travelling"]) { + if (isset($travelling[$member['id']]['equestria']) && $travelling[$member['id']]['equestria']) { + $prefixes[] = null; + } else { + $prefixes[] = "+" . $proxy["prefix"] . ($proxy["suffix"] !== "" && $proxy["suffix"] !== null ? "..." . $proxy["suffix"] : ""); + } + } else { + $prefixes[] = $proxy["prefix"] . ($proxy["suffix"] !== "" && $proxy["suffix"] !== null ? "..." . $proxy["suffix"] : ""); + } + } + + $lastFronted = null; + if (!$metadata["median"]) { + $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)) { + $lastFronted = [ + 'now' => true, + 'relative' => timeAgo(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json"), true)["timestamp"]), + 'absolute' => date("D j M Y, G:i:s (e)", strtotime(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json"), true)["timestamp"])), + 'timestamp' => strtotime(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json"), true)["timestamp"]), + 'duration' => [ + 'seconds' => null, + 'pretty' => null + ] + ]; + } else { + $switches = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/switches.json"), true); + + $thisMember = array_filter($switches, function ($item) { + global $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)) { + $seconds = (strtotime($frontingEnd["timestamp"]) - strtotime($frontingStart["timestamp"])); + + $lastFronted = [ + 'now' => false, + 'relative' => timeAgo($frontingEnd["timestamp"]), + 'absolute' => date("D j M Y, G:i:s (e)", strtotime($frontingEnd["timestamp"])), + 'timestamp' => strtotime($frontingEnd["timestamp"]), + 'duration' => [ + 'seconds' => $seconds, + 'pretty' => $seconds . ($french ? " secondes" : " seconds") + ] + ]; + if ($french) { + if ($seconds > 60) { + if ($seconds > 3600) { + $lastFronted['duration']['pretty'] = round($seconds / 3600) . " heures"; + } else { + $lastFronted['duration']['pretty'] = round($seconds / 60) . " minutes"; + } + } + } else { + if ($seconds > 60) { + if ($seconds > 3600) { + $lastFronted['duration']['pretty'] = round($seconds / 3600) . " hours"; + } else { + $lastFronted['duration']['pretty'] = round($seconds / 60) . " minutes"; + } + } + } + } + } + } + + $speciesList = []; + foreach ($metadata["species"] ?? [] as $species) { + if ($french) { + $name = match ($species) { + "earth" => $metadata["robot"] ? "Robot poney terrestre" : (!$metadata["plush"] ? "Poney terrestre" : "Poney terrestre en peluche"), + "alicorn" => $metadata["robot"] ? "Robot alicorne" : (!$metadata["plush"] ? "Alicorne" : "Alicorne en peluche"), + "crystal" => $metadata["robot"] ? "Robot poney de crystal" : (!$metadata["plush"] ? "Poney de crystal" : "Poney de crystal en peluche"), + "pegasus" => $metadata["robot"] ? "Robot pégase" : (!$metadata["plush"] ? "Pégase" : "Pégase en peluche"), + "batpony" => $metadata["robot"] ? "Robot Poney chauve souris" : (!$metadata["plush"] ? "Poney chauve souris" : "Poney chauve souris en peluche"), + "unicorn" => $metadata["robot"] ? "Robot licorne" : (!$metadata["plush"] ? "Licorne" : "Licorne en peluche"), + "changeling" => "Changelin", + default => $species . "_" . $metadata["robot"] + }; + } else { + $name = match ($species) { + "earth" => $metadata["robot"] ? "Robot earth pony" : (!$metadata["plush"] ? "Earth pony" : "Earth pony plush"), + "alicorn" => $metadata["robot"] ? "Robot alicorn" : (!$metadata["plush"] ? "Alicorn" : "Alicorn plush"), + "crystal" => $metadata["robot"] ? "Robot crystal pony" : (!$metadata["plush"] ? "Crystal pony" : "Crystal pony plush"), + "pegasus" => $metadata["robot"] ? "Robot pegasus" : (!$metadata["plush"] ? "Pegasus" : "Pegasus plush"), + "batpony" => $metadata["robot"] ? "Robot bat pony" : (!$metadata["plush"] ? "Bat pony" : "Bat pony plush"), + "unicorn" => $metadata["robot"] ? "Robot unicorn" : (!$metadata["plush"] ? "Unicorn" : "Unicorn plush"), + "changeling" => "Changeling", + default => $species . "_" . $metadata["robot"] + }; + } + + $speciesList[] = [ + "id" => $species, + "name" => $name, + "robot" => $metadata["robot"], + "plush" => $metadata["plush"], + "icon" => $species . ($metadata["robot"] ? "-robot" : ($metadata["plush"] ? "-plush" : "")) . ".png" + ]; + } + + $app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true); + + $systemData = []; + $systemData['page'] = "/" . ($system === "gdapd" ? "raindrops" : ($system === $app["other"]["id"] ? $app["other"]["slug"] : "cloudburst")); + $systemData['icon'] = getAsset($system); + $systemData['name'] = $system === "gdapd" ? "Raindrops" : ($system === $app["other"]["id"] ? $app["other"]["short"] : "Cloudburst"); + $systemData['full_name'] = $system === "gdapd" ? "Raindrops System" : ($system === $app["other"]["id"] ? $app["other"]["name"] : "Cloudburst System"); + $systemData['temporary'] = false; + + if ($travelling[$member['id']]["travelling"] && !$travelling[$member['id']]["equestria"]) { + $systemData['page'] = "/" . ($system === "gdapd" ? "cloudburst" : "raindrops"); + $systemData['icon'] = getAsset($system === "gdapd" ? "ynmuc" : "gdapd"); + $systemData['name'] = $system === "gdapd" ? "Cloudburst" : "Raindrops"; + $systemData['full_name'] = $system === "gdapd" ? "Cloudburst System" : "Raindrops System"; + $systemData['temporary'] = true; + } + + if ($travelling[$member['id']]["travelling"] && $travelling[$member['id']]["equestria"]) { + $systemData['page'] = null; + $systemData['icon'] = "../logo/equestria.png"; + $systemData['name'] = "Equestria"; + $systemData['full_name'] = "Equestria"; + $systemData['temporary'] = true; + } + + $marefriends = []; + foreach ($metadata["marefriends"] as $marefriend) { + $mfSystem = explode("/", $marefriend)[0]; + $mfMemberID = explode("/", $marefriend)[1]; + $mfMember = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$mfSystem/members.json"), true), function ($item) use ($mfMemberID) { + return $item["id"] === $mfMemberID; + }); + sort($mfMember); + $mfMember = $mfMember[0]; + + $marefriends[] = [ + "id" => $marefriend, + "link" => "/" . ($mfMember["name"]), + "icon" => getAsset($mfSystem, $mfMemberID, "heads"), + "name" => $mfMember["display_name"] ?? $mfMember["name"], + "full_name" => $mfMember["display_name"] ?? $mfMember["name"] + ]; + } + + $sexfriends = null; + + if ($isLoggedIn) { + $sexfriends = []; + foreach ($metadata["sexfriends"] as $marefriend) { + $mfSystem = explode("/", $marefriend)[0]; + $mfMemberID = explode("/", $marefriend)[1]; + $mfMember = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$mfSystem/members.json"), true), function ($item) use ($mfMemberID) { + return $item["id"] === $mfMemberID; + }); + sort($mfMember); + $mfMember = $mfMember[0]; + + $sexfriends[] = [ + "id" => $marefriend, + "link" => "/" . ($mfMember["name"]), + "icon" => getAsset($mfSystem, $mfMemberID, "heads"), + "name" => $mfMember["display_name"] ?? $mfMember["name"], + "full_name" => $mfMember["display_name"] ?? $mfMember["name"] + ]; + } + } + + $sisters = []; + foreach ($metadata["sisters"] as $marefriend) { + $mfSystem = explode("/", $marefriend)[0]; + $mfMemberID = explode("/", $marefriend)[1]; + $mfMember = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$mfSystem/members.json"), true), function ($item) use ($mfMemberID) { + return $item["id"] === $mfMemberID; + }); + sort($mfMember); + $mfMember = $mfMember[0]; + + $sisters[] = [ + "id" => $marefriend, + "link" => "/" . ($mfMember["name"]), + "icon" => getAsset($mfSystem, $mfMemberID, "heads"), + "name" => $mfMember["display_name"] ?? $mfMember["name"], + "full_name" => $mfMember["display_name"] ?? $mfMember["name"] + ]; + } + + $caretakers = null; + + if ($metadata["little"] >= 2) { + $caretakers = []; + foreach ($metadata["caretakers"] as $marefriend) { + $mfSystem = explode("/", $marefriend)[0]; + $mfMemberID = explode("/", $marefriend)[1]; + $mfMember = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$mfSystem/members.json"), true), function ($item) use ($mfMemberID) { + return $item["id"] === $mfMemberID; + }); + sort($mfMember); + $mfMember = $mfMember[0]; + + $caretakers[] = [ + "id" => $marefriend, + "link" => "/" . ($mfMember["name"]), + "icon" => getAsset($mfSystem, $mfMemberID, "heads"), + "name" => $mfMember["display_name"] ?? $mfMember["name"], + "full_name" => $mfMember["display_name"] ?? $mfMember["name"] + ]; + } + } + + $badges = []; + + if ($metadata["host"] ?? false) { + if (!$travelling[$member['id']]["travelling"]) { + $badges[] = [ + "id" => "mcf", + "color" => "primary", + "html" => ( + $french + ? + 'Fronteuse la plus présente' + : + 'Most common fronter' + ) + ]; + } + } + + /*if (($metadata["age_spells"] ?? false) && !$french) { + $badges[] = [ + "id" => "age_spells", + "color" => "#6f42c1", + "html" => 'Affected by age spells' + ]; + }*/ + + if ($metadata["fictive"] ?? false) { + $badges[] = [ + "id" => "fictive", + "color" => "info", + "html" => ( + $french + ? + 'Fictive' + : + 'Fictive' + ) + ]; + } + + if ($metadata["persecutor"] ?? false) { + $badges[] = [ + "id" => "persecutor", + "color" => "danger", + "html" => ( + $french + ? + 'Persécutrice' + : + 'Persecutor' + ) + ]; + } + + if ($metadata["less_frequent"] ?? false) { + $badges[] = [ + "id" => "nonverbal", + "color" => "#6610f2", + "html" => ( + $french + ? + 'Fronte moins souvent' + : + 'Fronts less often' + ) + ]; + } + + if ($metadata["nonverbal"] ?? false) { + $badges[] = [ + "id" => "nonverbal", + "color" => "#20c997", + "html" => ( + $french + ? + 'Non verbal IRL' + : + 'Non verbal IRL' + ) + ]; + } + + if ($member["name"] === "fusion") { + $badges[] = [ + "id" => "fusion", + "color" => "d63384", + "html" => 'Fusion' + ]; + } + + if (($metadata["leader"] ?? false)) { + $badges[] = [ + "id" => "leader", + "color" => "d6a833", + "html" => ( + $french + ? + 'Dirigeante' + : + 'Leader' + ) + ]; + } + + if ($metadata["protector"] ?? false) { + $badges[] = [ + "id" => "protector", + "color" => "black", + "html" => ( + $french + ? + '
' . ucfirst(getMemberPronouns($member['pronouns'])["subjective"]) . ' ' . (getMemberPronouns($member['pronouns'])["third"] ? "is" : "are") . ' a protector in the system and will front when somepony cannot handle it anymore." class="badge rounded-pill bg-black">' . (getMemberPronouns($member['pronouns'])["gender"] === "female" ? "Protectrice" : (getMemberPronouns($member['pronouns'])["gender"] === "male" ? "Protecteur" : "Protectrice")) . '
' + : + 'Protector' + ) + ]; + } + + if (($metadata["little"] ?? 0) === 2) { + $badges[] = [ + "id" => "little", + "color" => "success", + "html" => ( + $french + ? + '
' . ucfirst(getMemberPronouns($member['pronouns'])["subjective"]) . ' ' . (getMemberPronouns($member['pronouns'])["third"] ? "is" : "are") . ' mentally younger, and therefore behaves and feels younger than the body is." class="badge rounded-pill bg-success">Petit' . (getMemberPronouns($member['pronouns'])["gender"] === "female" ? "e" : (getMemberPronouns($member['pronouns'])["gender"] === "male" ? "" : "·e")) . '
' + : + 'Little' + ) + ]; + } + + if (($metadata["little"] ?? 0) === 3) { + $badges[] = [ + "id" => "younger", + "color" => "dark", + "html" => ( + $french + ? + 'Plus jeune' + : + 'Younger' + ) + ]; + } + + if (($metadata["age_regressor"] ?? false)) { + if ($metadata["regression"] !== null && $metadata["regression"] !== false) { + $regression = _header_getMember($metadata["regression"], $system); + $badges[] = [ + "id" => "regressor_median", + "color" => "secondary", + "html" => ( + $french + ? + 'Régresse en âge en '. (getMiniName($regression["display_name"] ?? $regression["name"])) . '' + : + 'Age regresses into '. (getMiniName($regression["display_name"] ?? $regression["name"])) . '' + ) + ]; + } + } + + if ($metadata["median"] !== null && $metadata["median"] !== false) { + $source = _header_getMember($metadata["median"], $system); + if ($metadata["little"] > 0) { + $badges[] = [ + "id" => "regressed", + "color" => "warning", + "html" => ( + $french + ? + 'Régressé en âge de ' . (getMiniName($source["display_name"] ?? $source["name"])) . '' + : + 'Age regressed from ' . (getMiniName($source["display_name"] ?? $source["name"])) . '' + ) + ]; + } else { + $badges[] = [ + "id" => "facet", + "color" => "light", + "html" => ( + $french + ? + 'Facette de ' . getMiniName($source["display_name"] ?? $source["name"]) . '' + : + 'Facet of ' . getMiniName($source["display_name"] ?? $source["name"]) . '' + ) + ]; + } + } + + return [ + 'id' => $member['name'], + 'color' => $member["color"] ?? "000000", + 'icon' => [ + "online" => getAsset($system, $member["id"]), + "offline" => "pf-$system-$id.webp" + ], + 'median' => $metadata["median"], + 'little' => $metadata["little"] >= 2, + 'name' => $member["display_name"] ?? $member["name"], + 'badges' => $badges, + 'prefixes' => $prefixes, + 'pronouns' => getTooltipsFromMark($member["pronouns"], $french) ?? "they/them", + 'pronouns_usage' => getMemberPronouns($member['pronouns']), + 'last_fronted' => $lastFronted, + 'species' => $speciesList, + 'system' => $systemData, + 'relations' => [ + 'marefriends' => $marefriends ?? [], + 'sexfriends' => $sexfriends ?? null, + 'sisters' => $sisters ?? [], + 'caretakers' => $caretakers ?? [] + ] + ]; +} \ No newline at end of file diff --git a/includes/util/bitset.inc b/includes/util/bitset.inc new file mode 100644 index 0000000..131cb39 --- /dev/null +++ b/includes/util/bitset.inc @@ -0,0 +1,21 @@ + 1990) { + $age = (int)date('Y') - $metadata["birth"]["year"] + (strtotime(date('Y') . "-" . $metadata["birth"]["date"]) <= time() ? 0 : -1); + } + + if ($age > 0 && $age <= 10) { + $metadata["little"] = 2; + } else if ($age > 0 && $age <= 15) { + $metadata["little"] = 3; + } + + return $metadata; +} \ No newline at end of file diff --git a/includes/util/functions.inc b/includes/util/functions.inc new file mode 100644 index 0000000..24b059a --- /dev/null +++ b/includes/util/functions.inc @@ -0,0 +1,551 @@ + ''])["uuid"]); + } else { + return "/error/nomember/?s=$systemID&m=$memberID&t=$type"; + } + + $id = $id1 . $id2; + + if (str_ends_with((getMemberWithoutSystem($memberID) ?? ['name' => ''])["name"], "-travelling")) { + $id1 = preg_replace("/^([\da-f]{8})-([\da-f]{4})-([\da-f]{4})-([\da-f]{4})-([\da-f]{12})$/", "$1$2$3$4$5", json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($systemID === "gdapd" ? "ynmuc" : "gdapd") . "/general.json"), true)["uuid"]); + + $members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($systemID === "gdapd" ? "ynmuc" : "gdapd") . "/members.json"), true); + $list = array_map(function ($i) { + return $i["name"]; + }, $members); + + if (in_array(substr(getMemberWithoutSystem($memberID)["name"], 0, -11), $list)) { + $id2 = preg_replace("/^([\da-f]{8})-([\da-f]{4})-([\da-f]{4})-([\da-f]{4})-([\da-f]{12})$/", "$1$2$3$4$5", getMemberFromName(substr(getMemberWithoutSystem($memberID)["name"], 0, -11))["uuid"]); + } else { + return "/error/nomember/?s=$systemID&m=$memberID&t=$type"; + } + + $id = $id1 . $id2; + } + } else { + $id = $id1; + } + + 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 { + 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"; + } + } +} + +if (!function_exists("rgbToHsl")) { + function rgbToHsl($r, $g, $b) { + $oldR = $r; + $oldG = $g; + $oldB = $b; + + $r /= 255; + $g /= 255; + $b /= 255; + + $max = max($r, $g, $b); + $min = min($r, $g, $b); + + $l = ($max + $min) / 2; + $d = $max - $min; + + if ($d == 0) { + $h = $s = 0; + } else { + $s = $d / (1 - abs(2 * $l - 1)); + + switch ($max) { + case $r: + $h = 60 * fmod((($g - $b) / $d), 6); + if ($b > $g) { + $h += 360; + } + break; + + case $g: + $h = 60 * (($b - $r) / $d + 2); + break; + + case $b: + $h = 60 * (($r - $g) / $d + 4); + break; + } + } + + return array(round($h, 2), round($s, 2), round($l, 2)); + } +} + +if (!function_exists("imageCreateCorners")) { + function imageCreateCorners($sourceImageFile, $radius) { + # test source image + if (file_exists($sourceImageFile)) { + $res = is_array($info = getimagesize($sourceImageFile)); + } + else $res = false; + + # open image + if ($res) { + $w = $info[0]; + $h = $info[1]; + switch ($info['mime']) { + case 'image/jpeg': $src = imagecreatefromjpeg($sourceImageFile); + break; + case 'image/gif': $src = imagecreatefromgif($sourceImageFile); + break; + case 'image/png': $src = imagecreatefrompng($sourceImageFile); + break; + default: + $res = false; + } + } + + # create corners + if ($res) { + + $q = 10; # change this if you want + $radius *= $q; + + # find unique color + do { + $r = rand(0, 255); + $g = rand(0, 255); + $b = rand(0, 255); + } + while (imagecolorexact($src, $r, $g, $b) < 0); + + $nw = $w*$q; + $nh = $h*$q; + + $img = imagecreatetruecolor($nw, $nh); + $alphacolor = imagecolorallocatealpha($img, $r, $g, $b, 127); + imagealphablending($img, false); + imagesavealpha($img, true); + imagefilledrectangle($img, 0, 0, $nw, $nh, $alphacolor); + + imagefill($img, 0, 0, $alphacolor); + imagecopyresampled($img, $src, 0, 0, 0, 0, $nw, $nh, $w, $h); + + imagearc($img, $radius-1, $radius-1, $radius*2, $radius*2, 180, 270, $alphacolor); + imagefilltoborder($img, 0, 0, $alphacolor, $alphacolor); + imagearc($img, $nw-$radius, $radius-1, $radius*2, $radius*2, 270, 0, $alphacolor); + imagefilltoborder($img, $nw-1, 0, $alphacolor, $alphacolor); + imagearc($img, $radius-1, $nh-$radius, $radius*2, $radius*2, 90, 180, $alphacolor); + imagefilltoborder($img, 0, $nh-1, $alphacolor, $alphacolor); + imagearc($img, $nw-$radius, $nh-$radius, $radius*2, $radius*2, 0, 90, $alphacolor); + imagefilltoborder($img, $nw-1, $nh-1, $alphacolor, $alphacolor); + imagealphablending($img, true); + imagecolortransparent($img, $alphacolor); + + # resize image down + $dest = imagecreatetruecolor($w, $h); + imagealphablending($dest, false); + imagesavealpha($dest, true); + imagefilledrectangle($dest, 0, 0, $w, $h, $alphacolor); + imagecopyresampled($dest, $img, 0, 0, 0, 0, $w, $h, $nw, $nh); + + # output image + $res = $dest; + imagedestroy($src); + imagedestroy($img); + } + + return $res; + } +} + +if (!function_exists("getMiniName")) { + function getMiniName(string $name) { + $parts = explode(" ", $name); + + if (strlen($parts[0]) > 3 && $parts[0] !== "Sweetie" && $parts[0] !== "Filly" && $parts[0] !== "Windy" && (isset($parts[1]) && $parts[1] !== "Brightdawn" && $parts[1] !== "Fizz")) { + if ($parts[0] === "Princess") { + array_shift($parts); + } + + if (str_contains($parts[0], "/")) { + return explode("/", $parts[0])[0]; + } else { + return $parts[0]; + } + } else { + return $name; + } + } +} + +if (!function_exists("withCaretakersDown")) { + function withCaretakersDown(array $ordered): array { + return $ordered; + } +} + +if (!function_exists("getSystemMember")) { + function getSystemMember(string $system, string $id) { + $app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true); + $systemID = $system; + + $members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($systemID === $app["other"]["id"] ? "other" : $systemID) . "/members.json"), true); + $member = null; + + foreach ($members as $m) { + if ($m["id"] === $id) $member = $m; + } + + $member["system"] = $member["_system"] = $system; + + return $member; + } +} + +if (!function_exists("getMemberWithoutSystem")) { + function getMemberWithoutSystem(string $id) { + global $isLowerLoggedIn; global $isLoggedIn; + $member = null; + + $members1 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/members.json"), true); + foreach ($members1 as $m) { + $m["_system"] = "ynmuc"; + $m["system"] = "ynmuc"; + if ($m["id"] === $id) $member = $m; + } + + $members2 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/members.json"), true); + foreach ($members2 as $m) { + $m["_system"] = "gdapd"; + $m["system"] = "gdapd"; + if ($m["id"] === $id) $member = $m; + } + + if ($isLowerLoggedIn || $isLoggedIn) { + $app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true); + $members3 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/other/members.json"), true); + + foreach ($members3 as $m) { + $m["_system"] = $app["other"]["id"]; + $m["system"] = $app["other"]["id"]; + if ($m["id"] === $id) $member = $m; + } + } + + return $member; + } +} + +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']) . '
+
' . (isset($member['travelling']) && $member['travelling'] ? "+" . ($member['proxy_tags'][0]['prefix'] ?? " ") : ($member['proxy_tags'][0]['prefix'] ?? " ")) . '
+
'); + }} + } +} + +if (!function_exists("prettySize")) { + function prettySize($bytes) { + if ($bytes > 1024) { + if ($bytes > 1024**2) { + if ($bytes > 1024**3) { + return round($bytes / 1024**3, 1) . " GB"; + } else { + return round($bytes / 1024**2, 1) . " MB"; + } + } else { + return round($bytes / 1024, 1) . " KB"; + } + } else { + return $bytes . " B"; + } + } +} + +if (!function_exists("showSystem")) { + function showSystem(string $id, string $name, string $color, bool $hideTitle) { + $app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true); + global $travelling; + + $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('
'); + } else { + echo('
'); + } + if (!$hideTitle) echo(' +

' . $name . '
+
'); + + if ($hideTitle) { + echo('
'); + } else { + echo('
'); + } + + if ($id === $app["other"]["id"]) { + showMembersFromList(scoreOrder([...array_map(function ($i) use ($id, $travelling) { + $i["travelling"] = false; + $i["system"] = $id; + $i["equestria"] = false; + return $i; + }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . (isset($app["other"]) && $id === $app["other"]["id"] ? "other" : $id) . "/members.json"), true))], $id)); + } else { + showMembersFromList(scoreOrder([...array_map(function ($i) use ($id, $travelling) { + $i["travelling"] = false; + $i["system"] = $id; + $i["equestria"] = $travelling[$i['id']]['travelling'] && $travelling[$i['id']]['equestria']; + return $i; + }, array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . (isset($app["other"]) && $id === $app["other"]["id"] ? "other" : $id) . "/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'])); + })), ...array_map(function ($i) use ($id) { + $i["travelling"] = true; + $i["system"] = ($id === "gdapd" ? "ynmuc" : "gdapd"); + return $i; + }, array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($id === "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']); + }))], $id)); + } + + echo('
+ +
'); + } +} + +if (!function_exists("cloudburst")) { + function cloudburst(bool $hideTitle): void { + showSystem("ynmuc", "Cloudburst System", "#5f08a9a6", $hideTitle); + } +} + + +if (!function_exists("raindrops")) { + function raindrops(bool $hideTitle): void { + showSystem("gdapd", "Raindrops System", "#a95f08a6", $hideTitle); + } +} + +if (!function_exists("other")) { + function other(bool $hideTitle): void { + $app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true); + showSystem($app["other"]["id"], $app["other"]["name"], "#" . $app["other"]["color"] . "a6", $hideTitle); + } +} + +if (!function_exists("getMember")) { + function getMember(string $id) { + global $systemID; + + $members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/members.json"), true); + $member = null; + + foreach ($members as $m) { + if ($m["id"] === $id) $member = $m; + } + + return $member; + } +} + +if (!function_exists("timeAgo")) { + function timeAgo($time, $french = false): string { + if (!is_numeric($time)) { + $time = strtotime($time); + } + + $periods = ["sec", "min", "hr", "d", "wk", "mo", "y", "ages"]; + $periods_fr = $periods; + $lengths = array("60", "60", "24", "7", "4.35", "12", "100"); + + $now = time(); + + $difference = $now - $time; + if ($difference <= 10 && $difference >= 0) { + return $tense = "now"; + } elseif ($difference > 0) { + $tense = "ago"; + } else { + $tense = "later"; + } + + for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) { + $difference /= $lengths[$j]; + } + + $difference = round($difference); + + $period = $periods[$j]; + return "{$difference} {$period} {$tense}"; + } +} + +if (!function_exists("timeIn")) { + function timeIn($time): string { + if (!is_numeric($time)) { + $time = strtotime($time); + } + + $periods = ["second", "minute", "hour", "day", "week", "month", "year", "age"]; + $lengths = array("60", "60", "24", "7", "4.35", "12", "100"); + + $now = time(); + + $difference = $time - $now; + if ($difference <= 10 && $difference >= 0) { + return $tense = "now"; + } elseif ($difference > 0) { + $tense = "in"; + } else { + $tense = "ago"; + } + + for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) { + $difference /= $lengths[$j]; + } + + $difference = round($difference); + + $period = $periods[$j] . ($difference >1 ? "s" :''); + return "{$tense} {$difference} {$period}"; + } +} + +if (!function_exists("duration")) { + function duration($seconds) { + global $lang; global $pages; + + if ($seconds >= 60) { + if (floor($seconds / 60) >= 60) { + if (floor($seconds / 3600) >= 24) { + $days = floor($seconds / 86400); + + if ($lang["_french"]) { + return $days . " jour" . ($days > 1 ? "s" : ""); + } else { + return $days . " day" . ($days > 1 ? "s" : ""); + } + } else { + $hours = floor($seconds / 3600); + + if ($lang["_french"]) { + return $hours . " heure" . ($hours > 1 ? "s" : ""); + } else { + return $hours . " hour" . ($hours > 1 ? "s" : ""); + } + } + } else { + $minutes = floor($seconds / 60); + return $minutes . " minute" . ($minutes > 1 ? "s" : ""); + } + } else { + if ($lang["_french"]) { + return $seconds . " secondes"; + } else { + return $seconds . " seconds"; + } + } + } +} + +if (!function_exists("relativeDate")) { + function relativeDate($date, $showTime = true) { + if (!is_numeric($date)) $date = strtotime($date); + + if (!$showTime) { + if (date('Y-m-d', $date) === date('Y-m-d')) { + return "today"; + } elseif (date('Y-m-d', $date) === date('Y-m-d', time() + 86400)) { + return "tomorrow"; + } elseif ($date < time() + 518400) { + return date('l', $date); + } else { + return date('D j M', $date); + } + } else { + if (date('Y-m-d', $date) === date('Y-m-d')) { + return "today, " . date('H:i', $date) . ""; + } elseif (date('Y-m-d', $date) === date('Y-m-d', time() + 86400)) { + return "tomorrow, " . date('H:i', $date) . ""; + } elseif ($date < time() + 518400) { + return date('l', $date) . ", " . date('H:i', $date) . ""; + } else { + return date('D j M', $date) . ", " . date('H:i', $date) . ""; + } + } + } +} + +if (!function_exists("getMemberSystem")) { + function getMemberSystem(string $id) { + $list = scoreOrderGlobal(); + + foreach ($list as $item) { + if ($item["id"] === $id) return $item["_system"]; + } + } +} + +if (!function_exists("getMemberFromName")) { + function getMemberFromName(string $name) { + $list = [...json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/members.json"), true), ...json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/members.json"), true), ...json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/other/members.json"), true)]; + + foreach ($list as $item) { + if ($item["name"] === $name) return getMemberWithoutSystem($item["id"]); + } + } +} + +if (!function_exists("resolveMember")) { + function resolveMember(mixed $name) { + if (is_string($name)) { + if (str_ends_with($name, "-travelling")) { + return substr($name, 0, strlen($name) - 11); + } else { + return $name; + } + } else { + return $name; + } + } +} \ No newline at end of file diff --git a/includes/util/homepage.inc b/includes/util/homepage.inc new file mode 100644 index 0000000..ebb99da --- /dev/null +++ b/includes/util/homepage.inc @@ -0,0 +1,36 @@ + + + 0) || isset($member["_metadata"]["birth"]["year"]) && $member["_metadata"]["birth"]["year"] > 1900) || ((isset($member["_metadata"]["birth"]["age"]) && $member["_metadata"]["birth"]["age"] === -1) && in_array("alicorn", $member["_metadata"]["species"])), + isset($member["_metadata"]["birth"]["date"]) && trim($member["_metadata"]["birth"]["date"]) !== "" && $member["_metadata"]["birth"]["date"] !== "01-01", + file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . ".html") && strlen(preg_replace("/[^a-zA-Z0-9]/m", "", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . ".html"))) > 200, + file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . "-private.html") && strlen(preg_replace("/[^a-zA-Z0-9]/m", "", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . "-private.html"))) > 200, + isset($member["banner"]), + file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $member["name"] . ".png"), + isset($member["color"]) + ]; + + $result = [ + "values" => $values, + "pages" => [], + "characters" => [], + "score" => (float)array_reduce($values, function ($a, $b) { + return $a + $b; + }), + "score2" => (float)array_reduce($values, function ($a, $b) { + return $a + $b; + }), + "actions" => [] + ]; + + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . ".html") && strlen(preg_replace("/[^a-zA-Z0-9]/m", "", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . ".html"))) <= 200) { + $result["pages"][] = true; + $result["score"] += strlen(preg_replace("/[^a-zA-Z0-9]/m", "", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . ".html"))) / 201; + } else { + $result["pages"][] = false; + } + + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . "-private.html") && strlen(preg_replace("/[^a-zA-Z0-9]/m", "", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . "-private.html"))) <= 200) { + $result["pages"][] = true; + $result["score"] += strlen(preg_replace("/[^a-zA-Z0-9]/m", "", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . "-private.html"))) / 201; + } else { + $result["pages"][] = false; + } + + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . ".html")) { + $result["characters"][] = strlen(preg_replace("/[^a-zA-Z0-9]/m", "", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . ".html"))); + } else { + $result["characters"][] = -1; + } + + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . "-private.html")) { + $result["characters"][] = strlen(preg_replace("/[^a-zA-Z0-9]/m", "", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . "-private.html"))); + } else { + $result["characters"][] = -1; + } + + if (!((isset($member["_metadata"]["birth"]["age"]) && $member["_metadata"]["birth"]["age"] > 0) || isset($member["_metadata"]["birth"]["year"]) && $member["_metadata"]["birth"]["year"] > 1900) && !(isset($member["_metadata"]["birth"]["age"]) && $member["_metadata"]["birth"]["age"] === -1) && in_array("alicorn", $member["_metadata"]["species"])) { + $result["score"] += 0.5; + } + + $result["progress"] = $result["score"] / 7; + $result["sortable"] = (int)($result["progress"] * 100000000000000); + + if (!$result["values"][5]) { + $result["actions"][] = "a Pony Town character"; + } + + if (!$result["values"][6]) { + $result["actions"][] = "a color"; + } + + if (!$result["values"][2]) { + if ($result["characters"][0] === -1) { + $result["actions"][] = "a public page"; + } else { + $result["actions"][] = (200 - $result["characters"][0]) . " characters to the public page"; + } + } + + if (!$result["values"][3]) { + if ($result["characters"][1] === -1) { + $result["actions"][] = "a private page"; + } else { + $result["actions"][] = (200 - $result["characters"][1]) . " characters to the private page"; + } + } + + if (!$result["values"][4]) { + $result["actions"][] = "a banner"; + } + + if (!$result["values"][0]) { + $result["actions"][] = "an age"; + } + + if (!$result["values"][1]) { + $result["actions"][] = "a birthdate"; + } + + return $result; +} \ No newline at end of file diff --git a/includes/util/pronouns.inc b/includes/util/pronouns.inc new file mode 100644 index 0000000..6ab2487 --- /dev/null +++ b/includes/util/pronouns.inc @@ -0,0 +1,149 @@ + [ + "gender" => "ponygender", + "gender:fr" => "poneygenre", + "object" => "pony", + "person" => "pony", + "possessive_det" => "pony's", + "possessive_pro" => "pony's", + "reflexive" => "ponyself", + "subjective" => "pony", + "third" => true, + "color" => "warning" + ], + "she" => [ + "gender" => "female", + "gender:fr" => "fille", + "object" => "her", + "person" => "girl", + "possessive_det" => "her", + "possessive_pro" => "hers", + "reflexive" => "herself", + "subjective" => "she", + "third" => true, + "color" => "success" + ], + "he" => [ + "gender" => "male", + "gender:fr" => "garçon", + "object" => "him", + "person" => "boy", + "possessive_det" => "his", + "possessive_pro" => "his", + "reflexive" => "himself", + "subjective" => "he", + "third" => true, + "color" => "info" + ], + "it" => [ + "gender" => "agender", + "gender:fr" => "agenre", + "object" => "it", + "person" => "person", + "possessive_det" => "its", + "possessive_pro" => "its", + "reflexive" => "itself", + "subjective" => "it", + "third" => true, + "color" => "light" + ], + "they" => [ + "gender" => "non binary", + "gender:fr" => "non binaire", + "object" => "them", + "person" => "person", + "possessive_det" => "their", + "possessive_pro" => "theirs", + "reflexive" => "themself", + "subjective" => "they", + "third" => false, + "color" => "primary" + ] +]; + +$pronounGetCount = 0; + +$possibilitiesPerSet = []; +foreach ($pronounsSets as $name => $set) { + if (!isset($possibilitiesPerSet[$name])) $possibilitiesPerSet[$name] = []; + $possibilitiesPerSet[$name][] = $name; + + foreach ($set as $category => $value) { + if (is_string($value)) $possibilitiesPerSet[$name][] = $value; + } +} + +function getSetFromValue(string $value) { + global $possibilitiesPerSet; + + foreach ($possibilitiesPerSet as $name => $set) { + if (in_array($value, $set)) { + return $name; + } + } + + return null; +} + +function getPronounsFromMark(?string $mark = null): array { + if (!isset($mark) || trim($mark) === "") { + return ["they"]; + } else { + $parts = array_unique(array_map(function ($i) { + return getSetFromValue($i); + }, explode("/", $mark))); + return $parts; + } +} + +function getMemberPronouns(?string $pronouns): ?array { + global $pronounsSets; + $list = getPronounsFromMark($pronouns); + return $pronounsSets[$list[array_rand($list)]] ?? $pronounsSets["she"]; +} + +function getGenderFromPronoun(string $pronoun, bool $french = false) { + global $pronounsSets; + $set = getPronounsFromMark($pronoun)[0]; + + if ($french) { + return ($pronounsSets[$set] ?? $pronounsSets["they"])["gender:fr"]; + } else { + return ($pronounsSets[$set] ?? $pronounsSets["they"])["gender"]; + } +} + +function pronounInFrench(string $pronoun): string { + return match ($pronoun) { + "she" => "elle", + "her" => "elle", + "he" => "il", + "him" => "lui", + "they" => "iel", + "them" => "iel", + "it" => "iel", + "its" => "iel", + "pony" => "poney", + "pony's" => "à poney", + "ponys" => "à poney", + default => $pronoun, + }; +} + +function getTooltipsFromMark(string $mark = null, bool $french = false): ?string { + if (!isset($mark)) { + return null; + } else { + if ($french) { + return implode("/", array_map(function ($i) { + return "" . pronounInFrench($i) . ""; + }, explode("/", $mark))); + } else { + return implode("/", array_map(function ($i) { + return "" . $i . ""; + }, explode("/", $mark))); + } + } +} \ No newline at end of file diff --git a/includes/util/rainbow.inc b/includes/util/rainbow.inc new file mode 100644 index 0000000..66ac2fc --- /dev/null +++ b/includes/util/rainbow.inc @@ -0,0 +1,56 @@ + $member + ]; + + if (isset($member["color"])) { + $data[$member["name"]]["rgb"] = [ + hexdec(substr($member["color"], 0, 2)), + hexdec(substr($member["color"], 2, 2)), + hexdec(substr($member["color"], 4, 2)) + ]; + $data[$member["name"]]["hsl"] = rgbToHsl( + $data[$member["name"]]["rgb"][0], + $data[$member["name"]]["rgb"][1], + $data[$member["name"]]["rgb"][2] + ); + } else { + $data[$member["name"]]["rgb"] = [255, 255, 255]; + $data[$member["name"]]["hsl"] = rgbToHsl(255, 255, 255); + } + } + + return $data; +} + +function getMembersByColor($hideCloudburst = false): array { + $members = rainbow($hideCloudburst); + uasort($members, function ($a, $b) { + return $a['hsl'][0] - $b['hsl'][0]; + }); + + $sorted = []; + foreach ($members as $data) { + $data["_data"]["hue"] = $data["hsl"][0]; + $sorted[] = $data["_data"]; + } + + return $sorted; +} \ No newline at end of file diff --git a/includes/util/random.inc b/includes/util/random.inc new file mode 100644 index 0000000..b6e7905 --- /dev/null +++ b/includes/util/random.inc @@ -0,0 +1,15 @@ + "/raindrops", + "cb" => "/cloudburst", + "minty" => "/cloudydreams", + "twilight" => "/twi", + "luna" => "/princessluna", + "cloudy" => "/cloudydreams", + "zipp" => "/zippstorm", + "babs" => "/babsseed", + "frost" => "/frostcrystals", + "violet" => "/violetdawn" +]; + +foreach ($members as $member) { + for ($i = 1; $i < strlen($member["name"]); $i++) { + $part = substr($member["name"], 0, $i); + + if (in_array($part, array_keys($list))) { + $list[$part] = false; + } else { + $list[$part] = "/" . $member["name"]; + } + } + + foreach ($member["proxy_tags"] as $proxy) { + $system = $member["_system"] === "gdapd" ? "rd" : "cb"; + $list[$system . preg_replace("/[^a-z]/m", "", $proxy["prefix"])] = "/" . $member["name"]; + } + + $list[$member["id"]] = "/" . $member["name"]; + $list[$member["uuid"]] = "/" . $member["name"]; +} + +$list["minty"] = "/cloudydreams"; +$list["twilight"] = "/twi"; + +if (in_array($toplevel, array_keys($list)) && $list[$toplevel]) { + if ($toplevel !== "unknown") { + header("Location: " . $list[$toplevel]); + } else { + peh_error("Page not found: " . strip_tags($toplevel), 404); + } +} else { + peh_error("Page not found: " . strip_tags($toplevel), 404); +} \ No newline at end of file diff --git a/includes/util/travelling.inc b/includes/util/travelling.inc new file mode 100644 index 0000000..0d1696a --- /dev/null +++ b/includes/util/travelling.inc @@ -0,0 +1,62 @@ + false, + "history" => [] + ]; + + @file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling/travelling.json", utf8_encode(json_encode($travelling, JSON_PRETTY_PRINT))); + } + + if (!isset($travelling[$member["id"]]["equestria"])) { + $travelling[$member["id"]]["equestria"] = false; + } +} + +function withTravelers(array $members, string $system): array { + global $travelling; + 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/includes/wakeup.inc b/includes/wakeup.inc deleted file mode 100644 index 587e705..0000000 --- a/includes/wakeup.inc +++ /dev/null @@ -1,114 +0,0 @@ -

Wake-up alert -
- - · -
-

- -Turn ON - -

Sending next notification never

- - - - - - \ No newline at end of file diff --git a/pages/about.inc b/pages/about.inc deleted file mode 100644 index 8a62d66..0000000 --- a/pages/about.inc +++ /dev/null @@ -1,80 +0,0 @@ - - -
-
-
-

About Cold Haze

-

- Cold Haze Engine version 2..
- Version date:
- Version ID:
- Install path:
- Server software: , via
- Transport protocol: -

- -

- PHP
- Zend Engine:
- Server API:
- Memory usage:
- Server OS:
- Server domain name:
- Server architecture: -

- -

- Disk space usage
- Engine:
- Database: -

-
-
- - diff --git a/pages/alphabet.inc b/pages/alphabet.inc index 55cb130..37bd74d 100644 --- a/pages/alphabet.inc +++ b/pages/alphabet.inc @@ -1,7 +1,7 @@ @@ -35,4 +35,4 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc';
- + diff --git a/pages/api/chrome.php b/pages/api/chrome.php new file mode 100644 index 0000000..0be8a94 --- /dev/null +++ b/pages/api/chrome.php @@ -0,0 +1,87 @@ + + + + + + + + + Luna for Chrome OS + + + +
+
+ +

Please login to Cold Haze

+

To proceed with activating Luna on this Chromebook, you need to login to Cold Haze. You also need to make sure you properly enroled this computer into Chrome Enterprise.

+ +
+
+ + + + +window.close(); \ No newline at end of file diff --git a/pages/api/cloudburst-img.php b/pages/api/cloudburst-img.php index 1967a90..7d22aad 100644 --- a/pages/api/cloudburst-img.php +++ b/pages/api/cloudburst-img.php @@ -1,6 +1,6 @@ "Plex", diff --git a/pages/api/pluralkit-integration.php b/pages/api/pluralkit-integration.php index 0793873..f5bb4dd 100644 --- a/pages/api/pluralkit-integration.php +++ b/pages/api/pluralkit-integration.php @@ -1,6 +1,6 @@ 1) { - $context = stream_context_create([ - 'http' => [ - 'method' => 'POST', - 'header' => - "Content-Type: text/plain\r\n" . - "Title: 🐴 Switch occurred in the $name\r\n" . - "Priority: default\r\n" . - "Tags: switch\r\n" . - "Actions: view, Open " . $fronters["members"][0]["display_name"] . " on Cold Haze, https://ponies.equestria.horse/" . $fronters["members"][0]["name"] . "/, clear=true;view, Open " . $fronters["members"][1]["display_name"] . " on Cold Haze, https://ponies.equestria.horse/" . $fronters["members"][1]["name"] . "/, clear=true\r\n" . - "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => ($fronters["members"][0]["display_name"] ?? $fronters["members"][0]["name"]) . " and " . ($fronters["members"][1]["display_name"] ?? $fronters["members"][1]["name"]) . " switched in just now" - ] - ]); - } else if (count($fronters["members"]) > 0) { - $context = stream_context_create([ - 'http' => [ - 'method' => 'POST', - 'header' => - "Content-Type: text/plain\r\n" . - "Title: 🐴 Switch occurred in the $name\r\n" . - "Priority: default\r\n" . - "Tags: switch\r\n" . - "Actions: view, Open on Cold Haze, https://ponies.equestria.horse/" . $fronters["members"][0]["name"] . "/, clear=true\r\n" . - "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => ($fronters["members"][0]["display_name"] ?? $fronters["members"][0]["name"]) . " switched in just now" - ] - ]); - } else { - $context = stream_context_create([ - 'http' => [ - 'method' => 'POST', - 'header' => - "Content-Type: text/plain\r\n" . - "Title: 🐴 Switch occurred in the $name\r\n" . - "Priority: default\r\n" . - "Tags: switch\r\n" . - "Actions: view, Open on Cold Haze, https://ponies.equestria.horse/, clear=true\r\n" . - "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => "The fallback pony switched in just now" - ] - ]); - } + if (count($fronters["members"]) > 1) { + $context = stream_context_create([ + 'http' => [ + 'method' => 'POST', + 'header' => + "Content-Type: text/plain\r\n" . + "Title: 🐴 Switch occurred in $name\r\n" . + "Priority: default\r\n" . + "Tags: switch\r\n" . + "Actions: view, Open " . $fronters["members"][0]["display_name"] . " on Cold Haze, https://ponies.equestria.horse/" . $fronters["members"][0]["name"] . "/, clear=true;view, Open " . $fronters["members"][1]["display_name"] . " on Cold Haze, https://ponies.equestria.horse/" . $fronters["members"][1]["name"] . "/, clear=true\r\n" . + "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), + 'content' => ($fronters["members"][0]["display_name"] ?? $fronters["members"][0]["name"]) . " and " . ($fronters["members"][1]["display_name"] ?? $fronters["members"][1]["name"]) . " switched in just now" + ] + ]); + } else if (count($fronters["members"]) > 0) { + $context = stream_context_create([ + 'http' => [ + 'method' => 'POST', + 'header' => + "Content-Type: text/plain\r\n" . + "Title: 🐴 Switch occurred in $name\r\n" . + "Priority: default\r\n" . + "Tags: switch\r\n" . + "Actions: view, Open on Cold Haze, https://ponies.equestria.horse/" . $fronters["members"][0]["name"] . "/, clear=true\r\n" . + "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), + 'content' => ($fronters["members"][0]["display_name"] ?? $fronters["members"][0]["name"]) . " switched in just now" + ] + ]); + } else { + $context = stream_context_create([ + 'http' => [ + 'method' => 'POST', + 'header' => + "Content-Type: text/plain\r\n" . + "Title: 🐴 Switch occurred in $name\r\n" . + "Priority: default\r\n" . + "Tags: switch\r\n" . + "Actions: view, Open on Cold Haze, https://ponies.equestria.horse/, clear=true\r\n" . + "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), + 'content' => "The fallback pony switched in just now" + ] + ]); + } + if ($system !== $app["other"]["id"] || !isset($app["other"])) { file_get_contents('https://' . $ntfy["server"] . '/public-switches', false, $context); } if ($system === "gdapd") { $topic = "public-switches-raindrops"; - - if (count($fronters["members"]) > 0) { - file_get_contents('https://' . $ntfy["server"] . '/public-switches-fr', false, stream_context_create([ - 'http' => [ - 'method' => 'POST', - 'header' => - "Content-Type: text/plain\r\n" . - "Title: 🐴 $name vient de switch\r\n" . - "Priority: default\r\n" . - "Tags: switch\r\n" . - "Actions: view, Voir sur Cold Haze, https://fr.equestria.horse/" . $fronters["members"][0]["name"] . "/, clear=true\r\n" . - "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => ($fronters["members"][0]["display_name"] ?? $fronters["members"][0]["name"]) . " est désormais au front" - ] - ])); - } else { - file_get_contents('https://' . $ntfy["server"] . '/public-switches-fr', false, stream_context_create([ - 'http' => [ - 'method' => 'POST', - 'header' => - "Content-Type: text/plain\r\n" . - "Title: 🐴 $name vient de switch\r\n" . - "Priority: default\r\n" . - "Tags: switch\r\n" . - "Actions: view, Voir sur Cold Haze, https://fr.equestria.horse/, clear=true\r\n" . - "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => "Le poney de trait est désormais au front" - ] - ])); - } } else if ($system === "ynmuc") { $topic = "public-switches-cloudburst"; } else { diff --git a/pages/api/ponytown.php b/pages/api/ponytown.php index f41ac01..e75ea33 100644 --- a/pages/api/ponytown.php +++ b/pages/api/ponytown.php @@ -1,6 +1,6 @@ @@ -174,4 +174,4 @@ $travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includ
- + diff --git a/pages/byspecies.inc b/pages/byspecies.inc index 28f114e..ee2b372 100644 --- a/pages/byspecies.inc +++ b/pages/byspecies.inc @@ -1,4 +1,4 @@ - 0): ?> - ">" style="width:24px;"> ,
'); $index++; endforeach; ?> + ">" style="width:24px;"> ,
'); $index++; endforeach; ?> - @@ -54,4 +54,4 @@ function species(array $members, string $id, string $name) { global $systemID; g - \ No newline at end of file + \ No newline at end of file diff --git a/pages/computers.inc b/pages/computers.inc index 56a1b5d..fb88296 100644 --- a/pages/computers.inc +++ b/pages/computers.inc @@ -1,6 +1,6 @@ @@ -812,7 +814,13 @@ if (count($parts) === 2 || count($parts) === 3) { + + @@ -881,4 +893,4 @@ if (count($parts) === 2 || count($parts) === 3) { } - + diff --git a/pages/debug.inc b/pages/debug.inc index 1327af5..6d2b4c9 100644 --- a/pages/debug.inc +++ b/pages/debug.inc @@ -1,7 +1,7 @@ - + diff --git a/pages/docs.inc b/pages/docs.inc index 2e43727..a94f92e 100644 --- a/pages/docs.inc +++ b/pages/docs.inc @@ -1,7 +1,7 @@
@@ -401,4 +401,4 @@ function showDocument($item) { ?> } - + diff --git a/pages/edit-private.inc b/pages/edit-private.inc index 4d89b5c..f26c8c6 100644 --- a/pages/edit-private.inc +++ b/pages/edit-private.inc @@ -34,7 +34,7 @@ if ($member === null) { peh_error("System member not found", 404); } - require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/edit-private.inc'; + require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/fragments/edit-private.inc'; } exit; \ No newline at end of file diff --git a/pages/edit.inc b/pages/edit.inc index e074087..28b8d88 100644 --- a/pages/edit.inc +++ b/pages/edit.inc @@ -19,7 +19,7 @@ if ($isLowerLoggedIn && $systemID !== $app["other"]["id"]) { } if ($member === null) { - require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/sysedit.inc'; + require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/fragments/sysedit.inc'; } else { $members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "/members.json"), true); $memberData = null; @@ -38,7 +38,7 @@ if ($member === null) { peh_error("System member not found", 404); } - require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/edit.inc'; + require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/fragments/edit.inc'; } exit; \ No newline at end of file diff --git a/pages/emergency.inc b/pages/emergency.inc index 0d34251..244571b 100644 --- a/pages/emergency.inc +++ b/pages/emergency.inc @@ -1,15 +1,15 @@
- +
- + diff --git a/pages/fronting.inc b/pages/fronting.inc index a2b5cb0..6cd464b 100644 --- a/pages/fronting.inc +++ b/pages/fronting.inc @@ -1,15 +1,15 @@
- +
- + diff --git a/pages/games.inc b/pages/games.inc index 4df95f1..ca881e4 100644 --- a/pages/games.inc +++ b/pages/games.inc @@ -1,7 +1,7 @@ @@ -80,4 +80,4 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc';
- + diff --git a/pages/home.inc b/pages/home.inc index 82ff3d5..86bf513 100644 --- a/pages/home.inc +++ b/pages/home.inc @@ -4,7 +4,7 @@ if (isset($_GET["ec"])) { header("HTTP/1.1 " . $_GET["ec"] . " Error"); } -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; global $readOnly; global $isNormallyLoggedIn; global $_PROFILE; global $lang; global $pages; global $isLowerLoggedIn; global $app; global $isLoggedIn; ?> +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; global $readOnly; global $isNormallyLoggedIn; global $_PROFILE; global $lang; global $pages; global $isLowerLoggedIn; global $app; global $isLoggedIn; ?>
@@ -21,7 +21,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; require_once $_SE
- +
.png" style="width:128px;">

@@ -34,15 +34,11 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; require_once $_SE

Cold Haze

- -

poneys dans une tête

-

ponies in 3 plural systems

-
@@ -79,4 +75,4 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; require_once $_SE - \ No newline at end of file + \ No newline at end of file diff --git a/pages/home.old.inc b/pages/home.old.inc index f918549..085af58 100644 --- a/pages/home.old.inc +++ b/pages/home.old.inc @@ -4,7 +4,7 @@ if (isset($_GET["ec"])) { header("HTTP/1.1 " . $_GET["ec"] . " Error"); } -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; global $readOnly; global $isNormallyLoggedIn; global $_PROFILE; global $lang; global $pages; global $isLowerLoggedIn; global $app; global $isLoggedIn; ?> +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; global $readOnly; global $isNormallyLoggedIn; global $_PROFILE; global $lang; global $pages; global $isLowerLoggedIn; global $app; global $isLoggedIn; ?>
@@ -21,7 +21,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; require_once $_SE
- +
.png" style="width:128px;">

@@ -34,15 +34,11 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; require_once $_SE

Cold Haze

- -

poneys dans une tête

-

ponies in 3 plural systems

-

@@ -80,4 +76,4 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; require_once $_SE - \ No newline at end of file + \ No newline at end of file diff --git a/pages/login.inc b/pages/login.inc index 8d71574..313be91 100644 --- a/pages/login.inc +++ b/pages/login.inc @@ -1,9 +1,25 @@ + +
@@ -36,4 +52,4 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; global $readOnl
- + diff --git a/pages/metadata.inc b/pages/metadata.inc index 9faefef..768f548 100644 --- a/pages/metadata.inc +++ b/pages/metadata.inc @@ -1,8 +1,8 @@ @@ -678,4 +678,4 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; - + diff --git a/pages/page.inc b/pages/page.inc index d35dba8..8446062 100644 --- a/pages/page.inc +++ b/pages/page.inc @@ -49,8 +49,8 @@ $systemID = $system === "cloudburst" ? "ynmuc" : ($system === $app["other"]["slu if ($member === null) { global $_SystemName; $_SystemName = $system; - $pageFile = $_SERVER['DOCUMENT_ROOT'] . '/includes/system.inc'; - require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/system.inc'; + $pageFile = $_SERVER['DOCUMENT_ROOT'] . '/includes/fragments/system.inc'; + require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/fragments/system.inc'; } else if ($member === "-" && isset($parts[2])) { if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/includes/system/' . $parts[2] . '.inc')) { global $_SystemPage; @@ -112,8 +112,8 @@ if ($member === null) { global $_MemberName; $_MemberName = $member; - $pageFile = $_SERVER['DOCUMENT_ROOT'] . '/includes/member.inc'; - require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/member.inc'; + $pageFile = $_SERVER['DOCUMENT_ROOT'] . '/includes/fragments/member.inc'; + require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/fragments/member.inc'; } exit; \ No newline at end of file diff --git a/pages/ponytown.inc b/pages/ponytown.inc index d055c9c..7ad38f7 100644 --- a/pages/ponytown.inc +++ b/pages/ponytown.inc @@ -23,7 +23,7 @@ if ($isLowerLoggedIn && $member["_system"] !== $app["other"]["id"]) { $title = ($member["display_name"] ?? $member["name"]) . " · " . $title; -require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; +require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; $member = getMemberWithoutSystem($parts[2]); @@ -255,4 +255,4 @@ $member = getMemberWithoutSystem($parts[2]); - \ No newline at end of file + \ No newline at end of file diff --git a/pages/profiles.inc b/pages/profiles.inc index dd6df4b..41e5222 100644 --- a/pages/profiles.inc +++ b/pages/profiles.inc @@ -1,8 +1,8 @@ @@ -101,4 +101,4 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/profiles.inc'; - + diff --git a/pages/relations.inc b/pages/relations.inc index b66ab25..7a05def 100644 --- a/pages/relations.inc +++ b/pages/relations.inc @@ -1,7 +1,7 @@ @@ -102,4 +102,4 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; - + diff --git a/pages/rules.inc b/pages/rules.inc index ec007df..1238b7d 100644 --- a/pages/rules.inc +++ b/pages/rules.inc @@ -1,7 +1,7 @@ @@ -134,7 +134,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc';

>Rule #:

type="text" placeholder="Rule name" class="form-control" style="margin-bottom:15px;color:white;background:#111;border-color:#222;" name="payload[][name]" value="", ">", $rule["name"]))) ?>"> - +