From 885a05be06d0b42835652208c729e5fded451c26 Mon Sep 17 00:00:00 2001 From: Minteck Date: Wed, 8 Feb 2023 22:42:21 +0100 Subject: Updated 9 files, added 2 files and deleted pages/bitset.inc (automated) --- assets/logo/banner.js | 2 +- assets/logo/pacifier.png | Bin 0 -> 2128 bytes includes/bitset.inc | 142 +-------------- includes/flags.json | 23 +++ includes/fullbanner.inc | 7 - includes/metadata.inc | 182 ++++++++++++------- includes/pages.json | 9 - includes/planner.inc | 20 ++- includes/refresh.php | 5 +- pages/bitset.inc | 457 ----------------------------------------------- pages/metadata.inc | 65 +++++-- pages/rules.inc | 10 +- 12 files changed, 217 insertions(+), 705 deletions(-) create mode 100644 assets/logo/pacifier.png create mode 100644 includes/flags.json delete mode 100644 pages/bitset.inc diff --git a/assets/logo/banner.js b/assets/logo/banner.js index 076e8ce..da54b4d 100644 --- a/assets/logo/banner.js +++ b/assets/logo/banner.js @@ -134,7 +134,7 @@ async function refreshBanner(_, french) { ${data['id'] === "unknown" ? (french ? "Espèce : préférez demander" : "Species: best to ask") : ` ${french ? "Espèce :" : "Species:"} - ${data['species'].map(species => ` + ${data['species'].filter(i => i && i['name'] !== "_").map(species => ` ${species['name']} `).join("")}`} ` : ''} diff --git a/assets/logo/pacifier.png b/assets/logo/pacifier.png new file mode 100644 index 0000000..caa54ab Binary files /dev/null and b/assets/logo/pacifier.png differ diff --git a/includes/bitset.inc b/includes/bitset.inc index 5106d80..8e3f5b2 100644 --- a/includes/bitset.inc +++ b/includes/bitset.inc @@ -1,145 +1,5 @@ "earth", - "0010" => "unicorn", - "0011" => "pegasus", - "0100" => "alicorn", - "0101" => "batpony", - "0110" => "crystal", - "0111" => "changeling", - default => null, - }; - - $species2 = match ($species2) { - "0001" => "earth", - "0010" => "unicorn", - "0011" => "pegasus", - "0100" => "alicorn", - "0101" => "batpony", - "0110" => "crystal", - "0111" => "changeling", - default => null, - }; - - $alignment1 = match ($alignment1) { - "0000" => "aroace", - "0001" => "hetero", - "0010" => "homo", - "0011" => "bi", - "0100" => "pan", - default => null, - }; - - $alignment2 = match ($alignment2) { - "0000" => "aroace", - "0001" => "hetero", - "0010" => "homo", - "0011" => "bi", - "0100" => "pan", - default => null, - }; - - $little = 0; - - if (isset($birthData["age"]) && $birthData["age"] !== 0) { - $age = $birthData["age"]; - } else if (isset($birthData["year"]) && $birthData["year"] > 1900) { - $age = (int)date('Y') - $birthData["year"] + (strtotime(date('Y') . "-" . $birthData["date"]) <= time() ? 0 : -1); - } else { - $age = -2; - } - - if ($age <= 10 && $age > 0) { - $little = 2; - } - - if ($age < 16 && $age > 10) { - $little = 3; - } - - return [ - 'shared_memory' => $sharedMemory, - 'median' => false, - 'protector' => $protector, - 'fictive' => $fictive, - 'little' => $little, - 'not_talking' => false, - 'sexual_features' => $sexualFeatures, - 'host' => false, - 'robot' => $robot, - 'magic' => 0, - 'sensitivity' => 0, - 'food' => $food, - 'plush' => $plush, - 'nonverbal' => $nonverbal, - 'less_frequent' => $lessFrequent, - 'age_spells' => false, - 'age_regressor' => false, - 'leader' => $leader, - 'persecutor' => $persecutor, - 'sexually_active' => $sexuallyActive, - 'polyamorous' => [ - 'romantic' => $polyamorous1, - 'sexual' => $polyamorous2 - ], - 'alignment' => [ - 'romantic' => $alignment1, - 'sexual' => $alignment2 - ], - 'species' => array_filter([ - $species1, - $species2 - ], function ($i) { - return isset($i); - }) - ]; -} - function parseMetadata ($metadata) { - if (isset($metadata)) { - if ($metadata["bitset"]) { - $m = parseBitset($metadata["bitset"], $metadata["birth"] ?? []); - $m["sexfriends"] = $metadata["sexfriends"] ?? []; - $m["marefriends"] = $metadata["marefriends"] ?? []; - $m["bitset"] = $metadata["bitset"] ?? 0; - $m["sisters"] = $metadata["sisters"] ?? []; - $m["regression"] = $metadata["regression"] ?? null; - $m["caretakers"] = $metadata["caretakers"] ?? []; - $m["median"] = $metadata["median"] ?? null; - $m["birth"] = $metadata["birth"] ?? null; - $m["heat"] = $metadata["heat"] ?? null; - $m["code"] = $metadata["code"] ?? null; - $m["interest"] = $metadata["interest"] ?? null; - } else { - $m = $metadata; - } - - return $m; - } else { - return $metadata; - } + return $metadata; } \ No newline at end of file diff --git a/includes/flags.json b/includes/flags.json new file mode 100644 index 0000000..1802615 --- /dev/null +++ b/includes/flags.json @@ -0,0 +1,23 @@ +{ + "age_regressor": null, + "age_spells": null, + "host": null, + "not_talking": null, + "median": null, + + "protector": "Protector", + "leader": "Leader", + "fictive": "Fictive", + "sexual_features": "Enable sexual features (for ponies below 16)", + "sexually_active": "Preemptive sexual consent", + "robot": "Robot", + "plush": "Plush", + "polyamorous": { + "romantic": "Polyamorous (romantic)", + "sexual": "Polyamorous (sexual)" + }, + "non_verbal": "Non verbal in real life", + "less_frequent": "Fronts less frequently", + "persecutor": "Persecutor", + "pacifier": "Sleeps with pacifier" +} \ No newline at end of file diff --git a/includes/fullbanner.inc b/includes/fullbanner.inc index b5a05b1..f6741c9 100644 --- a/includes/fullbanner.inc +++ b/includes/fullbanner.inc @@ -13,13 +13,6 @@ - - -
- This member's metadata needs an update. It still uses the old JSON metadata system instead of the new 24bit integer-based system. Contact a developer to request an update. (only administrators can see this; file: /includes/data/metadata/.json) -
- -
. diff --git a/includes/metadata.inc b/includes/metadata.inc index 7bc82ef..d7875c5 100644 --- a/includes/metadata.inc +++ b/includes/metadata.inc @@ -16,47 +16,145 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $member File

