diff --git a/api_db.php b/api_db.php index 5195114e..d4f84df7 100644 --- a/api_db.php +++ b/api_db.php @@ -8,6 +8,7 @@ $api = true; header('Content-type: application/json'); +require("scripts/pi-hole/php/database.php"); require("scripts/pi-hole/php/password.php"); require("scripts/pi-hole/php/auth.php"); check_cors(); @@ -48,7 +49,7 @@ function resolveHostname($clientip, $printIP) return $clientname; } -// Get posible non-standard location of FTL's database +// Get possible non-standard location of FTL's database $FTLsettings = parse_ini_file("/etc/pihole/pihole-FTL.conf"); if(isset($FTLsettings["DBFILE"])) { @@ -62,37 +63,7 @@ else // Needs package php5-sqlite, e.g. // sudo apt-get install php5-sqlite -function SQLite3_connect($trytoreconnect) -{ - global $DBFILE; - try - { - // connect to database - return new SQLite3($DBFILE, SQLITE3_OPEN_READONLY); - } - catch (Exception $exception) - { - // sqlite3 throws an exception when it is unable to connect, try to reconnect after 3 seconds - if($trytoreconnect) - { - sleep(3); - $db = SQLite3_connect(false); - } - } -} - -if(strlen($DBFILE) > 0) -{ - $db = SQLite3_connect(true); -} -else -{ - die("No database available"); -} -if(!$db) -{ - die("Error connecting to database"); -} +$db = SQLite3_connect($DBFILE); if(isset($_GET["network"]) && $auth) { @@ -100,7 +71,16 @@ if(isset($_GET["network"]) && $auth) $results = $db->query('SELECT * FROM network'); while($results !== false && $res = $results->fetchArray(SQLITE3_ASSOC)) + { + $id = $res["id"]; + // Empty array for holding the IP addresses + $res["ip"] = array(); + // Get IP addresses for this device + $network_addresses = $db->query("SELECT ip FROM network_addresses WHERE network_id = $id ORDER BY lastSeen DESC"); + while($network_addresses !== false && $ip = $network_addresses->fetchArray(SQLITE3_ASSOC)) + array_push($res["ip"],$ip["ip"]); array_push($network, $res); + } $data = array_merge($data, array('network' => $network)); } diff --git a/list.php b/list.php index 5cbff9c7..7e9d5f62 100644 --- a/list.php +++ b/list.php @@ -35,13 +35,9 @@ function getFullName() {
- - - -
@@ -53,7 +49,7 @@ function getFullName() {
- +
@@ -1133,7 +1145,12 @@ if (isset($_GET['tab']) && in_array($_GET['tab'], array("sysadmin", "blocklists"
+ Whitelist (exact) +
+
+
+
+
+
@@ -1319,9 +1346,7 @@ if (isset($_GET['tab']) && in_array($_GET['tab'], array("sysadmin", "blocklists"
- - - +
@@ -1347,9 +1372,8 @@ if (isset($_GET['tab']) && in_array($_GET['tab'], array("sysadmin", "blocklists" -
- - + +
diff --git a/style/pi-hole.css b/style/pi-hole.css index 660a9bc9..1f47baa7 100644 --- a/style/pi-hole.css +++ b/style/pi-hole.css @@ -24,6 +24,23 @@ .skin-blue .list-group-item:hover { background: #ddd; } + +.skin-blue .not-used { + background: #eee; +} + +.skin-blue .not-used:hover { + background: #c5c5c95; +} + +.skin-blue .used { + background: #fff; +} + +.skin-blue .used:hover { + background: #ddd; +} + @-webkit-keyframes Pulse{ from {color:#630030;-webkit-text-shadow:0 0 2px transparent;} 50% {color:#e33100;-webkit-text-shadow:0 0 5px #e33100;}