]>
Commit | Line | Data |
---|---|---|
54b9603c BM |
1 | <?php |
2 | ||
c06c1713 | 3 | require_once "../inc/common.php"; |
54b9603c | 4 | |
055ded3a | 5 | if (!isset($_POST) || empty($_POST)) |
54b9603c BM |
6 | die(json_encode(["error" => "Incorrect parameters"])); |
7 | ||
41aad10c BM |
8 | foreach(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 | } | |
54b9603c | 14 | |
41aad10c BM |
15 | if ($tls_verify == "false") |
16 | $tls_verify = false; | |
17 | elseif ($tls_verify == "true") | |
18 | $tls_verify = true; | |
19 | ||
20 | if (($edit_existing) && ($password == "****************")) | |
54b9603c | 21 | { |
41aad10c BM |
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 | } | |
54b9603c | 31 | } |
41aad10c BM |
32 | |
33 | try { | |
34 | $rpc = new UnrealIRCd\Connection | |
35 | ( | |
36 | "wss://$host:$port", | |
37 | "$user:$password", | |
38 | ["tls_verify" => $tls_verify] | |
39 | ); | |
40 | } | |
41 | catch (Exception $e) | |
42 | { | |
43 | die(json_encode(["error" => "Unable to connect to UnrealIRCd: ".$e->getMessage()])); | |
44 | } | |
45 | ||
46 | die(json_encode(["success" => "Successfully connected"])); |