forked from schrauger/VPS-Debug-Site
/
db.php
43 lines (33 loc) · 1.14 KB
/
db.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
include('head.php');
require_once('config.php'); // database credentials
try {
// Create connection
$conn = new mysqli($servername, $username, $password);
} catch (mysqli_sql_exception $e) {
header('HTTP/1.1 500 Internal Server Error');
die("Connection failed: " . $e->errorMessage());
}
// Check connection
if ($conn->connect_error) {
header('HTTP/1.1 500 Internal Server Error');
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT VARIABLE_VALUE as 'message' FROM information_schema.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'";
if (!$result = $conn->query($sql)) {
// echo "Error";
printf("<span class=\"output broken\"><i class=\"material-icons\">warning</i>Error Message: %s\n </span>", $conn->error());
}
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<span class=\"output running\"><i class=\"material-icons\">done</i>wsrep_cluster_size: " . $row["message"] . "</span>";
}
} else {
echo "0 results";
}
echo "<br />" . $sql;
$conn->close();
?>
<?php include('links.php'); ?>
<?php include('footer.php'); ?>