]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | ||
3 | require_once "../inc/common.php"; | |
4 | ||
5 | if (!isset($_POST) || empty($_POST)) | |
6 | die(json_encode(["error" => "Incorrect parameters"])); | |
7 | ||
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 | } | |
14 | ||
15 | if ($tls_verify == "false") | |
16 | $tls_verify = false; | |
17 | elseif ($tls_verify == "true") | |
18 | $tls_verify = true; | |
19 | ||
20 | if (($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 | ||
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"])); |