]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blame_incremental - api/installation2.php
Add Settings - RPC Servers (start of multi-server work).
[irc/unrealircd/unrealircd-webpanel.git] / api / installation2.php
... / ...
CommitLineData
1<?php
2
3require_once "../inc/common.php";
4
5if (!isset($_POST) || empty($_POST))
6 die(json_encode(["error" => "Incorrect parameters"]));
7
8foreach(array("tls_verify","host","port","user","password","edit_existing") as $k)
9{
10 if (!isset($_POST[$k]))
11 die("MISSING: $k");
12 ${$k} = $_POST[$k];
13}
14
15if ($tls_verify == "false")
16 $tls_verify = false;
17elseif ($tls_verify == "true")
18 $tls_verify = true;
19
20if (($edit_existing) && ($password == "****************"))
21{
22 /* If editing existing and password unchanged,
23 * try to look up existing password.
24 */
25 if (isset($config["unrealircd"][$edit_existing]))
26 {
27 $password = $config["unrealircd"][$edit_existing]["rpc_password"];
28 if (str_starts_with($password, "secret:"))
29 $password = secret_decrypt($password);
30 }
31}
32
33try {
34 $rpc = new UnrealIRCd\Connection
35 (
36 "wss://$host:$port",
37 "$user:$password",
38 ["tls_verify" => $tls_verify]
39 );
40}
41catch (Exception $e)
42{
43 die(json_encode(["error" => "Unable to connect to UnrealIRCd: ".$e->getMessage()]));
44}
45
46die(json_encode(["success" => "Successfully connected"]));