X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-webpanel.git/blobdiff_plain/41aad10cbe0755aee50f597cb2cadd3029de7e1d..e653740512b00c37a7fc19d9f41889f0844d6c68:/settings/rpc-servers.php?ds=sidebyside
diff --git a/settings/rpc-servers.php b/settings/rpc-servers.php
index 0840eb0..6ab87ba 100644
--- a/settings/rpc-servers.php
+++ b/settings/rpc-servers.php
@@ -2,6 +2,18 @@
require_once "../inc/common.php";
require_once "../inc/header.php";
+if (isset($_POST['do_del_server']))
+{
+ $server = $_POST['del_server_name'] ?? null;
+ if (isset($config["unrealircd"][$server]))
+ {
+ unset($config["unrealircd"][$server]);
+ set_at_least_one_default_rpc_server();
+ write_config("unrealircd");
+ } else {
+ Message::Fail("Delete failed: could not find server");
+ }
+} else
if (isset($_POST['do_add_server']))
{
$opts = (object)$_POST;
@@ -21,7 +33,7 @@ if (isset($_POST['do_add_server']))
$new_properties = [
"rpc_user" => $opts->rpc_user,
"rpc_password" => $opts->rpc_password,
- "host"=>$opts->rpc_iphost,
+ "host"=>$opts->rpc_host,
"port"=>$opts->rpc_port,
"tls_verify_cert"=>isset($opts->rpc_tls_verify_cert)?true:false,
"default"=>isset($opts->rpc_default)?true:false,
@@ -34,8 +46,10 @@ if (isset($_POST['do_add_server']))
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]);
+ // name change? unset the old one
+ if ($opts->edit_existing != $opts->rpc_displayname)
+ unset($config["unrealircd"][$opts->edit_existing]);
+ // set new properties
$config["unrealircd"][$opts->rpc_displayname] = $new_properties;
} else {
// Add new server
@@ -44,32 +58,14 @@ if (isset($_POST['do_add_server']))
}
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)
- {
- /* Make first server in the list the default */
- foreach ($config["unrealircd"] as $name=>$e)
- {
- $config["unrealircd"][$name]["default"] = true;
- break;
- }
- }
- }
+ set_default_rpc_server($opts->rpc_displayname);
+ else
+ set_at_least_one_default_rpc_server();
/* And write the new config */
write_config();
- // TODO: change this message if it's the first server added? tell them to browse around?
- Message::Success("RPC Server successfully added.");
+
+ Message::Success("RPC Server successfully ". (empty($opts->edit_existing) ? "added" : "modified").".");
}
?>
@@ -80,6 +76,15 @@ You normally only need one server, but it can be useful to have multiple servers
you can switch to a secondary server in case the primary server goes down.
+the UnrealIRCd instructions ".
+ "and then click Add Server below.");
+}
+?>
+
127.0.0.1
for the same machine.