]>
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 $options = []; /* options that we pass to new UnrealIRCd\Connection */
15 $rpc = null; /* Initialize, mostly for API page failures */
17 $server = get_active_rpc_server();
22 Message
::Fail("No RPC server configured. Go to Settings - RPC Servers.");
25 $host = $config["unrealircd"][$server]["host"];
26 $port = $config["unrealircd"][$server]["port"];
27 $rpc_user = $config["unrealircd"][$server]["rpc_user"];
28 $rpc_password = $config["unrealircd"][$server]["rpc_password"];
29 if (str_starts_with($rpc_password, "secret:"))
30 $rpc_password = secret_decrypt($rpc_password);
31 if (isset($config["unrealircd"][$server]["tls_verify_cert"]))
32 $options["tls_verify"] = $config["unrealircd"][$server]["tls_verify_cert"];
34 if (!$host || !$port || !$rpc_user)
38 die("RPC Server is missing credentials");
41 if ($rpc_password === null)
45 Message
::Fail("Your RPC password in the DB was encrypted with a different key than config/config.php contains.<br>\n".
46 "Either restore your previous config/config.php or start with a fresh database.<br>\n");
50 $user = unreal_get_current_user();
53 /* Set issuer for all the RPC commands */
54 $options['issuer'] = $user->username
;
59 $rpc = new UnrealIRCd\Connection
62 "$rpc_user:$rpc_password",
70 Message
::Fail("Unable to connect to UnrealIRCd: ".$e->getMessage() . "<br>".
71 "Verify that the connection details from Settings - RPC Servers match the ones in UnrealIRCd ".
72 "and that UnrealIRCd is up and running");