From 30303a3ad0d0f31d93c25f42bfd10d70e8277b72 Mon Sep 17 00:00:00 2001 From: Minteck Date: Sat, 10 Dec 2022 22:27:08 +0100 Subject: Update --- pages/metadata.inc | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 pages/metadata.inc (limited to 'pages/metadata.inc') diff --git a/pages/metadata.inc b/pages/metadata.inc new file mode 100644 index 0000000..ecb8aba --- /dev/null +++ b/pages/metadata.inc @@ -0,0 +1,123 @@ + "01-01", + "year" => null, + "age" => 0 + ]; + + if (isset($_GET["age"]) && is_numeric($_GET["age"])) { + $toUpdate["birth"]["age"] = (int)$_GET["age"]; + } + + if (isset($_GET["birth"]) && trim($_GET['birth']) !== "" && !!preg_match("/^\d{4}-\d{2}-\d{2}$/m", $_GET['birth'])) { + $toUpdate["birth"]["year"] = (int)substr($_GET["birth"],0, 4); + $toUpdate["birth"]["date"] = substr($_GET["birth"],5); + } + + foreach ($toUpdate as $item => $value) { + $metadata[$item] = $value; + } + + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $memberID . ".json", json_encode($metadata)); + + header("Location: /" . $_GET['_']); + } else { + require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/metadata.inc'; + } +} + +exit; \ No newline at end of file -- cgit