]>
Commit | Line | Data |
---|---|---|
78069032 VP |
1 | <?php |
2 | ||
3 | require_once "../common.php"; | |
4 | ||
5 | $method; | |
6 | ||
7 | if (!isset($_GET) || empty($_GET)) | |
8 | die(json_encode(["error" => "Incorrect parameters"])); | |
9 | foreach($_GET as $key => $str) | |
10 | ${$key} = $str; | |
11 | ||
12 | if ($method == "rpc") | |
13 | { | |
14 | if (isset($tls_verify)) | |
15 | { | |
16 | if ($tls_verify == "false") | |
17 | $tls_verify = false; | |
18 | elseif ($tls_verify == "true") | |
19 | $tls_verify = true; | |
20 | } | |
21 | try { | |
22 | $rpc = new UnrealIRCd\Connection | |
23 | ( | |
24 | "wss://$host:$port", | |
25 | "$user:$password", | |
26 | ["tls_verify" => $tls_verify] | |
27 | ); | |
28 | } | |
29 | catch (Exception $e) | |
30 | { | |
31 | die(json_encode(["error" => "Unable to connect to UnrealIRCd: ".$e->getMessage()])); | |
32 | } | |
33 | die(json_encode(["success" => "Successfully connected"])); | |
34 | } | |
35 | elseif ($method == "sql") | |
36 | { | |
37 | $conn = mysqli_connect($host, $user, $password, $database); | |
38 | ||
39 | // check connection | |
40 | if (mysqli_connect_errno()) | |
41 | die(json_encode(["error" => "Failed to connect to MySQL: " . mysqli_connect_error()])); | |
42 | ||
43 | // close connection | |
44 | mysqli_close($conn); | |
45 | die(json_encode(["success" => "SQL Connection successful"])); | |
46 | ||
47 | } |