diff options
Diffstat (limited to 'pages')
-rw-r--r-- | pages/bitset.php | 261 | ||||
-rw-r--r-- | pages/demo.php | 130 | ||||
-rw-r--r-- | pages/emergency.php | 2 | ||||
-rw-r--r-- | pages/fronting.php | 2 | ||||
-rw-r--r-- | pages/home.php | 14 | ||||
-rw-r--r-- | pages/login.php | 42 | ||||
-rw-r--r-- | pages/logout.php | 19 | ||||
-rw-r--r-- | pages/page.php | 53 | ||||
-rw-r--r-- | pages/parser.php | 2 | ||||
-rw-r--r-- | pages/pleasure.php | 18 | ||||
-rw-r--r-- | pages/prefix.php | 2 | ||||
-rw-r--r-- | pages/relations.php | 28 | ||||
-rw-r--r-- | pages/score.php | 26 | ||||
-rw-r--r-- | pages/splitting.php | 57 | ||||
-rw-r--r-- | pages/travelling.php | 81 |
15 files changed, 607 insertions, 130 deletions
diff --git a/pages/bitset.php b/pages/bitset.php index c3cdf0a..11031e2 100644 --- a/pages/bitset.php +++ b/pages/bitset.php @@ -3,7 +3,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; if (!$isLoggedIn) header("Location: /login") and die(); -$title = "Bitset Calculator"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; +$title = "Bitset calculator"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; ?> @@ -11,47 +11,68 @@ $title = "Bitset Calculator"; require_once $_SERVER['DOCUMENT_ROOT'] . '/include <div class="container"> <div id="page-content"> <h2>Bitset Calculator</h2> - <!--<div class="alert alert-dark"> - <details> - <summary>About the 24bit integer-based metadata system</summary> - </details> - </div>--> </div> - <div style="display:grid; grid-template-columns: repeat(24, 1fr);"> - <div data-bs-toggle="tooltip" title="Shared memory access" id="binary-bit-1" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#fa77ef;">0</div> - <div data-bs-toggle="tooltip" title="Shared memory access" id="binary-bit-2" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#fa77ef;">0</div> - <div data-bs-toggle="tooltip" title="Median system" id="binary-bit-3" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color: #a14700;">0</div> - <div data-bs-toggle="tooltip" title="Little/age regressor" id="binary-bit-4" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#b277fa;">0</div> - <div data-bs-toggle="tooltip" title="Little/age regressor" id="binary-bit-5" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#b277fa;">0</div> - <div data-bs-toggle="tooltip" title="Protector" id="binary-bit-6" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#77faab;">0</div> - <div data-bs-toggle="tooltip" title="Fictive" id="binary-bit-7" class="font-monospace tooltip-nohelp text-info" style="text-align: center;cursor: pointer;">0</div> - <div data-bs-toggle="tooltip" title="Not talking" id="binary-bit-8" class="font-monospace tooltip-nohelp text-danger" style="text-align: center;cursor: pointer;">0</div> - <div data-bs-toggle="tooltip" title="Host" id="binary-bit-9" class="font-monospace tooltip-nohelp text-primary" style="text-align: center;cursor: pointer;">0</div> - <div data-bs-toggle="tooltip" title="1st species" id="binary-bit-10" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#fab277;">0</div> - <div data-bs-toggle="tooltip" title="1st species" id="binary-bit-11" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#fab277;">0</div> - <div data-bs-toggle="tooltip" title="1st species" id="binary-bit-12" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#fab277;">0</div> - <div data-bs-toggle="tooltip" title="1st species" id="binary-bit-13" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#fab277;">1</div> - <div data-bs-toggle="tooltip" title="2nd species" id="binary-bit-14" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#faf377;">0</div> - <div data-bs-toggle="tooltip" title="2nd species" id="binary-bit-15" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#faf377;">0</div> - <div data-bs-toggle="tooltip" title="2nd species" id="binary-bit-16" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#faf377;">0</div> - <div data-bs-toggle="tooltip" title="2nd species" id="binary-bit-17" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#faf377;">0</div> - <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-18" class="font-monospace tooltip-nohelp text-muted" style="text-align: center;cursor: pointer;">0</div> - <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-19" class="font-monospace tooltip-nohelp text-muted" style="text-align: center;cursor: pointer;">0</div> - <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-20" class="font-monospace tooltip-nohelp text-muted" style="text-align: center;cursor: pointer;">0</div> - <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-21" class="font-monospace tooltip-nohelp text-muted" style="text-align: center;cursor: pointer;">0</div> - <div data-bs-toggle="tooltip" title="Robot" id="binary-bit-22" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;">0</div> - <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-23" class="font-monospace tooltip-nohelp text-muted" style="text-align: center;cursor: pointer;">0</div> - <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-24" class="font-monospace tooltip-nohelp text-muted" style="text-align: center;cursor: pointer;">0</div> + <div style="display:grid; grid-template-columns: repeat(48, 1fr);"> + <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-1" class="font-monospace tooltip-nohelp text-muted" style="text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-2" class="font-monospace tooltip-nohelp text-muted" style="text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-3" class="font-monospace tooltip-nohelp text-muted" style="text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-4" class="font-monospace tooltip-nohelp text-muted" style="text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-5" class="font-monospace tooltip-nohelp text-muted" style="text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-6" class="font-monospace tooltip-nohelp text-muted" style="text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-7" class="font-monospace tooltip-nohelp text-muted" style="text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-8" class="font-monospace tooltip-nohelp text-muted" style="text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-9" class="font-monospace tooltip-nohelp text-muted" style="text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-10" class="font-monospace tooltip-nohelp text-muted" style="text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-11" class="font-monospace tooltip-nohelp text-muted" style="text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-12" class="font-monospace tooltip-nohelp text-muted" style="text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-13" class="font-monospace tooltip-nohelp text-muted" style="text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-14" class="font-monospace tooltip-nohelp text-muted" style="text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-15" class="font-monospace tooltip-nohelp text-muted" style="text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-16" class="font-monospace tooltip-nohelp text-muted" style="text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Eatable food" id="binary-bit-17" class="font-monospace tooltip-nohelp" style="color: #d63384;text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Eatable food" id="binary-bit-18" class="font-monospace tooltip-nohelp" style="color: #d63384;text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Ability to use magic" id="binary-bit-19" class="font-monospace tooltip-nohelp" style="color: #fd7e14;text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Ability to use magic" id="binary-bit-20" class="font-monospace tooltip-nohelp" style="color: #fd7e14;text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Ability to use magic" id="binary-bit-21" class="font-monospace tooltip-nohelp" style="color: #fd7e14;text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Affectionative or sexual sensitivity" id="binary-bit-22" class="font-monospace tooltip-nohelp" style="color:#ffc107; text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Affectionative or sexual sensitivity" id="binary-bit-23" class="font-monospace tooltip-nohelp" style="color:#ffc107; text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Affectionative or sexual sensitivity" id="binary-bit-24" class="font-monospace tooltip-nohelp" style="color:#ffc107; text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Shared memory access" id="binary-bit-25" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#fa77ef;">0</div> + <div data-bs-toggle="tooltip" title="Shared memory access" id="binary-bit-26" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#fa77ef;">0</div> + <div data-bs-toggle="tooltip" title="Median system" id="binary-bit-27" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color: #a14700;">0</div> + <div data-bs-toggle="tooltip" title="Little/age regressor" id="binary-bit-28" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#b277fa;">0</div> + <div data-bs-toggle="tooltip" title="Little/age regressor" id="binary-bit-29" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#b277fa;">0</div> + <div data-bs-toggle="tooltip" title="Protector" id="binary-bit-30" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#77faab;">0</div> + <div data-bs-toggle="tooltip" title="Fictive" id="binary-bit-31" class="font-monospace tooltip-nohelp text-info" style="text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Not talking" id="binary-bit-32" class="font-monospace tooltip-nohelp text-danger" style="text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Host" id="binary-bit-33" class="font-monospace tooltip-nohelp text-primary" style="text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="1st species" id="binary-bit-34" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#fab277;">0</div> + <div data-bs-toggle="tooltip" title="1st species" id="binary-bit-35" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#fab277;">0</div> + <div data-bs-toggle="tooltip" title="1st species" id="binary-bit-36" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#fab277;">0</div> + <div data-bs-toggle="tooltip" title="1st species" id="binary-bit-37" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#fab277;">1</div> + <div data-bs-toggle="tooltip" title="2nd species" id="binary-bit-38" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#faf377;">0</div> + <div data-bs-toggle="tooltip" title="2nd species" id="binary-bit-39" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#faf377;">0</div> + <div data-bs-toggle="tooltip" title="2nd species" id="binary-bit-40" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#faf377;">0</div> + <div data-bs-toggle="tooltip" title="2nd species" id="binary-bit-41" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#faf377;">0</div> + <div data-bs-toggle="tooltip" title="3rd species" id="binary-bit-42" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#abfa77;">0</div> + <div data-bs-toggle="tooltip" title="3rd species" id="binary-bit-43" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#abfa77;">0</div> + <div data-bs-toggle="tooltip" title="3rd species" id="binary-bit-44" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#abfa77;">0</div> + <div data-bs-toggle="tooltip" title="3rd species" id="binary-bit-45" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#abfa77;">0</div> + <div data-bs-toggle="tooltip" title="Robot" id="binary-bit-46" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Plush" id="binary-bit-47" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#6610f2;">0</div> + <div data-bs-toggle="tooltip" title="Affected by age spells" id="binary-bit-48" class="font-monospace tooltip-nohelp" style="color:#6f42c1;text-align: center;cursor: pointer;">0</div> </div> <br> <p> - <b>Input:</b> <input onchange="calculateInput();" onkeydown="calculateInput()" onkeyup="calculateInput()" value="2048" id="input" type="number" class="form-control" style="width:256px;display: inline-block;color:white;background:#111;border-color:#222;" maxlength="8" max="16777215" min="16777215"><br> - <b>Output:</b> <span id="output-color" style="border-radius:5px;display:inline-block;width:16px;height:16px;background-color:black;vertical-align:middle;"></span> <span style="vertical-align:middle;"><code id="output-bin">0b000000000000100000000000</code>, <code id="output-hex">0x000800</code>, <code id="output-dec">2048</code></span> + <b>Input:</b> <input onchange="calculateInput();" onkeydown="calculateInput()" onkeyup="calculateInput()" value="2048" id="input" type="number" class="form-control" style="width:256px;display: inline-block;color:white;background:#111;border-color:#222;" maxlength="10" max="4294967295" min="2048"><br> + <b>Output:</b> <code id="output-bin">0b000000000000000000000000000000000000100000000000</code>, <code id="output-hex">0x000008000000</code>, <code id="output-dec">2048</code> </p> <script> - for (let i = 1; i <= 24; i++) { + for (let i = 1; i <= 48; i++) { document.getElementById("binary-bit-" + i).onclick = (event) => { let el = event.target; + console.log(el, el.innerText); + if (el.innerText === "0") { el.innerText = "1"; } else { @@ -60,10 +81,10 @@ $title = "Bitset Calculator"; require_once $_SERVER['DOCUMENT_ROOT'] . '/include calculateOutput(); - let binString = ("0".repeat(24 - parseInt(document.getElementById("input").value).toString(2).length)) + parseInt(document.getElementById("input").value).toString(2); + let binString = ("0".repeat(48 - parseInt(document.getElementById("input").value).toString(2).length)) + parseInt(document.getElementById("input").value).toString(2); let bin = binString.split("").map((i) => parseInt(i)); - for (let i = 1; i <= 24; i++) { + for (let i = 1; i <= 48; i++) { if (bin[i - 1]) { document.getElementById("binary-bit-" + i).innerText = bin[i - 1].toString(); } else { @@ -71,16 +92,22 @@ $title = "Bitset Calculator"; require_once $_SERVER['DOCUMENT_ROOT'] . '/include } } - let sharedMemory = parseInt(binString.substring(0, 2), 2); - let median = binString.substring(2, 3) !== "0"; - let little = parseInt(binString.substring(3, 5), 2); - let protector = binString.substring(5, 6) !== "0"; - let fictive = binString.substring(6, 7) !== "0"; - let notTalking = binString.substring(7, 8) !== "0"; - let host = binString.substring(8, 9) !== "0"; - let robot = binString.substring(21, 22) !== "0"; - let species1 = binString.substring(9, 13); - let species2 = binString.substring(13, 17); + let sharedMemory = parseInt(binString.substring(8 + 16, 10 + 16), 2); + let median = binString.substring(10 + 16, 11 + 16) !== "0"; + let little = parseInt(binString.substring(11 + 16, 13 + 16), 2); + let protector = binString.substring(13 + 16, 14 + 16) !== "0"; + let fictive = binString.substring(14 + 16, 15 + 16) !== "0"; + let notTalking = binString.substring(15 + 16, 16 + 16) !== "0"; + let host = binString.substring(16 + 16, 17 + 16) !== "0"; + let robot = binString.substring(29 + 16, 30 + 16) !== "0"; + let plush = binString.substring(30 + 16, 31 + 16) !== "0"; + let species1 = binString.substring(17 + 16, 21 + 16); + let species2 = binString.substring(21 + 16, 25 + 16); + let species3 = binString.substring(25 + 16, 29 + 16); + let food = parseInt(binString.substring(16, 2 + 16), 2); + let magic = parseInt(binString.substring(2 + 16, 5 + 16), 2); + let sensitivity = parseInt(binString.substring(5 + 16, 8 + 16), 2); + let ageSpells = binString.substring(31 + 16, 32 + 16) !== "0"; document.getElementById("value-0").value = sharedMemory; document.getElementById("value-1").value = little; @@ -92,11 +119,17 @@ $title = "Bitset Calculator"; require_once $_SERVER['DOCUMENT_ROOT'] . '/include document.getElementById("value-7").checked = notTalking; document.getElementById("value-8").checked = host; document.getElementById("value-9").checked = robot; + document.getElementById("value-10").checked = plush; + document.getElementById("value-11").value = food; + document.getElementById("value-12").value = magic; + document.getElementById("value-13").value = sensitivity; + document.getElementById("value-14").value = species3; + document.getElementById("value-15").checked = ageSpells; } } function calculateOutput() { - let bin = [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null].map((_, i) => { + let bin = [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null].map((_, i) => { let e = i + 1; return document.getElementById("binary-bit-" + e).innerText; }).join(""); @@ -105,19 +138,18 @@ $title = "Bitset Calculator"; require_once $_SERVER['DOCUMENT_ROOT'] . '/include let hex = parseInt(bin, 2).toString(16); - document.getElementById("output-hex").innerText = "0x" + "0".repeat(6 - hex.length) + hex; - document.getElementById("output-color").style.backgroundColor = "#" + "0".repeat(6 - hex.length) + hex; + document.getElementById("output-hex").innerText = "0x" + "0".repeat(12 - hex.length) + hex; document.getElementById("output-dec").innerText = parseInt(bin, 2).toString(); document.getElementById("input").value = parseInt(bin, 2).toString(); } function calculateInput() { - if (parseInt(document.getElementById("input").value).toString().length > 8) return; + if (parseInt(document.getElementById("input").value).toString().length > 10) return; - let binString = ("0".repeat(24 - parseInt(document.getElementById("input").value).toString(2).length)) + parseInt(document.getElementById("input").value).toString(2); + let binString = ("0".repeat(48 - parseInt(document.getElementById("input").value).toString(2).length)) + parseInt(document.getElementById("input").value).toString(2); let bin = binString.split("").map((i) => parseInt(i)); - for (let i = 1; i <= 24; i++) { + for (let i = 1; i <= 48; i++) { if (bin[i - 1]) { document.getElementById("binary-bit-" + i).innerText = bin[i - 1].toString(); } else { @@ -125,27 +157,39 @@ $title = "Bitset Calculator"; require_once $_SERVER['DOCUMENT_ROOT'] . '/include } } - let sharedMemory = parseInt(binString.substring(0, 2), 2); - let median = binString.substring(2, 3) !== "0"; - let little = parseInt(binString.substring(3, 5), 2); - let protector = binString.substring(5, 6) !== "0"; - let fictive = binString.substring(6, 7) !== "0"; - let notTalking = binString.substring(7, 8) !== "0"; - let host = binString.substring(8, 9) !== "0"; - let robot = binString.substring(21, 22) !== "0"; - let species1 = binString.substring(9, 13); - let species2 = binString.substring(13, 17); + let sharedMemory = parseInt(binString.substring(8 + 16, 10 + 16), 2); + let median = binString.substring(10 + 16, 11 + 16) !== "0"; + let little = parseInt(binString.substring(11 + 16, 13 + 16), 2); + let protector = binString.substring(13 + 16, 14 + 16) !== "0"; + let fictive = binString.substring(14 + 16, 15 + 16) !== "0"; + let notTalking = binString.substring(15 + 16, 16 + 16) !== "0"; + let host = binString.substring(16 + 16, 17 + 16) !== "0"; + let robot = binString.substring(29 + 16, 30 + 16) !== "0"; + let plush = binString.substring(30 + 16, 31 + 16) !== "0"; + let ageSpells = binString.substring(31 + 16, 32 + 16) !== "0"; + let species1 = binString.substring(17 + 16, 21 + 16); + let species2 = binString.substring(21 + 16, 25 + 16); + let species3 = binString.substring(25 + 16, 29 + 16); + let food = parseInt(binString.substring(16, 2 + 16), 2); + let magic = parseInt(binString.substring(2 + 16, 5 + 16), 2); + let sensitivity = parseInt(binString.substring(5 + 16, 8 + 16), 2); document.getElementById("value-0").value = sharedMemory; document.getElementById("value-1").value = little; document.getElementById("value-2").value = species1; document.getElementById("value-3").value = species2; + document.getElementById("value-11").value = food; + document.getElementById("value-12").value = magic; + document.getElementById("value-13").value = sensitivity; document.getElementById("value-4").checked = median; document.getElementById("value-5").checked = protector; document.getElementById("value-6").checked = fictive; document.getElementById("value-7").checked = notTalking; document.getElementById("value-8").checked = host; document.getElementById("value-9").checked = robot; + document.getElementById("value-10").checked = plush; + document.getElementById("value-14").value = species3; + document.getElementById("value-15").checked = ageSpells; calculateOutput(); @@ -163,6 +207,12 @@ $title = "Bitset Calculator"; require_once $_SERVER['DOCUMENT_ROOT'] . '/include let val7 = document.getElementById("value-7").checked; let val8 = document.getElementById("value-8").checked; let val9 = document.getElementById("value-9").checked; + let val10 = document.getElementById("value-10").checked; + let val11 = document.getElementById("value-11").value; + let val12 = document.getElementById("value-12").value; + let val13 = document.getElementById("value-13").value; + let val14 = document.getElementById("value-14").value; + let val15 = document.getElementById("value-15").checked; let val0bin = parseInt(val0).toString(2); val0bin = val0bin.length === 1 ? "0" + val0bin : val0bin; @@ -170,8 +220,18 @@ $title = "Bitset Calculator"; require_once $_SERVER['DOCUMENT_ROOT'] . '/include let val1bin = parseInt(val1).toString(2); val1bin = val1bin.length === 1 ? "0" + val1bin : val1bin; + let val11bin = parseInt(val11).toString(2); + val11bin = val11bin.length === 1 ? "0" + val11bin : val11bin; + + let val12bin = parseInt(val12).toString(2); + val12bin = val12bin.length === 1 ? "00" + val12bin : (val12bin.length === 2 ? "0" + val12bin : val12bin); + + let val13bin = parseInt(val13).toString(2); + val13bin = val13bin.length === 1 ? "00" + val13bin : (val13bin.length === 2 ? "0" + val13bin : val13bin); + let val2bin = val2; let val3bin = val3; + let val14bin = val14; let val4bin = val4 ? "1" : "0"; let val5bin = val5 ? "1" : "0"; @@ -179,14 +239,16 @@ $title = "Bitset Calculator"; require_once $_SERVER['DOCUMENT_ROOT'] . '/include let val7bin = val7 ? "1" : "0"; let val8bin = val8 ? "1" : "0"; let val9bin = val9 ? "1" : "0"; + let val10bin = val10 ? "1" : "0"; + let val15bin = val15 ? "1" : "0"; - let bin = val0bin + val4bin + val1bin + val5bin + val6bin + val7bin + val8bin + val2bin + val3bin + "0000" + val9bin + "00"; + let bin = "0000000000000000" + val11bin + val12bin + val13bin + val0bin + val4bin + val1bin + val5bin + val6bin + val7bin + val8bin + val2bin + val3bin + val14bin + val9bin + val10bin + val15bin; console.log(bin, parseInt(bin, 2)); let parts = bin.split("").map((i) => parseInt(i)); - for (let i = 1; i <= 24; i++) { + for (let i = 1; i <= 48; i++) { if (parts[i - 1]) { document.getElementById("binary-bit-" + i).innerText = parts[i - 1].toString(); } else { @@ -204,6 +266,15 @@ $title = "Bitset Calculator"; require_once $_SERVER['DOCUMENT_ROOT'] . '/include <option value="1">Partial direct access</option> <option value="0" selected>No direct access</option> </select> + <img alt="" src="/assets/icons/visibility-public.svg" style="filter:invert(1);width:24px;margin-left:5px;margin-top:-5px;" title="This information will be shown publicly" data-bs-toggle="tooltip"> + <br> + <b>Food: </b><select class="tooltip-nohelp form-select" style='display:inline-block;width:max-content;color:white;background-color:#111;border-color:#222;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");' id="value-11" onchange="updateFromSelection();"> + <option value="0" selected>Doesn't need to eat</option> + <option value="1">Can't eat fish or meat</option> + <option value="2">Can't eat meat</option> + <option value="3">Can eat everything</option> + </select> + <img alt="" src="/assets/icons/visibility-public.svg" style="filter:invert(1);width:24px;margin-left:5px;margin-top:-5px;" title="This information will be shown publicly" data-bs-toggle="tooltip"> <br> <b>Little/age regressor: </b><select class="tooltip-nohelp form-select" style='display:inline-block;width:max-content;color:white;background-color:#111;border-color:#222;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");' id="value-1" onchange="updateFromSelection();"> <option value="0" selected>None</option> @@ -211,6 +282,7 @@ $title = "Bitset Calculator"; require_once $_SERVER['DOCUMENT_ROOT'] . '/include <option value="3">Younger</option> <option value="1">Age regressor</option> </select> + <img alt="" src="/assets/icons/visibility-public.svg" style="filter:invert(1);width:24px;margin-left:5px;margin-top:-5px;" title="This information will be shown publicly" data-bs-toggle="tooltip"> <br> <b>Species: </b><select class="tooltip-nohelp form-select" style='display:inline-block;width:max-content;color:white;background-color:#111;border-color:#222;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");' id="value-2" onchange="updateFromSelection();"> <option value="0000" disabled>None</option> @@ -230,32 +302,69 @@ $title = "Bitset Calculator"; require_once $_SERVER['DOCUMENT_ROOT'] . '/include <option value="0101">Bat pony</option> <option value="0110">Crystal pony</option> </select> + <select class="tooltip-nohelp form-select" style='display:inline-block;width:max-content;color:white;background-color:#111;border-color:#222;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");' id="value-14" onchange="updateFromSelection();"> + <option value="0000">None</option> + <option value="0001">Earth pony</option> + <option value="0010">Unicorn</option> + <option value="0011">Pegasus</option> + <option value="0100">Alicorn</option> + <option value="0101">Bat pony</option> + <option value="0110">Crystal pony</option> + </select> + <img alt="" src="/assets/icons/visibility-public.svg" style="filter:invert(1);width:24px;margin-left:5px;margin-top:-5px;" title="This information will be shown publicly" data-bs-toggle="tooltip"> + <br> + <b>Magic: </b><select class="tooltip-nohelp form-select" style='display:inline-block;width:max-content;color:white;background-color:#111;border-color:#222;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");' id="value-12" onchange="updateFromSelection();"> + <option value="0" selected>Can't use magic</option> + <option value="1">Can use magic in some cases</option> + <option value="2">Can use magic with a horn</option> + <option value="3">Can use magic with wings</option> + <option value="4">Can use magic with wings and a horn</option> + <option value="5">Can use magic with another part of the body</option> + </select> + <img alt="" src="/assets/icons/visibility-public.svg" style="filter:invert(1);width:24px;margin-left:5px;margin-top:-5px;" title="This information will be shown publicly" data-bs-toggle="tooltip"> + <br> + <b>Sensitivity: </b><select class="tooltip-nohelp form-select" style='display:inline-block;width:max-content;color:white;background-color:#111;border-color:#222;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");' id="value-13" onchange="updateFromSelection();"> + <option value="0" selected>None</option> + <option value="1">May be sensitive</option> + <option value="2">Affectionately sensitive</option> + <option value="3">Sexually sensitive</option> + <option value="4">Sensitive in both ways</option> + </select> + <img alt="" src="/assets/icons/visibility-private.svg" style="filter:invert(1);width:24px;margin-left:5px;margin-top:-5px;" title="This information will remain private" data-bs-toggle="tooltip"> </p> <p> - <label> + <label style="margin-bottom:5px;"> <input type="checkbox" id="value-4" onchange="updateFromSelection();"> Part of a median system - </label><br> - <label> + </label><img alt="" src="/assets/icons/visibility-public.svg" style="filter:invert(1);width:24px;margin-left:5px;margin-top:-5px;" title="This information will be shown publicly" data-bs-toggle="tooltip"><br> + <label style="margin-bottom:5px;"> <input type="checkbox" id="value-5" onchange="updateFromSelection();"> Protector - </label><br> - <label> + </label><img alt="" src="/assets/icons/visibility-public.svg" style="filter:invert(1);width:24px;margin-left:5px;margin-top:-5px;" title="This information will be shown publicly" data-bs-toggle="tooltip"><br> + <label style="margin-bottom:5px;"> <input type="checkbox" id="value-6" onchange="updateFromSelection();"> Fictive - </label><br> - <label> + </label><img alt="" src="/assets/icons/visibility-public.svg" style="filter:invert(1);width:24px;margin-left:5px;margin-top:-5px;" title="This information will be shown publicly" data-bs-toggle="tooltip"><br> + <label style="margin-bottom:5px;"> <input type="checkbox" id="value-7" onchange="updateFromSelection();"> Not talking - </label><br> - <label> + </label><img alt="" src="/assets/icons/visibility-public.svg" style="filter:invert(1);width:24px;margin-left:5px;margin-top:-5px;" title="This information will be shown publicly" data-bs-toggle="tooltip"><br> + <label style="margin-bottom:5px;"> <input type="checkbox" id="value-8" onchange="updateFromSelection();"> Host - </label><br> - <label> + </label><img alt="" src="/assets/icons/visibility-public.svg" style="filter:invert(1);width:24px;margin-left:5px;margin-top:-5px;" title="This information will be shown publicly" data-bs-toggle="tooltip"><br> + <label style="margin-bottom:5px;"> <input type="checkbox" id="value-9" onchange="updateFromSelection();"> Robot - </label> + </label><img alt="" src="/assets/icons/visibility-public.svg" style="filter:invert(1);width:24px;margin-left:5px;margin-top:-5px;" title="This information will be shown publicly" data-bs-toggle="tooltip"><br> + <label style="margin-bottom:5px;"> + <input type="checkbox" id="value-10" onchange="updateFromSelection();"> + Plush + </label><img alt="" src="/assets/icons/visibility-public.svg" style="filter:invert(1);width:24px;margin-left:5px;margin-top:-5px;" title="This information will be shown publicly" data-bs-toggle="tooltip"><br> + <label style="margin-bottom:5px;"> + <input type="checkbox" id="value-15" onchange="updateFromSelection();"> + Affected by age spells + </label><img alt="" src="/assets/icons/visibility-private.svg" style="filter:invert(1);width:24px;margin-left:5px;margin-top:-5px;" title="This information will remain private" data-bs-toggle="tooltip"> </p> </div> diff --git a/pages/demo.php b/pages/demo.php new file mode 100644 index 0000000..a408763 --- /dev/null +++ b/pages/demo.php @@ -0,0 +1,130 @@ +<?php + +$title = "Mode démonstration"; $demoHeader = true; $emergencyHeader = true; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; + +?> + +<script src="/app/banner.js"></script> +<br> +<div class="container"> + <div> + <div id="header" style="text-align: center;"> + <img alt="" src="/assets/uploads/raindrops.png" style="width:128px;"> + <h3>Raindrops System</h3> + <p>Système plural de <?= count(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true)) - 1 ?> poneys</p> + <hr> + </div> + + <div id="list"> + <p>Cliquez sur quelqu'un pour avoir plus d'information sur elle.</p> + <div class="list-group"> + <?php foreach (scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true), "gdapd") as $member): ?> + <a onclick="showMember('<?= $member["id"] ?>');" class="list-group-item"> + <img src="/assets/uploads/pt-<?= $member["name"] ?>.png" style="width:32px;vertical-align: middle;"> + <span style="vertical-align: middle;margin-left: 5px;"> + <b><?= getMiniName($member["display_name"] ?? $member["name"]) ?></b> + <?= $member["_metadata"]["host"] ? "(hôte)" : "" ?><?= $member["_metadata"]["protector"] ? "(protectrice)" : "" ?><?= $member["_metadata"]["little"] === 2 ? (isset($member["_metadata"]["median"]) ? "(" . getMiniName(getSystemMember("gdapd", $member["_metadata"]["median"])["display_name"]) . " régressée en âge)" : "(petite)") : "" ?> + </span> + </a> + <?php endforeach; ?> + </div> + </div> + </div> +</div> + +<div class="modal fade" id="member"> + <div class="modal-dialog modal-xl"> + <div class="modal-content"> + <div class="modal-header"> + <h4 class="modal-title"> + <img id="modal-img" src="/assets/uploads/pt.png" style="width:32px;vertical-align: middle;"> + <span style="vertical-align: middle;"><span id="modal-member">Member</span> · Raindrops System</span> + </h4> + <button type="button" class="btn-close" data-bs-dismiss="modal"></button> + </div> + + <div class="modal-body"> + <?php foreach (scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true), "gdapd") as $member): ?> + <div class="modal-member-content" id="modal-member-content-<?= $member["id"] ?>"> + <script> + <?php global $memberData; $memberData = $member; ?> + window.currentMemberData = JSON.parse(atob(`<?= base64_encode(json_encode(getMemberBannerData($member["id"], "gdapd", true))) ?>`)); + </script> + <div id="member-banner"></div> + <script> + refreshBanner(false, true); + document.getElementById("member-banner").id = ""; + </script> + </div> + <?php endforeach; ?> + </div> + </div> + </div> +</div> + +<style> + .list-group-item { + color: #fff; + background-color: #222; + border: 1px solid rgba(255, 255, 255, .125); + } + + .list-group-item.disabled { + color: #fff; + background-color: #222; + border-color: rgba(255, 255, 255, .125); + opacity: .75; + } + + .list-group-item:hover { + background-color: #252525; + color: #ddd; + } + + .list-group-item:active, .list-group-item:focus { + background-color: #272727; + color: #bbb; + } + + a { + cursor: pointer; + } + + .modal-header { + border-bottom: 1px solid #353738; + } + + .modal-content { + border: 1px solid rgba(255, 255, 255, .2); + background-color: #111; + } + + .btn-close { + filter: invert(1); + } +</style> + +<script> + window._phpMembers = JSON.parse(atob(`<?= base64_encode(json_encode(array_values(scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true), "gdapd")))) ?>`)); + window.members = {}; + + for (let member of window._phpMembers) { + window.members[member.id] = member; + } + + function showMember(id) { + let member = members[id]; + document.getElementById("modal-member").innerText = member["display_name"]; + document.getElementById("modal-img").src = "/assets/uploads/pt-" + member["name"] + ".png"; + + Array.from(document.getElementsByClassName("modal-member-content")).forEach((i) => { + i.style.display = "none"; + }); + document.getElementById("modal-member-content-" + id).style.display = ""; + + let modal = new bootstrap.Modal(document.getElementById('member')); + modal.show(); + } +</script> + +<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'; ?> diff --git a/pages/emergency.php b/pages/emergency.php index 2e38a6f..0405bca 100644 --- a/pages/emergency.php +++ b/pages/emergency.php @@ -4,7 +4,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLogg if (!$isLoggedIn) header("Location: /login") and die(); $emergencyHeader = true; -$title = "Emergency Alert"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; +$title = "Emergency alert"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; ?> diff --git a/pages/fronting.php b/pages/fronting.php index 21d6691..eae0b61 100644 --- a/pages/fronting.php +++ b/pages/fronting.php @@ -1,4 +1,4 @@ -<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; if (!$isLoggedIn) header("Location: /login") and die(); $title = "Front Planner"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; ?> +<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; if (!$isLoggedIn) header("Location: /login") and die(); $title = "Front planner"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; ?> <br> <div class="container"> diff --git a/pages/home.php b/pages/home.php index 2127712..340df44 100644 --- a/pages/home.php +++ b/pages/home.php @@ -9,11 +9,11 @@ </div> <?php endif; ?> - <?php global $isLoggedIn; global $_PROFILE; global $travelling; if ($isLoggedIn): $byColor = getMembersByColor(); ?> + <?php global $travelling; if (!isset($_GET['legacy'])): $byColor = getMembersByColor(); ?> <div style="text-align: center;"> <img alt="" src="/assets/logo/logo.png" style="width:128px;"> <p style="z-index:999;position:relative;background:black;margin: 20px -10px 0 -20px;padding-right:30px;height:32px;text-align: center;display:grid;grid-template-columns: repeat(<?= count($byColor) ?>, 1fr);"> - <?php foreach ($byColor as $member): ?><a data-bs-html="true" class="rainbow-item tooltip-nohelp" title="<b><?= $member["display_name"] ?? $member["name"] ?></b><br><?= ($travelling[$member['id']]["travelling"] ? $member["_system"] === "ynmuc" : $member["_system"] === "gdapd") ? "Raindrops System" : "Cloudburst System" ?>" data-bs-toggle="tooltip" style="overflow: hidden;" href="/<?= $member["_system"] === "gdapd" ? "raindrops" : "cloudburst" ?>/<?= $member["name"] ?>"><img src="/assets/uploads/pt-<?= $member["name"] ?>.png" style="width:32px;height:32px;position:absolute;z-index:99;"></a><?php endforeach; ?> + <?php foreach ($byColor as $member): ?><a data-bs-html="true" class="rainbow-item tooltip-nohelp" title="<b><?= $member["display_name"] ?? $member["name"] ?></b><br><?= ($travelling[$member['id']]["travelling"] ? $member["_system"] === "ynmuc" : $member["_system"] === "gdapd") ? "Raindrops System" : "Cloudburst System" ?>" data-bs-toggle="tooltip" style="overflow: hidden;" href="/<?= $member["name"] ?>"><img src="/assets/uploads/pt-<?= $member["name"] ?>.png" style="width:32px;height:32px;position:absolute;z-index:99;"></a><?php endforeach; ?> </p> <div style="margin-top:-33px;margin-bottom:0;margin-left:-20px;margin-right:20px;height:32px;text-align: center;display:grid;grid-template-columns: repeat(<?= count($byColor) ?>, 1fr);"> <?php foreach ($byColor as $member): ?><div> @@ -21,8 +21,8 @@ </div><?php endforeach; ?> </div> <div style="padding:5px 10px;background:#222;border-bottom-left-radius: 10px;border-bottom-right-radius: 10px;"> - <h2 style="margin-top: 20px;">Cuties and Plurality</h2> - <p>A safe place for <?= count($byColor) ?> ponies in 2 plural systems</p> + <h2 style="margin-top: 20px;">Cold Haze</h2> + <p><?= count($byColor) ?> ponies in 2 plural systems</p> </div> </div> <hr style="border-color:rgba(255, 255, 255, .25);"> @@ -37,7 +37,7 @@ <div> <!-- Main title --> - <span style="font-weight:bold;font-size:24px;">Cuties and Plurality</span><br> + <span style="font-weight:bold;font-size:24px;">Cold Haze</span><br> <!-- Tagline --> <span style="font-weight:normal;font-size:16px;">Just a small safe place for two plural systems</span> @@ -48,8 +48,8 @@ </div> <?php endif; ?> - <?php if ($isLoggedIn && ((int)date('H') >= 20 || (int)date('H') < 6)): ?> - <a href="/emergency" style="text-decoration: none;margin-top:15px;display:block;font-size:24px;"> + <?php global $isLoggedIn; if ($isLoggedIn && ((int)date('H') >= 20 || (int)date('H') < 6)): ?> + <a href="/-/emergency" style="text-decoration: none;margin-top:15px;display:block;"> <div class="alert alert-danger"> <b>Are you in need of help?</b> If you need immediate help from a loved one, you may want to enable the emergency alert by clicking here, even if that will wake up the <?= $_PROFILE['name'] === "Raindrops System" ? "Cloudburst System" : "Raindrops System" ?>. Use it as you need. </div> diff --git a/pages/login.php b/pages/login.php index a6f075f..8611f5f 100644 --- a/pages/login.php +++ b/pages/login.php @@ -1,2 +1,42 @@ <?php -header("Location: /Authentication/Start") and die();
\ No newline at end of file + +$title = "Login"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; + +?> + +<br> +<div class="container"> + <div> + <h2>Login</h2> + <?php global $isLoggedIn; if ($isLoggedIn): ?> + <div class="alert alert-warning"> + <b>You are already logged in.</b> If you want to login to a different account or using a different authentication method, you may do so now. + </div> + <?php endif; ?> + <p>Select how you want to log into Cold Haze.</p> + <div class="row"> + <div class="col-md-6"> + <div class="card" style="margin-bottom:10px;text-align: center;"> + <div class="card-body"> + <img src="https://git.equestria.dev/equestria.dev/design/raw/branch/mane/logo/dark/banner.svg" style="height:48px;" alt=""> + <h4 class="card-title" style="margin-top:15px;">Equestria.dev Private Authentication</h4> + <p>For website administrators, allows to change content and access private information.</p> + <a href="/Authentication/Start" class="btn btn-primary">Continue</a> + </div> + </div> + </div> + <div class="col-md-6"> + <div class="card" style="margin-bottom:10px;text-align: center;"> + <div class="card-body"> + <img src="https://equestria.horse/assets/favicon.png" style="height:48px;" alt=""><img src="/assets/logo/gitlab.svg" style="height:48px;margin-left:15px;" alt=""><img src="/assets/logo/github.svg" style="height:48px;margin-left:15px;" alt=""> + <h4 class="card-title" style="margin-top:15px;">Equestria.horse/GitLab/GitHub</h4> + <p>For website users, allows to view more content, ask questions, and set notes for members.</p> + <a href="#" class="btn btn-primary disabled">Continue</a> + </div> + </div> + </div> + </div> + </div> +</div> + +<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'; ?> diff --git a/pages/logout.php b/pages/logout.php index ea1bfce..0263278 100644 --- a/pages/logout.php +++ b/pages/logout.php @@ -1,16 +1,15 @@ <?php if (isset($_COOKIE['PEH2_SESSION_TOKEN'])) { - if (str_contains($_COOKIE['PEH2_SESSION_TOKEN'], ".") || str_contains($_COOKIE['PEH2_SESSION_TOKEN'], "/")) { - header("Location: /") and die(); - } - if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . str_replace(".", "", str_replace("/", "", $_COOKIE['PEH2_SESSION_TOKEN'])))) { unlink($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . str_replace(".", "", str_replace("/", "", $_COOKIE['PEH2_SESSION_TOKEN']))); - header("Location: /") and die(); - } else { - header("Location: /") and die(); } -} else { - header("Location: /") and die(); -}
\ No newline at end of file +} + +if (isset($_COOKIE['PEH2_USER_TOKEN'])) { + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens-public/" . str_replace(".", "", str_replace("/", "", $_COOKIE['PEH2_USER_TOKEN'])))) { + unlink($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens-public/" . str_replace(".", "", str_replace("/", "", $_COOKIE['PEH2_USER_TOKEN']))); + } +} + +header("Location: /") and die();
\ No newline at end of file diff --git a/pages/page.php b/pages/page.php index 00622b3..a00a0f1 100644 --- a/pages/page.php +++ b/pages/page.php @@ -4,6 +4,28 @@ $travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includ if (!isset($_GET['_']) || trim($_GET['_']) === "") header("Location: /?error=Invalid request") and die(); $parts = explode("/", $_GET['_']); + +if (($parts[0] !== "cloudburst" && $parts[0] !== "raindrops") && (!(count($parts) > 2) || $parts[1] === "-")) { + $namesCloudburst = [...array_map(function ($i) { + return $i['name']; + }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-members.json"), true)), "unknown-cb"]; + $namesRaindrops = [...array_map(function ($i) { + return $i['name']; + }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true)), "unknown-rd"]; + + $parts = explode("/", $_GET['_']); + array_unshift($parts, ""); + $parts = array_values($parts); + + if (in_array($parts[1], $namesCloudburst)) { + $parts[0] = "cloudburst"; + } else if (in_array($parts[1], $namesRaindrops)) { + $parts[0] = "raindrops"; + } + + if ($parts[1] === "unknown-rd" || $parts[1] === "unknown-cb") $parts[1] = "unknown"; +} + $system = $parts[0]; $member = ($parts[1] ?? null) === "" ? null : $parts[1]; @@ -12,12 +34,16 @@ $systemCommonName = $system === "cloudburst" ? "Cloudburst System" : "Raindrops $systemID = $system === "cloudburst" ? "ynmuc" : "gdapd"; if ($member === null) { + global $_SystemName; + $_SystemName = $system; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/system.php'; } else if ($member === "-" && isset($parts[2])) { if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/includes/system/' . $parts[2] . '.php')) { + global $_SystemPage; + $_SystemPage = $parts[2]; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/system/' . $parts[2] . '.php'; } else { - header("Location: /?error=Page not found") and die(); + header("Location: /?error=Page not found: " . $parts[2]) and die(); } } else { $memberFoundInAnotherSystem = false; @@ -44,25 +70,32 @@ if ($member === null) { $memberCommonName = $m['display_name'] ?? $m['name']; $memberID = $m['id']; $system = $systemID === "gdapd" ? "cloudburst" : "raindrops"; - $systemCommonName = $system === "cloudburst" ? "Cloudburst System" : "Raindrops System"; $systemID = $system === "cloudburst" ? "ynmuc" : "gdapd"; } else if ($m['name'] === $member) { $memberFoundInAnotherSystem = true; } } - if ($memberData === null) { - if ($memberFoundInAnotherSystem) { - header("Location: /" . ($systemID === "gdapd" ? "cloudburst" : "raindrops") . "/" . $member) and die(); - } else { - header("Location: /?error=System member not found") and die(); - } + global $_SystemName; + $_SystemName = $system; + + if (str_ends_with($member, "-travelling")) { + header("Location: /" . substr($member, 0, strlen($member) - 11)) and die(); } - if ($travelling[$memberID]['travelling'] && !$traveller) { - header("Location: /" . ($systemID === "gdapd" ? "cloudburst" : "raindrops") . "/" . $member) and die(); + if (isset($parts[2]) && $parts[2] === "-" && isset($parts[3])) { + if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/includes/member/' . $parts[3] . '.php')) { + global $_MemberPage; + $_MemberPage = $parts[3]; + require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/member/' . $parts[3] . '.php'; + } else { + header("Location: /?error=Page not found: " . $parts[3]) and die(); + } + die(); } + global $_MemberName; + $_MemberName = $member; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/member.php'; } diff --git a/pages/parser.php b/pages/parser.php index e3d70b8..cb07179 100644 --- a/pages/parser.php +++ b/pages/parser.php @@ -1,4 +1,4 @@ -<?php $title = "Message Parser"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; ?> +<?php $title = "Message parser"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; ?> <br> <div class="container"> diff --git a/pages/pleasure.php b/pages/pleasure.php new file mode 100644 index 0000000..db63f5a --- /dev/null +++ b/pages/pleasure.php @@ -0,0 +1,18 @@ +<?php + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; +if (!$isLoggedIn) header("Location: /login") and die(); + +$emergencyHeader = true; +$title = "Pleasure alert"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; + +?> + +<br> +<div class="container"> + <div id="page-content"> + <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/pleasure.php"; ?> + </div> +</div> + +<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'; ?> diff --git a/pages/prefix.php b/pages/prefix.php index 721baa5..73e9c8a 100644 --- a/pages/prefix.php +++ b/pages/prefix.php @@ -1,4 +1,4 @@ -<?php $title = "Prefix Generator"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; ?> +<?php $title = "Prefix generator"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; ?> <br> <div class="container"> diff --git a/pages/relations.php b/pages/relations.php index 54fc4ec..d0f5583 100644 --- a/pages/relations.php +++ b/pages/relations.php @@ -5,9 +5,9 @@ <div id="page-content"> <h2>Relations</h2> <?php foreach (scoreOrderGlobal() as $member): if (count($member["_metadata"]["marefriends"]) > 0 || count($member["_metadata"]["sisters"]) > 0): ?> - <div class="relation" style="background-color:rgba(255, 255, 255, .1);margin-bottom:10px;padding:10px;border-radius:10px;display:grid;grid-template-columns: 1fr 2fr 2fr;"> - <a class="relation-intro" style="background-color:rgba(255, 255, 255, .05);border-right:1px solid rgba(255, 255, 255, .1);margin:-10px;padding:10px;border-top-left-radius:10px;border-bottom-left-radius:10px;color: white;text-decoration: none;" href="/<?= $member["_system"] === "gdapd" ? "raindrops" : "cloudburst" ?>/<?= $member["name"] ?>"> - <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $member['name'] . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> + <div class="relation" style="background-color:rgba(255, 255, 255, .1);margin-bottom:10px;padding:10px;border-radius:10px;display:grid;grid-template-columns: 1.5fr <?= $member["_metadata"]["little"] === 2 ? "2fr 2fr 2fr" : "3fr 3fr" ?>;"> + <a class="relation-intro" style="background-color:rgba(255, 255, 255, .05);border-right:1px solid rgba(255, 255, 255, .1);margin:-10px;padding:10px;border-top-left-radius:10px;border-bottom-left-radius:10px;color: white;text-decoration: none;" href="/<?= $member["name"] ?>"> + <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> </a> <div class="relation-item relation-item-marefriends" style="margin-left:10px;padding:0 20px;"> @@ -16,7 +16,7 @@ <span class="text-muted">None</span> <?php else: ?> <?php $index = 0; foreach ($member["_metadata"]["marefriends"] as $id): $mfSystem = explode("/", $id)[0]; $marefriend = getSystemMember(explode("/", $id)[0], explode("/", $id)[1]); ?> - <a class="member-link" href="/<?= $mfSystem === "gdapd" ? "raindrops" : "cloudburst" ?>/<?= $marefriend["name"] ?>"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $marefriend['name'] . ".png") ? "-" . $marefriend['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($marefriend["display_name"] ?? $marefriend["name"]) ?></a><?php if ($index + 2 <= count($member["_metadata"]["marefriends"])) echo('<span class="list-separator-desktop">, </span><span class="list-separator-mobile"><br></span>'); $index++; ?> + <a class="member-link" href="/<?= $marefriend["name"] ?>"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $marefriend['name'] . ".png") ? "-" . $marefriend['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($marefriend["display_name"] ?? $marefriend["name"]) ?></a><?php if ($index + 2 <= count($member["_metadata"]["marefriends"])) echo('<span class="list-separator-desktop">, </span><span class="list-separator-mobile"><br></span>'); $index++; ?> <?php endforeach; ?> <?php endif; ?> </div> @@ -27,10 +27,23 @@ <span class="text-muted">None</span> <?php else: ?> <?php $index = 0; foreach ($member["_metadata"]["sisters"] as $id): $mfSystem = explode("/", $id)[0]; $marefriend = getSystemMember(explode("/", $id)[0], explode("/", $id)[1]); ?> - <a class="member-link" href="/<?= $mfSystem === "gdapd" ? "raindrops" : "cloudburst" ?>/<?= $marefriend["name"] ?>"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $marefriend['name'] . ".png") ? "-" . $marefriend['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($marefriend["display_name"] ?? $marefriend["name"]) ?></a><?php if ($index + 2 <= count($member["_metadata"]["sisters"])) echo('<span class="list-separator-desktop">, </span><span class="list-separator-mobile"><br></span>'); $index++; ?> + <a class="member-link" href="/<?= $marefriend["name"] ?>"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $marefriend['name'] . ".png") ? "-" . $marefriend['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($marefriend["display_name"] ?? $marefriend["name"]) ?></a><?php if ($index + 2 <= count($member["_metadata"]["sisters"])) echo('<span class="list-separator-desktop">, </span><span class="list-separator-mobile"><br></span>'); $index++; ?> <?php endforeach; ?> <?php endif; ?> </div> + + <?php if ($member["_metadata"]["little"] === 2): ?> + <div class="relation-item relation-item-sisters" style="padding:0 20px;"> + <b style="padding-right:5px;">Caretakers:</b><span class="list-separator-mobile"><br></span> + <?php if (count($member["_metadata"]["caretakers"]) === 0): ?> + <span class="text-muted">None</span> + <?php else: ?> + <?php $index = 0; foreach ($member["_metadata"]["caretakers"] as $id): $mfSystem = explode("/", $id)[0]; $marefriend = getSystemMember(explode("/", $id)[0], explode("/", $id)[1]); ?> + <a class="member-link" href="/<?= $marefriend["name"] ?>"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $marefriend['name'] . ".png") ? "-" . $marefriend['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($marefriend["display_name"] ?? $marefriend["name"]) ?></a><?php if ($index + 2 <= count($member["_metadata"]["sisters"])) echo('<span class="list-separator-desktop">, </span><span class="list-separator-mobile"><br></span>'); $index++; ?> + <?php endforeach; ?> + <?php endif; ?> + </div> + <?php endif; ?> </div> <?php endif; endforeach; ?> </div> @@ -57,9 +70,12 @@ margin-top: 10px; margin-left: 0 !important; padding: 10px 0 !important; - text-align: center; } } + + .relation-item { + text-align: center; + } </style> </div> diff --git a/pages/score.php b/pages/score.php index 0074016..96a9d17 100644 --- a/pages/score.php +++ b/pages/score.php @@ -3,7 +3,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; if (!$isLoggedIn) header("Location: /login") and die(); -$title = "Score System Testing"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; +$title = "Score system testing"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; ?> @@ -16,7 +16,7 @@ $title = "Score System Testing"; require_once $_SERVER['DOCUMENT_ROOT'] . '/incl $scores = []; foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true) as $member) { - if ($member["name"] !== "unknown") { + if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && !str_ends_with($member["name"], "-travelling")) { require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.php"; $metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-$member[id]-metadata.json"), true)); $score = calculateScore($metadata, $member["display_name"] ?? $member["name"]); @@ -37,7 +37,7 @@ $title = "Score System Testing"; require_once $_SERVER['DOCUMENT_ROOT'] . '/incl $scores = []; foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true) as $member) { - if ($member["name"] !== "unknown") { + if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && !str_ends_with($member["name"], "-travelling")) { $name = $member["display_name"] ?? $member["name"]; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.php"; $metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-$member[id]-metadata.json"), true)); @@ -45,7 +45,7 @@ $title = "Score System Testing"; require_once $_SERVER['DOCUMENT_ROOT'] . '/incl $scores[] = [ "name" => $name, - "page" => "/raindrops/" . $member["name"], + "page" => "/" . $member["name"], "score" => $score["total"], "details" => $score ]; @@ -73,7 +73,7 @@ $title = "Score System Testing"; require_once $_SERVER['DOCUMENT_ROOT'] . '/incl $scores = []; foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-members.json"), true) as $member) { - if ($member["name"] !== "unknown") { + if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && !str_ends_with($member["name"], "-travelling")) { require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.php"; $metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-$member[id]-metadata.json"), true)); $score = calculateScore($metadata, $member["display_name"] ?? $member["name"]); @@ -94,7 +94,7 @@ $title = "Score System Testing"; require_once $_SERVER['DOCUMENT_ROOT'] . '/incl $scores = []; foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-members.json"), true) as $member) { - if ($member["name"] !== "unknown") { + if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && !str_ends_with($member["name"], "-travelling")) { $name = $member["display_name"] ?? $member["name"]; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.php"; $metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-$member[id]-metadata.json"), true)); @@ -102,7 +102,7 @@ $title = "Score System Testing"; require_once $_SERVER['DOCUMENT_ROOT'] . '/incl $scores[] = [ "name" => $name, - "page" => "/cloudburst/" . $member["name"], + "page" => "/" . $member["name"], "score" => $score["total"], "details" => $score ]; @@ -129,7 +129,7 @@ $title = "Score System Testing"; require_once $_SERVER['DOCUMENT_ROOT'] . '/incl $scores = []; foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true) as $member) { - if ($member["name"] !== "unknown") { + if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && !str_ends_with($member["name"], "-travelling")) { require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.php"; $metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-$member[id]-metadata.json"), true)); $score = calculateScore($metadata, $member["display_name"] ?? $member["name"]); @@ -138,7 +138,7 @@ $title = "Score System Testing"; require_once $_SERVER['DOCUMENT_ROOT'] . '/incl } } foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-members.json"), true) as $member) { - if ($member["name"] !== "unknown") { + if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && !str_ends_with($member["name"], "-travelling")) { require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.php"; $metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-$member[id]-metadata.json"), true)); $score = calculateScore($metadata, $member["display_name"] ?? $member["name"]); @@ -159,7 +159,7 @@ $title = "Score System Testing"; require_once $_SERVER['DOCUMENT_ROOT'] . '/incl $scores = []; foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true) as $member) { - if ($member["name"] !== "unknown") { + if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && !str_ends_with($member["name"], "-travelling")) { $name = $member["display_name"] ?? $member["name"]; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.php"; $metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-$member[id]-metadata.json"), true)); @@ -167,14 +167,14 @@ $title = "Score System Testing"; require_once $_SERVER['DOCUMENT_ROOT'] . '/incl $scores[] = [ "name" => $name, - "page" => "/raindrops/" . $member["name"], + "page" => "/" . $member["name"], "score" => $score["total"], "details" => $score ]; } } foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-members.json"), true) as $member) { - if ($member["name"] !== "unknown") { + if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && !str_ends_with($member["name"], "-travelling")) { $name = $member["display_name"] ?? $member["name"]; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.php"; $metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-$member[id]-metadata.json"), true)); @@ -182,7 +182,7 @@ $title = "Score System Testing"; require_once $_SERVER['DOCUMENT_ROOT'] . '/incl $scores[] = [ "name" => $name, - "page" => "/cloudburst/" . $member["name"], + "page" => "/" . $member["name"], "score" => $score["total"], "details" => $score ]; diff --git a/pages/splitting.php b/pages/splitting.php new file mode 100644 index 0000000..fab97f1 --- /dev/null +++ b/pages/splitting.php @@ -0,0 +1,57 @@ +<?php + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; +if (!$isLoggedIn) header("Location: /login") and die(); + +$title = "Members by splitting date"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; + +?> + +<br> +<div class="container"> + <div id="page-content"> + <h2>Members by splitting date</h2> + <?php $members = scoreOrderGlobal(); uasort($members, function ($a, $b) { + return strtotime($a["created"]) - strtotime($b["created"]); + }); foreach ($members as $member): ?> + <div class="relation" style="background-color:rgba(255, 255, 255, .1);margin-bottom:10px;padding:10px;border-radius:10px;display:grid;grid-template-columns: 1fr 2fr max-content;"> + <a class="relation-intro" style="background-color:rgba(255, 255, 255, .05);border-right:1px solid rgba(255, 255, 255, .1);margin:-10px;padding:10px;border-top-left-radius:10px;border-bottom-left-radius:10px;color: white;display:flex;align-items:center;text-decoration: none;" href="/<?= $member["name"] ?>"> + <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> + </a> + + <div class="relation-item" style="display:flex;align-items:center;margin-left:10px;padding:0 20px;"> + Formed at least <?= timeAgo($member["created"]) ?> (<?= date('l j F Y', strtotime($member["created"])) ?>) + </div> + </div> + <?php endforeach; ?> + </div> + + <style> + @media (max-width: 991px) { + .relation { + grid-template-columns: 1fr !important; + } + + .relation-intro { + text-align: center; + border-bottom-left-radius: 0 !important; + border-top-right-radius: 10px; + border-right: none !important; + border-bottom: 1px solid rgba(255, 255, 255, .1); + } + + .relation-item-marefriends { + margin-top: 20px !important; + } + + .relation-item { + margin-top: 10px; + margin-left: 0 !important; + padding: 10px 0 !important; + text-align: center; + } + } + </style> +</div> + +<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'; ?> diff --git a/pages/travelling.php b/pages/travelling.php index 260ea15..affe92e 100644 --- a/pages/travelling.php +++ b/pages/travelling.php @@ -3,18 +3,93 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; if (!$isLoggedIn) header("Location: /login") and die(); $travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling.json"), true); +$app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true); + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php"; if (isset($_GET['toggleTravel'])) { if (isset($travelling[$_GET['member']])) { + $id = $_GET['member']; + $member = getSystemMember(getMemberSystem($id), $id); + $system = getMemberSystem($id); + $metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system-$id-metadata.json"), true)); + $travellingSystem = $system === "gdapd" ? "ynmuc" : "gdapd"; + if ($travelling[$_GET['member']]["travelling"]) { + $travelling[$_GET['member']]["travelling"] = false; $travelling[$_GET['member']]["history"][count($travelling[$_GET['member']]["history"]) - 1]["end"] = date("c"); + + // Insert code here to run after a travelling member is DELETED. + // $id is the member ID (e.g. rirgf) + // $member is the member object + // $system is the ID of the system the member comes from + // $travellingSystem is the ID of the system the member visits + // $metadata is the ponies.equestria.horse metadata object + // $travellingMember is the member ID from the other system + if (isset($travelling[$_GET['member']]["pluralkit"])) { + $travellingMember = $travelling[$_GET['member']]["pluralkit"]; + $reqOptions = [ + 'http' => [ + 'method' => "DELETE", + 'header' => "Authorization: " . $app["pluralkit"][$travellingSystem === "gdapd" ? "raindrops" : "cloudburst"] + ] + ]; + + $reqContext = stream_context_create($reqOptions); + + // No actual data is received on DELETE, so we don't even bother trying to collect req response; if it fails it will put a warning in the logs anyway. + sleep(1); + file_get_contents("https://api.pluralkit.me/v2/members/$travellingMember", false, $reqContext); + } } else { $travelling[$_GET['member']]["travelling"] = true; + $travelling[$_GET['member']]["pluralkit"] = null; $travelling[$_GET['member']]["history"][] = [ "start" => date("c"), "end" => null ]; + + // Insert code here to run after a travelling member is ADDED. + // $id is the member ID (e.g. rirgf) + // $member is the member + // $system is the system the member comes from + // $metadata is the ponies.equestria.horse metadata + // $travellingMember is unset here + // Store the travelling member ID in $travelling[$id]['pluralkit'] + $reqOptions = [ + 'http' => [ + 'method' => "POST", + 'header' => "Authorization: " . $app["pluralkit"][$travellingSystem === "gdapd" ? "raindrops" : "cloudburst"] . "\r\n" . + "Content-Type: application/json", + 'content' => json_encode([ + 'name' => "$member[name]-travelling", + 'display_name' => $member["display_name"], + 'color' => $member["color"], + 'birthday' => $member["birthday"], + 'created' => $member["created"], + 'pronouns' => $member["pronouns"], + 'avatar_url' => $member["avatar_url"], + 'banner' => $member["banner"], + 'description' => "**This pony is visiting this system from the " . ($system === "gdapd" ? "Raindrops System" : "Cloudburst System") . ". They are not a permanent member of this system**\n\n$member[description]", + 'proxy_tags' => array_map(function ($i) { + $i["prefix"] = "+" . $i['prefix']; + return $i; + }, $member["proxy_tags"]), + 'privacy' => $member["privacy"] + ]) + ] + ]; + + $reqContext = stream_context_create($reqOptions); + + sleep(1); + $member = json_decode(file_get_contents("https://api.pluralkit.me/v2/members", false, $reqContext), true); + + // Member exists? + if (isset($member)) { + $travelling[$id]['pluralkit'] = $member["id"]; + } } } @@ -23,7 +98,7 @@ if (isset($_GET['toggleTravel'])) { die(); } -$title = "System Travelling"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; +$title = "System travels manager"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; global $travelling; ?> @@ -44,8 +119,8 @@ global $travelling; <h2>System Travelling</h2> <?php foreach (scoreOrderGlobal() as $member): ?> <div class="relation" style="background-color:rgba(255, 255, 255, .1);margin-bottom:10px;padding:10px;border-radius:10px;display:grid;grid-template-columns: 1fr 2fr max-content;"> - <a class="relation-intro" style="background-color:rgba(255, 255, 255, .05);border-right:1px solid rgba(255, 255, 255, .1);margin:-10px;padding:10px;border-top-left-radius:10px;border-bottom-left-radius:10px;color: white;display:flex;align-items:center;text-decoration: none;" href="/<?= $member["_system"] === "gdapd" ? "raindrops" : "cloudburst" ?>/<?= $member["name"] ?>"> - <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $member['name'] . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> + <a class="relation-intro" style="background-color:rgba(255, 255, 255, .05);border-right:1px solid rgba(255, 255, 255, .1);margin:-10px;padding:10px;border-top-left-radius:10px;border-bottom-left-radius:10px;color: white;display:flex;align-items:center;text-decoration: none;" href="/<?= $member["name"] ?>"> + <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> </a> <div class="relation-item" style="display:flex;align-items:center;margin-left:10px;padding:0 20px;"> |