File FTL.php-improve-get-response-ftl.patch of Package pihole-admin-lte
Index: AdminLTE-5.18/scripts/pi-hole/php/FTL.php
===================================================================
--- AdminLTE-5.18.orig/scripts/pi-hole/php/FTL.php
+++ AdminLTE-5.18/scripts/pi-hole/php/FTL.php
@@ -47,12 +47,24 @@ function connectFTL()
return fsockopen($address, $port, $errno, $errstr, 1.0);
}
+/**
+ * Sends a request to pihole-FTL, or send to 127.0.0.1 and the port
+ * from PORTFILE specified in config.
+ *
+ * @param $requestin String to send to FTL.
+ */
function sendRequestFTL($requestin, $socket)
{
$request = '>'.$requestin;
fwrite($socket, $request) or exit('{"error":"Could not send data to server"}');
}
+/**
+ * Reads a response from pihole-FTL, or read from 127.0.0.1 and the port
+ * from PORTFILE specified in config.
+ *
+ * Returns response as string per line in array.
+ */
function getResponseFTL($socket)
{
$response = array();