+ +
+ +

General information

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

Relationships

+

- Bitset
- · Edit... - "> -

-

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

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

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

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

- Primary interest (keep it short):
+ Age regressed version (local ID)
+ "> +

+ +
+ +

Technical details

+ +

+ Primary interest (keep it short)
">

- Age regressed version (local ID):
- "> + Member code
+ ">

+ +
+ +

Age information

+

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

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

-

- Member code:
- "> -

+ +
+ +

Toggleable flags

+ + $name): if (!is_array($name) && !is_null($name)): ?> +
+ $name2): ?> +
+ + +
+ @@ -66,52 +164,4 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $member
- - - - \ No newline at end of file diff --git a/includes/pages.json b/includes/pages.json index 777351b..985a224 100644 --- a/includes/pages.json +++ b/includes/pages.json @@ -44,15 +44,6 @@ "admin": false, "rail": false }, - "bitset": { - "name": { - "en": "Bitset calculator", - "fr": "Bitset calculator" - }, - "short": "Bitset", - "admin": true, - "rail": true - }, "byfront": { "name": { "en": "Members by last fronted", diff --git a/includes/planner.inc b/includes/planner.inc index 003d3cc..1bc5143 100644 --- a/includes/planner.inc +++ b/includes/planner.inc @@ -13,6 +13,16 @@ global $_PROFILE; $cloudburst = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/planner/ynmuc.json"), true); $raindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/planner/gdapd.json"), true); +function pacifier($id) { + $metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $id . ".json"), true)); + + if ($metadata["pacifier"]) { + return ""; + } + + return ""; +} + foreach ($cloudburst as $id => $day) { foreach ($day as $index => $fronter) { if (is_string($fronter)) { @@ -180,7 +190,7 @@ function day($display, $diff): void { if ($diff < 0) $disabled = true; else $dis Other/unknown/fallback pony - " style="width:24px;"> + " style="width:24px;"> @@ -197,7 +207,7 @@ function day($display, $diff): void { if ($diff < 0) $disabled = true; else $dis Other/unknown/fallback pony - " style="width:24px;"> + " style="width:24px;"> @@ -224,7 +234,7 @@ function day($display, $diff): void { if ($diff < 0) $disabled = true; else $dis Other/unknown/fallback pony - " style="width:24px;"> + " style="width:24px;"> @@ -241,7 +251,7 @@ function day($display, $diff): void { if ($diff < 0) $disabled = true; else $dis Other/unknown/fallback pony - " style="width:24px;"> + " style="width:24px;"> @@ -545,7 +555,7 @@ function day($display, $diff): void { if ($diff < 0) $disabled = true; else $dis } function openEditCofronter(system, id, date) { - let display = formatDate(offset).display; + let display = formatDate(date).display; window.selectedFronting = { system: system === "cloudburst" ? "ynmuc" : "gdapd", diff --git a/includes/refresh.php b/includes/refresh.php index bbf8b01..ecf724a 100644 --- a/includes/refresh.php +++ b/includes/refresh.php @@ -243,8 +243,11 @@ foreach (json_decode(file_get_contents("./data/ynmuc/members.json"), true) as $m echo("Backing up...\n"); -if (date('i') === "00" || date('i') === "01" || date('i') === "02" || date('i') === "03" || date('i') === "04") { +$lastBackup = (int)trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/backup.txt")); + +if (time() - $lastBackup >= 3600) { require_once "./backup.inc"; + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/backup.txt", time()); echo("Backup completed\n"); } else { echo("Backup skipped\n"); diff --git a/pages/bitset.inc b/pages/bitset.inc deleted file mode 100644 index bd8412b..0000000 --- a/pages/bitset.inc +++ /dev/null @@ -1,457 +0,0 @@ - - - - - - - - -
-
-
-

Bitset calculator

-
-
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
1
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
-
-

-
- 0b000000000000000000000000000000000000100000000000, 0x000008000000, 2048 -

- - - - - - - - - - - - - - - - - - - - - -
- Memory polling: - - -
- Food: - - -
- Little/younger: - - -
- Species: - - - - -
- Alignment: - - - -
-

-
-
-
-
-
-
-
-
-
-
-
-
-

- - -
- - diff --git a/pages/metadata.inc b/pages/metadata.inc index 870ca42..5e2c452 100644 --- a/pages/metadata.inc +++ b/pages/metadata.inc @@ -67,6 +67,40 @@ if ($member === null) { $toUpdate["bitset"] = (int)$_GET["bitset"]; } + if (isset($_GET["food"]) && is_numeric($_GET["food"])) { + $toUpdate["food"] = (int)$_GET["food"]; + } + + if (isset($_GET["shared_memory"]) && is_numeric($_GET["shared_memory"])) { + $toUpdate["shared_memory"] = (int)$_GET["shared_memory"]; + } + + if (isset($_GET["species"][0])) { + if (trim($_GET["species"][0]) === "") { + $toUpdate["species"][0] = null; + } else { + $toUpdate["species"][0] = $_GET["species"][0]; + } + } + + if (isset($_GET["species"][1])) { + if (trim($_GET["species"][1]) === "") { + $toUpdate["species"][1] = null; + } else { + $toUpdate["species"][1] = $_GET["species"][1]; + } + } + + $toUpdate["alignment"] = []; + + if (isset($_GET["alignment"]["sexual"])) { + $toUpdate["alignment"]["sexual"] = $_GET["alignment"]["sexual"]; + } + + if (isset($_GET["alignment"]["romantic"])) { + $toUpdate["alignment"]["romantic"] = $_GET["alignment"]["romantic"]; + } + if (isset($_GET["interest"])) { $toUpdate["interest"] = strip_tags($_GET["interest"]); } @@ -122,23 +156,28 @@ if ($member === null) { $toUpdate["code"] = $_GET['membc']; } + $flags = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/flags.json"), true); + + foreach ($flags as $id => $name) if (!is_array($name)) { + if (isset($_GET['flags'][$id])) { + $toUpdate[$id] = true; + } else { + $toUpdate[$id] = false; + } + } else foreach ($name as $id2 => $_) { + if (isset($_GET['flags'][$id][$id2])) { + $toUpdate[$id][$id2] = true; + } else { + $toUpdate[$id][$id2] = false; + } + } + foreach ($toUpdate as $item => $value) { $metadata[$item] = $value; } - $metadata = [ - "bitset" => $metadata["bitset"] ?? 0, - "regression" => $metadata["regression"] ?? null, - "median" => $metadata["median"] ?? null, - "sexfriends" => $metadata["sexfriends"] ?? [], - "marefriends" => $metadata["marefriends"] ?? [], - "sisters" => $metadata["sisters"] ?? [], - "caretakers" => $metadata["caretakers"] ?? [], - "heat" => $metadata["heat"] ?? null, - "birth" => $metadata["birth"] ?? ["age" => 0, "date" => "01-01", "year" => null], - "code" => $metadata["code"] ?? null, - "interest" => $metadata["interest"] ?? null - ]; + if (isset($metadata["bitset"])) unset($metadata["bitset"]); + if (trim($metadata["species"][1]) === "") unset($metadata["species"][1]); file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $memberID . ".json", json_encode($metadata)); diff --git a/pages/rules.inc b/pages/rules.inc index bf156f2..7257cf1 100644 --- a/pages/rules.inc +++ b/pages/rules.inc @@ -29,7 +29,7 @@ if (isset($_POST["updateRules"])) { $_POST["payload"][$index] = $rule; } - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/rules/rules.json", utf8_encode(json_encode($_POST["payload"]))); + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/rules/rules.json", json_encode($_POST["payload"])); header("Location: /-/rules"); die(); @@ -60,7 +60,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc';

- Rule : + Rule : ", ">", $rule["name"])) ?> Unapproved @@ -103,7 +103,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc';
-

text(strip_tags($rule["content"])) ?>

+

text(str_replace("<", "<", str_replace(">", ">", $rule["content"]))) ?>

@@ -132,9 +132,9 @@ 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=""> + 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"]))) ?>"> - +