|
|
|
@ -111,11 +111,30 @@ if (is_file("/etc/pihole/adlists.list")) {
|
|
|
|
|
die("[ERROR] File not found: <code>/etc/pihole/adlists.list</code>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get all URLs starting with "http" or "www" from adlists and re-index array numerically
|
|
|
|
|
$adlistsUrls = array_values(preg_grep("/(^http)|(^www)/i", file($adLists, FILE_IGNORE_NEW_LINES)));
|
|
|
|
|
// Get possible non-standard location of FTL's database
|
|
|
|
|
$FTLsettings = parse_ini_file("/etc/pihole/pihole-FTL.conf");
|
|
|
|
|
if(isset($FTLsettings["GRAVITYDB"])) {
|
|
|
|
|
$gravityDBFile = $FTLsettings["GRAVITYDB"];
|
|
|
|
|
} else {
|
|
|
|
|
$gravityDBFile = "/etc/pihole/gravity.db";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Connect to gravity.db
|
|
|
|
|
try {
|
|
|
|
|
$db = new SQLite3($gravityDBFile, SQLITE3_OPEN_READONLY);
|
|
|
|
|
} catch (Exception $exception) {
|
|
|
|
|
die("[ERROR]: Failed to connect to gravity.db");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get all adlist addresses
|
|
|
|
|
$adlistResults = $db->query("SELECT address FROM vw_adlist");
|
|
|
|
|
$adlistsUrls = array();
|
|
|
|
|
while($row = $adlistResults->fetchArray()) {
|
|
|
|
|
array_push($adlistsUrls, $row[0]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (empty($adlistsUrls))
|
|
|
|
|
die("[ERROR]: There are no adlist URL's found within <code>$adLists</code>");
|
|
|
|
|
die("[ERROR]: There are no adlists configured");
|
|
|
|
|
|
|
|
|
|
// Get total number of blocklists (Including Whitelist, Blacklist & Wildcard lists)
|
|
|
|
|
$adlistsCount = count($adlistsUrls) + 3;
|
|
|
|
|