mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
Save adblock settings
This commit is contained in:
parent
ca7bde25c6
commit
b1d26b0296
@ -1,17 +1,43 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'includes/status_messages.php';
|
require_once 'includes/status_messages.php';
|
||||||
require_once 'app/lib/system.php';
|
|
||||||
require_once 'config.php';
|
require_once 'config.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Manages ad blocking (dnsmasq) configuration
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function DisplayAdBlockConfig()
|
function DisplayAdBlockConfig()
|
||||||
{
|
{
|
||||||
$status = new StatusMessages();
|
$status = new StatusMessages();
|
||||||
$system = new System();
|
exec('cat '. RASPI_DNSMASQ_CONFIG, $return);
|
||||||
|
$arrConf = ParseConfig($return);
|
||||||
|
|
||||||
|
if (!RASPI_MONITOR_ENABLED) {
|
||||||
|
if (isset($_POST['saveadblocksettings'])) {
|
||||||
|
if ($_POST['adblock-enable'] == "1") {
|
||||||
|
$arrConf['conf-file'] = '/etc/dnsmasq.d/domains.txt';
|
||||||
|
$arrConf['addn-hosts'] = '/etc/dnsmasq.d/hostnames.txt';
|
||||||
|
} else {
|
||||||
|
unset($arrConf['conf-file']);
|
||||||
|
unset($arrConf['addn-hosts']);
|
||||||
|
}
|
||||||
|
$config = array_map(function($value, $key) {
|
||||||
|
return $key.'='.$value;
|
||||||
|
}, array_values($arrConf), array_keys($arrConf));
|
||||||
|
$config = implode(PHP_EOL, $config);
|
||||||
|
$config = $config . PHP_EOL;
|
||||||
|
|
||||||
|
file_put_contents("/tmp/dnsmasqdata", $config);
|
||||||
|
system('sudo cp /tmp/dnsmasqdata '.RASPI_DNSMASQ_CONFIG, $return);
|
||||||
|
|
||||||
|
if ($return == 0) {
|
||||||
|
$status->addMessage('Adblock configuration updated successfully', 'success');
|
||||||
|
} else {
|
||||||
|
$status->addMessage('Adblock configuration failed to be updated.', 'danger');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
exec('pidof dnsmasq | wc -l', $dnsmasq);
|
exec('pidof dnsmasq | wc -l', $dnsmasq);
|
||||||
$dnsmasq_state = ($dnsmasq[0] > 0);
|
$dnsmasq_state = ($dnsmasq[0] > 0);
|
||||||
@ -20,16 +46,11 @@ function DisplayAdBlockConfig()
|
|||||||
echo renderTemplate(
|
echo renderTemplate(
|
||||||
"adblock", compact(
|
"adblock", compact(
|
||||||
"status",
|
"status",
|
||||||
"serviceStatus"
|
"serviceStatus",
|
||||||
|
"arrConf"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* BZ: todo
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function SaveAdBlockConfig()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user