Add new Pi-hole diagnostics page.

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2020-05-11 01:00:59 +02:00
committed by XhmikosR
parent 7d409ad76c
commit b0f54f5451
7 changed files with 228 additions and 14 deletions

View File

@@ -413,6 +413,37 @@ if (isset($_GET['getGraphData']) && $auth)
$data = array_merge($data, $result);
}
if (isset($_GET['status']))
{
$results = $db->query('SELECT COUNT(*) FROM message;');
if(!is_bool($results))
$result = array('message_count' => $results->fetchArray()[0]);
else
$result = array();
$data = array_merge($data, $result);
}
if(isset($_GET["messages"]) && $auth)
{
$messages = array();
$results = $db->query('SELECT * FROM message');
while($results !== false && $res = $results->fetchArray(SQLITE3_ASSOC))
{
// Convert string to to UTF-8 encoding to ensure php-json can handle it.
// Furthermore, convert special characters to HTML entities to prevent XSS attacks.
foreach ($res as $key => $value) {
if (is_string($value))
$res[$key] = htmlspecialchars(utf8_encode($value));
}
array_push($messages, $res);
}
$data = array_merge($data, array('messages' => $messages));
}
if(isset($_GET["jsonForceObject"]))
{
echo json_encode($data, JSON_FORCE_OBJECT);