X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-webpanel.git/blobdiff_plain/41aad10cbe0755aee50f597cb2cadd3029de7e1d..e653740512b00c37a7fc19d9f41889f0844d6c68:/settings/rpc-servers.php 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."); +} +?> +
@@ -116,8 +121,8 @@ you can switch to a secondary server in case the primary server goes down.
Make this the default (primary) server that will be used for connections.
- - + + The hostname or IP address of your UnrealIRCd server. You should use 127.0.0.1 for the same machine.
@@ -171,10 +176,45 @@ you can switch to a secondary server in case the primary server goes down.
+ + + + + +
+ @@ -182,7 +222,10 @@ you can switch to a secondary server in case the primary server goes down.
$e) + $servers = get_config('unrealircd'); + if (!$servers) + $servers = []; + foreach($servers as $name=>$e) { $primary = ""; if (isset($e["default"]) && $e["default"]) @@ -193,9 +236,10 @@ you can switch to a secondary server in case the primary server goes down.
$port = htmlspecialchars($e["port"]); $rpc_user = htmlspecialchars($e["rpc_user"]); $tls_verify_cert = $e["tls_verify_cert"] ? "true" : "false"; - $name = "$name"; + $html_name = "$name"; echo ""; - echo ""; + echo ""; + echo ""; echo ""; echo ""; echo ""; @@ -208,7 +252,7 @@ you can switch to a secondary server in case the primary server goes down.
Display name Hostname Port
".$name.$primary."".$html_name.$primary."".$host."".$port."".$rpc_user."