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 | |
parent | c946d7217bff529d246084f9b83212ad0ab730a3 (diff) | |
download | pfsense-13541a81e1173fc02af9af8ab7fe46df2a51007d.zip pfsense-13541a81e1173fc02af9af8ab7fe46df2a51007d.tar.gz |
GET/POST conversions
18 files changed, 321 insertions, 390 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 diff --git a/src/usr/local/www/services_dnsmasq_domainoverride_edit.php b/src/usr/local/www/services_dnsmasq_domainoverride_edit.php index 4f6df88..77001af 100644 --- a/src/usr/local/www/services_dnsmasq_domainoverride_edit.php +++ b/src/usr/local/www/services_dnsmasq_domainoverride_edit.php @@ -39,11 +39,8 @@ if (!is_array($config['dnsmasq']['domainoverrides'])) { $a_domainOverrides = &$config['dnsmasq']['domainoverrides']; -if (is_numericint($_GET['id'])) { - $id = $_GET['id']; -} -if (isset($_POST['id']) && is_numericint($_POST['id'])) { - $id = $_POST['id']; +if (is_numericint($_REQUEST['id'])) { + $id = $_REQUEST['id']; } if (isset($id) && $a_domainOverrides[$id]) { @@ -58,7 +55,7 @@ if (isset($id) && $a_domainOverrides[$id]) { $pconfig['descr'] = $a_domainOverrides[$id]['descr']; } -if ($_POST) { +if ($_POST['save']) { unset($input_errors); $pconfig = $_POST; diff --git a/src/usr/local/www/services_dnsmasq_edit.php b/src/usr/local/www/services_dnsmasq_edit.php index d6b58b2..b476052 100644 --- a/src/usr/local/www/services_dnsmasq_edit.php +++ b/src/usr/local/www/services_dnsmasq_edit.php @@ -39,13 +39,11 @@ if (!is_array($config['dnsmasq']['hosts'])) { $a_hosts = &$config['dnsmasq']['hosts']; -if (is_numericint($_GET['id'])) { - $id = $_GET['id']; -} -if (isset($_POST['id']) && is_numericint($_POST['id'])) { - $id = $_POST['id']; +if (is_numericint($_REQUEST['id'])) { + $id = $_REQUEST['id']; } + if (isset($id) && $a_hosts[$id]) { $pconfig['host'] = $a_hosts[$id]['host']; $pconfig['domain'] = $a_hosts[$id]['domain']; @@ -54,7 +52,7 @@ if (isset($id) && $a_hosts[$id]) { $pconfig['aliases'] = $a_hosts[$id]['aliases']; } -if ($_POST) { +if ($_POST['save']) { unset($input_errors); $pconfig = $_POST; @@ -165,8 +163,8 @@ if ($_POST) { } // Delete a row in the options table -if ($_GET['act'] == "delopt") { - $idx = $_GET['id']; +if ($_POST['act'] == "delopt") { + $idx = $_POST['id']; if ($pconfig['aliases'] && is_array($pconfig['aliases']['item'][$idx])) { unset($pconfig['aliases']['item'][$idx]); @@ -174,7 +172,7 @@ if ($_GET['act'] == "delopt") { } // Add an option row -if ($_GET['act'] == "addopt") { +if ($_REQUEST['act'] == "addopt") { if (!is_array($pconfig['aliases']['item'])) { $pconfig['aliases']['item'] = array(); } diff --git a/src/usr/local/www/services_dyndns.php b/src/usr/local/www/services_dyndns.php index 1178bc9..3c7777a 100644 --- a/src/usr/local/www/services_dyndns.php +++ b/src/usr/local/www/services_dyndns.php @@ -35,27 +35,27 @@ if (!is_array($config['dyndnses']['dyndns'])) { $a_dyndns = &$config['dyndnses']['dyndns']; global $dyndns_split_domain_types; -if ($_GET['act'] == "del") { - $conf = $a_dyndns[$_GET['id']]; +if ($_POST['act'] == "del") { + $conf = $a_dyndns[$_POST['id']]; if (in_array($conf['type'], $dyndns_split_domain_types)) { $hostname = $conf['host'] . "." . $conf['domainname']; } else { $hostname = $conf['host']; } @unlink("{$g['conf_path']}/dyndns_{$conf['interface']}{$conf['type']}" . escapeshellarg($hostname) . "{$conf['id']}.cache"); - unset($a_dyndns[$_GET['id']]); + unset($a_dyndns[$_POST['id']]); write_config(); services_dyndns_configure(); header("Location: services_dyndns.php"); exit; -} else if ($_GET['act'] == "toggle") { - if ($a_dyndns[$_GET['id']]) { - if (isset($a_dyndns[$_GET['id']]['enable'])) { - unset($a_dyndns[$_GET['id']]['enable']); +} else if ($_POST['act'] == "toggle") { + if ($a_dyndns[$_POST['id']]) { + if (isset($a_dyndns[$_POST['id']]['enable'])) { + unset($a_dyndns[$_POST['id']]['enable']); } else { - $a_dyndns[$_GET['id']]['enable'] = true; + $a_dyndns[$_POST['id']]['enable'] = true; } write_config(); services_dyndns_configure(); @@ -64,6 +64,7 @@ if ($_GET['act'] == "del") { exit; } } + $pgtitle = array(gettext("Services"), gettext("Dynamic DNS"), gettext("Dynamic DNS Clients")); $pglinks = array("", "@self", "@self"); include("head.inc"); @@ -188,13 +189,13 @@ foreach ($a_dyndns as $dyndns): <a class="fa fa-pencil" title="<?=gettext('Edit service')?>" href="services_dyndns_edit.php?id=<?=$i?>"></a> <?php if (isset($dyndns['enable'])) { ?> - <a class="fa fa-ban" title="<?=gettext('Disable service')?>" href="?act=toggle&id=<?=$i?>"></a> + <a class="fa fa-ban" title="<?=gettext('Disable service')?>" href="?act=toggle&id=<?=$i?>" usepost></a> <?php } else { ?> - <a class="fa fa-check-square-o" title="<?=gettext('Enable service')?>" href="?act=toggle&id=<?=$i?>"></a> + <a class="fa fa-check-square-o" title="<?=gettext('Enable service')?>" href="?act=toggle&id=<?=$i?>" usepost></a> <?php } ?> - <a class="fa fa-trash" title="<?=gettext('Delete service')?>" href="services_dyndns.php?act=del&id=<?=$i?>"></a> + <a class="fa fa-trash" title="<?=gettext('Delete service')?>" href="services_dyndns.php?act=del&id=<?=$i?>" usepost></a> </td> </tr> <?php diff --git a/src/usr/local/www/services_dyndns_edit.php b/src/usr/local/www/services_dyndns_edit.php index c14869e..f0b75ae 100644 --- a/src/usr/local/www/services_dyndns_edit.php +++ b/src/usr/local/www/services_dyndns_edit.php @@ -46,13 +46,7 @@ if (!is_array($config['dyndnses']['dyndns'])) { } $a_dyndns = &$config['dyndnses']['dyndns']; - -if (is_numericint($_GET['id'])) { - $id = $_GET['id']; -} -if (isset($_POST['id']) && is_numericint($_POST['id'])) { - $id = $_POST['id']; -} +$id = $_REQUEST['id']; if (isset($id) && isset($a_dyndns[$id])) { $pconfig['username'] = $a_dyndns[$id]['username']; @@ -76,7 +70,7 @@ if (isset($id) && isset($a_dyndns[$id])) { $pconfig['descr'] = $a_dyndns[$id]['descr']; } -if ($_POST) { +if ($_POST['save']) { global $dyndns_split_domain_types; unset($input_errors); $pconfig = $_POST; diff --git a/src/usr/local/www/services_igmpproxy.php b/src/usr/local/www/services_igmpproxy.php index 5de6aa1..d2df78c 100644 --- a/src/usr/local/www/services_igmpproxy.php +++ b/src/usr/local/www/services_igmpproxy.php @@ -39,7 +39,7 @@ if (!is_array($config['igmpproxy']['igmpentry'])) { //igmpproxy_sort(); $a_igmpproxy = &$config['igmpproxy']['igmpentry']; -if ($_POST) { +if ($_POST['submit']) { $pconfig = $_POST; $changes_applied = true; @@ -50,9 +50,9 @@ if ($_POST) { clear_subsystem_dirty('igmpproxy'); } -if ($_GET['act'] == "del") { - if ($a_igmpproxy[$_GET['id']]) { - unset($a_igmpproxy[$_GET['id']]); +if ($_POST['act'] == "del") { + if ($a_igmpproxy[$_POST['id']]) { + unset($a_igmpproxy[$_POST['id']]); write_config(); mark_subsystem_dirty('igmpproxy'); header("Location: services_igmpproxy.php"); @@ -116,7 +116,7 @@ foreach ($a_igmpproxy as $igmpentry): </td> <td> <a class="fa fa-pencil" title="<?=gettext('Edit IGMP entry')?>" href="services_igmpproxy_edit.php?id=<?=$i?>"></a> - <a class="fa fa-trash" title="<?=gettext('Delete IGMP entry')?>" href="services_igmpproxy.php?act=del&id=<?=$i?>"></a> + <a class="fa fa-trash" title="<?=gettext('Delete IGMP entry')?>" href="services_igmpproxy.php?act=del&id=<?=$i?>" usepost></a> </td> </tr> <?php diff --git a/src/usr/local/www/services_igmpproxy_edit.php b/src/usr/local/www/services_igmpproxy_edit.php index e0abca1..757d2e2 100644 --- a/src/usr/local/www/services_igmpproxy_edit.php +++ b/src/usr/local/www/services_igmpproxy_edit.php @@ -42,11 +42,8 @@ if (!is_array($config['igmpproxy']['igmpentry'])) { //igmpproxy_sort(); $a_igmpproxy = &$config['igmpproxy']['igmpentry']; -if (is_numericint($_GET['id'])) { - $id = $_GET['id']; -} -if (isset($_POST['id']) && is_numericint($_POST['id'])) { - $id = $_POST['id']; +if (is_numericint($_REQUEST['id'])) { + $id = $_REQUEST['id']; } if (isset($id) && $a_igmpproxy[$id]) { @@ -57,7 +54,7 @@ if (isset($id) && $a_igmpproxy[$id]) { $pconfig['descr'] = html_entity_decode($a_igmpproxy[$id]['descr']); } -if ($_POST) { +if ($_POST['save']) { unset($input_errors); $pconfig = $_POST; diff --git a/src/usr/local/www/services_pppoe.php b/src/usr/local/www/services_pppoe.php index 85b3531..54442ff 100644 --- a/src/usr/local/www/services_pppoe.php +++ b/src/usr/local/www/services_pppoe.php @@ -36,42 +36,39 @@ if (!is_array($config['pppoes']['pppoe'])) { $a_pppoes = &$config['pppoes']['pppoe']; -if ($_POST) { - $pconfig = $_POST; - if ($_POST['apply']) { - if (file_exists("{$g['tmp_path']}/.vpn_pppoe.apply")) { - $toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.vpn_pppoe.apply")); - foreach ($toapplylist as $pppoeid) { - if (!is_numeric($pppoeid)) { - continue; - } - if (is_array($config['pppoes']['pppoe'])) { - foreach ($config['pppoes']['pppoe'] as $pppoe) { - if ($pppoe['pppoeid'] == $pppoeid) { - vpn_pppoe_configure($pppoe); - break; - } +if ($_POST['apply']) { + if (file_exists("{$g['tmp_path']}/.vpn_pppoe.apply")) { + $toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.vpn_pppoe.apply")); + foreach ($toapplylist as $pppoeid) { + if (!is_numeric($pppoeid)) { + continue; + } + if (is_array($config['pppoes']['pppoe'])) { + foreach ($config['pppoes']['pppoe'] as $pppoe) { + if ($pppoe['pppoeid'] == $pppoeid) { + vpn_pppoe_configure($pppoe); + break; } } } - @unlink("{$g['tmp_path']}/.vpn_pppoe.apply"); } - $retval = 0; - $retval |= filter_configure(); - clear_subsystem_dirty('vpnpppoe'); + @unlink("{$g['tmp_path']}/.vpn_pppoe.apply"); } + $retval = 0; + $retval |= filter_configure(); + clear_subsystem_dirty('vpnpppoe'); } -if ($_GET['act'] == "del") { - if ($a_pppoes[$_GET['id']]) { - if ("{$g['varrun_path']}/pppoe" . $a_pppoes[$_GET['id']]['pppoeid'] . "-vpn.pid") { - killbypid("{$g['varrun_path']}/pppoe" . $a_pppoes[$_GET['id']]['pppoeid'] . "-vpn.pid"); +if ($_POST['act'] == "del") { + if ($a_pppoes[$_POST['id']]) { + if ("{$g['varrun_path']}/pppoe" . $a_pppoes[$_POST['id']]['pppoeid'] . "-vpn.pid") { + killbypid("{$g['varrun_path']}/pppoe" . $a_pppoes[$_POST['id']]['pppoeid'] . "-vpn.pid"); } - if (is_dir("{$g['varetc_path']}/pppoe" . $a_pppoes[$_GET['id']]['pppoeid'])) { - mwexec("/bin/rm -r {$g['varetc_path']}/pppoe" . $a_pppoes[$_GET['id']]['pppoeid']); + if (is_dir("{$g['varetc_path']}/pppoe" . $a_pppoes[$_POST['id']]['pppoeid'])) { + mwexec("/bin/rm -r {$g['varetc_path']}/pppoe" . $a_pppoes[$_POST['id']]['pppoeid']); } - unset($a_pppoes[$_GET['id']]); + unset($a_pppoes[$_POST['id']]); write_config(); header("Location: services_pppoe.php"); exit; @@ -94,7 +91,7 @@ if (is_subsystem_dirty('vpnpppoe')) { <div class="panel panel-default"> <div class="panel-heading"><h2 class="panel-title"><?=gettext('PPPoE Server')?></h2></div> <div class="panel-body"> - + <div class="table-responsive"> <table class="table table-striped table-hover table-condensed table-rowdblclickedit"> <thead> @@ -126,7 +123,7 @@ foreach ($a_pppoes as $pppoe): </td> <td> <a class="fa fa-pencil" title="<?=gettext('Edit PPPoE instance')?>" href="services_pppoe_edit.php?id=<?=$i?>"></a> - <a class="fa fa-trash" title="<?=gettext('Delete PPPoE instance')?>" href="services_pppoe.php?act=del&id=<?=$i?>"></a> + <a class="fa fa-trash" title="<?=gettext('Delete PPPoE instance')?>" href="services_pppoe.php?act=del&id=<?=$i?>" usepost></a> </td> </tr> <?php diff --git a/src/usr/local/www/services_pppoe_edit.php b/src/usr/local/www/services_pppoe_edit.php index 0f1ee42..12a6e55 100644 --- a/src/usr/local/www/services_pppoe_edit.php +++ b/src/usr/local/www/services_pppoe_edit.php @@ -52,11 +52,8 @@ if (!is_array($config['pppoes']['pppoe'])) { $a_pppoes = &$config['pppoes']['pppoe']; -if (is_numericint($_GET['id'])) { - $id = $_GET['id']; -} -if (isset($_POST['id']) && is_numericint($_POST['id'])) { - $id = $_POST['id']; +if (is_numericint($_REQUEST['id'])) { + $id = $_REQUEST['id']; } if (isset($id) && $a_pppoes[$id]) { @@ -98,7 +95,7 @@ if (isset($id) && $a_pppoes[$id]) { } } -if ($_POST) { +if ($_POST['save']) { unset($input_errors); $pconfig = $_POST; diff --git a/src/usr/local/www/services_rfc2136.php b/src/usr/local/www/services_rfc2136.php index c5d23c1..d5aadae 100644 --- a/src/usr/local/www/services_rfc2136.php +++ b/src/usr/local/www/services_rfc2136.php @@ -34,19 +34,19 @@ if (!is_array($config['dnsupdates']['dnsupdate'])) { $a_rfc2136 = &$config['dnsupdates']['dnsupdate']; -if ($_GET['act'] == "del") { - unset($a_rfc2136[$_GET['id']]); +if ($_POST['act'] == "del") { + unset($a_rfc2136[$_POST['id']]); write_config(); header("Location: services_rfc2136.php"); exit; -} else if ($_GET['act'] == "toggle") { - if ($a_rfc2136[$_GET['id']]) { - if (isset($a_rfc2136[$_GET['id']]['enable'])) { - unset($a_rfc2136[$_GET['id']]['enable']); +} else if ($_POST['act'] == "toggle") { + if ($a_rfc2136[$_POST['id']]) { + if (isset($a_rfc2136[$_POST['id']]['enable'])) { + unset($a_rfc2136[$_POST['id']]['enable']); } else { - $a_rfc2136[$_GET['id']]['enable'] = true; + $a_rfc2136[$_POST['id']]['enable'] = true; } write_config(); @@ -176,13 +176,13 @@ foreach ($a_rfc2136 as $rfc2136): <a class="fa fa-pencil" title="<?=gettext('Edit client')?>" href="services_rfc2136_edit.php?id=<?=$i?>"></a> <?php if (isset($rfc2136['enable'])) { ?> - <a class="fa fa-ban" title="<?=gettext('Disable client')?>" href="?act=toggle&id=<?=$i?>"></a> + <a class="fa fa-ban" title="<?=gettext('Disable client')?>" href="?act=toggle&id=<?=$i?>" usepost></a> <?php } else { ?> - <a class="fa fa-check-square-o" title="<?=gettext('Enable client')?>" href="?act=toggle&id=<?=$i?>"></a> + <a class="fa fa-check-square-o" title="<?=gettext('Enable client')?>" href="?act=toggle&id=<?=$i?>" usepost></a> <?php } ?> - <a class="fa fa-trash" title="<?=gettext('Delete client')?>" href="services_rfc2136.php?act=del&id=<?=$i?>"></a> + <a class="fa fa-trash" title="<?=gettext('Delete client')?>" href="services_rfc2136.php?act=del&id=<?=$i?>" usepost></a> </td> </tr> <?php diff --git a/src/usr/local/www/services_rfc2136_edit.php b/src/usr/local/www/services_rfc2136_edit.php index 8da130d..48ce990 100644 --- a/src/usr/local/www/services_rfc2136_edit.php +++ b/src/usr/local/www/services_rfc2136_edit.php @@ -34,11 +34,8 @@ if (!is_array($config['dnsupdates']['dnsupdate'])) { $a_rfc2136 = &$config['dnsupdates']['dnsupdate']; -if (is_numericint($_GET['id'])) { - $id = $_GET['id']; -} -if (isset($_POST['id']) && is_numericint($_POST['id'])) { - $id = $_POST['id']; +if (is_numericint($_REQUEST['id'])) { + $id = $_REQUEST['id']; } if (isset($id) && isset($a_rfc2136[$id])) { @@ -66,7 +63,7 @@ if (isset($id) && isset($a_rfc2136[$id])) { } -if ($_POST) { +if ($_POST['save']) { unset($input_errors); $pconfig = $_POST; diff --git a/src/usr/local/www/services_router_advertisements.php b/src/usr/local/www/services_router_advertisements.php index 57b3d17..a705546 100644 --- a/src/usr/local/www/services_router_advertisements.php +++ b/src/usr/local/www/services_router_advertisements.php @@ -38,10 +38,7 @@ if (!$g['services_dhcp_server_enable']) { exit; } -$if = $_GET['if']; -if ($_POST['if']) { - $if = $_POST['if']; -} +$if = $_REQUEST['if']; /* if OLSRD is enabled, allow WAN to house DHCP. */ if ($config['installedpackages']['olsrd']) { @@ -53,7 +50,7 @@ if ($config['installedpackages']['olsrd']) { } } -if (!$_GET['if']) { +if (!$_REQUEST['if']) { $info_msg = gettext("The DHCPv6 Server can only be enabled on interfaces configured with static, non unique local IP addresses.") . "<br />" . gettext("Only interfaces configured with a static IP will be shown."); } @@ -136,7 +133,7 @@ $ramode_help = gettext('Select the Operating Mode for the Router Advertisement ( gettext('It is not required to activate DHCPv6 server on pfSense when set to "Managed", "Assisted" or "Stateless DHCP", it can be another host on the network.') . '</div>'; -if ($_POST) { +if ($_POST['save']) { unset($input_errors); $pconfig = $_POST; diff --git a/src/usr/local/www/services_unbound.php b/src/usr/local/www/services_unbound.php index 827bf94..5c3caa1 100644 --- a/src/usr/local/www/services_unbound.php +++ b/src/usr/local/www/services_unbound.php @@ -86,125 +86,127 @@ if (empty($a_unboundcfg['system_domain_local_zone_type'])) { $pconfig['system_domain_local_zone_type'] = $a_unboundcfg['system_domain_local_zone_type']; } -if ($_POST) { - if ($_POST['apply']) { - $retval = 0; - $retval |= services_unbound_configure(); - if ($retval == 0) { - clear_subsystem_dirty('unbound'); - } - /* Update resolv.conf in case the interface bindings exclude localhost. */ - system_resolvconf_generate(); - /* Start or restart dhcpleases when it's necessary */ - system_dhcpleases_configure(); - } else { - $pconfig = $_POST; - unset($input_errors); - - if (isset($pconfig['enable']) && isset($config['dnsmasq']['enable'])) { - if ($pconfig['port'] == $config['dnsmasq']['port']) { - $input_errors[] = gettext("The DNS Forwarder is enabled using this port. Choose a non-conflicting port, or disable the DNS Forwarder."); - } + +if ($_POST['apply']) { + $retval = 0; + $retval |= services_unbound_configure(); + if ($retval == 0) { + clear_subsystem_dirty('unbound'); + } + /* 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 ($_POST['save']) { + $pconfig = $_POST; + unset($input_errors); + + if (isset($pconfig['enable']) && isset($config['dnsmasq']['enable'])) { + if ($pconfig['port'] == $config['dnsmasq']['port']) { + $input_errors[] = gettext("The DNS Forwarder is enabled using this port. Choose a non-conflicting port, or disable the DNS Forwarder."); } + } - // forwarding mode requires having valid DNS servers - if (isset($pconfig['forwarding'])) { - $founddns = false; - if (isset($config['system']['dnsallowoverride'])) { - $dns_servers = get_dns_servers(); - if (is_array($dns_servers)) { - foreach ($dns_servers as $dns_server) { - if (!ip_in_subnet($dns_server, "127.0.0.0/8")) { - $founddns = true; - } - } - } - } - if (is_array($config['system']['dnsserver'])) { - foreach ($config['system']['dnsserver'] as $dnsserver) { - if (is_ipaddr($dnsserver)) { + // forwarding mode requires having valid DNS servers + if (isset($pconfig['forwarding'])) { + $founddns = false; + if (isset($config['system']['dnsallowoverride'])) { + $dns_servers = get_dns_servers(); + if (is_array($dns_servers)) { + foreach ($dns_servers as $dns_server) { + if (!ip_in_subnet($dns_server, "127.0.0.0/8")) { $founddns = true; } } } - if ($founddns == false) { - $input_errors[] = gettext("At least one DNS server must be specified under System > General Setup to enable Forwarding mode."); + } + if (is_array($config['system']['dnsserver'])) { + foreach ($config['system']['dnsserver'] as $dnsserver) { + if (is_ipaddr($dnsserver)) { + $founddns = true; + } } } - - if (empty($pconfig['active_interface'])) { - $input_errors[] = gettext("One or more Network Interfaces must be selected for binding."); - } else if (!isset($config['system']['dnslocalhost']) && (!in_array("lo0", $pconfig['active_interface']) && !in_array("all", $pconfig['active_interface']))) { - $input_errors[] = gettext("This system is configured to use the DNS Resolver as its DNS server, so Localhost or All must be selected in Network Interfaces."); + if ($founddns == false) { + $input_errors[] = gettext("At least one DNS server must be specified under System > General Setup to enable Forwarding mode."); } + } - if (empty($pconfig['outgoing_interface'])) { - $input_errors[] = gettext("One or more Outgoing Network Interfaces must be selected."); - } + if (empty($pconfig['active_interface'])) { + $input_errors[] = gettext("One or more Network Interfaces must be selected for binding."); + } else if (!isset($config['system']['dnslocalhost']) && (!in_array("lo0", $pconfig['active_interface']) && !in_array("all", $pconfig['active_interface']))) { + $input_errors[] = gettext("This system is configured to use the DNS Resolver as its DNS server, so Localhost or All must be selected in Network Interfaces."); + } - if ($pconfig['port'] && !is_port($pconfig['port'])) { - $input_errors[] = gettext("A valid port number must be specified."); - } + if (empty($pconfig['outgoing_interface'])) { + $input_errors[] = gettext("One or more Outgoing Network Interfaces must be selected."); + } - if (is_array($pconfig['active_interface']) && !empty($pconfig['active_interface'])) { - $display_active_interface = $pconfig['active_interface']; - $pconfig['active_interface'] = implode(",", $pconfig['active_interface']); - } + if ($pconfig['port'] && !is_port($pconfig['port'])) { + $input_errors[] = gettext("A valid port number must be specified."); + } - $display_custom_options = $pconfig['custom_options']; - $pconfig['custom_options'] = base64_encode(str_replace("\r\n", "\n", $pconfig['custom_options'])); + if (is_array($pconfig['active_interface']) && !empty($pconfig['active_interface'])) { + $display_active_interface = $pconfig['active_interface']; + $pconfig['active_interface'] = implode(",", $pconfig['active_interface']); + } - if (is_array($pconfig['outgoing_interface']) && !empty($pconfig['outgoing_interface'])) { - $display_outgoing_interface = $pconfig['outgoing_interface']; - $pconfig['outgoing_interface'] = implode(",", $pconfig['outgoing_interface']); - } + $display_custom_options = $pconfig['custom_options']; + $pconfig['custom_options'] = base64_encode(str_replace("\r\n", "\n", $pconfig['custom_options'])); - $test_output = array(); - if (test_unbound_config($pconfig, $test_output)) { - $input_errors[] = gettext("The generated config file cannot be parsed by unbound. Please correct the following errors:"); - $input_errors = array_merge($input_errors, $test_output); - } + if (is_array($pconfig['outgoing_interface']) && !empty($pconfig['outgoing_interface'])) { + $display_outgoing_interface = $pconfig['outgoing_interface']; + $pconfig['outgoing_interface'] = implode(",", $pconfig['outgoing_interface']); + } - if (!$input_errors) { - $a_unboundcfg['enable'] = isset($pconfig['enable']); - $a_unboundcfg['port'] = $pconfig['port']; - $a_unboundcfg['dnssec'] = isset($pconfig['dnssec']); - $a_unboundcfg['forwarding'] = isset($pconfig['forwarding']); - $a_unboundcfg['regdhcp'] = isset($pconfig['regdhcp']); - $a_unboundcfg['regdhcpstatic'] = isset($pconfig['regdhcpstatic']); - $a_unboundcfg['active_interface'] = $pconfig['active_interface']; - $a_unboundcfg['outgoing_interface'] = $pconfig['outgoing_interface']; - $a_unboundcfg['system_domain_local_zone_type'] = $pconfig['system_domain_local_zone_type']; - $a_unboundcfg['custom_options'] = $pconfig['custom_options']; - - write_config(gettext("DNS Resolver configured.")); - mark_subsystem_dirty('unbound'); - } + $test_output = array(); + if (test_unbound_config($pconfig, $test_output)) { + $input_errors[] = gettext("The generated config file cannot be parsed by unbound. Please correct the following errors:"); + $input_errors = array_merge($input_errors, $test_output); + } - $pconfig['active_interface'] = $display_active_interface; - $pconfig['outgoing_interface'] = $display_outgoing_interface; - $pconfig['custom_options'] = $display_custom_options; + if (!$input_errors) { + $a_unboundcfg['enable'] = isset($pconfig['enable']); + $a_unboundcfg['port'] = $pconfig['port']; + $a_unboundcfg['dnssec'] = isset($pconfig['dnssec']); + $a_unboundcfg['forwarding'] = isset($pconfig['forwarding']); + $a_unboundcfg['regdhcp'] = isset($pconfig['regdhcp']); + $a_unboundcfg['regdhcpstatic'] = isset($pconfig['regdhcpstatic']); + $a_unboundcfg['active_interface'] = $pconfig['active_interface']; + $a_unboundcfg['outgoing_interface'] = $pconfig['outgoing_interface']; + $a_unboundcfg['system_domain_local_zone_type'] = $pconfig['system_domain_local_zone_type']; + $a_unboundcfg['custom_options'] = $pconfig['custom_options']; + + write_config(gettext("DNS Resolver configured.")); + mark_subsystem_dirty('unbound'); } + + $pconfig['active_interface'] = $display_active_interface; + $pconfig['outgoing_interface'] = $display_outgoing_interface; + $pconfig['custom_options'] = $display_custom_options; } + if ($pconfig['custom_options']) { $customoptions = true; } else { $customoptions = false; } -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('unbound'); header("Location: services_unbound.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('unbound'); header("Location: services_unbound.php"); @@ -460,7 +462,7 @@ foreach ($a_hosts as $hostent): </td> <td> <a class="fa fa-pencil" title="<?=gettext('Edit host override')?>" href="services_unbound_host_edit.php?id=<?=$i?>"></a> - <a class="fa fa-trash" title="<?=gettext('Delete host override')?>" href="services_unbound.php?type=host&act=del&id=<?=$i?>"></a> + <a class="fa fa-trash" title="<?=gettext('Delete host override')?>" href="services_unbound.php?type=host&act=del&id=<?=$i?>" usepost></a> </td> </tr> @@ -534,7 +536,7 @@ foreach ($a_domainOverrides as $doment): </td> <td> <a class="fa fa-pencil" title="<?=gettext('Edit domain override')?>" href="services_unbound_domainoverride_edit.php?id=<?=$i?>"></a> - <a class="fa fa-trash" title="<?=gettext('Delete domain override')?>" href="services_unbound.php?act=del&type=doverride&id=<?=$i?>"></a> + <a class="fa fa-trash" title="<?=gettext('Delete domain override')?>" href="services_unbound.php?act=del&type=doverride&id=<?=$i?>" usepost></a> </td> </tr> <?php diff --git a/src/usr/local/www/services_unbound_acls.php b/src/usr/local/www/services_unbound_acls.php index e2eb7ee..5264020 100644 --- a/src/usr/local/www/services_unbound_acls.php +++ b/src/usr/local/www/services_unbound_acls.php @@ -36,7 +36,7 @@ if (!is_array($config['unbound']['acls'])) { $a_acls = &$config['unbound']['acls']; -$id = $_GET['id']; +$id = $_REQUEST['id']; if (isset($_POST['aclid'])) { $id = $_POST['aclid']; @@ -47,13 +47,9 @@ if (!empty($id) && !is_numeric($id)) { exit; } -$act = $_GET['act']; +$act = $_REQUEST['act']; -if (isset($_POST['act'])) { - $act = $_POST['act']; -} - -if ($act == "del") { +if ($_POST['act'] == "del") { if (!$a_acls[$id]) { pfSenseHeader("services_unbound_acls.php"); exit; @@ -84,83 +80,72 @@ if ($act == 'new') { $networkacl = array('0' => array('acl_network' => '', 'mask' => '', 'description' => '')); } -if ($_POST) { +if ($_POST['apply']) { + $retval = 0; + $retval |= services_unbound_configure(); + if ($retval == 0) { + clear_subsystem_dirty('unbound'); + } +} +if ($_POST['save']) { unset($input_errors); $pconfig = $_POST; $deleting = false; - // Delete a row from the networks table - for ($idx = 0; $idx < 50; $idx++) { - if ($pconfig['dlt' . $idx] == 'Delete') { - unset($networkacl[$idx]); - $deleting = true; - break; - } - } + // input validation - only allow 50 entries in a single ACL + for ($x = 0; $x < 50; $x++) { + if (isset($pconfig["acl_network{$x}"])) { + $networkacl[$x] = array(); + $networkacl[$x]['acl_network'] = $pconfig["acl_network{$x}"]; + $networkacl[$x]['mask'] = $pconfig["mask{$x}"]; + $networkacl[$x]['description'] = $pconfig["description{$x}"]; + if (!is_ipaddr($networkacl[$x]['acl_network'])) { + $input_errors[] = gettext("A valid IP address must be entered for each row under Networks."); + } - if ($_POST['apply']) { - $retval = 0; - $retval |= services_unbound_configure(); - if ($retval == 0) { - clear_subsystem_dirty('unbound'); - } - } else if (!$deleting) { - - // input validation - only allow 50 entries in a single ACL - for ($x = 0; $x < 50; $x++) { - if (isset($pconfig["acl_network{$x}"])) { - $networkacl[$x] = array(); - $networkacl[$x]['acl_network'] = $pconfig["acl_network{$x}"]; - $networkacl[$x]['mask'] = $pconfig["mask{$x}"]; - $networkacl[$x]['description'] = $pconfig["description{$x}"]; - if (!is_ipaddr($networkacl[$x]['acl_network'])) { - $input_errors[] = gettext("A valid IP address must be entered for each row under Networks."); + if (is_ipaddr($networkacl[$x]['acl_network'])) { + if (!is_subnet($networkacl[$x]['acl_network']."/".$networkacl[$x]['mask'])) { + $input_errors[] = gettext("A valid IPv4 netmask must be entered for each IPv4 row under Networks."); } - - if (is_ipaddr($networkacl[$x]['acl_network'])) { - if (!is_subnet($networkacl[$x]['acl_network']."/".$networkacl[$x]['mask'])) { - $input_errors[] = gettext("A valid IPv4 netmask must be entered for each IPv4 row under Networks."); - } - } else if (function_exists("is_ipaddrv6")) { - if (!is_ipaddrv6($networkacl[$x]['acl_network'])) { - $input_errors[] = gettext("A valid IPv6 address must be entered for {$networkacl[$x]['acl_network']}."); - } else if (!is_subnetv6($networkacl[$x]['acl_network']."/".$networkacl[$x]['mask'])) { - $input_errors[] = gettext("A valid IPv6 netmask must be entered for each IPv6 row under Networks."); - } - } else { - $input_errors[] = gettext("A valid IP address must be entered for each row under Networks."); + } else if (function_exists("is_ipaddrv6")) { + if (!is_ipaddrv6($networkacl[$x]['acl_network'])) { + $input_errors[] = gettext("A valid IPv6 address must be entered for {$networkacl[$x]['acl_network']}."); + } else if (!is_subnetv6($networkacl[$x]['acl_network']."/".$networkacl[$x]['mask'])) { + $input_errors[] = gettext("A valid IPv6 netmask must be entered for each IPv6 row under Networks."); } - } else if (isset($networkacl[$x])) { - unset($networkacl[$x]); + } else { + $input_errors[] = gettext("A valid IP address must be entered for each row under Networks."); } + } else if (isset($networkacl[$x])) { + unset($networkacl[$x]); } + } - if (!$input_errors) { - if (strtolower($pconfig['save']) == gettext("save")) { - $acl_entry = array(); - $acl_entry['aclid'] = $pconfig['aclid']; - $acl_entry['aclname'] = $pconfig['aclname']; - $acl_entry['aclaction'] = $pconfig['aclaction']; - $acl_entry['description'] = $pconfig['description']; - $acl_entry['aclid'] = $pconfig['aclid']; - $acl_entry['row'] = array(); - - foreach ($networkacl as $acl) { - $acl_entry['row'][] = $acl; - } + if (!$input_errors) { + if (strtolower($pconfig['save']) == gettext("save")) { + $acl_entry = array(); + $acl_entry['aclid'] = $pconfig['aclid']; + $acl_entry['aclname'] = $pconfig['aclname']; + $acl_entry['aclaction'] = $pconfig['aclaction']; + $acl_entry['description'] = $pconfig['description']; + $acl_entry['aclid'] = $pconfig['aclid']; + $acl_entry['row'] = array(); + + foreach ($networkacl as $acl) { + $acl_entry['row'][] = $acl; + } - if (isset($id) && $a_acls[$id]) { - $a_acls[$id] = $acl_entry; - } else { - $a_acls[] = $acl_entry; - } + if (isset($id) && $a_acls[$id]) { + $a_acls[$id] = $acl_entry; + } else { + $a_acls[] = $acl_entry; + } - mark_subsystem_dirty("unbound"); - write_config(); + mark_subsystem_dirty("unbound"); + write_config(); - pfSenseHeader("/services_unbound_acls.php"); - exit; - } + pfSenseHeader("/services_unbound_acls.php"); + exit; } } } @@ -319,7 +304,7 @@ if ($act == "new" || $act == "edit") { </td> <td> <a class="fa fa-pencil" title="<?=gettext('Edit ACL')?>" href="services_unbound_acls.php?act=edit&id=<?=$i?>"></a> - <a class="fa fa-trash" title="<?=gettext('Delete ACL')?>" href="services_unbound_acls.php?act=del&id=<?=$i?>"></a> + <a class="fa fa-trash" title="<?=gettext('Delete ACL')?>" href="services_unbound_acls.php?act=del&id=<?=$i?>" usepost></a> </td> </tr> <?php diff --git a/src/usr/local/www/services_unbound_domainoverride_edit.php b/src/usr/local/www/services_unbound_domainoverride_edit.php index 4d46435..e87122b 100644 --- a/src/usr/local/www/services_unbound_domainoverride_edit.php +++ b/src/usr/local/www/services_unbound_domainoverride_edit.php @@ -39,13 +39,7 @@ if (!is_array($config['unbound']['domainoverrides'])) { } $a_domainOverrides = &$config['unbound']['domainoverrides']; - -if (is_numericint($_GET['id'])) { - $id = $_GET['id']; -} -if (isset($_POST['id']) && is_numericint($_POST['id'])) { - $id = $_POST['id']; -} +$id = $_REQUEST['id']; if (isset($id) && $a_domainOverrides[$id]) { $pconfig['domain'] = $a_domainOverrides[$id]['domain']; @@ -53,7 +47,7 @@ if (isset($id) && $a_domainOverrides[$id]) { $pconfig['descr'] = $a_domainOverrides[$id]['descr']; } -if ($_POST) { +if ($_POST['save']) { unset($input_errors); $pconfig = $_POST; diff --git a/src/usr/local/www/services_unbound_host_edit.php b/src/usr/local/www/services_unbound_host_edit.php index 9b54292..b5949f3 100644 --- a/src/usr/local/www/services_unbound_host_edit.php +++ b/src/usr/local/www/services_unbound_host_edit.php @@ -53,13 +53,7 @@ if (!is_array($config['unbound']['hosts'])) { } $a_hosts = &$config['unbound']['hosts']; - -if (is_numericint($_GET['id'])) { - $id = $_GET['id']; -} -if (isset($_POST['id']) && is_numericint($_POST['id'])) { - $id = $_POST['id']; -} +$id = $_REQUEST['id']; if (isset($id) && $a_hosts[$id]) { $pconfig['host'] = $a_hosts[$id]['host']; @@ -69,7 +63,7 @@ if (isset($id) && $a_hosts[$id]) { $pconfig['aliases'] = $a_hosts[$id]['aliases']; } -if ($_POST) { +if ($_POST['save']) { unset($input_errors); $pconfig = $_POST; @@ -179,24 +173,6 @@ if ($_POST) { } } -// Delete a row in the options table -if ($_GET['act'] == "delopt") { - $idx = $_GET['id']; - - if ($pconfig['aliases'] && is_array($pconfig['aliases']['item'][$idx])) { - unset($pconfig['aliases']['item'][$idx]); - } -} - -// Add an option row -if ($_GET['act'] == "addopt") { - if (!is_array($pconfig['aliases']['item'])) { - $pconfig['aliases']['item'] = array(); - } - - array_push($pconfig['aliases']['item'], array('host' => null, 'domain' => null, 'description' => null)); -} - $pgtitle = array(gettext("Services"), gettext("DNS Resolver"), gettext("General Settings"), gettext("Edit Host Override")); $pglinks = array("", "services_unbound.php", "services_unbound.php", "@self"); $shortcut_section = "resolver"; diff --git a/src/usr/local/www/services_wol.php b/src/usr/local/www/services_wol.php index 4119561..5afbf26 100644 --- a/src/usr/local/www/services_wol.php +++ b/src/usr/local/www/services_wol.php @@ -36,7 +36,7 @@ if (!is_array($config['wol']['wolentry'])) { } $a_wol = &$config['wol']['wolentry']; -if ($_GET['wakeall'] != "") { +if ($_REQUEST['wakeall'] != "") { $i = 0; $savemsg = ""; foreach ($a_wol as $wolent) { @@ -59,25 +59,20 @@ if ($_GET['wakeall'] != "") { } } -if ($_POST || $_GET['mac']) { +if ($_POST['Submit'] || $_POST['mac']) { unset($input_errors); - if ($_GET['mac']) { + if ($_POST['mac']) { /* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */ - $_GET['mac'] = strtolower(str_replace("-", ":", $_GET['mac'])); - $mac = $_GET['mac']; - $if = $_GET['if']; - } else { - /* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */ - $_POST['mac'] = strtolower(str_replace("-", ":", $_POST['mac'])); - $mac = $_POST['mac']; - $if = $_POST['interface']; + $mac = strtolower(str_replace("-", ":", $_POST['mac'])); + $if = $_POST['if']; } /* input validation */ if (!$mac || !is_macaddr($mac)) { $input_errors[] = gettext("A valid MAC address must be specified."); } + if (!$if) { $input_errors[] = gettext("A valid interface must be specified."); } @@ -101,9 +96,9 @@ if ($_POST || $_GET['mac']) { } } -if ($_GET['act'] == "del") { - if ($a_wol[$_GET['id']]) { - unset($a_wol[$_GET['id']]); +if ($_POST['act'] == "del") { + if ($a_wol[$_POST['id']]) { + unset($a_wol[$_POST['id']]); write_config(); header("Location: services_wol.php"); exit; @@ -192,8 +187,8 @@ print $form; </td> <td> <a class="fa fa-pencil" title="<?=gettext('Edit Device')?>" href="services_wol_edit.php?id=<?=$i?>"></a> - <a class="fa fa-trash" title="<?=gettext('Delete Device')?>" href="services_wol.php?act=del&id=<?=$i?>"></a> - <a class="fa fa-power-off" title="<?=gettext('Wake Device')?>" href="?mac=<?=$wolent['mac'];?>&if=<?=$wolent['interface'];?>"></a> + <a class="fa fa-trash" title="<?=gettext('Delete Device')?>" href="services_wol.php?act=del&id=<?=$i?>" usepost></a> + <a class="fa fa-power-off" title="<?=gettext('Wake Device')?>" href="?mac=<?=$wolent['mac'];?>&if=<?=$wolent['interface'];?>" usepost></a> </td> </tr> <?php endforeach?> diff --git a/src/usr/local/www/services_wol_edit.php b/src/usr/local/www/services_wol_edit.php index 17b192f..fe4011c 100644 --- a/src/usr/local/www/services_wol_edit.php +++ b/src/usr/local/www/services_wol_edit.php @@ -41,33 +41,35 @@ function wol_sort() { } require_once("guiconfig.inc"); + if (!is_array($config['wol']['wolentry'])) { $config['wol']['wolentry'] = array(); } + $a_wol = &$config['wol']['wolentry']; -if (is_numericint($_GET['id'])) { - $id = $_GET['id']; -} -if (isset($_POST['id']) && is_numericint($_POST['id'])) { - $id = $_POST['id']; +if (is_numericint($_REQUEST['id'])) { + $id = $_REQUEST['id']; } + if (isset($id) && $a_wol[$id]) { $pconfig['interface'] = $a_wol[$id]['interface']; $pconfig['mac'] = $a_wol[$id]['mac']; $pconfig['descr'] = $a_wol[$id]['descr']; } else { - $pconfig['interface'] = $_GET['if']; - $pconfig['mac'] = $_GET['mac']; - $pconfig['descr'] = $_GET['descr']; + $pconfig['interface'] = $_REQUEST['if']; + $pconfig['mac'] = $_REQUEST['mac']; + $pconfig['descr'] = $_REQUEST['descr']; } -if ($_POST) { +if ($_POST['save']) { unset($input_errors); $pconfig = $_POST; + + ) /* input validation */ $reqdfields = explode(" ", "interface mac"); $reqdfieldsn = array(gettext("Interface"), gettext("MAC address")); |