Calling FTL API directly from PHP

- Using constants for default values
- Remove unnecessary variable
- Replace `piholeStatusAPI()` with a call to FTL API
- Transfer `api.php?status` code from `api.php` to `api_FTL.php`
- Change `piholeStatus()` to use FTL info (no need to use `pihole`).

Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
This commit is contained in:
RD WebDesign
2022-02-16 02:40:37 -03:00
parent 652bb23052
commit 84d31da743
5 changed files with 419 additions and 479 deletions

View File

@@ -13,14 +13,10 @@ require_once("scripts/pi-hole/php/database.php");
require_once("scripts/pi-hole/php/auth.php");
check_cors();
$FTL_IP = "127.0.0.1";
$data = array();
// Common API functions
if (isset($_GET['status'])) {
$data = array_merge($data, array("status" => piholeStatusAPI()));
} elseif (isset($_GET['enable']) && $auth) {
if (isset($_GET['enable']) && $auth) {
if(isset($_GET["auth"]))
{
if($_GET["auth"] !== $pwhash)