diff options
author | Steve Beaver <sbeaver@netgate.com> | 2017-02-14 14:42:13 -0500 |
---|---|---|
committer | Steve Beaver <sbeaver@netgate.com> | 2017-02-14 14:42:13 -0500 |
commit | 13541a81e1173fc02af9af8ab7fe46df2a51007d (patch) | |
tree | c87a8d90338bfb1e2c245b58e77cca67b70c8c60 /src/usr/local/www/services_dnsmasq.php | |
parent | c946d7217bff529d246084f9b83212ad0ab730a3 (diff) | |
download | pfsense-13541a81e1173fc02af9af8ab7fe46df2a51007d.zip pfsense-13541a81e1173fc02af9af8ab7fe46df2a51007d.tar.gz |
GET/POST conversions
Diffstat (limited to 'src/usr/local/www/services_dnsmasq.php')
-rw-r--r-- | src/usr/local/www/services_dnsmasq.php | 138 |
1 files changed, 70 insertions, 68 deletions
diff --git a/src/usr/local/www/services_dnsmasq.php b/src/usr/local/www/services_dnsmasq.php index 090f54a..c834457 100644 --- a/src/usr/local/www/services_dnsmasq.php +++ b/src/usr/local/www/services_dnsmasq.php @@ -110,87 +110,89 @@ for ($idx=0; $idx<count($a_domainOverrides); $idx++) { domains_sort(); -if ($_POST) { - if ($_POST['apply']) { - $retval = 0; - $retval |= services_dnsmasq_configure(); - - // Reload filter (we might need to sync to CARP hosts) - filter_configure(); - /* Update resolv.conf in case the interface bindings exclude localhost. */ - system_resolvconf_generate(); - /* Start or restart dhcpleases when it's necessary */ - system_dhcpleases_configure(); - - if ($retval == 0) { - clear_subsystem_dirty('hosts'); - } - } else { - $pconfig = $_POST; - unset($input_errors); - - $config['dnsmasq']['enable'] = ($_POST['enable']) ? true : false; - $config['dnsmasq']['regdhcp'] = ($_POST['regdhcp']) ? true : false; - $config['dnsmasq']['regdhcpstatic'] = ($_POST['regdhcpstatic']) ? true : false; - $config['dnsmasq']['dhcpfirst'] = ($_POST['dhcpfirst']) ? true : false; - $config['dnsmasq']['strict_order'] = ($_POST['strict_order']) ? true : false; - $config['dnsmasq']['domain_needed'] = ($_POST['domain_needed']) ? true : false; - $config['dnsmasq']['no_private_reverse'] = ($_POST['no_private_reverse']) ? true : false; - $config['dnsmasq']['custom_options'] = str_replace("\r\n", "\n", $_POST['custom_options']); - $config['dnsmasq']['strictbind'] = ($_POST['strictbind']) ? true : false; - - if (isset($_POST['enable']) && isset($config['unbound']['enable'])) { - if ($_POST['port'] == $config['unbound']['port']) { - $input_errors[] = gettext("The DNS Resolver is enabled using this port. Choose a non-conflicting port, or disable DNS Resolver."); - } - } - if ($_POST['port']) { - if (is_port($_POST['port'])) { - $config['dnsmasq']['port'] = $_POST['port']; - } else { - $input_errors[] = gettext("A valid port number must be specified."); - } - } else if (isset($config['dnsmasq']['port'])) { - unset($config['dnsmasq']['port']); - } +if ($_POST['apply']) { + $retval = 0; + $retval |= services_dnsmasq_configure(); + + // Reload filter (we might need to sync to CARP hosts) + filter_configure(); + /* Update resolv.conf in case the interface bindings exclude localhost. */ + system_resolvconf_generate(); + /* Start or restart dhcpleases when it's necessary */ + system_dhcpleases_configure(); + + if ($retval == 0) { + clear_subsystem_dirty('hosts'); + } +} - if (is_array($_POST['interface'])) { - $config['dnsmasq']['interface'] = implode(",", $_POST['interface']); - } elseif (isset($config['dnsmasq']['interface'])) { - unset($config['dnsmasq']['interface']); +if ($_POST['save']) { + $pconfig = $_POST; + unset($input_errors); + + $config['dnsmasq']['enable'] = ($_POST['enable']) ? true : false; + $config['dnsmasq']['regdhcp'] = ($_POST['regdhcp']) ? true : false; + $config['dnsmasq']['regdhcpstatic'] = ($_POST['regdhcpstatic']) ? true : false; + $config['dnsmasq']['dhcpfirst'] = ($_POST['dhcpfirst']) ? true : false; + $config['dnsmasq']['strict_order'] = ($_POST['strict_order']) ? true : false; + $config['dnsmasq']['domain_needed'] = ($_POST['domain_needed']) ? true : false; + $config['dnsmasq']['no_private_reverse'] = ($_POST['no_private_reverse']) ? true : false; + $config['dnsmasq']['custom_options'] = str_replace("\r\n", "\n", $_POST['custom_options']); + $config['dnsmasq']['strictbind'] = ($_POST['strictbind']) ? true : false; + + if (isset($_POST['enable']) && isset($config['unbound']['enable'])) { + if ($_POST['port'] == $config['unbound']['port']) { + $input_errors[] = gettext("The DNS Resolver is enabled using this port. Choose a non-conflicting port, or disable DNS Resolver."); } + } - if ($config['dnsmasq']['custom_options']) { - $args = ''; - foreach (preg_split('/\s+/', $config['dnsmasq']['custom_options']) as $c) { - $args .= escapeshellarg("--{$c}") . " "; - } - exec("/usr/local/sbin/dnsmasq --test $args", $output, $rc); - if ($rc != 0) { - $input_errors[] = gettext("Invalid custom options"); - } + if ($_POST['port']) { + if (is_port($_POST['port'])) { + $config['dnsmasq']['port'] = $_POST['port']; + } else { + $input_errors[] = gettext("A valid port number must be specified."); } + } else if (isset($config['dnsmasq']['port'])) { + unset($config['dnsmasq']['port']); + } - if (!$input_errors) { - write_config(); - mark_subsystem_dirty('hosts'); + if (is_array($_POST['interface'])) { + $config['dnsmasq']['interface'] = implode(",", $_POST['interface']); + } elseif (isset($config['dnsmasq']['interface'])) { + unset($config['dnsmasq']['interface']); + } + + if ($config['dnsmasq']['custom_options']) { + $args = ''; + foreach (preg_split('/\s+/', $config['dnsmasq']['custom_options']) as $c) { + $args .= escapeshellarg("--{$c}") . " "; } + exec("/usr/local/sbin/dnsmasq --test $args", $output, $rc); + if ($rc != 0) { + $input_errors[] = gettext("Invalid custom options"); + } + } + + if (!$input_errors) { + write_config(); + mark_subsystem_dirty('hosts'); } } -if ($_GET['act'] == "del") { - if ($_GET['type'] == 'host') { - if ($a_hosts[$_GET['id']]) { - unset($a_hosts[$_GET['id']]); + +if ($_POST['act'] == "del") { + if ($_POST['type'] == 'host') { + if ($a_hosts[$_POST['id']]) { + unset($a_hosts[$_POST['id']]); write_config(); mark_subsystem_dirty('hosts'); header("Location: services_dnsmasq.php"); exit; } - } elseif ($_GET['type'] == 'doverride') { - if ($a_domainOverrides[$_GET['id']]) { - unset($a_domainOverrides[$_GET['id']]); + } elseif ($_POST['type'] == 'doverride') { + if ($a_domainOverrides[$_POST['id']]) { + unset($a_domainOverrides[$_POST['id']]); write_config(); mark_subsystem_dirty('hosts'); header("Location: services_dnsmasq.php"); @@ -386,7 +388,7 @@ foreach ($a_hosts as $i => $hostent): </td> <td> <a class="fa fa-pencil" title="<?=gettext('Edit host override')?>" href="services_dnsmasq_edit.php?id=<?=$hostent['idx']?>"></a> - <a class="fa fa-trash" title="<?=gettext('Delete host override')?>" href="services_dnsmasq.php?type=host&act=del&id=<?=$hostent['idx']?>"></a> + <a class="fa fa-trash" title="<?=gettext('Delete host override')?>" href="services_dnsmasq.php?type=host&act=del&id=<?=$hostent['idx']?>" usepost></a> </td> </tr> @@ -458,7 +460,7 @@ foreach ($a_domainOverrides as $i => $doment): </td> <td> <a class="fa fa-pencil" title="<?=gettext('Edit domain override')?>" href="services_dnsmasq_domainoverride_edit.php?id=<?=$doment['idx']?>"></a> - <a class="fa fa-trash" title="<?=gettext('Delete domain override')?>" href="services_dnsmasq.php?act=del&type=doverride&id=<?=$doment['idx']?>"></a> + <a class="fa fa-trash" title="<?=gettext('Delete domain override')?>" href="services_dnsmasq.php?act=del&type=doverride&id=<?=$doment['idx']?>" usepost></a> </td> </tr> <?php |