Added contant adblock_listpath

This commit is contained in:
billz 2020-03-27 14:32:27 +00:00
parent ab68168951
commit 46213b90b0
3 changed files with 12 additions and 4 deletions

View file

@ -11,6 +11,8 @@ define('RASPI_CACHE_PATH', sys_get_temp_dir() . '/raspap');
// These are typical for default RPi installs. Modify if needed. // These are typical for default RPi installs. Modify if needed.
define('RASPI_DNSMASQ_CONFIG', '/etc/dnsmasq.conf'); define('RASPI_DNSMASQ_CONFIG', '/etc/dnsmasq.conf');
define('RASPI_DNSMASQ_LEASES', '/var/lib/misc/dnsmasq.leases'); define('RASPI_DNSMASQ_LEASES', '/var/lib/misc/dnsmasq.leases');
define('RASPI_ADBLOCK_LISTPATH', '/etc/raspap/adblock/');
define('RASPI_ADBLOCK_CONFIG', '/etc/dnsmasq.d/090_adblock.conf');
define('RASPI_HOSTAPD_CONFIG', '/etc/hostapd/hostapd.conf'); define('RASPI_HOSTAPD_CONFIG', '/etc/hostapd/hostapd.conf');
define('RASPI_DHCPCD_CONFIG', '/etc/dhcpcd.conf'); define('RASPI_DHCPCD_CONFIG', '/etc/dhcpcd.conf');
define('RASPI_WPA_SUPPLICANT_CONFIG', '/etc/wpa_supplicant/wpa_supplicant.conf'); define('RASPI_WPA_SUPPLICANT_CONFIG', '/etc/wpa_supplicant/wpa_supplicant.conf');

View file

@ -16,18 +16,21 @@ function DisplayAdBlockConfig()
if (!RASPI_MONITOR_ENABLED) { if (!RASPI_MONITOR_ENABLED) {
if (isset($_POST['saveadblocksettings'])) { if (isset($_POST['saveadblocksettings'])) {
if ($_POST['adblock-enable'] == "1") { if ($_POST['adblock-enable'] == "1") {
$arrConf['conf-file'] = '/etc/dnsmasq.d/domains.txt'; $arrConf['conf-file'] = RASPI_ADBLOCK_LISTPATH .'domains.txt';
$arrConf['addn-hosts'] = '/etc/dnsmasq.d/hostnames.txt'; $arrConf['addn-hosts'] = RASPI_ADBLOCK_LISTPATH .'hostnames.txt';
} else { } else {
unset($arrConf['conf-file']); unset($arrConf['conf-file']);
unset($arrConf['addn-hosts']); unset($arrConf['addn-hosts']);
} }
$config = array_map(function($value, $key) { $config = array_map(function($value, $key) {
return $key.'='.$value; if (is_bool($value)) {
return $key;
} else {
return $key.'='.$value;
}
}, array_values($arrConf), array_keys($arrConf)); }, array_values($arrConf), array_keys($arrConf));
$config = implode(PHP_EOL, $config); $config = implode(PHP_EOL, $config);
$config = $config . PHP_EOL; $config = $config . PHP_EOL;
file_put_contents("/tmp/dnsmasqdata", $config); file_put_contents("/tmp/dnsmasqdata", $config);
system('sudo cp /tmp/dnsmasqdata '.RASPI_DNSMASQ_CONFIG, $return); system('sudo cp /tmp/dnsmasqdata '.RASPI_DNSMASQ_CONFIG, $return);
@ -47,6 +50,7 @@ function DisplayAdBlockConfig()
"adblock", compact( "adblock", compact(
"status", "status",
"serviceStatus", "serviceStatus",
"dnsmasq_state",
"arrConf" "arrConf"
) )
); );

View file

@ -15,6 +15,8 @@ $defaults = [
// These are typical for default RPi installs. Modify if needed. // These are typical for default RPi installs. Modify if needed.
'RASPI_DNSMASQ_CONFIG' => '/etc/dnsmasq.conf', 'RASPI_DNSMASQ_CONFIG' => '/etc/dnsmasq.conf',
'RASPI_DNSMASQ_LEASES' => '/var/lib/misc/dnsmasq.leases', 'RASPI_DNSMASQ_LEASES' => '/var/lib/misc/dnsmasq.leases',
'RASPI_ADBLOCK_LISTPATH' => '/etc/raspap/adblock/',
'RASPI_ADBLOCK_CONFIG' => '/etc/dnsmasq.d/090_adblock.conf',
'RASPI_HOSTAPD_CONFIG' => '/etc/hostapd/hostapd.conf', 'RASPI_HOSTAPD_CONFIG' => '/etc/hostapd/hostapd.conf',
'RASPI_DHCPCD_CONFIG' => '/etc/dhcpcd.conf', 'RASPI_DHCPCD_CONFIG' => '/etc/dhcpcd.conf',
'RASPI_WPA_SUPPLICANT_CONFIG' => '/etc/wpa_supplicant/wpa_supplicant.conf', 'RASPI_WPA_SUPPLICANT_CONFIG' => '/etc/wpa_supplicant/wpa_supplicant.conf',