Skip to content

Commit

Permalink
Add a default option for PORTFILE
Browse files Browse the repository at this point in the history
Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
  • Loading branch information
rdwebdesign committed Jun 8, 2022
1 parent e2d52c7 commit 1317528
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions scripts/pi-hole/php/FTL.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
const DEFAULT_FTLCONFFILE = "/etc/pihole/pihole-FTL.conf";
const DEFAULT_FTL_IP = "127.0.0.1";
const DEFAULT_FTL_PORT = 4711;
const DEFAULT_FTL_PORTFILE = "/run/pihole-FTL.port";

function piholeFTLConfig($piholeFTLConfFile = DEFAULT_FTLCONFFILE, $force = false) {
static $piholeFTLConfig;
Expand All @@ -30,7 +31,7 @@ function connectFTL($address, $port) {
if ($address == DEFAULT_FTL_IP) {
$config = piholeFTLConfig();
// Read port
$portfileName = isset($config['PORTFILE']) ? $config['PORTFILE'] : '';
$portfileName = isset($config['PORTFILE']) ? $config['PORTFILE'] : DEFAULT_FTL_PORTFILE;
if ($portfileName != '') {
$portfileContents = file_get_contents($portfileName);
if (is_numeric($portfileContents)) {
Expand Down Expand Up @@ -79,9 +80,9 @@ function getResponseFTL($socket) {
}

function disconnectFTL($socket) {
if (is_resource($socket)) {
fclose($socket);
}
if (is_resource($socket)) {
fclose($socket);
}
}

function callFTLAPI($request, $FTL_IP = DEFAULT_FTL_IP, $port = DEFAULT_FTL_PORT) {
Expand Down

0 comments on commit 1317528

Please sign in to comment.