]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blame - api/installation.php
Move some PHP files from ./ to ./inc: common, connection, header, footer
[irc/unrealircd/unrealircd-webpanel.git] / api / installation.php
CommitLineData
78069032
VP
1<?php
2
54b9603c
BM
3/** For handling installation BEFORE any backend and user is configured */
4
c06c1713 5require_once "../inc/common.php";
78069032 6
f0106ef0
VP
7/* only let this happen pre-config */
8if (file_exists("../config/config.php"))
9680dd58 9 die(json_encode(["error" => "Configuration file exists."]));
78069032
VP
10
11if (!isset($_GET) || empty($_GET))
9680dd58 12 die(json_encode(["error" => "Incorrect parameters"]));
78069032 13foreach($_GET as $key => $str)
9680dd58 14 ${$key} = $str;
78069032 15
54b9603c 16if ($method == "sql")
78069032 17{
9680dd58 18 $conn = mysqli_connect($host, $user, $password, $database);
78069032 19
9680dd58
VP
20 // check connection
21 if (mysqli_connect_errno())
22 die(json_encode(["error" => "Failed to connect to MySQL: " . mysqli_connect_error()]));
78069032 23
9680dd58
VP
24 // close connection
25 mysqli_close($conn);
26 die(json_encode(["success" => "SQL Connection successful"]));
78069032 27
54b9603c 28}