mirror of
https://github.com/pi-hole/web.git
synced 2024-12-06 19:36:21 +01:00
Merge pull request #2163 from pi-hole/speed/api
Improve loop for getAllQueries from FTL's memory
This commit is contained in:
+27
-12
@@ -306,19 +306,34 @@ if (isset($_GET['getAllQueries']) && $auth) {
|
||||
if (array_key_exists("FTLnotrunning", $return)) {
|
||||
$data = array("FTLnotrunning" => true);
|
||||
} else {
|
||||
$allQueries = array();
|
||||
foreach ($return as $line) {
|
||||
$tmp = str_getcsv($line," ");
|
||||
// UTF-8 encode domain
|
||||
$tmp[2] = utf8_encode(str_replace("~"," ",$tmp[2]));
|
||||
// UTF-8 encode client host name
|
||||
$tmp[3] = utf8_encode($tmp[3]);
|
||||
array_push($allQueries,$tmp);
|
||||
}
|
||||
// Start the JSON string
|
||||
echo '{"data":[';
|
||||
$first = true;
|
||||
|
||||
$result = array('data' => $allQueries);
|
||||
$data = array_merge($data, $result);
|
||||
}
|
||||
foreach($return as $line) {
|
||||
|
||||
// Insert a comma before the next record (except on the first one)
|
||||
if (!$first) {
|
||||
echo ",";
|
||||
} else {
|
||||
$first = false;
|
||||
}
|
||||
|
||||
$row = str_getcsv($line," ");
|
||||
// UTF-8 encode domain
|
||||
$domain = utf8_encode(str_replace("~"," ",$row[2]));
|
||||
// UTF-8 encode client host name
|
||||
$client = utf8_encode($row[3]);
|
||||
|
||||
// Insert into array and output it in JSON format
|
||||
// array: time type domain client status dnssecStatus reply response_time CNAMEDomain regexID upstream destination EDE
|
||||
echo json_encode([$row[0], $row[1], $domain, $client, $row[4], $row[5], $row[6], $row[7], $row[8], $row[9], $row[10], $row[11]]);
|
||||
}
|
||||
// Finish the JSON string
|
||||
echo ']}';
|
||||
// exit at the end
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET["recentBlocked"]) && $auth) {
|
||||
|
||||
Reference in New Issue
Block a user