]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blame - api/test_rpc_server.php
Make $pages[] not have a string value in the end but an array with ["url"=>...]
[irc/unrealircd/unrealircd-webpanel.git] / api / test_rpc_server.php
CommitLineData
54b9603c
BM
1<?php
2
c06c1713 3require_once "../inc/common.php";
54b9603c 4
055ded3a 5if (!isset($_POST) || empty($_POST))
54b9603c
BM
6 die(json_encode(["error" => "Incorrect parameters"]));
7
41aad10c
BM
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}
54b9603c 14
41aad10c
BM
15if ($tls_verify == "false")
16 $tls_verify = false;
17elseif ($tls_verify == "true")
18 $tls_verify = true;
19
20if (($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
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"]));