- if (!empty($opts->edit_existing))
- {
- // Change existing server
- if (!isset($config["unrealircd"][$opts->edit_existing]))
- die("Editing a server that does not exist!?"); // not very graceful, isn't it?
- if ($new_properties["rpc_password"] == "****************")
- $new_properties["rpc_password"] = $config["unrealircd"][$opts->edit_existing]["rpc_password"];
- // we unset because there could be a rename
- unset($config["unrealircd"][$opts->edit_existing]);
- $config["unrealircd"][$opts->rpc_displayname] = $new_properties;
- } else {
- // Add new server
- $config["unrealircd"][$opts->rpc_displayname] = $new_properties;
- // TODO: encrypt pwd ;)
- }
-
- if ($new_properties["default"])
- {
- /* Mark all other servers as non-default */
- foreach ($config["unrealircd"] as $name=>$e)
- if ($name != $opts->rpc_displayname)
- $config["unrealircd"][$name]["default"] = false;
- } else {
- /* Ensure at least 1 server is default */
- $has_default_server = false;
- foreach ($config["unrealircd"] as $name=>$e)
- if ($e["default"])
- $has_default_server = true;
- if (!$has_default_server)