]>
jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - inc/connection.php
6 function connect_to_ircd()
11 $is_api_page = str_contains($_SERVER['SCRIPT_FILENAME'], "/api/") ? true : false;
13 $rpc = null; /* Initialize, mostly for API page failures */
15 $server = get_active_rpc_server();
20 Message
::Fail("No RPC server configured. Go to Settings - RPC Servers.");
23 $host = $config["unrealircd"][$server]["host"];
24 $port = $config["unrealircd"][$server]["port"];
25 $rpc_user = $config["unrealircd"][$server]["rpc_user"];
26 $rpc_password = $config["unrealircd"][$server]["rpc_password"];
27 if (str_starts_with($rpc_password, "secret:"))
28 $rpc_password = secret_decrypt($rpc_password);
29 $tls_verify = $config["unrealircd"][$server]["tls_verify_cert"];
31 if (!$host || !$port || !$rpc_user)
35 die("RPC Server is missing credentials");
38 if ($rpc_password === null)
42 Message
::Fail("Your RPC password in the DB was encrypted with a different key than config/config.php contains.<br>\n".
43 "Either restore your previous config/config.php or start with a fresh database.<br>\n");
49 $rpc = new UnrealIRCd\Connection
52 "$rpc_user:$rpc_password",
53 ["tls_verify" => $tls_verify]
60 Message
::Fail("Unable to connect to UnrealIRCd: ".$e->getMessage() . "<br>".
61 "Verify that the connection details from Settings - RPC Servers match the ones in UnrealIRCd ".
62 "and that UnrealIRCd is up and running");
66 $user = unreal_get_current_user();
69 /* Set issuer for all the RPC commands */
70 $rpc->rpc()->set_issuer($user->username
);