$value) {
if (trim($value) === "") $_POST[$key] = null;
if (isset($_POST[$key])) $_POST[$key] = str_replace(">", ">", str_replace("<", "<", str_replace("&", "&", substr($_POST[$key], 0, $key === "description" ? 400 : 100))));
}
foreach ($methods as $name => $method) {
if (isset($_POST[$name]) && isset($method["adapter"])) {
$_POST[$name] = exec("cd \"$_SERVER[DOCUMENT_ROOT]/includes/external/addressbook\" && node \"$_SERVER[DOCUMENT_ROOT]/includes/external/addressbook/$method[adapter]\" \"$_POST[$name]\"");
}
}
$contacts[$id] = $_POST;
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/addressbook/contacts.json", json_encode($contacts));
createJob("UpdateContactMethods", [
"contact" => $id
]);
header("Location: /-/contacts");
die();
} else if (isset($_GET["delete"])) {
if (isset($contacts[$_GET["delete"]])) {
unset($contacts[$_GET["delete"]]);
}
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/addressbook/contacts.json", json_encode($contacts));
header("Location: /-/contacts");
die();
}
require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; global $Parsedown;
$cache = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/addressbook/saved.json"), true);
uasort($contacts, function ($a, $b) {
return strnatcasecmp($a["nick"], $b["nick"]);
});
?>