- $host = get_config("unrealircd::host");
- $port = get_config("unrealircd::port");
- $rpc_user = get_config("unrealircd::rpc_user");
- $rpc_password = get_config("unrealircd::rpc_password");
+ $is_api_page = str_contains($_SERVER['SCRIPT_FILENAME'], "/api/") ? true : false;
+
+ $options = []; /* options that we pass to new UnrealIRCd\Connection */
+
+ $rpc = null; /* Initialize, mostly for API page failures */
+
+ $server = get_active_rpc_server();
+ if (!$server)
+ {
+ if ($is_api_page)
+ return;
+ Message::Fail("No RPC server configured. Go to Settings - RPC Servers.");
+ die;
+ }
+ $host = $config["unrealircd"][$server]["host"];
+ $port = $config["unrealircd"][$server]["port"];
+ $rpc_user = $config["unrealircd"][$server]["rpc_user"];
+ $rpc_password = $config["unrealircd"][$server]["rpc_password"];