"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); } if (isset($_GET["membc"])) { $toUpdate["code"] = $_GET['membc']; } 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 ]; 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;