summaryrefslogtreecommitdiffstats
path: root/src/usr/local/www
diff options
context:
space:
mode:
Diffstat (limited to 'src/usr/local/www')
-rw-r--r--src/usr/local/www/diag_dns.php2
-rw-r--r--src/usr/local/www/firewall_aliases.php2
-rw-r--r--src/usr/local/www/firewall_aliases_edit.php38
-rw-r--r--src/usr/local/www/firewall_aliases_import.php4
-rw-r--r--src/usr/local/www/firewall_nat_1to1.php10
-rw-r--r--src/usr/local/www/firewall_nat_1to1_edit.php6
-rw-r--r--src/usr/local/www/firewall_nat_edit.php31
-rw-r--r--src/usr/local/www/firewall_nat_npt.php10
-rw-r--r--src/usr/local/www/firewall_nat_npt_edit.php2
-rw-r--r--src/usr/local/www/firewall_nat_out.php12
-rw-r--r--src/usr/local/www/firewall_nat_out_edit.php24
-rw-r--r--src/usr/local/www/firewall_rules.php14
-rw-r--r--src/usr/local/www/firewall_rules_edit.php50
-rw-r--r--src/usr/local/www/firewall_schedule.php2
-rw-r--r--src/usr/local/www/firewall_schedule_edit.php2
-rw-r--r--src/usr/local/www/firewall_virtual_ip.php2
-rw-r--r--src/usr/local/www/firewall_virtual_ip_edit.php2
-rw-r--r--src/usr/local/www/getserviceproviders.php9
-rw-r--r--src/usr/local/www/guiconfig.inc23
-rw-r--r--src/usr/local/www/index.php202
-rwxr-xr-xsrc/usr/local/www/interfaces.php5
-rw-r--r--src/usr/local/www/interfaces_bridge_edit.php4
-rw-r--r--src/usr/local/www/interfaces_ppps_edit.php4
-rw-r--r--src/usr/local/www/js/pfSenseHelpers.js5
-rw-r--r--src/usr/local/www/load_balancer_pool_edit.php2
-rw-r--r--src/usr/local/www/load_balancer_virtual_server_edit.php2
-rw-r--r--src/usr/local/www/pkg.php20
-rw-r--r--src/usr/local/www/pkg_edit.php18
-rw-r--r--src/usr/local/www/services_captiveportal_vouchers_edit.php2
-rw-r--r--src/usr/local/www/services_checkip.php7
-rw-r--r--src/usr/local/www/services_dnsmasq_domainoverride_edit.php2
-rw-r--r--src/usr/local/www/services_dnsmasq_edit.php16
-rw-r--r--src/usr/local/www/services_dyndns_edit.php2
-rw-r--r--src/usr/local/www/services_unbound.php21
-rw-r--r--src/usr/local/www/services_unbound_domainoverride_edit.php17
-rw-r--r--src/usr/local/www/services_unbound_host_edit.php42
-rw-r--r--src/usr/local/www/status_carp.php15
-rw-r--r--src/usr/local/www/status_logs_settings.php2
-rw-r--r--src/usr/local/www/system.php5
-rw-r--r--src/usr/local/www/system_advanced_firewall.php2
-rw-r--r--src/usr/local/www/system_certmanager.php156
-rw-r--r--src/usr/local/www/system_routes.php2
-rw-r--r--src/usr/local/www/system_routes_edit.php2
-rw-r--r--src/usr/local/www/system_update_settings.php2
-rw-r--r--src/usr/local/www/system_user_settings.php8
-rw-r--r--src/usr/local/www/system_usermanager.php8
-rw-r--r--src/usr/local/www/vpn_ipsec.php6
-rw-r--r--src/usr/local/www/vpn_ipsec_mobile.php2
-rw-r--r--src/usr/local/www/vpn_ipsec_phase1.php2
-rw-r--r--src/usr/local/www/vpn_ipsec_phase2.php2
-rw-r--r--src/usr/local/www/vpn_ipsec_settings.php2
-rw-r--r--src/usr/local/www/vpn_openvpn_client.php2
-rw-r--r--src/usr/local/www/widgets/javascript/thermal_sensors.js81
-rw-r--r--src/usr/local/www/widgets/widgets/captive_portal_status.widget.php8
-rw-r--r--src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php100
-rw-r--r--src/usr/local/www/widgets/widgets/gateways.widget.php322
-rw-r--r--src/usr/local/www/widgets/widgets/gmirror_status.widget.php7
-rw-r--r--src/usr/local/www/widgets/widgets/installed_packages.widget.php4
-rw-r--r--src/usr/local/www/widgets/widgets/interface_statistics.widget.php40
-rw-r--r--src/usr/local/www/widgets/widgets/interfaces.widget.php80
-rw-r--r--src/usr/local/www/widgets/widgets/ipsec.widget.php22
-rw-r--r--src/usr/local/www/widgets/widgets/log.widget.php52
-rw-r--r--src/usr/local/www/widgets/widgets/ntp_status.widget.php11
-rw-r--r--src/usr/local/www/widgets/widgets/openvpn.widget.php608
-rw-r--r--src/usr/local/www/widgets/widgets/picture.widget.php21
-rw-r--r--src/usr/local/www/widgets/widgets/rss.widget.php47
-rw-r--r--src/usr/local/www/widgets/widgets/services_status.widget.php31
-rw-r--r--src/usr/local/www/widgets/widgets/smart_status.widget.php32
-rw-r--r--src/usr/local/www/widgets/widgets/system_information.widget.php140
-rw-r--r--src/usr/local/www/widgets/widgets/thermal_sensors.widget.php163
-rw-r--r--src/usr/local/www/widgets/widgets/traffic_graphs.widget.php506
-rw-r--r--src/usr/local/www/widgets/widgets/wake_on_lan.widget.php42
-rw-r--r--src/usr/local/www/wizard.php2
-rw-r--r--src/usr/local/www/wizards/openvpn_wizard.inc6
-rw-r--r--src/usr/local/www/wizards/setup_wizard.xml6
-rw-r--r--src/usr/local/www/wizards/traffic_shaper_wizard_dedicated.inc6
-rw-r--r--src/usr/local/www/wizards/traffic_shaper_wizard_multi_all.inc5
77 files changed, 1837 insertions, 1339 deletions
diff --git a/src/usr/local/www/diag_dns.php b/src/usr/local/www/diag_dns.php
index de1b8bb..74238f1 100644
--- a/src/usr/local/www/diag_dns.php
+++ b/src/usr/local/www/diag_dns.php
@@ -117,7 +117,7 @@ if (isset($_POST['create_alias']) && (is_hostname($host) || is_ipaddr($host))) {
} else {
$a_aliases[] = $newalias;
}
- write_config();
+ write_config(gettext("Created an alias from Diagnostics - DNS Lookup page."));
$createdalias = true;
}
}
diff --git a/src/usr/local/www/firewall_aliases.php b/src/usr/local/www/firewall_aliases.php
index 54ac0d8..f932acd 100644
--- a/src/usr/local/www/firewall_aliases.php
+++ b/src/usr/local/www/firewall_aliases.php
@@ -97,7 +97,7 @@ if ($_POST['act'] == "del") {
unlink_if_exists("/var/db/aliastables/" . $a_aliases[$_POST['id']]['name'] . ".txt");
}
unset($a_aliases[$_POST['id']]);
- if (write_config()) {
+ if (write_config(gettext("Deleted a firewall alias."))) {
filter_configure();
mark_subsystem_dirty('aliases');
}
diff --git a/src/usr/local/www/firewall_aliases_edit.php b/src/usr/local/www/firewall_aliases_edit.php
index fc4b8b0..7a38c57 100644
--- a/src/usr/local/www/firewall_aliases_edit.php
+++ b/src/usr/local/www/firewall_aliases_edit.php
@@ -429,7 +429,7 @@ if ($_POST['save']) {
}
}
} else if ($_POST['type'] == "port") {
- if (!is_port($input_address) && !is_portrange($input_address)) {
+ if (!is_port_or_range($input_address)) {
$input_errors[] = sprintf(gettext("%s is not a valid port or alias."), $input_address);
}
} else if ($_POST['type'] == "host" || $_POST['type'] == "network") {
@@ -523,7 +523,7 @@ if ($_POST['save']) {
// Sort list
$a_aliases = msort($a_aliases, "name");
- if (write_config()) {
+ if (write_config(gettext("Edited a firewall alias."))) {
mark_subsystem_dirty('aliases');
}
@@ -611,6 +611,26 @@ $pattern_str = array(
'urltable_ports' => '.*' // Alias Name or URL
);
+$title_str = array(
+ 'network' => 'An IPv4 network address like 1.2.3.0, an IPv6 network address like 1:2a:3b:ffff::0, IP address range, FQDN or an alias',
+ 'host' => 'An IPv4 address like 1.2.3.4, an IPv6 address like 1:2a:3b:ffff::1, IP address range, FQDN or an alias',
+ 'port' => 'A port number, port number range or an alias',
+ 'url' => 'URL',
+ 'url_ports' => 'URL',
+ 'urltable' => 'URL',
+ 'urltable_ports' => 'URL'
+);
+
+$placeholder_str = array(
+ 'network' => 'Address',
+ 'host' => 'Address',
+ 'port' => 'Port',
+ 'url' => 'URL',
+ 'url_ports' => 'URL',
+ 'urltable' => 'URL',
+ 'urltable_ports' => 'URL'
+);
+
$types = array(
'host' => gettext("Host(s)"),
'network' => gettext("Network(s)"),
@@ -715,7 +735,7 @@ while ($counter < count($addresses)) {
$group->add(new Form_IpAddress(
'address' . $counter,
- $tab == 'port' ? 'Port':'Address',
+ 'Address',
$address,
'ALIASV4V6'
))->addMask('address_subnet' . $counter, $address_subnet)->setWidth(4)->setPattern($pattern_str[$tab]);
@@ -787,9 +807,15 @@ events.push(function() {
// Set the input field pattern by tab type
var patternstr = <?=json_encode($pattern_str);?>;
- for (i = 0; i < <?=$counter;?>; i++) {
- $('#address' + i).prop('pattern', patternstr[tab]);
- }
+ var titlestr = <?=json_encode($title_str);?>;
+ var placeholderstr = <?=json_encode($placeholder_str);?>;
+ $("[id^='address']").each(function () {
+ if (/^address[0-9]+$/.test(this.id)) {
+ $('#' + this.id).prop('pattern', patternstr[tab]);
+ $('#' + this.id).prop('title', titlestr[tab]);
+ $('#' + this.id).prop('placeholder', placeholderstr[tab]);
+ }
+ });
// Hide and disable rows other than the first
hideRowsAfter(1, (tab == 'urltable') || (tab == 'urltable_ports'));
diff --git a/src/usr/local/www/firewall_aliases_import.php b/src/usr/local/www/firewall_aliases_import.php
index d3928ee..df7fd86 100644
--- a/src/usr/local/www/firewall_aliases_import.php
+++ b/src/usr/local/www/firewall_aliases_import.php
@@ -121,7 +121,7 @@ if ($_POST) {
if ($tab == "port") {
// Port alias
if (!empty($impip)) {
- if (is_port($impip) || is_portrange($impip)) {
+ if (is_port_or_range($impip)) {
$imported_ips[] = $impip;
$imported_descs[] = $impdesc;
} else {
@@ -183,7 +183,7 @@ if ($_POST) {
// Sort list
$a_aliases = msort($a_aliases, "name");
- if (write_config()) {
+ if (write_config(gettext("Imported a firewall alias."))) {
mark_subsystem_dirty('aliases');
}
diff --git a/src/usr/local/www/firewall_nat_1to1.php b/src/usr/local/www/firewall_nat_1to1.php
index d779da8..77684cd 100644
--- a/src/usr/local/www/firewall_nat_1to1.php
+++ b/src/usr/local/www/firewall_nat_1to1.php
@@ -53,7 +53,7 @@ if (array_key_exists('order-store', $_POST)) {
$a_1to1 = $a_1to1_new;
- if (write_config()) {
+ if (write_config(gettext("Firewall: NAT: 1:1 - reordered NAT 1:1 mappings."))) {
mark_subsystem_dirty('natconf');
}
@@ -76,7 +76,7 @@ if ($_POST['apply']) {
if ($_POST['act'] == "del") {
if ($a_1to1[$_POST['id']]) {
unset($a_1to1[$_POST['id']]);
- if (write_config()) {
+ if (write_config(gettext("Firewall: NAT: 1:1 - deleted NAT 1:1 mapping."))) {
mark_subsystem_dirty('natconf');
}
@@ -92,7 +92,7 @@ if (isset($_POST['del_x'])) {
unset($a_1to1[$rulei]);
}
- if (write_config()) {
+ if (write_config(gettext("Firewall: NAT: 1:1 - deleted selected NAT 1:1 mappings."))) {
mark_subsystem_dirty('natconf');
}
@@ -104,10 +104,12 @@ if (isset($_POST['del_x'])) {
if ($a_1to1[$_POST['id']]) {
if (isset($a_1to1[$_POST['id']]['disabled'])) {
unset($a_1to1[$_POST['id']]['disabled']);
+ $wc_msg = gettext('Firewall: NAT: 1:1 - enabled a NAT 1:1 rule.');
} else {
$a_1to1[$_POST['id']]['disabled'] = true;
+ $wc_msg = gettext('Firewall: NAT: 1:1 - disabled a NAT 1:1 rule.');
}
- if (write_config(gettext("Firewall: NAT: 1:1, enable/disable NAT rule"))) {
+ if (write_config($wc_msg)) {
mark_subsystem_dirty('natconf');
}
header("Location: firewall_nat_1to1.php");
diff --git a/src/usr/local/www/firewall_nat_1to1_edit.php b/src/usr/local/www/firewall_nat_1to1_edit.php
index e27d433..f3f3734 100644
--- a/src/usr/local/www/firewall_nat_1to1_edit.php
+++ b/src/usr/local/www/firewall_nat_1to1_edit.php
@@ -104,6 +104,10 @@ if ($_POST['save']) {
* cannot think he is slick and perform a XSS attack on the unwilling
*/
foreach ($_POST as $key => $value) {
+ if ($key == 'descr') {
+ continue;
+ }
+
$temp = str_replace(">", "", $value);
$newpost = htmlentities($temp);
@@ -275,7 +279,7 @@ if ($_POST['save']) {
}
}
- if (write_config()) {
+ if (write_config(gettext("Firewall: NAT: 1:1 - saved/edited NAT 1:1 mapping."))) {
mark_subsystem_dirty('natconf');
}
header("Location: firewall_nat_1to1.php");
diff --git a/src/usr/local/www/firewall_nat_edit.php b/src/usr/local/www/firewall_nat_edit.php
index 96869b5..ddba4fa 100644
--- a/src/usr/local/www/firewall_nat_edit.php
+++ b/src/usr/local/www/firewall_nat_edit.php
@@ -114,6 +114,10 @@ if (isset($_REQUEST['dup']) && is_numericint($_REQUEST['dup'])) {
unset($input_errors);
foreach ($_REQUEST as $key => $value) {
+ if ($key == 'descr') {
+ continue;
+ }
+
$temp = $value;
$newpost = htmlentities($temp);
@@ -255,20 +259,20 @@ if ($_POST['save']) {
$input_errors[] = sprintf(gettext("Redirect target IP must be IPv4."));
}
- if ($_POST['srcbeginport'] && !is_portoralias($_POST['srcbeginport'])) {
+ if ($_POST['srcbeginport'] && !is_port_or_alias($_POST['srcbeginport'])) {
$input_errors[] = sprintf(gettext("%s is not a valid start source port. It must be a port alias or integer between 1 and 65535."), $_POST['srcbeginport']);
}
- if ($_POST['srcendport'] && !is_portoralias($_POST['srcendport'])) {
+ if ($_POST['srcendport'] && !is_port_or_alias($_POST['srcendport'])) {
$input_errors[] = sprintf(gettext("%s is not a valid end source port. It must be a port alias or integer between 1 and 65535."), $_POST['srcendport']);
}
- if ($_POST['dstbeginport'] && !is_portoralias($_POST['dstbeginport'])) {
+ if ($_POST['dstbeginport'] && !is_port_or_alias($_POST['dstbeginport'])) {
$input_errors[] = sprintf(gettext("%s is not a valid start destination port. It must be a port alias or integer between 1 and 65535."), $_POST['dstbeginport']);
}
- if ($_POST['dstendport'] && !is_portoralias($_POST['dstendport'])) {
+ if ($_POST['dstendport'] && !is_port_or_alias($_POST['dstendport'])) {
$input_errors[] = sprintf(gettext("%s is not a valid end destination port. It must be a port alias or integer between 1 and 65535."), $_POST['dstendport']);
}
- if ((strtoupper($_POST['proto']) == "TCP" || strtoupper($_POST['proto']) == "UDP" || strtoupper($_POST['proto']) == "TCP/UDP") && (!isset($_POST['nordr']) && !is_portoralias($_POST['localbeginport']))) {
+ if ((strtoupper($_POST['proto']) == "TCP" || strtoupper($_POST['proto']) == "UDP" || strtoupper($_POST['proto']) == "TCP/UDP") && (!isset($_POST['nordr']) && !is_port_or_alias($_POST['localbeginport']))) {
$input_errors[] = sprintf(gettext("%s is not a valid redirect target port. It must be a port alias or integer between 1 and 65535."), $_POST['localbeginport']);
}
@@ -516,7 +520,7 @@ if ($_POST['save']) {
}
}
- if (write_config()) {
+ if (write_config(gettext("Firewall: NAT: Port Forward - saved/edited a port forward rule."))) {
mark_subsystem_dirty('natconf');
}
@@ -584,14 +588,16 @@ function build_dsttype_list() {
$list[$ifent . 'ip'] = $ifdesc . ' address';
}
}
-
+
+ //Temporary array so we can sort IPs
+ $templist = array();
if (is_array($config['virtualip']['vip'])) {
foreach ($config['virtualip']['vip'] as $sn) {
if (is_ipaddrv6($sn['subnet'])) {
continue;
}
if (($sn['mode'] == "proxyarp" || $sn['mode'] == "other") && $sn['type'] == "network") {
- $list[$sn['subnet'] . '/' . $sn['subnet_bits']] = 'Subnet: ' . $sn['subnet'] . '/' . $sn['subnet_bits'] . ' (' . $sn['descr'] . ')';
+ $templist[$sn['subnet'] . '/' . $sn['subnet_bits']] = 'Subnet: ' . $sn['subnet'] . '/' . $sn['subnet_bits'] . ' (' . $sn['descr'] . ')';
if (isset($sn['noexpand'])) {
continue;
}
@@ -602,13 +608,18 @@ function build_dsttype_list() {
for ($i = 0; $i <= $len; $i++) {
$snip = long2ip32($start+$i);
- $list[$snip] = $snip . ' (' . $sn['descr'] . ')';
+ $templist[$snip] = $snip . ' (' . $sn['descr'] . ')';
}
} else {
- $list[$sn['subnet']] = $sn['subnet'] . ' (' . $sn['descr'] . ')';
+ $templist[$sn['subnet']] = $sn['subnet'] . ' (' . $sn['descr'] . ')';
}
}
}
+
+ //Sort temp IP array and append onto main array
+ asort($templist);
+ $list = array_merge($list, $templist);
+ unset($templist);
return($list);
}
diff --git a/src/usr/local/www/firewall_nat_npt.php b/src/usr/local/www/firewall_nat_npt.php
index a12fe40..503b8c5 100644
--- a/src/usr/local/www/firewall_nat_npt.php
+++ b/src/usr/local/www/firewall_nat_npt.php
@@ -54,7 +54,7 @@ if (array_key_exists('order-store', $_REQUEST)) {
$a_npt = $a_npt_new;
- if (write_config()) {
+ if (write_config(gettext("Firewall: NAT: NPt - reordered NPt mappings."))) {
mark_subsystem_dirty('natconf');
}
@@ -76,7 +76,7 @@ if ($_POST['apply']) {
if ($_POST['act'] == "del") {
if ($a_npt[$_POST['id']]) {
unset($a_npt[$_POST['id']]);
- if (write_config()) {
+ if (write_config(gettext("Firewall: NAT: NPt - deleted NPt mapping."))) {
mark_subsystem_dirty('natconf');
}
header("Location: firewall_nat_npt.php");
@@ -91,7 +91,7 @@ if (isset($_POST['del_x'])) {
unset($a_npt[$rulei]);
}
- if (write_config()) {
+ if (write_config(gettext("Firewall: NAT: NPt - deleted selected NPt mappings."))) {
mark_subsystem_dirty('natconf');
}
@@ -103,10 +103,12 @@ if (isset($_POST['del_x'])) {
if ($a_npt[$_POST['id']]) {
if (isset($a_npt[$_POST['id']]['disabled'])) {
unset($a_npt[$_POST['id']]['disabled']);
+ $wc_msg = gettext('Firewall: NAT: NPt - enabled NPt rule.');
} else {
$a_npt[$_POST['id']]['disabled'] = true;
+ $wc_msg = gettext('Firewall: NAT: NPt - disabled NPt rule.');
}
- if (write_config(gettext("Firewall: NAT: NPt, enable/disable NAT rule"))) {
+ if (write_config($wc_msg)) {
mark_subsystem_dirty('natconf');
}
header("Location: firewall_nat_npt.php");
diff --git a/src/usr/local/www/firewall_nat_npt_edit.php b/src/usr/local/www/firewall_nat_npt_edit.php
index 8bc53bd..f0958e4 100644
--- a/src/usr/local/www/firewall_nat_npt_edit.php
+++ b/src/usr/local/www/firewall_nat_npt_edit.php
@@ -128,7 +128,7 @@ if ($_POST['save']) {
}
}
- if (write_config()) {
+ if (write_config(gettext("Firewall: NAT: NPt - saved/edited NPt mapping."))) {
mark_subsystem_dirty('natconf');
}
diff --git a/src/usr/local/www/firewall_nat_out.php b/src/usr/local/www/firewall_nat_out.php
index 44e0cea..d08eb30 100644
--- a/src/usr/local/www/firewall_nat_out.php
+++ b/src/usr/local/www/firewall_nat_out.php
@@ -62,7 +62,7 @@ if (isset($_REQUEST['order-store'])) {
$a_out = $a_out_new;
- if (write_config()) {
+ if (write_config(gettext("Firewall: NAT: Outbound - reordered outbound NAT mappings."))) {
mark_subsystem_dirty('natconf');
}
@@ -139,7 +139,7 @@ if ($_POST['save']) {
$config['nat']['outbound']['mode'] = $_POST['mode'];
- if (write_config()) {
+ if (write_config(gettext("Firewall: NAT: Outbound - saved outbound NAT settings."))) {
mark_subsystem_dirty('natconf');
}
@@ -152,7 +152,7 @@ if ($_POST['act'] == "del") {
if ($a_out[$_POST['id']]) {
unset($a_out[$_POST['id']]);
- if (write_config()) {
+ if (write_config(gettext("Firewall: NAT: Outbound - deleted outbound NAT mapping."))) {
mark_subsystem_dirty('natconf');
}
@@ -173,7 +173,7 @@ if (isset($_POST['del_x'])) {
unset($a_out[$rulei]);
}
- if (write_config()) {
+ if (write_config(gettext("Firewall: NAT: Outbound - deleted selected outbound NAT mappings."))) {
mark_subsystem_dirty('natconf');
}
@@ -185,10 +185,12 @@ if (isset($_POST['del_x'])) {
if ($a_out[$_POST['id']]) {
if (isset($a_out[$_POST['id']]['disabled'])) {
unset($a_out[$_POST['id']]['disabled']);
+ $wc_msg = gettext('Firewall: NAT: Outbound - enabled outbound NAT rule.');
} else {
$a_out[$_POST['id']]['disabled'] = true;
+ $wc_msg = gettext('Firewall: NAT: Outbound - disabled outbound NAT rule.');
}
- if (write_config("Firewall: NAT: Outbound, enable/disable NAT rule")) {
+ if (write_config($wc_msg)) {
mark_subsystem_dirty('natconf');
}
diff --git a/src/usr/local/www/firewall_nat_out_edit.php b/src/usr/local/www/firewall_nat_out_edit.php
index 92f9060..ad7e3d0 100644
--- a/src/usr/local/www/firewall_nat_out_edit.php
+++ b/src/usr/local/www/firewall_nat_out_edit.php
@@ -146,6 +146,10 @@ if ($_POST['save']) {
* cannot think he is slick and perform a XSS attack on the unwilling
*/
foreach ($_POST as $key => $value) {
+ if ($key == 'descr') {
+ continue;
+ }
+
$temp = str_replace(">", "", $value);
$newpost = htmlentities($temp);
if ($newpost <> $temp) {
@@ -185,15 +189,15 @@ if ($_POST['save']) {
$_POST['target'] = substr($_POST['target'], 1);
}
- if ($protocol_uses_ports && $_POST['sourceport'] <> "" && !(is_portoralias($_POST['sourceport']) || is_portrange($_POST['sourceport']))) {
+ if ($protocol_uses_ports && $_POST['sourceport'] <> "" && !is_port_or_range_or_alias($_POST['sourceport'])) {
$input_errors[] = gettext("A valid port or port alias must be supplied for the source port entry.");
}
- if ($protocol_uses_ports && $_POST['dstport'] <> "" && !(is_portoralias($_POST['dstport']) || is_portrange($_POST['dstport']))) {
+ if ($protocol_uses_ports && $_POST['dstport'] <> "" && !is_port_or_range_or_alias($_POST['dstport'])) {
$input_errors[] = gettext("A valid port or port alias must be supplied for the destination port entry.");
}
- if ($protocol_uses_ports && $_POST['natport'] <> "" && !(is_portoralias($_POST['natport']) || is_portrange($_POST['natport'])) && !isset($_POST['nonat'])) {
+ if ($protocol_uses_ports && $_POST['natport'] <> "" && !is_port_or_range_or_alias($_POST['natport']) && !isset($_POST['nonat'])) {
$input_errors[] = gettext("A valid port must be supplied for the NAT port entry.");
}
@@ -378,7 +382,7 @@ if ($_POST['save']) {
}
}
- if (write_config()) {
+ if (write_config(gettext("Firewall: NAT: Outbound - saved/edited outbound NAT mapping."))) {
mark_subsystem_dirty('natconf');
}
header("Location: firewall_nat_out.php");
@@ -406,10 +410,12 @@ function build_target_list() {
$list[""] = gettext('Interface Address');
+ //Temporary array so we can sort IPs
+ $templist = array();
if (is_array($config['virtualip']['vip'])) {
foreach ($config['virtualip']['vip'] as $sn) {
if (($sn['mode'] == "proxyarp" || $sn['mode'] == "other") && $sn['type'] == "network") {
- $list['S' . $sn['subnet'] . '/' . $sn['subnet_bits']] = gettext('Subnet: ') . $sn['subnet'] . '/' . $sn['subnet_bits'] . ' (' . $sn['descr'] . ')';
+ $templist['S' . $sn['subnet'] . '/' . $sn['subnet_bits']] = gettext('Subnet: ') . $sn['subnet'] . '/' . $sn['subnet_bits'] . ' (' . $sn['descr'] . ')';
if (isset($sn['noexpand'])) {
continue;
}
@@ -419,13 +425,17 @@ function build_target_list() {
for ($i = 0; $i <= $len; $i++) {
$snip = long2ip32($start+$i);
- $list['I' . $snip] = $snip . ' (' . $sn['descr'] . ')';
+ $templist['I' . $snip] = $snip . ' (' . $sn['descr'] . ')';
}
} else {
- $list['I' . $sn['subnet']] = $sn['subnet'] . ' (' . $sn['descr'] . ')';
+ $templist['I' . $sn['subnet']] = $sn['subnet'] . ' (' . $sn['descr'] . ')';
}
}
}
+ asort($templist);
+ //Append sorted IP array onto main array
+ $list = array_merge($list, $templist);
+ unset($templist);
foreach ($a_aliases as $alias) {
if ($alias['type'] != "host") {
diff --git a/src/usr/local/www/firewall_rules.php b/src/usr/local/www/firewall_rules.php
index aff201a..c917100 100644
--- a/src/usr/local/www/firewall_rules.php
+++ b/src/usr/local/www/firewall_rules.php
@@ -187,7 +187,7 @@ if ($_POST['act'] == "del") {
$mvnrows = -1;
move_separators($a_separators, $ridx, $mvnrows);
- if (write_config()) {
+ if (write_config(gettext("Firewall: Rules - deleted a firewall rule."))) {
mark_subsystem_dirty('filter');
}
@@ -223,7 +223,7 @@ if (isset($_POST['del_x'])) {
}
if ($deleted) {
- if (write_config()) {
+ if (write_config(gettext("Firewall: Rules - deleted selected firewall rules."))) {
mark_subsystem_dirty('filter');
}
}
@@ -235,10 +235,12 @@ if (isset($_POST['del_x'])) {
if ($a_filter[$_POST['id']]) {
if (isset($a_filter[$_POST['id']]['disabled'])) {
unset($a_filter[$_POST['id']]['disabled']);
+ $wc_msg = gettext('Firewall: Rules - enabled a firewall rule.');
} else {
$a_filter[$_POST['id']]['disabled'] = true;
+ $wc_msg = gettext('Firewall: Rules - disabled a firewall rule.');
}
- if (write_config()) {
+ if (write_config($wc_msg)) {
mark_subsystem_dirty('filter');
}
@@ -289,7 +291,7 @@ if (isset($_POST['del_x'])) {
}
}
- if (write_config()) {
+ if (write_config(gettext("Firewall: Rules - reordered firewall rules."))) {
mark_subsystem_dirty('filter');
}
@@ -330,7 +332,7 @@ if (is_subsystem_dirty('filter')) {
print_apply_box(gettext("The firewall rule configuration has been changed.") . "<br />" . gettext("The changes must be applied for them to take effect."));
}
-display_top_tabs($tab_array, false, 'pills', "usepost");
+display_top_tabs($tab_array, false, 'pills');
$showantilockout = false;
$showprivate = false;
@@ -940,7 +942,7 @@ events.push(function() {
}
});
- // If so, change the icon to show the insetion point
+ // If so, change the icon to show the insertion point
if (ruleselected) {
if (e.shiftKey) {
$(this).removeClass().addClass("fa fa-lg fa-arrow-down text-danger");
diff --git a/src/usr/local/www/firewall_rules_edit.php b/src/usr/local/www/firewall_rules_edit.php
index 171cab6..1012906 100644
--- a/src/usr/local/www/firewall_rules_edit.php
+++ b/src/usr/local/www/firewall_rules_edit.php
@@ -295,6 +295,7 @@ if (isset($id) && $a_filter[$id]) {
if ($_REQUEST['if']) {
$pconfig['interface'] = $_REQUEST['if'];
}
+ $pconfig['ipprotocol'] = "inet"; // other things depend on this, set a sensible default
$pconfig['type'] = "pass";
$pconfig['proto'] = "tcp"; // for new blank rules, default=tcp, also ensures ports fields are visible
$pconfig['src'] = "any";
@@ -319,6 +320,19 @@ if ($_POST['save']) {
if (!array_key_exists($_POST['ipprotocol'], $icmplookup)) {
$input_errors[] = gettext("The IP protocol is not recognized.");
+ unset($_POST['ipprotocol']);
+ }
+
+ // add validation + input error for $_POST['interface']
+
+ $valid = ($_POST['interface'] == "FloatingRules" || isset($_POST['floating'])) ? ['pass','block','reject', 'match'] : ['pass','block','reject'];
+ if (!(is_string($_POST['type']) && in_array($_POST['type'], $valid))) {
+ $input_errors[] = gettext("A valid rule type is not selected.");
+ unset($_POST['type']);
+ }
+
+ if (isset($_POST['tracker']) && !is_numericint($_POST['tracker'])) {
+ unset($_POST['tracker']); // silently unset hidden input if invalid
}
if (isset($a_filter[$id]['associated-rule-id'])) {
@@ -328,7 +342,7 @@ if ($_POST['save']) {
}
}
- if (($_POST['ipprotocol'] <> "") && ($_POST['gateway'] <> "")) {
+ if (isset($_POST['ipprotocol']) && $_POST['gateway'] <> '') {
if (is_array($config['gateways']['gateway_group'])) {
foreach ($config['gateways']['gateway_group'] as $gw_group) {
if ($gw_group['name'] == $_POST['gateway'] && $_POST['ipprotocol'] != $a_gatewaygroups[$_POST['gateway']]['ipprotocol']) {
@@ -423,6 +437,11 @@ if ($_POST['save']) {
$pconfig = $_POST;
+ if (!isset($pconfig['ipprotocol'])) {
+ // other things depend on this, so ensure a valid value if none provided
+ $pconfig['ipprotocol'] = "inet";
+ }
+
if (($_POST['proto'] == "icmp") && count($_POST['icmptype'])) {
$pconfig['icmptype'] = implode(',', $_POST['icmptype']);
} else {
@@ -472,16 +491,16 @@ if ($_POST['save']) {
$_POST['dstendport'] = 0;
}
- if ($_POST['srcbeginport'] && !is_portoralias($_POST['srcbeginport'])) {
+ if ($_POST['srcbeginport'] && !is_port_or_alias($_POST['srcbeginport'])) {
$input_errors[] = sprintf(gettext("%s is not a valid start source port. It must be a port alias or integer between 1 and 65535."), $_POST['srcbeginport']);
}
- if ($_POST['srcendport'] && !is_portoralias($_POST['srcendport'])) {
+ if ($_POST['srcendport'] && !is_port_or_alias($_POST['srcendport'])) {
$input_errors[] = sprintf(gettext("%s is not a valid end source port. It must be a port alias or integer between 1 and 65535."), $_POST['srcendport']);
}
- if ($_POST['dstbeginport'] && !is_portoralias($_POST['dstbeginport'])) {
+ if ($_POST['dstbeginport'] && !is_port_or_alias($_POST['dstbeginport'])) {
$input_errors[] = sprintf(gettext("%s is not a valid start destination port. It must be a port alias or integer between 1 and 65535."), $_POST['dstbeginport']);
}
- if ($_POST['dstendport'] && !is_portoralias($_POST['dstendport'])) {
+ if ($_POST['dstendport'] && !is_port_or_alias($_POST['dstendport'])) {
$input_errors[] = sprintf(gettext("%s is not a valid end destination port. It must be a port alias or integer between 1 and 65535."), $_POST['dstendport']);
}
if (!$_POST['srcbeginport_cust'] && $_POST['srcendport_cust']) {
@@ -554,14 +573,14 @@ if ($_POST['save']) {
}
}
if ((is_ipaddrv6($_POST['src']) || is_ipaddrv6($_POST['dst'])) && ($_POST['ipprotocol'] == "inet")) {
- $input_errors[] = gettext("IPv6 addresses cannot be used in IPv4 rules.");
+ $input_errors[] = gettext("IPv6 addresses cannot be used in IPv4 rules (except within an alias).");
}
if ((is_ipaddrv4($_POST['src']) || is_ipaddrv4($_POST['dst'])) && ($_POST['ipprotocol'] == "inet6")) {
- $input_errors[] = gettext("IPv4 addresses can not be used in IPv6 rules.");
+ $input_errors[] = gettext("IPv4 addresses can not be used in IPv6 rules (except within an alias).");
}
if ((is_ipaddr($_POST['src']) || is_ipaddr($_POST['dst'])) && ($_POST['ipprotocol'] == "inet46")) {
- $input_errors[] = gettext("IPv4 and IPv6 addresses can not be used in rules that apply to both IPv4 and IPv6.");
+ $input_errors[] = gettext("IPv4 and IPv6 addresses can not be used in rules that apply to both IPv4 and IPv6 (except within an alias).");
}
if ($_POST['srcbeginport'] > $_POST['srcendport']) {
@@ -593,8 +612,8 @@ if ($_POST['save']) {
} elseif (!isset($t) || count($t) == 0) {
// not specified or none selected
unset($_POST['icmptype']);
- } else {
- // check data
+ } elseif (isset($_POST['ipprotocol'])) {
+ // check data; if ipprotocol invalid then safe to skip this (we can't determine valid icmptypes, but input error already raised for ipprotocol)
$bad_types = array();
if ((count($t) == 1 && !isset($t['any'])) || count($t) > 1) {
// Only need to check valid if just one selected != "any", or >1 selected
@@ -642,7 +661,7 @@ if ($_POST['save']) {
$input_errors[] = gettext("Please select a gateway, normally the interface selected gateway, so the limiters work correctly");
}
}
- if (!empty($_POST['ruleid']) && !ctype_digit($_POST['ruleid'])) {
+ if (!empty($_POST['ruleid']) && !is_numericint($_POST['ruleid'])) {
$input_errors[] = gettext('ID must be an integer');
}
@@ -755,13 +774,12 @@ if ($_POST['save']) {
$filterent['tracker'] = empty($_POST['tracker']) ? (int)microtime(true) : $_POST['tracker'];
$filterent['type'] = $_POST['type'];
+
if (isset($_POST['interface'])) {
$filterent['interface'] = $_POST['interface'];
- }
+ } // FIXME: can $_POST['interface'] be unset at this point, if so then what?
- if (isset($_POST['ipprotocol'])) {
- $filterent['ipprotocol'] = $_POST['ipprotocol'];
- }
+ $filterent['ipprotocol'] = $_POST['ipprotocol'];
if ($_POST['tcpflags_any']) {
$filterent['tcpflags_any'] = true;
@@ -994,7 +1012,7 @@ if ($_POST['save']) {
filter_rules_sort();
- if (write_config()) {
+ if (write_config(gettext("Firewall: Rules - saved/edited a firewall rule."))) {
mark_subsystem_dirty('filter');
}
diff --git a/src/usr/local/www/firewall_schedule.php b/src/usr/local/www/firewall_schedule.php
index 066ae24..a803341 100644
--- a/src/usr/local/www/firewall_schedule.php
+++ b/src/usr/local/www/firewall_schedule.php
@@ -69,7 +69,7 @@ if ($_POST['act'] == "del") {
$savemsg = sprintf(gettext("Cannot delete schedule. Currently in use by %s."), $referenced_by);
} else {
unset($a_schedules[$_POST['id']]);
- write_config();
+ write_config(gettext("Firewall schedule deleted."));
header("Location: firewall_schedule.php");
exit;
}
diff --git a/src/usr/local/www/firewall_schedule_edit.php b/src/usr/local/www/firewall_schedule_edit.php
index 7267079..ce62b81 100644
--- a/src/usr/local/www/firewall_schedule_edit.php
+++ b/src/usr/local/www/firewall_schedule_edit.php
@@ -186,7 +186,7 @@ if ($_POST['save']) {
schedule_sort();
- if (write_config()) {
+ if (write_config(gettext("Firewall schedule configured."))) {
filter_configure();
}
diff --git a/src/usr/local/www/firewall_virtual_ip.php b/src/usr/local/www/firewall_virtual_ip.php
index d4ea401..183337e 100644
--- a/src/usr/local/www/firewall_virtual_ip.php
+++ b/src/usr/local/www/firewall_virtual_ip.php
@@ -215,7 +215,7 @@ if ($_POST['act'] == "del") {
if (count($config['virtualip']['vip']) == 0) {
unset($config['virtualip']['vip']);
}
- write_config();
+ write_config(gettext("Deleted a virtual IP."));
header("Location: firewall_virtual_ip.php");
exit;
}
diff --git a/src/usr/local/www/firewall_virtual_ip_edit.php b/src/usr/local/www/firewall_virtual_ip_edit.php
index 6a76e0b..f550d83 100644
--- a/src/usr/local/www/firewall_virtual_ip_edit.php
+++ b/src/usr/local/www/firewall_virtual_ip_edit.php
@@ -270,7 +270,7 @@ if ($_POST['save']) {
$a_vip[$id] = $vipent;
- if (write_config()) {
+ if (write_config(gettext("Saved/edited a virtual IP."))) {
mark_subsystem_dirty('vip');
file_put_contents("{$g['tmp_path']}/.firewall_virtual_ip.apply", serialize($toapplylist));
}
diff --git a/src/usr/local/www/getserviceproviders.php b/src/usr/local/www/getserviceproviders.php
index b9fd2b1..e4d9f91 100644
--- a/src/usr/local/www/getserviceproviders.php
+++ b/src/usr/local/www/getserviceproviders.php
@@ -42,6 +42,7 @@ function get_country_providers($country) {
return is_array($sp['provider'][0]) ? $sp['provider'] : array($sp['provider']);
}
}
+ $provider_list = (is_array($provider_list)) ? $provider_list : array();
return $provider_list;
}
@@ -59,8 +60,12 @@ function country_list() {
function providers_list($country) {
$serviceproviders = get_country_providers($country);
- foreach ($serviceproviders as $sp) {
- echo $sp['name']['value'] . "\n";
+ if (is_array($serviceproviders)) {
+ foreach ($serviceproviders as $sp) {
+ echo $sp['name']['value'] . "\n";
+ }
+ } else {
+ $serviceproviders = array();
}
}
diff --git a/src/usr/local/www/guiconfig.inc b/src/usr/local/www/guiconfig.inc
index 433b3b6..fb0134f 100644
--- a/src/usr/local/www/guiconfig.inc
+++ b/src/usr/local/www/guiconfig.inc
@@ -1091,13 +1091,14 @@ function add_package_tabs($tabgroup, &$tab_array) {
}
foreach ($config['installedpackages']['package'] as $pkg) {
- $pkg_config = read_package_configurationfile($pkg['name']);
-
- if (!isset($pkg_config['tabs']['tab'])) {
+ if (!is_array($pkg['tabs']['tab'])) {
continue;
}
- foreach ($pkg_config['tabs']['tab'] as $tab) {
+ foreach ($pkg['tabs']['tab'] as $tab) {
+ if ($tab['tabgroup'] != $tabgroup) {
+ continue;
+ }
$tab_entry = array();
if ($tab['name']) {
$tab_entry[] = $tab['name'];
@@ -1110,7 +1111,7 @@ function add_package_tabs($tabgroup, &$tab_array) {
}
function alias_info_popup($alias_id) {
- global $config;
+ global $config, $user_settings;
if (!is_array($config['aliases']['alias'][$alias_id])) {
return;
@@ -1120,7 +1121,13 @@ function alias_info_popup($alias_id) {
$alias = $config['aliases']['alias'][$alias_id];
$content = "";
- if ($alias['url']) {
+ if ($user_settings['webgui']['disablealiaspopupdetail']) {
+ if (strlen($alias['descr']) >= $maxlength) {
+ $alias['descr'] = substr($alias['descr'], 0, $maxlength) . '&hellip;';
+ }
+
+ $content .= $alias['descr'];
+ } else if ($alias['url']) {
// TODO: Change it when pf supports tables with ports
if ($alias['type'] == "urltable") {
exec("/sbin/pfctl -t {$alias['name']} -T show | wc -l", $total_entries);
@@ -1164,10 +1171,6 @@ function alias_info_popup($alias_id) {
$content .= "<table>\n";
}
- if (strlen($alias['descr']) >= $maxlength) {
- $alias['descr'] = substr($alias['descr'], 0, $maxlength) . '&hellip;';
- }
-
return $content;
}
diff --git a/src/usr/local/www/index.php b/src/usr/local/www/index.php
index cfd4578..e4ac5c2 100644
--- a/src/usr/local/www/index.php
+++ b/src/usr/local/www/index.php
@@ -108,16 +108,16 @@ foreach ($phpincludefiles as $includename) {
##build list of widgets
foreach (glob("/usr/local/www/widgets/widgets/*.widget.php") as $file) {
- $name = basename($file, '.widget.php');
+ $basename = basename($file, '.widget.php');
// Get the widget title that should be in a var defined in the widget's inc file.
- $widgettitle = ${$name . '_title'};
+ $widgettitle = ${$basename . '_title'};
if (empty(trim($widgettitle))) {
// Fall back to constructing a title from the file name of the widget.
- $widgettitle = ucwords(str_replace('_', ' ', $name));
+ $widgettitle = ucwords(str_replace('_', ' ', $basename));
}
- $widgets[ $name ] = array('name' => $widgettitle, 'display' => 'none');
+ $known_widgets[$basename . '-0'] = array('basename' => $basename, 'title' => $widgettitle, 'display' => 'none');
}
##if no config entry found, initialize config entry
@@ -133,11 +133,54 @@ if ($_POST && $_POST['sequence']) {
// Start with the user's widget settings.
$widget_settings = $user_settings['widgets'];
- $widget_settings['sequence'] = rtrim($_POST['sequence'], ',');
+ $widget_sep = ',';
+ $widget_seq_array = explode($widget_sep, rtrim($_POST['sequence'], $widget_sep));
+ $widget_counter_array = array();
+ $widget_sep = '';
- foreach ($widgets as $widgetname => $widgetconfig) {
- if ($_POST[$widgetname . '-config']) {
- $widget_settings[$widgetname . '-config'] = $_POST[$widgetname . '-config'];
+ // Make a record of the counter of each widget that is in use.
+ foreach ($widget_seq_array as $widget_seq_data) {
+ list($basename, $col, $display, $widget_counter) = explode(':', $widget_seq_data);
+
+ if ($widget_counter != 'next') {
+ $widget_counter_array[$basename][$widget_counter] = true;
+ $widget_sequence .= $widget_sep . $widget_seq_data;
+ $widget_sep = ',';
+ }
+ }
+
+ // Find any new entry (and do not assume there is only 1 new entry)
+ foreach ($widget_seq_array as $widget_seq_data) {
+ list($basename, $col, $display, $widget_counter) = explode(':', $widget_seq_data);
+
+ if ($widget_counter == 'next') {
+ // Construct the widget counter of the new widget instance by finding
+ // the first non-negative integer that is not in use.
+ // The reasoning here is that if you just deleted a widget instance,
+ // e.g. had System Information 0,1,2 and deleted 1,
+ // then when you add System Information again it will become instance 1,
+ // which will bring back whatever filter selections happened to be on
+ // the previous instance 1.
+ $instance_num = 0;
+
+ while (isset($widget_counter_array[$basename][$instance_num])) {
+ $instance_num++;
+ }
+
+ $widget_sequence .= $widget_sep . $basename . ':' . $col . ':' . $display . ':' . $instance_num;
+ $widget_counter_array[$basename][$instance_num] = true;
+ $widget_sep = ',';
+ }
+ }
+
+ $widget_settings['sequence'] = $widget_sequence;
+
+ foreach ($widget_counter_array as $basename => $instances) {
+ foreach ($instances as $instance => $value) {
+ $widgetconfigname = $basename . '-' . $instance . '-config';
+ if ($_POST[$widgetconfigname]) {
+ $widget_settings[$widgetconfigname] = $_POST[$widgetconfigname];
+ }
}
}
@@ -230,13 +273,20 @@ if ($user_settings['widgets']['sequence'] != "") {
$widgetsfromconfig = array();
foreach (explode(',', $pconfig['sequence']) as $line) {
- list($file, $col, $display) = explode(':', $line);
+ $line_items = explode(':', $line);
+ if (count($line_items) == 3) {
+ // There can be multiple copies of a widget on the dashboard.
+ // Default the copy number if it is not present (e.g. from old configs)
+ $line_items[] = 0;
+ }
+
+ list($basename, $col, $display, $copynum) = $line_items;
// be backwards compatible
// If the display column information is missing, we will assign a temporary
// column here. Next time the user saves the dashboard it will fix itself
if ($col == "") {
- if ($file == "system_information") {
+ if ($basename == "system_information") {
$col = "col1";
} else {
$col = "col2";
@@ -248,28 +298,32 @@ if ($user_settings['widgets']['sequence'] != "") {
$col = "col" . $dashboardcolumns;
}
- $offset = strpos($file, '-container');
+ $offset = strpos($basename, '-container');
if (false !== $offset) {
- $file = substr($file, 0, $offset);
+ $basename = substr($basename, 0, $offset);
}
// Get the widget title that should be in a var defined in the widget's inc file.
- $widgettitle = ${$file . '_title'};
+ $widgettitle = ${$basename . '_title'};
if (empty(trim($widgettitle))) {
// Fall back to constructing a title from the file name of the widget.
- $widgettitle = ucwords(str_replace('_', ' ', $file));
+ $widgettitle = ucwords(str_replace('_', ' ', $basename));
}
- $widgetsfromconfig[ $file ] = array(
- 'name' => $widgettitle,
+ $widgetkey = $basename . '-' . $copynum;
+
+ $widgetsfromconfig[$widgetkey] = array(
+ 'basename' => $basename,
+ 'title' => $widgettitle,
'col' => $col,
'display' => $display,
+ 'copynum' => $copynum,
);
}
// add widgets that may not be in the saved configuration, in case they are to be displayed later
- $widgets = $widgetsfromconfig + $widgets;
+ $widgets = $widgetsfromconfig + $known_widgets;
##find custom configurations of a particular widget and load its info to $pconfig
foreach ($widgets as $widgetname => $widgetconfig) {
@@ -317,15 +371,13 @@ pfSense_handle_custom_code("/usr/local/pkg/dashboard/pre_dashboard");
<div class="row">
<?php
-// Build the Available Widgets table using a sorted copy of the $widgets array
-$available = $widgets;
-uasort($available, function($a, $b){ return strcasecmp($a['name'], $b['name']); });
+// Build the Available Widgets table using a sorted copy of the $known_widgets array
+$available = $known_widgets;
+uasort($available, function($a, $b){ return strcasecmp($a['title'], $b['title']); });
-foreach ($available as $widgetname => $widgetconfig):
- if ($widgetconfig['display'] == 'none'):
+foreach ($available as $widgetkey => $widgetconfig):
?>
- <div class="col-sm-3"><a href="#" id="btnadd-<?=$widgetname?>"><i class="fa fa-plus"></i> <?=$widgetconfig['name']?></a></div>
- <?php endif; ?>
+ <div class="col-sm-3"><a href="#" id="btnadd-<?=$widgetconfig['basename']?>"><i class="fa fa-plus"></i> <?=$widgetconfig['title']?></a></div>
<?php endforeach; ?>
</div>
</div>
@@ -340,20 +392,20 @@ foreach ($available as $widgetname => $widgetconfig):
<?php
$widgetColumns = array();
-foreach ($widgets as $widgetname => $widgetconfig) {
+foreach ($widgets as $widgetkey => $widgetconfig) {
if ($widgetconfig['display'] == 'none') {
continue;
}
- if (!file_exists('/usr/local/www/widgets/widgets/'. $widgetname.'.widget.php')) {
+ if (!file_exists('/usr/local/www/widgets/widgets/'. $widgetconfig['basename'].'.widget.php')) {
continue;
}
- if (!isset($widgetColumns[ $widgetconfig['col'] ])) {
- $widgetColumns[ $widgetconfig['col'] ] = array();
+ if (!isset($widgetColumns[$widgetconfig['col']])) {
+ $widgetColumns[$widgetconfig['col']] = array();
}
- $widgetColumns[ $widgetconfig['col'] ][ $widgetname ] = $widgetconfig;
+ $widgetColumns[$widgetconfig['col']][$widgetkey] = $widgetconfig;
}
?>
@@ -369,36 +421,55 @@ foreach ($widgets as $widgetname => $widgetconfig) {
echo '<div class="col-md-' . $columnWidth . '" id="widgets-col' . $currentColumnNumber . '">';
$columnWidgets = $widgetColumns['col'.$currentColumnNumber];
- foreach ($columnWidgets as $widgetname => $widgetconfig) {
+ foreach ($columnWidgets as $widgetkey => $widgetconfig) {
+ // Construct some standard names for the ids this widget will use for its commonly-used elements.
+ // Included widget.php code can rely on and use these, so the format does not have to be repeated in every widget.php
+ $widget_panel_body_id = 'widget-' . $widgetkey . '_panel-body';
+ $widget_panel_footer_id = 'widget-' . $widgetkey . '_panel-footer';
+ $widget_showallnone_id = 'widget-' . $widgetkey . '_showallnone';
+
// Compose the widget title and include the title link if available
- $widgetlink = ${$widgetname . '_title_link'};
+ $widgetlink = ${$widgetconfig['basename'] . '_title_link'};
if ((strlen($widgetlink) > 0)) {
- $wtitle = '<a href="' . $widgetlink . '"> ' . $widgetconfig['name'] . '</a>';
+ $wtitle = '<a href="' . $widgetlink . '"> ' . $widgetconfig['title'] . '</a>';
} else {
- $wtitle = $widgetconfig['name'];
+ $wtitle = $widgetconfig['title'];
}
?>
- <div class="panel panel-default" id="widget-<?=$widgetname?>">
+ <div class="panel panel-default" id="widget-<?=$widgetkey?>">
<div class="panel-heading">
<h2 class="panel-title">
<?=$wtitle?>
<span class="widget-heading-icon">
- <a data-toggle="collapse" href="#widget-<?=$widgetname?>_panel-footer" class="config hidden">
+ <a data-toggle="collapse" href="#<?=$widget_panel_footer_id?>" class="config hidden">
<i class="fa fa-wrench"></i>
</a>
- <a data-toggle="collapse" href="#widget-<?=$widgetname?>_panel-body">
+ <a data-toggle="collapse" href="#<?=$widget_panel_body_id?>">
<!-- actual icon is determined in css based on state of body -->
<i class="fa fa-plus-circle"></i>
</a>
- <a data-toggle="close" href="#widget-<?=$widgetname?>">
+ <a data-toggle="close" href="#widget-<?=$widgetkey?>">
<i class="fa fa-times-circle"></i>
</a>
</span>
</h2>
</div>
- <div id="widget-<?=$widgetname?>_panel-body" class="panel-body collapse<?=($widgetconfig['display'] == 'close' ? '' : ' in')?>">
- <?php include_once('/usr/local/www/widgets/widgets/'. $widgetname.'.widget.php'); ?>
+ <div id="<?=$widget_panel_body_id?>" class="panel-body collapse<?=($widgetconfig['display'] == 'close' ? '' : ' in')?>">
+ <?php
+ // For backward compatibility, included *.widget.php code needs the var $widgetname
+ $widgetname = $widgetkey;
+ // Determine if this is the first instance of this particular widget.
+ // Provide the $widget_first_instance var, to make it easy for the included widget code
+ // to be able to know if it is being included for the first time.
+ if ($widgets_found[$widgetconfig['basename']]) {
+ $widget_first_instance = false;
+ } else {
+ $widget_first_instance = true;
+ $widgets_found[$widgetconfig['basename']] = true;
+ }
+ include('/usr/local/www/widgets/widgets/' . $widgetconfig['basename'] . '.widget.php');
+ ?>
</div>
</div>
<?php
@@ -428,7 +499,7 @@ function updateWidgets(newWidget) {
// Only save details for panels that have id's like'widget-*'
// Some widgets create other panels, so ignore any of those.
if ((widget.id.split('-')[0] == 'widget') && (typeof widget_basename !== 'undefined')) {
- sequence += widget_basename + ':' + col.id.split('-')[1] + ':' + (isOpen ? 'open' : 'close') + ',';
+ sequence += widget_basename + ':' + col.id.split('-')[1] + ':' + (isOpen ? 'open' : 'close') + ':' + widget.id.split('-')[2] + ',';
}
});
});
@@ -436,15 +507,62 @@ function updateWidgets(newWidget) {
if (typeof newWidget !== 'undefined') {
// The system_information widget is always added to column one. Others go in column two
if (newWidget == "system_information") {
- sequence += newWidget + ':' + 'col1:open';
+ sequence += newWidget.split('-')[0] + ':' + 'col1:open:next';
} else {
- sequence += newWidget + ':' + 'col2:open';
+ sequence += newWidget.split('-')[0] + ':' + 'col2:open:next';
}
}
$('input[name=sequence]', $('#widgetSequence_form')).val(sequence);
}
+// Determine if all the checkboxes are checked
+function are_all_checked(checkbox_panel_ref) {
+ var allBoxesChecked = true;
+ $(checkbox_panel_ref).each(function() {
+ if ((this.type == 'checkbox') && !this.checked) {
+ allBoxesChecked = false;
+ }
+ });
+ return allBoxesChecked;
+}
+
+// If the checkboxes are all checked, then clear them all.
+// Otherwise set them all.
+function set_clear_checkboxes(checkbox_panel_ref) {
+ checkTheBoxes = !are_all_checked(checkbox_panel_ref);
+
+ $(checkbox_panel_ref).each(function() {
+ $(this).prop("checked", checkTheBoxes);
+ });
+}
+
+// Set the given id to All or None button depending if the checkboxes are all checked.
+function set_all_none_button(checkbox_panel_ref, all_none_button_id) {
+ if (are_all_checked(checkbox_panel_ref)) {
+ text = "<?=gettext('None')?>";
+ } else {
+ text = "<?=gettext('All')?>";
+ }
+
+ $("#" + all_none_button_id).html('<i class="fa fa-undo icon-embed-btn"></i>' + text);
+}
+
+// Setup the necessary events to manage the All/None button and included checkboxes
+// used for selecting the items to show on a widget.
+function set_widget_checkbox_events(checkbox_panel_ref, all_none_button_id) {
+ set_all_none_button(checkbox_panel_ref, all_none_button_id);
+
+ $(checkbox_panel_ref).change(function() {
+ set_all_none_button(checkbox_panel_ref, all_none_button_id);
+ });
+
+ $("#" + all_none_button_id).click(function() {
+ set_clear_checkboxes(checkbox_panel_ref);
+ set_all_none_button(checkbox_panel_ref, all_none_button_id);
+ });
+}
+
events.push(function() {
// Make panels destroyable
diff --git a/src/usr/local/www/interfaces.php b/src/usr/local/www/interfaces.php
index e00856d..fd9965b 100755
--- a/src/usr/local/www/interfaces.php
+++ b/src/usr/local/www/interfaces.php
@@ -987,10 +987,7 @@ if ($_POST['apply']) {
kill_dhclient_process($wancfg['if']);
}
if ($wancfg['ipaddrv6'] == "dhcp6") {
- $pid = find_dhcp6c_process($wancfg['if']);
- if ($pid) {
- posix_kill($pid, SIGTERM);
- }
+ kill_dhcp6client_process($wancfg['if'],true);
}
}
$ppp = array();
diff --git a/src/usr/local/www/interfaces_bridge_edit.php b/src/usr/local/www/interfaces_bridge_edit.php
index dbcbb2b..2db6f54 100644
--- a/src/usr/local/www/interfaces_bridge_edit.php
+++ b/src/usr/local/www/interfaces_bridge_edit.php
@@ -186,7 +186,7 @@ if ($_POST['save']) {
if (is_array($_POST['static'])) {
foreach ($_POST['static'] as $ifstatic) {
if (is_array($_POST['members']) && !in_array($ifstatic, $_POST['members'])) {
- $input_errors[] = sprintf(gettext('Sticky interface (%s) is not part of the bridge. Remove the sticky interface to continuez.'), $ifacelist[$ifstatic]);
+ $input_errors[] = sprintf(gettext('Sticky interface (%s) is not part of the bridge. Remove the sticky interface to continue.'), $ifacelist[$ifstatic]);
}
}
$pconfig['static'] = implode(',', $_POST['static']);
@@ -450,7 +450,7 @@ $section->addInput(new Form_Select(
$spanlist['list'],
true
))->setHelp('Add the interface named by interface as a span port on the bridge. Span ports transmit a copy of every frame received by the bridge. ' .
- 'This is most useful for snooping a bridged network passively on another host connected to one of the span ports of the bridgez. %1$s' .
+ 'This is most useful for snooping a bridged network passively on another host connected to one of the span ports of the bridge. %1$s' .
'%2$sThe span interface cannot be part of the bridge member interfaces.%3$s', '<br />', '<strong>', '</strong>');
$edgelist = build_port_list($pconfig['edge']);
diff --git a/src/usr/local/www/interfaces_ppps_edit.php b/src/usr/local/www/interfaces_ppps_edit.php
index c772637..be1fa84 100644
--- a/src/usr/local/www/interfaces_ppps_edit.php
+++ b/src/usr/local/www/interfaces_ppps_edit.php
@@ -241,9 +241,6 @@ if ($_POST['save']) {
if ($_POST['type'] == "ppp" && count($_POST['interfaces']) > 1) {
$input_errors[] = gettext("Multilink connections (MLPPP) using the PPP link type is not currently supported. Please select only one Link Interface.");
}
- if ($_POST['provider'] && !is_domain($_POST['provider'])) {
- $input_errors[] = gettext("The Service name contains invalid characters.");
- }
if ($_POST['provider'] && $_POST['null_service']) {
$input_errors[] = gettext("Do not specify both a Service name and a NULL Service name.");
}
@@ -1235,4 +1232,3 @@ events.push(function() {
<?php
include("foot.inc");
-
diff --git a/src/usr/local/www/js/pfSenseHelpers.js b/src/usr/local/www/js/pfSenseHelpers.js
index 20bc298..fbd50af 100644
--- a/src/usr/local/www/js/pfSenseHelpers.js
+++ b/src/usr/local/www/js/pfSenseHelpers.js
@@ -664,14 +664,15 @@ $('[id*=restartservice-], [id*=stopservice-], [id*=startservice-]').click(functi
name = args[0];
mode_zone = args[2];
id = args[3];
- } else if (args[0] == "cpativeportal") {
+ } else if (args[0] == "captiveportal") {
action = args[1];
name = args[0];
mode_zone = args[2];
id = args[3];
} else {
action = args[0];
- name = args[1];
+ args.shift();
+ name = args.join('-');
}
$(this).children('i').removeClass().addClass('fa fa-cog fa-spin text-success');
diff --git a/src/usr/local/www/load_balancer_pool_edit.php b/src/usr/local/www/load_balancer_pool_edit.php
index 6478d8c..265f5d1 100644
--- a/src/usr/local/www/load_balancer_pool_edit.php
+++ b/src/usr/local/www/load_balancer_pool_edit.php
@@ -93,7 +93,7 @@ if ($_POST['save']) {
$input_errors[] = sprintf(gettext("Sorry, an alias is already named %s."), $_POST['name']);
}
- if (!is_portoralias($_POST['port'])) {
+ if (!is_port_or_alias($_POST['port'])) {
$input_errors[] = gettext("The port must be an integer between 1 and 65535, or a port alias.");
}
diff --git a/src/usr/local/www/load_balancer_virtual_server_edit.php b/src/usr/local/www/load_balancer_virtual_server_edit.php
index 17fd92a..9d5463c 100644
--- a/src/usr/local/www/load_balancer_virtual_server_edit.php
+++ b/src/usr/local/www/load_balancer_virtual_server_edit.php
@@ -88,7 +88,7 @@ if ($_POST['save']) {
$input_errors[] = gettext("The 'name' field must be 32 characters or less.");
}
- if ($_POST['port'] != "" && !is_portoralias($_POST['port'])) {
+ if ($_POST['port'] != "" && !is_port_or_alias($_POST['port'])) {
$input_errors[] = gettext("The port must be an integer between 1 and 65535, a port alias, or left blank.");
}
diff --git a/src/usr/local/www/pkg.php b/src/usr/local/www/pkg.php
index 55f5559..305f28b 100644
--- a/src/usr/local/www/pkg.php
+++ b/src/usr/local/www/pkg.php
@@ -93,24 +93,24 @@ $evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['con
if ($_REQUEST['act'] == "update") {
if (is_array($config['installedpackages'][$pkg['name']]) && $pkg['name'] != "" && $_REQUEST['ids'] !="") {
- #get current values
+ // get current values
$current_values=$config['installedpackages'][$pkg['name']]['config'];
- #get updated ids
+ // get updated ids
parse_str($_REQUEST['ids'], $update_list);
- #sort ids to know what to change
- #useful to do not lose data when using sorting and paging
+ // sort ids to know what to change
+ // useful to do not lose data when using sorting and paging
$sort_list=$update_list['ids'];
sort($sort_list);
- #apply updates
+ // apply updates
foreach ($update_list['ids'] as $key=> $value) {
$config['installedpackages'][$pkg['name']]['config'][$sort_list[$key]]=$current_values[$update_list['ids'][$key]];
}
- #save current config
- write_config();
- #sync package
+ // save current config
+ write_config(gettext("Package configuration changes saved from package settings page."));
+ // sync package
eval ("{$pkg['custom_php_resync_config_command']}");
}
- #function called via jquery, no need to continue after save changes.
+ // function called via jquery, no need to continue after save changes.
exit;
}
if ($_REQUEST['act'] == "del") {
@@ -129,7 +129,7 @@ if ($_REQUEST['act'] == "del") {
if ($a_pkg[$_REQUEST['id']]) {
unset($a_pkg[$_REQUEST['id']]);
- write_config();
+ write_config(gettext("Package configuration item deleted from package settings page."));
if ($pkg['custom_delete_php_command'] != "") {
if ($pkg['custom_php_command_before_form'] != "") {
eval($pkg['custom_php_command_before_form']);
diff --git a/src/usr/local/www/pkg_edit.php b/src/usr/local/www/pkg_edit.php
index 559645b..f2603e5 100644
--- a/src/usr/local/www/pkg_edit.php
+++ b/src/usr/local/www/pkg_edit.php
@@ -33,6 +33,7 @@ require_once("functions.inc");
require_once("filter.inc");
require_once("shaper.inc");
require_once("pkg-utils.inc");
+require_once("util.inc");
/* dummy stubs needed by some code that was MFC'd */
function pfSenseHeader($location) {
@@ -159,7 +160,6 @@ if ($_POST) {
}
}
- // donotsave is enabled. lets simply exit.
if (empty($pkg['donotsave'])) {
// store values in xml configuration file.
@@ -175,11 +175,24 @@ if ($_POST) {
foreach ($_POST as $key => $value) {
$matches = array();
if (preg_match("/^{$rowhelperfield['fieldname']}(\d+)$/", $key, $matches)) {
- $pkgarr[$rowhelpername][$matches[1]][$rowhelperfield['fieldname']] = $value;
+ if ($rowhelperfield['type'] == "textarea") {
+ $pkgarr[$rowhelpername][$matches[1]][$rowhelperfield['fieldname']] = unixnewlines($value);
+ } else {
+ $pkgarr[$rowhelpername][$matches[1]][$rowhelperfield['fieldname']] = $value;
+ }
}
}
}
break;
+ case "textarea":
+ $fieldname = $fields['fieldname'];
+ $fieldvalue = unixnewlines(trim($_POST[$fieldname]));
+ if ($fields['encoding'] == 'base64') {
+ $fieldvalue = base64_encode($fieldvalue);
+ }
+ if ($fieldname) {
+ $pkgarr[$fieldname] = $fieldvalue;
+ }
default:
$fieldname = $fields['fieldname'];
if ($fieldname == "interface_array") {
@@ -243,6 +256,7 @@ if ($_POST) {
$get_from_post = true;
}
} elseif (!$input_errors) {
+ // donotsave is enabled. lets simply exit.
exit;
}
}
diff --git a/src/usr/local/www/services_captiveportal_vouchers_edit.php b/src/usr/local/www/services_captiveportal_vouchers_edit.php
index f502dcf..289c562 100644
--- a/src/usr/local/www/services_captiveportal_vouchers_edit.php
+++ b/src/usr/local/www/services_captiveportal_vouchers_edit.php
@@ -212,7 +212,7 @@ if (isset($id) && $a_roll[$id]) {
'id',
null,
'hidden',
- $pconfig['id']
+ $id
));
}
diff --git a/src/usr/local/www/services_checkip.php b/src/usr/local/www/services_checkip.php
index 2b5f778..55c9a06 100644
--- a/src/usr/local/www/services_checkip.php
+++ b/src/usr/local/www/services_checkip.php
@@ -37,26 +37,31 @@ $a_checkipservice = &$config['checkipservices']['checkipservice'];
$dirty = false;
if ($_POST['act'] == "del") {
unset($a_checkipservice[$_POST['id']]);
+ $wc_msg = gettext('Deleted a check IP service.');
$dirty = true;
} else if ($_POST['act'] == "toggle") {
if ($a_checkipservice[$_POST['id']]) {
if (isset($a_checkipservice[$_POST['id']]['enable'])) {
unset($a_checkipservice[$_POST['id']]['enable']);
+ $wc_msg = gettext('Disabled a check IP service.');
} else {
$a_checkipservice[$_POST['id']]['enable'] = true;
+ $wc_msg = gettext('Enabled a check IP service.');
}
$dirty = true;
} else if ($_POST['id'] == count($a_checkipservice)) {
if (isset($config['checkipservices']['disable_factory_default'])) {
unset($config['checkipservices']['disable_factory_default']);
+ $wc_msg = gettext('Enabled the default check IP service.');
} else {
$config['checkipservices']['disable_factory_default'] = true;
+ $wc_msg = gettext('Disabled the default check IP service.');
}
$dirty = true;
}
}
if ($dirty) {
- write_config();
+ write_config($wc_msg);
header("Location: services_checkip.php");
exit;
diff --git a/src/usr/local/www/services_dnsmasq_domainoverride_edit.php b/src/usr/local/www/services_dnsmasq_domainoverride_edit.php
index 77001af..c558bd2 100644
--- a/src/usr/local/www/services_dnsmasq_domainoverride_edit.php
+++ b/src/usr/local/www/services_dnsmasq_domainoverride_edit.php
@@ -163,7 +163,7 @@ if (isset($id) && $a_domainOverrides[$id]) {
'id',
null,
'hidden',
- $pconfig['id']
+ $id
));
}
diff --git a/src/usr/local/www/services_dnsmasq_edit.php b/src/usr/local/www/services_dnsmasq_edit.php
index b476052..a11c259 100644
--- a/src/usr/local/www/services_dnsmasq_edit.php
+++ b/src/usr/local/www/services_dnsmasq_edit.php
@@ -131,11 +131,15 @@ if ($_POST['save']) {
}
if (($hostent['host'] == $_POST['host']) &&
- ($hostent['domain'] == $_POST['domain']) &&
- ((is_ipaddrv4($hostent['ip']) && is_ipaddrv4($_POST['ip'])) ||
- (is_ipaddrv6($hostent['ip']) && is_ipaddrv6($_POST['ip'])))) {
- $input_errors[] = gettext("This host/domain already exists.");
- break;
+ ($hostent['domain'] == $_POST['domain'])) {
+ if (is_ipaddrv4($hostent['ip']) && is_ipaddrv4($_POST['ip'])) {
+ $input_errors[] = gettext("This host/domain override combination already exists with an IPv4 address.");
+ break;
+ }
+ if (is_ipaddrv6($hostent['ip']) && is_ipaddrv6($_POST['ip'])) {
+ $input_errors[] = gettext("This host/domain override combination already exists with an IPv6 address.");
+ break;
+ }
}
}
@@ -228,7 +232,7 @@ if (isset($id) && $a_hosts[$id]) {
'id',
null,
'hidden',
- $pconfig['id']
+ $id
));
}
diff --git a/src/usr/local/www/services_dyndns_edit.php b/src/usr/local/www/services_dyndns_edit.php
index 083fce9..b30aa3d 100644
--- a/src/usr/local/www/services_dyndns_edit.php
+++ b/src/usr/local/www/services_dyndns_edit.php
@@ -372,7 +372,7 @@ $section->addInput(new Form_Input(
'Zone ID',
'text',
$pconfig['zoneid']
-))->setHelp('Route53: Enter AWS Region and Zone ID in the form REGION/ZONEID (example: "us-east-1/A1B2C3D4E5F6Z").%1$s' .
+))->setHelp('Route53: Enter AWS Zone ID.%1$s' .
'DNSimple: Enter the Record ID of record to update.', '<br />');
$section->addInput(new Form_Input(
diff --git a/src/usr/local/www/services_unbound.php b/src/usr/local/www/services_unbound.php
index 3f767c9..74ef389 100644
--- a/src/usr/local/www/services_unbound.php
+++ b/src/usr/local/www/services_unbound.php
@@ -441,8 +441,8 @@ events.push(function() {
<thead>
<tr>
<th><?=gettext("Host")?></th>
- <th><?=gettext("Domain")?></th>
- <th><?=gettext("IP")?></th>
+ <th><?=gettext("Parent domain of host")?></th>
+ <th><?=gettext("IP to return for host")?></th>
<th><?=gettext("Description")?></th>
<th><?=gettext("Actions")?></th>
</tr>
@@ -504,6 +504,14 @@ endforeach;
</div>
</div>
+<span class="help-block">
+ Enter any individual hosts for which the resolver's standard DNS lookup process should be overridden and a specific
+ IPv4 or IPv6 address should automatically be returned by the resolver. Standard and also non-standard names and parent domains
+ can be entered, such as 'test', 'mycompany.localdomain', '1.168.192.in-addr.arpa', or 'somesite.com'. Any lookup attempt for
+ the host will automatically return the given IP address, and the usual lookup server for the domain will not be queried for
+ the host's records.
+</span>
+
<nav class="action-buttons">
<a href="services_unbound_host_edit.php" class="btn btn-sm btn-success">
<i class="fa fa-plus icon-embed-btn"></i>
@@ -518,7 +526,7 @@ endforeach;
<thead>
<tr>
<th><?=gettext("Domain")?></th>
- <th><?=gettext("IP")?></th>
+ <th><?=gettext("Lookup Server IP Address")?></th>
<th><?=gettext("Description")?></th>
<th><?=gettext("Actions")?></th>
</tr>
@@ -553,6 +561,13 @@ endforeach;
</div>
</div>
+<span class="help-block">
+ Enter any domains for which the resolver's standard DNS lookup process should be overridden and a different (non-standard)
+ lookup server should be queried instead. Non-standard, 'invalid' and local domains, and subdomains, can also be entered,
+ such as 'test', 'mycompany.localdomain', '1.168.192.in-addr.arpa', or 'somesite.com'. The IP address is treated as the
+ authoritative lookup server for the domain (including all of its subdomains), and other lookup servers will not be queried.
+</span>
+
<nav class="action-buttons">
<a href="services_unbound_domainoverride_edit.php" class="btn btn-sm btn-success">
<i class="fa fa-plus icon-embed-btn"></i>
diff --git a/src/usr/local/www/services_unbound_domainoverride_edit.php b/src/usr/local/www/services_unbound_domainoverride_edit.php
index 17f2fee..f37f366 100644
--- a/src/usr/local/www/services_unbound_domainoverride_edit.php
+++ b/src/usr/local/www/services_unbound_domainoverride_edit.php
@@ -114,20 +114,20 @@ if ($input_errors) {
$form = new Form();
-$section = new Form_Section('Domain Override');
+$section = new Form_Section('Domains to Override with Custom Lookup Servers');
$section->addInput(new Form_Input(
'domain',
'*Domain',
'text',
$pconfig['domain']
-))->setHelp('Domain to override (NOTE: this does not have to be a valid TLD!) e.g.: test or mycompany.localdomain or 1.168.192.in-addr.arpa');
+))->setHelp('Domain whose lookups will be directed to a user-specified DNS lookup server.');
$section->addInput(new Form_IpAddress(
'ip',
'*IP Address',
$pconfig['ip']
-))->setHelp('IP address of the authoritative DNS server for this domain. e.g.: 192.168.100.100%1$s' .
+))->setHelp('IPv4 or IPv6 address of the authoritative DNS server for this domain. e.g.: 192.168.100.100%1$s' .
'To use a non-default port for communication, append an \'@\' with the port number.', '<br />')->setPattern('[a-zA-Z0-9@.:]+');
$section->addInput(new Form_Input(
@@ -146,6 +146,17 @@ if (isset($id) && $a_domainOverrides[$id]) {
));
}
+$section->addInput(new Form_StaticText(
+ '',
+ '<span class="help-block">' .
+ gettext("This page is used to specify domains for which the resolver's standard DNS lookup process will be overridden, " .
+ "and the resolver will query a different (non-standard) lookup server instead. It is possible to enter 'non-standard', 'invalid' " .
+ "and 'local' domains such as 'test', 'mycompany.localdomain', or '1.168.192.in-addr.arpa', as well as usual publicly resolvable " .
+ "domains such as 'org', 'info', or 'google.co.uk'. The IP address entered will be treated as the IP address of an authoritative " .
+ "lookup server for the domain (including all of its subdomains), and other lookup servers will not be queried.") .
+ '</span>'
+));
+
$form->add($section);
print $form;
diff --git a/src/usr/local/www/services_unbound_host_edit.php b/src/usr/local/www/services_unbound_host_edit.php
index c374631..e766204 100644
--- a/src/usr/local/www/services_unbound_host_edit.php
+++ b/src/usr/local/www/services_unbound_host_edit.php
@@ -142,10 +142,15 @@ if ($_POST['save']) {
}
if (($hostent['host'] == $_POST['host']) &&
- ($hostent['domain'] == $_POST['domain']) &&
- ((is_ipaddrv4($hostent['ip']) && is_ipaddrv4($_POST['ip'])) || (is_ipaddrv6($hostent['ip']) && is_ipaddrv6($_POST['ip'])))) {
- $input_errors[] = gettext("This host/domain already exists.");
- break;
+ ($hostent['domain'] == $_POST['domain'])) {
+ if (is_ipaddrv4($hostent['ip']) && is_ipaddrv4($_POST['ip'])) {
+ $input_errors[] = gettext("This host/domain override combination already exists with an IPv4 address.");
+ break;
+ }
+ if (is_ipaddrv6($hostent['ip']) && is_ipaddrv6($_POST['ip'])) {
+ $input_errors[] = gettext("This host/domain override combination already exists with an IPv6 address.");
+ break;
+ }
}
}
@@ -192,21 +197,21 @@ $section->addInput(new Form_Input(
'text',
$pconfig['host']
))->setHelp('Name of the host, without the domain part%1$s' .
- 'e.g.: "myhost"', '<br />');
+ 'e.g. enter "myhost" if the full domain name is "myhost.example.com"', '<br />');
$section->addInput(new Form_Input(
'domain',
'*Domain',
'text',
$pconfig['domain']
-))->setHelp('Domain of the host%1$s' .
- 'e.g.: "example.com"', '<br />');
+))->setHelp('Parent domain of the host%1$s' .
+ 'e.g. enter "example.com" for "myhost.example.com"', '<br />');
$section->addInput(new Form_IpAddress(
'ip',
'*IP Address',
$pconfig['ip']
-))->setHelp('IP address of the host%1$s' .
+))->setHelp('IPv4 or IPv6 address to be returned for the host%1$s' .
'e.g.: 192.168.100.100 or fd00:abcd::1', '<br />');
$section->addInput(new Form_Input(
@@ -221,10 +226,22 @@ if (isset($id) && $a_hosts[$id]) {
'id',
null,
'hidden',
- $pconfig['id']
+ $id
));
}
+$section->addInput(new Form_StaticText(
+ '',
+ '<span class="help-block">' .
+ gettext("This page is used to override the usual lookup process for a specific host. A host is defined by its name " .
+ "and parent domain (e.g., 'somesite.google.com' is entered as host='somesite' and parent domain='google.com'). Any " .
+ "attempt to lookup that host will automatically return the given IP address, and any usual external lookup server for " .
+ "the domain will not be queried. Both the name and parent domain can contain 'non-standard', 'invalid' and 'local' " .
+ "domains such as 'test', 'mycompany.localdomain', or '1.168.192.in-addr.arpa', as well as usual publicly resolvable names ".
+ "such as 'www' or 'google.co.uk'.") .
+ '</span>'
+));
+
$form->add($section);
$section = new Form_Section('Additional Names for this Host');
@@ -281,6 +298,13 @@ $form->addGlobal(new Form_Button(
'fa-plus'
))->removeClass('btn-primary')->addClass('btn-success addbtn');
+$section->addInput(new Form_StaticText(
+ '',
+ '<span class="help-block">'.
+ gettext("If the host can be accessed using multiple names, then enter any other names for the host which should also be overridden.") .
+ '</span>'
+));
+
$form->add($section);
print($form);
diff --git a/src/usr/local/www/status_carp.php b/src/usr/local/www/status_carp.php
index ba0c80a..84fa508 100644
--- a/src/usr/local/www/status_carp.php
+++ b/src/usr/local/www/status_carp.php
@@ -98,7 +98,7 @@ if ($_POST['disablecarp'] != "") {
$carp_detected_problems = get_single_sysctl("net.inet.carp.demotion");
if (!empty($_POST['resetdemotion'])) {
- set_single_sysctl("net.inet.carp.demotion", "-{$carp_detected_problems}");
+ set_single_sysctl("net.inet.carp.demotion", 0 - $carp_detected_problems);
sleep(1);
$carp_detected_problems = get_single_sysctl("net.inet.carp.demotion");
}
@@ -144,18 +144,17 @@ if ($carpcount == 0) {
}
// Sadly this needs to be here so that it is inside the form
- if ($carp_detected_problems > 0) {
+ if ($carp_detected_problems != 0) {
print_info_box(
- gettext("CARP has detected a problem and this unit has been demoted to BACKUP status.") .
+ gettext("CARP has detected a problem and this unit has a non-zero demotion status.") .
"<br/>" .
- gettext("Check the link status on all interfaces with configured CARP VIPs.") .
- "<br/>" .
- sprintf(gettext('Search the %1$sSystem Log%2$s for CARP demotion-related events.'), "<a href=\"/status_logs.php?filtertext=carp%3A+demoted+by\">", "</a>") .
+ gettext("Check the link status on all interfaces configured with CARP VIPs and ") .
+ sprintf(gettext('search the %1$sSystem Log%2$s for CARP demotion-related events.'), "<a href=\"/status_logs.php?filtertext=carp%3A+demoted+by\">", "</a>") .
"<br/><br/>" .
'<button type="submit" class="btn btn-warning" name="resetdemotion" id="resetdemotion" value="' .
- gettext("Reset CARP Demotion Status.") .
+ gettext("Reset CARP Demotion Status") .
'"><i class="fa fa-undo icon-embed-btn"></i>' .
- gettext("Reset CARP Demotion Status.") .
+ gettext("Reset CARP Demotion Status") .
'</button>',
'danger'
);
diff --git a/src/usr/local/www/status_logs_settings.php b/src/usr/local/www/status_logs_settings.php
index d431353..2ad1c5b 100644
--- a/src/usr/local/www/status_logs_settings.php
+++ b/src/usr/local/www/status_logs_settings.php
@@ -160,7 +160,7 @@ if ($_POST['resetlogs'] == gettext("Reset Log Files")) {
unset($config['syslog']['remoteserver3']);
}
- write_config();
+ write_config(gettext("Changed system logging options."));
$changes_applied = true;
$retval = 0;
diff --git a/src/usr/local/www/system.php b/src/usr/local/www/system.php
index d76a5de..5766499 100644
--- a/src/usr/local/www/system.php
+++ b/src/usr/local/www/system.php
@@ -63,6 +63,7 @@ $pconfig['webguicss'] = $config['system']['webgui']['webguicss'];
$pconfig['webguifixedmenu'] = $config['system']['webgui']['webguifixedmenu'];
$pconfig['dashboardcolumns'] = $config['system']['webgui']['dashboardcolumns'];
$pconfig['webguileftcolumnhyper'] = isset($config['system']['webgui']['webguileftcolumnhyper']);
+$pconfig['disablealiaspopupdetail'] = isset($config['system']['webgui']['disablealiaspopupdetail']);
$pconfig['dashboardavailablewidgetspanel'] = isset($config['system']['webgui']['dashboardavailablewidgetspanel']);
$pconfig['systemlogsfilterpanel'] = isset($config['system']['webgui']['systemlogsfilterpanel']);
$pconfig['systemlogsmanagelogpanel'] = isset($config['system']['webgui']['systemlogsmanagelogpanel']);
@@ -274,6 +275,9 @@ if ($_POST) {
unset($config['system']['webgui']['webguileftcolumnhyper']);
$config['system']['webgui']['webguileftcolumnhyper'] = $_POST['webguileftcolumnhyper'] ? true : false;
+ unset($config['system']['webgui']['disablealiaspopupdetail']);
+ $config['system']['webgui']['disablealiaspopupdetail'] = $_POST['disablealiaspopupdetail'] ? true : false;
+
unset($config['system']['webgui']['dashboardavailablewidgetspanel']);
$config['system']['webgui']['dashboardavailablewidgetspanel'] = $_POST['dashboardavailablewidgetspanel'] ? true : false;
@@ -580,6 +584,7 @@ gen_associatedpanels_fields(
$pconfig['statusmonitoringsettingspanel']);
gen_requirestatefilter_field($section, $pconfig['requirestatefilter']);
gen_webguileftcolumnhyper_field($section, $pconfig['webguileftcolumnhyper']);
+gen_disablealiaspopupdetail_field($section, $pconfig['disablealiaspopupdetail']);
$section->addInput(new Form_Checkbox(
'loginshowhost',
diff --git a/src/usr/local/www/system_advanced_firewall.php b/src/usr/local/www/system_advanced_firewall.php
index 27a5e23..3f7742f 100644
--- a/src/usr/local/www/system_advanced_firewall.php
+++ b/src/usr/local/www/system_advanced_firewall.php
@@ -348,7 +348,7 @@ if ($_POST) {
$config['system']['bogons']['interval'] = $_POST['bogonsinterval'];
}
- write_config();
+ write_config(gettext("Changed Advanced Firewall/NAT settings."));
// Kill filterdns when value changes, filter_configure() will restart it
if (($old_aliasesresolveinterval != $config['system']['aliasesresolveinterval']) &&
diff --git a/src/usr/local/www/system_certmanager.php b/src/usr/local/www/system_certmanager.php
index 777d416..7b5ea66 100644
--- a/src/usr/local/www/system_certmanager.php
+++ b/src/usr/local/www/system_certmanager.php
@@ -34,6 +34,7 @@ $cert_methods = array(
"import" => gettext("Import an existing Certificate"),
"internal" => gettext("Create an internal Certificate"),
"external" => gettext("Create a Certificate Signing Request"),
+ "sign" => gettext("Sign a Certificate Signing Request")
);
$cert_keylens = array("512", "1024", "2048", "3072", "4096", "7680", "8192", "15360", "16384");
@@ -81,7 +82,6 @@ foreach ($a_ca as $ca) {
$act = $_REQUEST['act'];
-
if ($_POST['act'] == "del") {
if (!isset($a_cert[$id])) {
@@ -96,7 +96,6 @@ if ($_POST['act'] == "del") {
exit;
}
-
if ($act == "new") {
$pconfig['method'] = $_POST['method'];
$pconfig['keylen'] = "2048";
@@ -172,6 +171,7 @@ if ($act == "p12") {
$args['friendly_name'] = $a_cert[$id]['descr'];
$ca = lookup_ca($a_cert[$id]['caref']);
+
if ($ca) {
$args['extracerts'] = openssl_x509_read(base64_decode($ca['crt']));
}
@@ -212,6 +212,24 @@ if ($_POST['save']) {
$pconfig = $_POST;
/* input validation */
+ if ($pconfig['method'] == "sign") {
+ $reqdfields = explode(" ",
+ "descr catosignwith");
+ $reqdfieldsn = array(
+ gettext("Descriptive name"),
+ gettext("CA to sign with"));
+
+ if (($_POST['csrtosign'] === "new") && (!strstr($_POST['csrpaste'], "BEGIN CERTIFICATE REQUEST") || !strstr($_POST['csrpaste'], "END CERTIFICATE REQUEST"))) {
+ $input_errors[] = gettext("This signing request does not appear to be valid.");
+ }
+
+ if ( (($_POST['csrtosign'] === "new") && (strlen($_POST['keypaste']) > 0)) && (!strstr($_POST['keypaste'], "BEGIN PRIVATE KEY") || !strstr($_POST['keypaste'], "END PRIVATE KEY"))) {
+ $input_errors[] = gettext("This private does not appear to be valid.");
+ $input_errors[] = gettext("Key data field should be blank, or a valid x509 private key");
+ }
+
+ }
+
if ($pconfig['method'] == "import") {
$reqdfields = explode(" ",
"descr cert key");
@@ -222,6 +240,7 @@ if ($_POST['save']) {
if ($_POST['cert'] && (!strstr($_POST['cert'], "BEGIN CERTIFICATE") || !strstr($_POST['cert'], "END CERTIFICATE"))) {
$input_errors[] = gettext("This certificate does not appear to be valid.");
}
+
if (cert_get_modulus($_POST['cert'], false) != prv_get_modulus($_POST['key'], false)) {
$input_errors[] = gettext("The submitted private key does not match the submitted certificate data.");
}
@@ -267,6 +286,7 @@ if ($_POST['save']) {
$altnames = array();
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
+
if ($pconfig['method'] != "import" && $pconfig['method'] != "existing") {
/* subjectAltNames */
foreach ($_POST as $key => $value) {
@@ -362,6 +382,48 @@ if ($_POST['save']) {
if ($cert && $a_user) {
$a_user[$userid]['cert'][] = $cert['refid'];
}
+ } else if ($pconfig['method'] == "sign") { // Sign a CSR
+ $csrid = lookup_cert($pconfig['csrtosign']);
+ $caid = lookup_ca($pconfig['catosignwith']);
+
+ // Read the CSR from $config, or if a new one, from the textarea
+ if ($pconfig['csrtosign'] === "new") {
+ $csr = $pconfig['csrpaste'];
+ } else {
+ $csr = base64_decode($csrid['csr']);
+ }
+
+ $old_err_level = error_reporting(0);
+
+ // Gather the information required for signed cert
+ $ca = base64_decode($caid['crt']);
+ $key = base64_decode($caid['prv']);
+ $duration = $pconfig['duration'];
+ $caref = $pconfig['catosignwith'];
+ $type = (cert_get_purpose($csrid)['server'] === "Yes") ? "server":"user";
+
+ // Sign the new cert and export it in x509 format
+ openssl_x509_export(openssl_csr_sign($csr, $ca, $key, $duration, ['x509_extensions' => 'v3_req']), $n509);
+
+ // Gather the details required to save the new cert
+ $newcert = array();
+ $newcert['refid'] = uniqid();
+ $newcert['caref'] = $caref;
+ $newcert['descr'] = $pconfig['descr'];
+ $newcert['type'] = $type;
+ $newcert['crt'] = base64_encode($n509);
+
+ if ($pconfig['csrtosign'] === "new") {
+ $newcert['prv'] = base64_encode($pconfig['keypaste']);
+ } else {
+ $newcert['prv'] = $csrid['prv'];
+ }
+
+ // Add it to the config file
+ $config['cert'][] = $newcert;
+
+ error_reporting($old_err_level);
+
} else {
$cert = array();
$cert['refid'] = uniqid();
@@ -435,6 +497,7 @@ if ($_POST['save']) {
}
}
}
+
error_reporting($old_err_level);
if (isset($id) && $a_cert[$id]) {
@@ -569,7 +632,7 @@ if ($act == "new" || (($_POST['save'] == gettext("Save")) && $input_errors)) {
));
}
- $section = new Form_Section('Add a New Certificate');
+ $section = new Form_Section('Add/Sign a New Certificate');
if (!isset($id)) {
$section->addInput(new Form_Select(
@@ -588,6 +651,73 @@ if ($act == "new" || (($_POST['save'] == gettext("Save")) && $input_errors)) {
))->addClass('toggle-existing');
$form->add($section);
+
+ // Return an array containing the IDs od all CAs
+ function list_cas() {
+ global $a_ca;
+ $allCas = array();
+
+ foreach ($a_ca as $ca) {
+ if ($ca['prv']) {
+ $allCas[$ca['refid']] = $ca['descr'];
+ }
+ }
+
+ return $allCas;
+ }
+
+ // Return an array containing the IDs od all CSRs
+ function list_csrs() {
+ global $config;
+ $allCsrs = array();
+
+ foreach ($config['cert'] as $cert) {
+ if ($cert['csr']) {
+ $allCsrs[$cert['refid']] = $cert['descr'];
+ }
+ }
+
+ return ['new' => gettext('New CSR (Paste below)')] + $allCsrs;
+ }
+
+ $section = new Form_Section('Sign CSR');
+ $section->addClass('toggle-sign collapse');
+
+ $section->AddInput(new Form_Select(
+ 'catosignwith',
+ '*CA to sign with',
+ $pconfig['catosignwith'],
+ list_cas()
+ ));
+
+ $section->AddInput(new Form_Select(
+ 'csrtosign',
+ '*CSR to sign',
+ isset($pconfig['csrtosign']) ? $pconfig['csrtosign'] : 'new',
+ list_csrs()
+ ));
+
+ $section->addInput(new Form_Input(
+ 'duration',
+ '*Certificate duration (days)',
+ 'number',
+ $pconfig['duration'] ? $pconfig['duration']:'3650'
+ ));
+
+ $section->addInput(new Form_Textarea(
+ 'csrpaste',
+ 'CSR data',
+ $pconfig['csrpaste']
+ ))->setHelp('Paste a Certificate Signing Request in X.509 PEM format here.');
+
+ $section->addInput(new Form_Textarea(
+ 'keypaste',
+ 'Key data',
+ $pconfig['keypaste']
+ ))->setHelp('Optionally paste a private key here. The key will be associated with the newly signed certificate in pfSense');
+
+ $form->add($section);
+
$section = new Form_Section('Import Certificate');
$section->addClass('toggle-import collapse');
@@ -1062,7 +1192,9 @@ foreach ($a_cert as $i => $cert):
<td>
<?php if (!$cert['csr']): ?>
<a href="system_certmanager.php?act=exp&amp;id=<?=$i?>" class="fa fa-certificate" title="<?=gettext("Export Certificate")?>"></a>
- <a href="system_certmanager.php?act=key&amp;id=<?=$i?>" class="fa fa-key" title="<?=gettext("Export Key")?>"></a>
+ <?php if ($cert['prv']): ?>
+ <a href="system_certmanager.php?act=key&amp;id=<?=$i?>" class="fa fa-key" title="<?=gettext("Export Key")?>"></a>
+ <?php endif?>
<a href="system_certmanager.php?act=p12&amp;id=<?=$i?>" class="fa fa-archive" title="<?=gettext("Export P12")?>"></a>
<?php else: ?>
<a href="system_certmanager.php?act=csr&amp;id=<?=$i?>" class="fa fa-pencil" title="<?=gettext("Update CSR")?>"></a>
@@ -1086,7 +1218,7 @@ foreach ($a_cert as $i => $cert):
<nav class="action-buttons">
<a href="?act=new" class="btn btn-success btn-sm">
<i class="fa fa-plus icon-embed-btn"></i>
- <?=gettext("Add")?>
+ <?=gettext("Add/Sign")?>
</a>
</nav>
<?php
@@ -1113,7 +1245,6 @@ events.push(function() {
}
$subject = cert_get_subject_array($ca['crt']);
-
?>
case "<?=$ca['refid'];?>":
$('#dn_country').val("<?=$subject[0]['v'];?>");
@@ -1129,15 +1260,28 @@ events.push(function() {
}
}
+ function set_csr_ro() {
+ var newcsr = ($('#csrtosign').val() == "new");
+
+ $('#csrpaste').attr('readonly', !newcsr);
+ $('#keypaste').attr('readonly', !newcsr);
+ setRequired('csrpaste', newcsr);
+ }
+
// ---------- Click checkbox handlers ---------------------------------------------------------
$('#caref').on('change', function() {
internalca_change();
});
+ $('#csrtosign').change(function () {
+ set_csr_ro();
+ });
+
// ---------- On initial page load ------------------------------------------------------------
internalca_change();
+ set_csr_ro();
// Suppress "Delete row" button if there are fewer than two rows
checkLastRow();
diff --git a/src/usr/local/www/system_routes.php b/src/usr/local/www/system_routes.php
index c04cca3..872d6a8 100644
--- a/src/usr/local/www/system_routes.php
+++ b/src/usr/local/www/system_routes.php
@@ -200,7 +200,7 @@ if($_POST['save']) {
$a_routes = $a_routes_new;
}
- if (write_config()) {
+ if (write_config(gettext("Saved static routes configuration."))) {
mark_subsystem_dirty('staticroutes');
}
header("Location: system_routes.php");
diff --git a/src/usr/local/www/system_routes_edit.php b/src/usr/local/www/system_routes_edit.php
index 45b26c1..b94523f 100644
--- a/src/usr/local/www/system_routes_edit.php
+++ b/src/usr/local/www/system_routes_edit.php
@@ -209,7 +209,7 @@ if ($_POST['save']) {
mark_subsystem_dirty('staticroutes');
- write_config();
+ write_config(gettext("Saved static route configuration."));
header("Location: system_routes.php");
exit;
diff --git a/src/usr/local/www/system_update_settings.php b/src/usr/local/www/system_update_settings.php
index 6984ca3..2d1549b 100644
--- a/src/usr/local/www/system_update_settings.php
+++ b/src/usr/local/www/system_update_settings.php
@@ -96,7 +96,7 @@ if ($_POST) {
unset($config['system']['gitsync']['dryrun']);
}
- write_config();
+ write_config(gettext("Saved system update settings."));
$savemsg = gettext("Changes have been saved successfully");
}
diff --git a/src/usr/local/www/system_user_settings.php b/src/usr/local/www/system_user_settings.php
index 7cf5c17..03d8355 100644
--- a/src/usr/local/www/system_user_settings.php
+++ b/src/usr/local/www/system_user_settings.php
@@ -47,6 +47,7 @@ if (isset($id) && $a_user[$id]) {
$pconfig['systemlogsmanagelogpanel'] = isset($a_user[$id]['systemlogsmanagelogpanel']);
$pconfig['statusmonitoringsettingspanel'] = isset($a_user[$id]['statusmonitoringsettingspanel']);
$pconfig['webguileftcolumnhyper'] = isset($a_user[$id]['webguileftcolumnhyper']);
+ $pconfig['disablealiaspopupdetail'] = isset($a_user[$id]['disablealiaspopupdetail']);
$pconfig['pagenamefirst'] = isset($a_user[$id]['pagenamefirst']);
} else {
echo gettext("The settings cannot be managed for a non-local user.");
@@ -118,6 +119,13 @@ if (isset($_POST['save'])) {
unset($userent['webguileftcolumnhyper']);
}
+ if ($_POST['disablealiaspopupdetail']) {
+ $pconfig['disablealiaspopupdetail'] = $userent['disablealiaspopupdetail'] = true;
+ } else {
+ $pconfig['disablealiaspopupdetail'] = false;
+ unset($userent['disablealiaspopupdetail']);
+ }
+
if ($_POST['pagenamefirst']) {
$pconfig['pagenamefirst'] = $userent['pagenamefirst'] = true;
} else {
diff --git a/src/usr/local/www/system_usermanager.php b/src/usr/local/www/system_usermanager.php
index 305f2d3..abf9d82 100644
--- a/src/usr/local/www/system_usermanager.php
+++ b/src/usr/local/www/system_usermanager.php
@@ -68,6 +68,7 @@ if (isset($id) && $a_user[$id]) {
$pconfig['systemlogsmanagelogpanel'] = isset($a_user[$id]['systemlogsmanagelogpanel']);
$pconfig['statusmonitoringsettingspanel'] = isset($a_user[$id]['statusmonitoringsettingspanel']);
$pconfig['webguileftcolumnhyper'] = isset($a_user[$id]['webguileftcolumnhyper']);
+ $pconfig['disablealiaspopupdetail'] = isset($a_user[$id]['disablealiaspopupdetail']);
$pconfig['pagenamefirst'] = isset($a_user[$id]['pagenamefirst']);
$pconfig['groups'] = local_user_get_groups($a_user[$id]);
$pconfig['utype'] = $a_user[$id]['scope'];
@@ -359,6 +360,12 @@ if ($_POST['save']) {
unset($userent['webguileftcolumnhyper']);
}
+ if ($_POST['disablealiaspopupdetail']) {
+ $userent['disablealiaspopupdetail'] = true;
+ } else {
+ unset($userent['disablealiaspopupdetail']);
+ }
+
if ($_POST['pagenamefirst']) {
$userent['pagenamefirst'] = true;
} else {
@@ -974,6 +981,7 @@ events.push(function() {
hideCheckbox('systemlogsmanagelogpanel', !adv);
hideCheckbox('statusmonitoringsettingspanel', !adv);
hideCheckbox('webguileftcolumnhyper', !adv);
+ hideCheckbox('disablealiaspopupdetail', !adv);
hideCheckbox('pagenamefirst', !adv);
}
diff --git a/src/usr/local/www/vpn_ipsec.php b/src/usr/local/www/vpn_ipsec.php
index 22ef39d..27ff7ce 100644
--- a/src/usr/local/www/vpn_ipsec.php
+++ b/src/usr/local/www/vpn_ipsec.php
@@ -65,7 +65,7 @@ if ($_POST['apply']) {
foreach ($_POST['p1entry'] as $p1entrydel) {
unset($a_phase1[$p1entrydel]);
}
- if (write_config()) {
+ if (write_config(gettext("Deleted selected IPsec Phase 1 entries."))) {
mark_subsystem_dirty('ipsec');
}
}
@@ -75,7 +75,7 @@ if ($_POST['apply']) {
foreach ($_POST['p2entry'] as $p2entrydel) {
unset($a_phase2[$p2entrydel]);
}
- if (write_config()) {
+ if (write_config(gettext("Deleted selected IPsec Phase 2 entries."))) {
mark_subsystem_dirty('ipsec');
}
}
@@ -209,7 +209,7 @@ if ($_POST['apply']) {
}
if ($save === 1) {
- if (write_config()) {
+ if (write_config(gettext("Saved configuration changes for IPsec tunnels."))) {
mark_subsystem_dirty('ipsec');
}
}
diff --git a/src/usr/local/www/vpn_ipsec_mobile.php b/src/usr/local/www/vpn_ipsec_mobile.php
index 32f9de3..992ab68 100644
--- a/src/usr/local/www/vpn_ipsec_mobile.php
+++ b/src/usr/local/www/vpn_ipsec_mobile.php
@@ -294,7 +294,7 @@ if ($_POST['save']) {
$a_client = $client;
- write_config();
+ write_config(gettext("Saved IPsec Mobile Clients configuration."));
mark_subsystem_dirty('ipsec');
header("Location: vpn_ipsec_mobile.php");
diff --git a/src/usr/local/www/vpn_ipsec_phase1.php b/src/usr/local/www/vpn_ipsec_phase1.php
index 6988f73..44b6a30 100644
--- a/src/usr/local/www/vpn_ipsec_phase1.php
+++ b/src/usr/local/www/vpn_ipsec_phase1.php
@@ -508,7 +508,7 @@ if ($_POST['save']) {
$a_phase1[] = $ph1ent;
}
- write_config();
+ write_config(gettext("Saved IPsec tunnel Phase 1 configuration."));
mark_subsystem_dirty('ipsec');
header("Location: vpn_ipsec.php");
diff --git a/src/usr/local/www/vpn_ipsec_phase2.php b/src/usr/local/www/vpn_ipsec_phase2.php
index dd62ede..061e178 100644
--- a/src/usr/local/www/vpn_ipsec_phase2.php
+++ b/src/usr/local/www/vpn_ipsec_phase2.php
@@ -392,7 +392,7 @@ if ($_POST['save']) {
$a_phase2[] = $ph2ent;
}
- write_config();
+ write_config(gettext("Saved IPsec tunnel Phase 2 configuration."));
mark_subsystem_dirty('ipsec');
header("Location: vpn_ipsec.php");
diff --git a/src/usr/local/www/vpn_ipsec_settings.php b/src/usr/local/www/vpn_ipsec_settings.php
index 199fc6a..325936d 100644
--- a/src/usr/local/www/vpn_ipsec_settings.php
+++ b/src/usr/local/www/vpn_ipsec_settings.php
@@ -163,7 +163,7 @@ if ($_POST['save']) {
}
}
- write_config();
+ write_config(gettext("Saved IPsec advanced settings."));
$changes_applied = true;
$retval = 0;
diff --git a/src/usr/local/www/vpn_openvpn_client.php b/src/usr/local/www/vpn_openvpn_client.php
index 9bf5a7a..71f0072 100644
--- a/src/usr/local/www/vpn_openvpn_client.php
+++ b/src/usr/local/www/vpn_openvpn_client.php
@@ -717,7 +717,7 @@ if ($act=="new" || $act=="edit"):
'%1$s%2$s%3$s',
'<div class="infoblock">',
sprint_info_box(gettext('When both peers support NCP and have it enabled, NCP overrides the Encryption Algorithm above.') . '<br />' .
- gettext('When disabled, only the selected Encryption Algorithm is allowedz.'), 'info', false),
+ gettext('When disabled, only the selected Encryption Algorithm is allowed.'), 'info', false),
'</div>');
foreach (explode(",", $pconfig['ncp-ciphers']) as $cipher) {
diff --git a/src/usr/local/www/widgets/javascript/thermal_sensors.js b/src/usr/local/www/widgets/javascript/thermal_sensors.js
index 2ee8c3e..5791961 100644
--- a/src/usr/local/www/widgets/javascript/thermal_sensors.js
+++ b/src/usr/local/www/widgets/javascript/thermal_sensors.js
@@ -23,7 +23,7 @@ criticalTemp = 100;
ajaxBusy = false;
//should be called from "thermal_sensors.widget.php"
-function showThermalSensorsData() {
+function showThermalSensorsData(widgetKey, tsParams, firstTime) {
if (!ajaxBusy) {
ajaxBusy = true;
//get data from thermal_sensors.widget.php
@@ -35,34 +35,35 @@ function showThermalSensorsData() {
type: 'get',
success: function(data) {
var thermalSensorsData = data || "";
- buildThermalSensorsData(thermalSensorsData);
+ buildThermalSensorsData(thermalSensorsData, widgetKey, tsParams, firstTime);
+ firstTime = false;
},
error: function(jqXHR, status, error) {
+ firstTime = true;
warningTemp = 9999;
- buildThermalSensorsDataRaw('<span class="alert-danger">Temperature data could not be read.</span>');
+ buildThermalSensorsDataRaw('<span class="alert-danger">Temperature data could not be read.</span>', widgetKey);
}
});
ajaxBusy = false;
}
//call itself in 11 seconds
- window.setTimeout(showThermalSensorsData, 11000);
+ window.setTimeout(function(){showThermalSensorsData(widgetKey, tsParams, firstTime);}, 11000);
}
-function buildThermalSensorsData(thermalSensorsData) {
- //NOTE: variable thermal_sensors_widget_showRawOutput is declared/set in "thermal_sensors.widget.php"
- if (thermal_sensors_widget_showRawOutput) {
- buildThermalSensorsDataRaw(thermalSensorsData);
+function buildThermalSensorsData(thermalSensorsData, widgetKey, tsParams, firstTime) {
+ if (tsParams.showRawOutput) {
+ buildThermalSensorsDataRaw(thermalSensorsData, widgetKey);
} else {
- if (warningTemp == 9999) {
- buildThermalSensorsDataGraph(thermalSensorsData);
+ if (firstTime) {
+ buildThermalSensorsDataGraph(thermalSensorsData, tsParams, widgetKey);
}
- updateThermalSensorsDataGraph(thermalSensorsData);
+ updateThermalSensorsDataGraph(thermalSensorsData, tsParams, widgetKey);
}
}
-function buildThermalSensorsDataRaw(thermalSensorsData) {
+function buildThermalSensorsDataRaw(thermalSensorsData, widgetKey) {
var thermalSensorsContent = "";
@@ -71,20 +72,20 @@ function buildThermalSensorsDataRaw(thermalSensorsData) {
//rawData = thermalSensorsData.split("|").join("<br />");
}
- loadThermalSensorsContainer(thermalSensorsContent);
+ loadThermalSensorsContainer(thermalSensorsContent, widgetKey);
}
-function loadThermalSensorsContainer (thermalSensorsContent) {
+function loadThermalSensorsContainer (thermalSensorsContent, widgetKey) {
if (thermalSensorsContent && thermalSensorsContent != "") {
//load generated graph (or raw data) into thermalSensorsContainer (thermalSensorsContainer DIV defined in "thermal_sensors.widget.php")
- $('#thermalSensorsContainer').html(thermalSensorsContent);
+ $('#thermalSensorsContainer-' + widgetKey).html(thermalSensorsContent);
} else {
- $('#thermalSensorsContainer').html("No Thermal Sensors data available.");
+ $('#thermalSensorsContainer-' + widgetKey).html("No Thermal Sensors data available.");
}
}
-function buildThermalSensorsDataGraph(thermalSensorsData) {
+function buildThermalSensorsDataGraph(thermalSensorsData, tsParams, widgetKey) {
var thermalSensorsArray = new Array();
@@ -103,26 +104,25 @@ function buildThermalSensorsDataGraph(thermalSensorsData) {
//set thresholds
if (sensorName.indexOf("cpu") > -1) { //check CPU Threshold config settings
- warningTemp = thermal_sensors_widget_coreWarningTempThreshold;
- criticalTemp = thermal_sensors_widget_coreCriticalTempThreshold;
+ warningTemp = tsParams.coreWarningTempThreshold;
+ criticalTemp = tsParams.coreCriticalTempThreshold;
} else { //assuming sensor is for a zone, check Zone Threshold config settings
- warningTemp = thermal_sensors_widget_zoneWarningTempThreshold;
- criticalTemp = thermal_sensors_widget_zoneCriticalTempThreshold;
+ warningTemp = tsParams.zoneWarningTempThreshold;
+ criticalTemp = tsParams.zoneCriticalTempThreshold;
}
- //NOTE: variable thermal_sensors_widget_showFullSensorName is declared/set in "thermal_sensors.widget.php"
- if (!thermal_sensors_widget_showFullSensorName) {
+ if (!tsParams.showFullSensorName) {
sensorName = getSensorFriendlyName(sensorName);
}
//build temperature item/row for a sensor
var thermalSensorRow = '<div class="progress">' +
- '<div id="temperaturebarL' + i + '" class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="1" style="width: 1%"></div>' +
- '<div id="temperaturebarM' + i + '" class="progress-bar progress-bar-warning progress-bar-striped" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0" style="width: 0%"></div>' +
- '<div id="temperaturebarH' + i + '" class="progress-bar progress-bar-danger progress-bar-striped" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0" style="width: 0%"></div>' +
+ '<div id="temperaturebarL' + i + widgetKey + '" class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="1" style="width: 1%"></div>' +
+ '<div id="temperaturebarM' + i + widgetKey + '" class="progress-bar progress-bar-warning progress-bar-striped" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0" style="width: 0%"></div>' +
+ '<div id="temperaturebarH' + i + widgetKey + '" class="progress-bar progress-bar-danger progress-bar-striped" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0" style="width: 0%"></div>' +
'</div>' +
- '<span><b>' + sensorName + ': </b></span>' + '<span id="temperaturemsg' + i + '">' + thermalSensorValue + ' &deg;C</span>';
+ '<span><b>' + sensorName + ': </b></span>' + '<span id="temperaturemsg' + i + widgetKey + '">' + thermalSensorValue + ' &deg;C</span>';
thermalSensorsHTMLContent = thermalSensorsHTMLContent + thermalSensorRow;
@@ -130,12 +130,12 @@ function buildThermalSensorsDataGraph(thermalSensorsData) {
}
//load generated graph into thermalSensorsContainer (DIV defined in "thermal_sensors.widget.php")
- loadThermalSensorsContainer(thermalSensorsHTMLContent);
+ loadThermalSensorsContainer(thermalSensorsHTMLContent, widgetKey);
}
-function updateThermalSensorsDataGraph(thermalSensorsData) {
+function updateThermalSensorsDataGraph(thermalSensorsData, tsParams, widgetKey) {
var thermalSensorsArray = new Array();
if (thermalSensorsData && thermalSensorsData != "") {
@@ -152,19 +152,18 @@ function updateThermalSensorsDataGraph(thermalSensorsData) {
//set thresholds
if (sensorName.indexOf("cpu") > -1) { //check CPU Threshold config settings
- warningTemp = thermal_sensors_widget_coreWarningTempThreshold;
- criticalTemp = thermal_sensors_widget_coreCriticalTempThreshold;
+ warningTemp = tsParams.coreWarningTempThreshold;
+ criticalTemp = tsParams.coreCriticalTempThreshold;
} else { //assuming sensor is for a zone, check Zone Threshold config settings
- warningTemp = thermal_sensors_widget_zoneWarningTempThreshold;
- criticalTemp = thermal_sensors_widget_zoneCriticalTempThreshold;
+ warningTemp = tsParams.zoneWarningTempThreshold;
+ criticalTemp = tsParams.zoneCriticalTempThreshold;
}
- //NOTE: variable thermal_sensors_widget_showFullSensorName is declared/set in "thermal_sensors.widget.php"
- if (!thermal_sensors_widget_showFullSensorName) {
+ if (!tsParams.showFullSensorName) {
sensorName = getSensorFriendlyName(sensorName);
}
- setTempProgress(i, thermalSensorValue);
+ setTempProgress(i, thermalSensorValue, widgetKey);
}
}
@@ -189,7 +188,7 @@ function getThermalSensorValue(stringValue) {
// Update the progress indicator
// transition = true allows the bar to move at default speed, false = instantaneous
-function setTempProgress(bar, percent) {
+function setTempProgress(bar, percent, widgetKey) {
var barTempL, barTempM, barTempH;
if (percent <= warningTemp) {
@@ -207,9 +206,9 @@ function setTempProgress(bar, percent) {
}
- $('#' + 'temperaturebarL' + bar).css('width', barTempL + '%').attr('aria-valuenow', barTempL);
- $('#' + 'temperaturebarM' + bar).css('width', barTempM + '%').attr('aria-valuenow', barTempM);
- $('#' + 'temperaturebarH' + bar).css('width', barTempH + '%').attr('aria-valuenow', barTempH);
+ $('#' + 'temperaturebarL' + bar + widgetKey).css('width', barTempL + '%').attr('aria-valuenow', barTempL);
+ $('#' + 'temperaturebarM' + bar + widgetKey).css('width', barTempM + '%').attr('aria-valuenow', barTempM);
+ $('#' + 'temperaturebarH' + bar + widgetKey).css('width', barTempH + '%').attr('aria-valuenow', barTempH);
- $('#' + 'temperaturemsg' + bar).html(percent + ' &deg;C');
+ $('#' + 'temperaturemsg' + bar + widgetKey).html(percent + ' &deg;C');
}
diff --git a/src/usr/local/www/widgets/widgets/captive_portal_status.widget.php b/src/usr/local/www/widgets/widgets/captive_portal_status.widget.php
index 65c8b4a..725ca60 100644
--- a/src/usr/local/www/widgets/widgets/captive_portal_status.widget.php
+++ b/src/usr/local/www/widgets/widgets/captive_portal_status.widget.php
@@ -54,9 +54,11 @@ unset($cpzone);
flush();
-function clientcmp($a, $b) {
- global $order;
- return strcmp($a[$order], $b[$order]);
+if (!function_exists('clientcmp')) {
+ function clientcmp($a, $b) {
+ global $order;
+ return strcmp($a[$order], $b[$order]);
+ }
}
$cpdb_all = array();
diff --git a/src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php b/src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php
index 6e90d4e..c5dfd98 100644
--- a/src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php
+++ b/src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php
@@ -29,17 +29,21 @@ require_once("functions.inc");
require_once("/usr/local/www/widgets/include/dyn_dns_status.inc");
// Constructs a unique key that will identify a Dynamic DNS entry in the filter list.
-function get_dyndnsent_key($dyndns) {
- return $dyndns['id'];
+if (!function_exists('get_dyndnsent_key')) {
+ function get_dyndnsent_key($dyndns) {
+ return $dyndns['id'];
+ }
}
-function get_dyndns_hostname_text($dyndns) {
- global $dyndns_split_domain_types;
- if (in_array($dyndns['type'], $dyndns_split_domain_types)) {
- return $dyndns['host'] . "." . $dyndns['domainname'];
- }
+if (!function_exists('get_dyndns_hostname_text')) {
+ function get_dyndns_hostname_text($dyndns) {
+ global $dyndns_split_domain_types;
+ if (in_array($dyndns['type'], $dyndns_split_domain_types)) {
+ return $dyndns['host'] . "." . $dyndns['domainname'];
+ }
- return $dyndns['host'];
+ return $dyndns['host'];
+ }
}
if (!is_array($config['dyndnses']['dyndns'])) {
@@ -64,9 +68,8 @@ array_walk($all_dyndns, function(&$dyndns) {
}
});
-$skipdyndns = explode(",", $user_settings['widgets']['dyn_dns_status']['filter']);
-
if ($_REQUEST['getdyndnsstatus']) {
+ $skipdyndns = explode(",", $user_settings['widgets'][$_REQUEST['getdyndnsstatus']]['filter']);
$first_entry = true;
foreach ($all_dyndns as $dyndns) {
if (in_array(get_dyndnsent_key($dyndns), $skipdyndns)) {
@@ -114,7 +117,7 @@ if ($_REQUEST['getdyndnsstatus']) {
}
}
exit;
-} else if ($_POST) {
+} else if ($_POST['widgetkey']) {
$validNames = array();
@@ -123,9 +126,9 @@ if ($_REQUEST['getdyndnsstatus']) {
}
if (is_array($_POST['show'])) {
- $user_settings['widgets']['dyn_dns_status']['filter'] = implode(',', array_diff($validNames, $_POST['show']));
+ $user_settings['widgets'][$_POST['widgetkey']]['filter'] = implode(',', array_diff($validNames, $_POST['show']));
} else {
- $user_settings['widgets']['dyn_dns_status']['filter'] = "";
+ $user_settings['widgets'][$_POST['widgetkey']]['filter'] = implode(',', $validNames);
}
save_widget_settings($_SESSION['Username'], $user_settings["widgets"], gettext("Saved Dynamic DNS Filter via Dashboard."));
@@ -134,28 +137,34 @@ if ($_REQUEST['getdyndnsstatus']) {
$iflist = get_configured_interface_with_descr();
-function get_dyndns_interface_text($dyndns_iface) {
- global $iflist;
- if (isset($iflist[$dyndns_iface])) {
- return $iflist[$dyndns_iface];
- }
+if (!function_exists('get_dyndns_interface_text')) {
+ function get_dyndns_interface_text($dyndns_iface) {
+ global $iflist;
+ if (isset($iflist[$dyndns_iface])) {
+ return $iflist[$dyndns_iface];
+ }
- // This will be a gateway group name.
- return $dyndns_iface;
+ // This will be a gateway group name.
+ return $dyndns_iface;
+ }
}
$dyndns_providers = array_combine(explode(" ", DYNDNS_PROVIDER_VALUES), explode(",", DYNDNS_PROVIDER_DESCRIPTIONS));
+$skipdyndns = explode(",", $user_settings['widgets'][$widgetkey]['filter']);
+$widgetkey_nodash = str_replace("-", "", $widgetkey);
-function get_dyndns_service_text($dyndns_type) {
- global $dyndns_providers;
+if (!function_exists('get_dyndns_service_text')) {
+ function get_dyndns_service_text($dyndns_type) {
+ global $dyndns_providers;
- if (isset($dyndns_providers[$dyndns_type])) {
- return $dyndns_providers[$dyndns_type];
- } else if ($dyndns_type == '_rfc2136_') {
- return "RFC 2136";
- }
+ if (isset($dyndns_providers[$dyndns_type])) {
+ return $dyndns_providers[$dyndns_type];
+ } else if ($dyndns_type == '_rfc2136_') {
+ return "RFC 2136";
+ }
- return $dyndns_type;
+ return $dyndns_type;
+ }
}
?>
@@ -204,15 +213,23 @@ function get_dyndns_service_text($dyndns_type) {
</td>
</tr>
<?php endforeach;?>
+ <?php if ($rowid == -1):?>
+ <tr>
+ <td colspan="4" class="text-center">
+ <?=gettext('All Dyn DNS entries are hidden.');?>
+ </td>
+ </tr>
+ <?php endif;?>
</tbody>
</table>
</div>
<!-- close the body we're wrapped in and add a configuration-panel -->
-</div><div id="widget-<?=$widgetname?>_panel-footer" class="panel-footer collapse">
+</div><div id="<?=$widget_panel_footer_id?>" class="panel-footer collapse">
<form action="/widgets/widgets/dyn_dns_status.widget.php" method="post" class="form-horizontal">
<div class="panel panel-default col-sm-10">
<div class="panel-body">
+ <input type="hidden" name="widgetkey" value="<?=$widgetkey; ?>">
<div class="table responsive">
<table class="table table-striped table-hover table-condensed">
<thead>
@@ -225,7 +242,7 @@ function get_dyndns_service_text($dyndns_type) {
</thead>
<tbody>
<?php
- $skipdyndns = explode(",", $user_settings['widgets']['dyn_dns_status']['filter']);
+ $skipdyndns = explode(",", $user_settings['widgets'][$widgetkey]['filter']);
foreach ($all_dyndns as $dyndns):
?>
<tr>
@@ -246,46 +263,41 @@ function get_dyndns_service_text($dyndns_type) {
<div class="form-group">
<div class="col-sm-offset-3 col-sm-6">
<button type="submit" class="btn btn-primary"><i class="fa fa-save icon-embed-btn"></i><?=gettext('Save')?></button>
- <button id="showalldyndns" type="button" class="btn btn-info"><i class="fa fa-undo icon-embed-btn"></i><?=gettext('All')?></button>
+ <button id="<?=$widget_showallnone_id?>" type="button" class="btn btn-info"><i class="fa fa-undo icon-embed-btn"></i><?=gettext('All')?></button>
</div>
</div>
</form>
<script type="text/javascript">
//<![CDATA[
- function dyndns_getstatus() {
+ function dyndns_getstatus_<?=$widgetkey_nodash?>() {
scroll(0,0);
var url = "/widgets/widgets/dyn_dns_status.widget.php";
- var pars = 'getdyndnsstatus=yes';
+ var pars = 'getdyndnsstatus=<?=$widgetkey?>';
$.ajax(
url,
{
type: 'get',
data: pars,
- complete: dyndnscallback
+ complete: dyndnscallback_<?=$widgetkey_nodash?>
});
}
- function dyndnscallback(transport) {
+ function dyndnscallback_<?=$widgetkey_nodash?>(transport) {
// The server returns a string of statuses separated by vertical bars
var responseStrings = transport.responseText.split("|");
for (var count=0; count<responseStrings.length; count++) {
- var divlabel = '#dyndnsstatus' + count;
+ var divlabel = '#widget-<?=$widgetkey?> #dyndnsstatus' + count;
$(divlabel).prop('innerHTML',responseStrings[count]);
}
// Refresh the status every 5 minutes
- setTimeout('dyndns_getstatus()', 5*60*1000);
+ setTimeout('dyndns_getstatus_<?=$widgetkey_nodash?>()', 5*60*1000);
}
events.push(function(){
- $("#showalldyndns").click(function() {
- $("#widget-<?=$widgetname?>_panel-footer [id^=show]").each(function() {
- $(this).prop("checked", true);
- });
- });
-
+ set_widget_checkbox_events("#<?=$widget_panel_footer_id?> [id^=show]", "<?=$widget_showallnone_id?>");
});
// Do the first status check 2 seconds after the dashboard opens
- setTimeout('dyndns_getstatus()', 2000);
+ setTimeout('dyndns_getstatus_<?=$widgetkey_nodash?>()', 2000);
//]]>
</script>
diff --git a/src/usr/local/www/widgets/widgets/gateways.widget.php b/src/usr/local/www/widgets/widgets/gateways.widget.php
index d414a5e..7dfd8ac 100644
--- a/src/usr/local/www/widgets/widgets/gateways.widget.php
+++ b/src/usr/local/www/widgets/widgets/gateways.widget.php
@@ -31,34 +31,164 @@ require_once("pfsense-utils.inc");
require_once("functions.inc");
require_once("/usr/local/www/widgets/include/gateways.inc");
+if (!function_exists('compose_table_body_contents')) {
+ function compose_table_body_contents($widgetkey) {
+ global $user_settings;
+
+ $rtnstr = '';
+
+ $a_gateways = return_gateways_array();
+ $gateways_status = array();
+ $gateways_status = return_gateways_status(true);
+
+ if (isset($user_settings["widgets"][$widgetkey]["display_type"])) {
+ $display_type = $user_settings["widgets"][$widgetkey]["display_type"];
+ } else {
+ $display_type = "gw_ip";
+ }
+
+ $hiddengateways = explode(",", $user_settings["widgets"][$widgetkey]["gatewaysfilter"]);
+ $gw_displayed = false;
+
+ foreach ($a_gateways as $gname => $gateway) {
+ if (in_array($gname, $hiddengateways)) {
+ continue;
+ }
+
+ $gw_displayed = true;
+ $rtnstr .= "<tr>\n";
+ $rtnstr .= "<td>\n";
+ $rtnstr .= htmlspecialchars($gateway['name']) . "<br />";
+ $rtnstr .= '<div id="gateway' . $counter . '" style="display:inline"><b>';
+
+ $monitor_address = "";
+ $monitor_address_disp = "";
+ if ($display_type == "monitor_ip" || $display_type == "both_ip") {
+ $monitor_address = $gateway['monitor'];
+ if ($monitor_address != "" && $display_type == "both_ip") {
+ $monitor_address_disp = " (" . $monitor_address . ")";
+ } else {
+ $monitor_address_disp = $monitor_address;
+ }
+ }
+
+ $if_gw = '';
+ // If the user asked to display Gateway IP or both IPs, or asked for just monitor IP but the monitor IP is blank
+ // then find the gateway IP (which is also the monitor IP if the monitor IP was not explicitly set).
+ if ($display_type == "gw_ip" || $display_type == "both_ip" || ($display_type == "monitor_ip" && $monitor_address == "")) {
+ if (is_ipaddr($gateway['gateway'])) {
+ $if_gw = htmlspecialchars($gateway['gateway']);
+ } else {
+ if ($gateway['ipprotocol'] == "inet") {
+ $if_gw = htmlspecialchars(get_interface_gateway($gateway['friendlyiface']));
+ }
+ if ($gateway['ipprotocol'] == "inet6") {
+ $if_gw = htmlspecialchars(get_interface_gateway_v6($gateway['friendlyiface']));
+ }
+ }
+ if ($if_gw == "") {
+ $if_gw = "~";
+ }
+ }
+
+ if ($monitor_address == $if_gw) {
+ $monitor_address_disp = "";
+ }
+
+ $rtnstr .= $if_gw . $monitor_address_disp;
+ unset ($if_gw);
+ unset ($monitor_address);
+ unset ($monitor_address_disp);
+ $counter++;
+
+ $rtnstr .= "</b>";
+ $rtnstr .= "</div>\n";
+ $rtnstr .= "</td>\n";
+
+ if ($gateways_status[$gname]) {
+ if (stristr($gateways_status[$gname]['status'], "force_down")) {
+ $online = gettext("Offline (forced)");
+ $bgcolor = "danger"; // lightcoral
+ } elseif (stristr($gateways_status[$gname]['status'], "down")) {
+ $online = gettext("Offline");
+ $bgcolor = "danger"; // lightcoral
+ } elseif (stristr($gateways_status[$gname]['status'], "highloss")) {
+ $online = gettext("Packetloss");
+ $bgcolor = "danger"; // lightcoral
+ } elseif (stristr($gateways_status[$gname]['status'], "loss")) {
+ $online = gettext("Packetloss");
+ $bgcolor = "warning"; // khaki
+ } elseif (stristr($gateways_status[$gname]['status'], "highdelay")) {
+ $online = gettext("Latency");
+ $bgcolor = "danger"; // lightcoral
+ } elseif (stristr($gateways_status[$gname]['status'], "delay")) {
+ $online = gettext("Latency");
+ $bgcolor = "warning"; // khaki
+ } elseif ($gateways_status[$gname]['status'] == "none") {
+ if ($gateways_status[$gname]['monitor_disable'] || ($gateways_status[$gname]['monitorip'] == "none")) {
+ $online = gettext("Online <br/>(unmonitored)");
+ } else {
+ $online = gettext("Online");
+ }
+ $bgcolor = "success"; // lightgreen
+ } elseif ($gateways_status[$gname]['status'] == "") {
+ $online = gettext("Pending");
+ $bgcolor = "info"; // lightgray
+ }
+ } else {
+ $online = gettext("Unknown");
+ $bgcolor = "info"; // lightblue
+ }
+
+ $rtnstr .= "<td>" . ($gateways_status[$gname] ? ($gateways_status[$gname]['delay'] ? htmlspecialchars(number_format((float)rtrim($gateways_status[$gname]['delay'], "ms"), 1)) . "ms" : '') : gettext("Pending")) . "</td>\n";
+ $rtnstr .= "<td>" . ($gateways_status[$gname] ? ($gateways_status[$gname]['stddev'] ? htmlspecialchars(number_format((float)rtrim($gateways_status[$gname]['stddev'], "ms"), 1)) . "ms" : '') : gettext("Pending")) . "</td>\n";
+ $rtnstr .= "<td>" . ($gateways_status[$gname] ? htmlspecialchars($gateways_status[$gname]['loss']) : gettext("Pending")) . "</td>\n";
+ $rtnstr .= '<td class="bg-' . $bgcolor . '">' . $online . "</td>\n";
+ $rtnstr .= "</tr>\n";
+ }
+
+ if (!$gw_displayed) {
+ $rtnstr .= '<tr>';
+ $rtnstr .= '<td colspan="5" class="text-center">';
+ if (count($a_gateways)) {
+ $rtnstr .= gettext('All gateways are hidden.');
+ } else {
+ $rtnstr .= gettext('No gateways found.');
+ }
+ $rtnstr .= '</td>';
+ $rtnstr .= '</tr>';
+ }
+ return($rtnstr);
+ }
+}
+
// Compose the table contents and pass it back to the ajax caller
if ($_REQUEST && $_REQUEST['ajax']) {
- print(compose_table_body_contents());
+ print(compose_table_body_contents($_REQUEST['widgetkey']));
exit;
}
-if ($_POST) {
+if ($_POST['widgetkey']) {
-
- if (!is_array($user_settings["widgets"]["gateways_widget"])) {
- $user_settings["widgets"]["gateways_widget"] = array();
+ if (!is_array($user_settings["widgets"][$_POST['widgetkey']])) {
+ $user_settings["widgets"][$_POST['widgetkey']] = array();
}
if (isset($_POST["display_type"])) {
- $user_settings["widgets"]["gateways_widget"]["display_type"] = $_POST["display_type"];
+ $user_settings["widgets"][$_POST['widgetkey']]["display_type"] = $_POST["display_type"];
}
- if (is_array($_POST['show'])) {
- $validNames = array();
- $a_gateways = return_gateways_array();
+ $validNames = array();
+ $a_gateways = return_gateways_array();
- foreach ($a_gateways as $gname => $gateway) {
- array_push($validNames, $gname);
- }
+ foreach ($a_gateways as $gname => $gateway) {
+ array_push($validNames, $gname);
+ }
- $user_settings["widgets"]["gateways_widget"]["gatewaysfilter"] = implode(',', array_diff($validNames, $_POST['show']));
+ if (is_array($_POST['show'])) {
+ $user_settings["widgets"][$_POST['widgetkey']]["gatewaysfilter"] = implode(',', array_diff($validNames, $_POST['show']));
} else {
- $user_settings["widgets"]["gateways_widget"]["gatewaysfilter"] = "";
+ $user_settings["widgets"][$_POST['widgetkey']]["gatewaysfilter"] = implode(',', $validNames);
}
save_widget_settings($_SESSION['Username'], $user_settings["widgets"], gettext("Updated gateways widget settings via dashboard."));
@@ -67,6 +197,8 @@ if ($_POST) {
}
$widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period'] * 1000 : 10000;
+$widgetkey_nodash = str_replace("-", "", $widgetkey);
+
?>
<div class="table-responsive">
@@ -80,15 +212,15 @@ $widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period
<th><?=gettext("Status")?></th>
</tr>
</thead>
- <tbody id="gwtblbody">
+ <tbody id="<?=$widgetkey?>-gwtblbody">
<?php
- print(compose_table_body_contents());
+ print(compose_table_body_contents($widgetkey));
?>
</tbody>
</table>
</div>
<!-- close the body we're wrapped in and add a configuration-panel -->
-</div><div id="widget-<?=$widgetname?>_panel-footer" class="panel-footer collapse">
+</div><div id="<?=$widget_panel_footer_id?>" class="panel-footer collapse">
<form action="/widgets/widgets/gateways.widget.php" method="post" class="form-horizontal">
<div class="form-group">
<label class="col-sm-3 control-label"><?=gettext('Display')?></label>
@@ -96,8 +228,8 @@ $widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period
$display_type_gw_ip = "checked";
$display_type_monitor_ip = "";
$display_type_both_ip = "";
- if (isset($user_settings["widgets"]["gateways_widget"]["display_type"])) {
- $selected_radio = $user_settings["widgets"]["gateways_widget"]["display_type"];
+ if (isset($user_settings["widgets"][$widgetkey]["display_type"])) {
+ $selected_radio = $user_settings["widgets"][$widgetkey]["display_type"];
if ($selected_radio == "gw_ip") {
$display_type_gw_ip = "checked";
$display_type_monitor_ip = "";
@@ -130,6 +262,7 @@ $widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period
<div class="panel panel-default col-sm-10">
<div class="panel-body">
+ <input type="hidden" name="widgetkey" value="<?=$widgetkey; ?>">
<div class="table responsive">
<table class="table table-striped table-hover table-condensed">
<thead>
@@ -141,7 +274,7 @@ $widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period
<tbody>
<?php
$a_gateways = return_gateways_array();
- $hiddengateways = explode(",", $user_settings["widgets"]["gateways_widget"]["gatewaysfilter"]);
+ $hiddengateways = explode(",", $user_settings["widgets"][$widgetkey]["gatewaysfilter"]);
$idx = 0;
foreach ($a_gateways as $gname => $gateway):
@@ -162,7 +295,7 @@ $widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period
<div class="form-group">
<div class="col-sm-offset-3 col-sm-6">
<button type="submit" class="btn btn-primary"><i class="fa fa-save icon-embed-btn"></i><?=gettext('Save')?></button>
- <button id="showallgateways" type="button" class="btn btn-info"><i class="fa fa-undo icon-embed-btn"></i><?=gettext('All')?></button>
+ <button id="<?=$widget_showallnone_id?>" type="button" class="btn btn-info"><i class="fa fa-undo icon-embed-btn"></i><?=gettext('All')?></button>
</div>
</div>
</form>
@@ -170,164 +303,29 @@ $widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period
<script>
//<![CDATA[
- function get_gw_stats() {
+ function get_gw_stats_<?=$widgetkey_nodash?>() {
var ajaxRequest;
ajaxRequest = $.ajax({
url: "/widgets/widgets/gateways.widget.php",
type: "post",
- data: { ajax: "ajax"}
+ data: { ajax: "ajax", widgetkey: "<?=$widgetkey?>"}
});
// Deal with the results of the above ajax call
ajaxRequest.done(function (response, textStatus, jqXHR) {
- $('#gwtblbody').html(response);
+ $('#<?=$widgetkey?>-gwtblbody').html(response);
// and do it again
- setTimeout(get_gw_stats, "<?=$widgetperiod?>");
+ setTimeout(get_gw_stats_<?=$widgetkey_nodash?>, "<?=$widgetperiod?>");
});
}
events.push(function(){
- $("#showallgateways").click(function() {
- $("#widget-<?=$widgetname?>_panel-footer [id^=show]").each(function() {
- $(this).prop("checked", true);
- });
- });
+ set_widget_checkbox_events("#<?=$widget_panel_footer_id?> [id^=show]", "<?=$widget_showallnone_id?>");
// Start polling for updates some small random number of seconds from now (so that all the widgets don't
// hit the server at exactly the same time)
- setTimeout(get_gw_stats, Math.floor((Math.random() * 10000) + 1000));
+ setTimeout(get_gw_stats_<?=$widgetkey_nodash?>, Math.floor((Math.random() * 10000) + 1000));
});
//]]>
</script>
-
-<?php
-function compose_table_body_contents() {
- global $user_settings;
-
- $rtnstr = '';
-
- $a_gateways = return_gateways_array();
- $gateways_status = array();
- $gateways_status = return_gateways_status(true);
-
- if (isset($user_settings["widgets"]["gateways_widget"]["display_type"])) {
- $display_type = $user_settings["widgets"]["gateways_widget"]["display_type"];
- } else {
- $display_type = "gw_ip";
- }
-
- $hiddengateways = explode(",", $user_settings["widgets"]["gateways_widget"]["gatewaysfilter"]);
- $gw_displayed = false;
-
- foreach ($a_gateways as $gname => $gateway) {
- if (in_array($gname, $hiddengateways)) {
- continue;
- }
-
- $gw_displayed = true;
- $rtnstr .= "<tr>\n";
- $rtnstr .= "<td>\n";
- $rtnstr .= htmlspecialchars($gateway['name']) . "<br />";
- $rtnstr .= '<div id="gateway' . $counter . '" style="display:inline"><b>';
-
- $monitor_address = "";
- $monitor_address_disp = "";
- if ($display_type == "monitor_ip" || $display_type == "both_ip") {
- $monitor_address = $gateway['monitor'];
- if ($monitor_address != "" && $display_type == "both_ip") {
- $monitor_address_disp = " (" . $monitor_address . ")";
- } else {
- $monitor_address_disp = $monitor_address;
- }
- }
-
- $if_gw = '';
- // If the user asked to display Gateway IP or both IPs, or asked for just monitor IP but the monitor IP is blank
- // then find the gateway IP (which is also the monitor IP if the monitor IP was not explicitly set).
- if ($display_type == "gw_ip" || $display_type == "both_ip" || ($display_type == "monitor_ip" && $monitor_address == "")) {
- if (is_ipaddr($gateway['gateway'])) {
- $if_gw = htmlspecialchars($gateway['gateway']);
- } else {
- if ($gateway['ipprotocol'] == "inet") {
- $if_gw = htmlspecialchars(get_interface_gateway($gateway['friendlyiface']));
- }
- if ($gateway['ipprotocol'] == "inet6") {
- $if_gw = htmlspecialchars(get_interface_gateway_v6($gateway['friendlyiface']));
- }
- }
- if ($if_gw == "") {
- $if_gw = "~";
- }
- }
-
- if ($monitor_address == $if_gw) {
- $monitor_address_disp = "";
- }
-
- $rtnstr .= $if_gw . $monitor_address_disp;
- unset ($if_gw);
- unset ($monitor_address);
- unset ($monitor_address_disp);
- $counter++;
-
- $rtnstr .= "</b>";
- $rtnstr .= "</div>\n";
- $rtnstr .= "</td>\n";
-
- if ($gateways_status[$gname]) {
- if (stristr($gateways_status[$gname]['status'], "force_down")) {
- $online = gettext("Offline (forced)");
- $bgcolor = "danger"; // lightcoral
- } elseif (stristr($gateways_status[$gname]['status'], "down")) {
- $online = gettext("Offline");
- $bgcolor = "danger"; // lightcoral
- } elseif (stristr($gateways_status[$gname]['status'], "highloss")) {
- $online = gettext("Packetloss");
- $bgcolor = "danger"; // lightcoral
- } elseif (stristr($gateways_status[$gname]['status'], "loss")) {
- $online = gettext("Packetloss");
- $bgcolor = "warning"; // khaki
- } elseif (stristr($gateways_status[$gname]['status'], "highdelay")) {
- $online = gettext("Latency");
- $bgcolor = "danger"; // lightcoral
- } elseif (stristr($gateways_status[$gname]['status'], "delay")) {
- $online = gettext("Latency");
- $bgcolor = "warning"; // khaki
- } elseif ($gateways_status[$gname]['status'] == "none") {
- if ($gateways_status[$gname]['monitor_disable'] || ($gateways_status[$gname]['monitorip'] == "none")) {
- $online = gettext("Online <br/>(unmonitored)");
- } else {
- $online = gettext("Online");
- }
- $bgcolor = "success"; // lightgreen
- } elseif ($gateways_status[$gname]['status'] == "") {
- $online = gettext("Pending");
- $bgcolor = "info"; // lightgray
- }
- } else {
- $online = gettext("Unknown");
- $bgcolor = "info"; // lightblue
- }
-
- $rtnstr .= "<td>" . ($gateways_status[$gname] ? htmlspecialchars($gateways_status[$gname]['delay']) : gettext("Pending")) . "</td>\n";
- $rtnstr .= "<td>" . ($gateways_status[$gname] ? htmlspecialchars($gateways_status[$gname]['stddev']) : gettext("Pending")) . "</td>\n";
- $rtnstr .= "<td>" . ($gateways_status[$gname] ? htmlspecialchars($gateways_status[$gname]['loss']) : gettext("Pending")) . "</td>\n";
- $rtnstr .= '<td class="bg-' . $bgcolor . '">' . $online . "</td>\n";
- $rtnstr .= "</tr>\n";
- }
-
- if (!$gw_displayed) {
- $rtnstr .= '<tr>';
- $rtnstr .= '<td colspan="5">';
- if (count($a_gateways)) {
- $rtnstr .= gettext('All gateways are hidden.');
- } else {
- $rtnstr .= gettext('No gateways found.');
- }
- $rtnstr .= '</td>';
- $rtnstr .= '</tr>';
- }
- return($rtnstr);
-}
-?>
diff --git a/src/usr/local/www/widgets/widgets/gmirror_status.widget.php b/src/usr/local/www/widgets/widgets/gmirror_status.widget.php
index 046e9f3..60f11ba 100644
--- a/src/usr/local/www/widgets/widgets/gmirror_status.widget.php
+++ b/src/usr/local/www/widgets/widgets/gmirror_status.widget.php
@@ -33,6 +33,7 @@ require_once("gmirror.inc");
<?=gmirror_html_status()?>
</div>
+<?php if ($widget_first_instance): ?>
<script type="text/javascript">
//<![CDATA[
function gmirrorStatusUpdateFromServer() {
@@ -45,7 +46,10 @@ function gmirrorStatusUpdateFromServer() {
return raw.replace(/<script>([\s\S]*)<\/script>/gi, '');
},
success: function(data){
- $('#gmirror_status').html(data);
+ $('[id="gmirror_status"]').html(data);
+ },
+ error: function(){
+ $('[id="gmirror_status"]').html("<div class=\"alert alert-danger\"><?=gettext('Unable to retrieve status'); ?></div>");
}
});
}
@@ -55,3 +59,4 @@ events.push(function(){
});
//]]>
</script>
+<?php endif; ?> \ No newline at end of file
diff --git a/src/usr/local/www/widgets/widgets/installed_packages.widget.php b/src/usr/local/www/widgets/widgets/installed_packages.widget.php
index 1840d6f..d344ce5 100644
--- a/src/usr/local/www/widgets/widgets/installed_packages.widget.php
+++ b/src/usr/local/www/widgets/widgets/installed_packages.widget.php
@@ -146,6 +146,7 @@ if ($_REQUEST && $_REQUEST['ajax']) {
<?=gettext("Packages may be added/managed here: ")?> <a href="pkg_mgr_installed.php"><?=gettext("System")?> -&gt; <?=gettext("Packages")?></a>
</p>
+<?php if ($widget_first_instance): ?>
<script type="text/javascript">
//<![CDATA[
@@ -160,7 +161,7 @@ if ($_REQUEST && $_REQUEST['ajax']) {
// Deal with the results of the above ajax call
ajaxRequest.done(function (response, textStatus, jqXHR) {
- $('#pkgtbl').html(response);
+ $('[id="pkgtbl"]').html(response);
// and do it again
// NOT! There is no need to refresh this widget
@@ -173,3 +174,4 @@ if ($_REQUEST && $_REQUEST['ajax']) {
});
//]]>
</script>
+<?php endif; ?> \ No newline at end of file
diff --git a/src/usr/local/www/widgets/widgets/interface_statistics.widget.php b/src/usr/local/www/widgets/widgets/interface_statistics.widget.php
index bb10731..7944b4b 100644
--- a/src/usr/local/www/widgets/widgets/interface_statistics.widget.php
+++ b/src/usr/local/www/widgets/widgets/interface_statistics.widget.php
@@ -48,7 +48,8 @@ if ($_REQUEST && $_REQUEST['ajax']) {
'collisions' => gettext('Collisions'),
);
- $skipinterfaces = explode(",", $user_settings['widgets']['interface_statistics']['iffilter']);
+ $skipinterfaces = explode(",", $user_settings['widgets'][$_REQUEST['widgetkey']]['iffilter']);
+ $interface_is_displayed = false;
print("<thead>");
print( "<tr>");
@@ -57,9 +58,14 @@ if ($_REQUEST && $_REQUEST['ajax']) {
foreach ($ifdescrs as $ifdescr => $ifname) {
if (!in_array($ifdescr, $skipinterfaces)) {
print( "<th>" . $ifname . "</th>");
+ $interface_is_displayed = true;
}
}
+ if (!$interface_is_displayed) {
+ print("<th>" . gettext('All interfaces are hidden.') . "</th>");
+ }
+
print( "</tr>");
print( "</thead>");
print( "<tbody>");
@@ -90,7 +96,7 @@ if ($_REQUEST && $_REQUEST['ajax']) {
}
print( "</tbody>");
exit;
-} else if ($_POST) {
+} else if ($_POST['widgetkey']) {
$validNames = array();
@@ -99,9 +105,9 @@ if ($_REQUEST && $_REQUEST['ajax']) {
}
if (is_array($_POST['show'])) {
- $user_settings['widgets']['interface_statistics']['iffilter'] = implode(',', array_diff($validNames, $_POST['show']));
+ $user_settings['widgets'][$_POST['widgetkey']]['iffilter'] = implode(',', array_diff($validNames, $_POST['show']));
} else {
- $user_settings['widgets']['interface_statistics']['iffilter'] = "";
+ $user_settings['widgets'][$_POST['widgetkey']]['iffilter'] = implode(',', $validNames);
}
save_widget_settings($_SESSION['Username'], $user_settings["widgets"], gettext("Saved Interface Statistics Filter via Dashboard."));
@@ -109,18 +115,20 @@ if ($_REQUEST && $_REQUEST['ajax']) {
}
$widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period'] * 1000 : 10000;
+$widgetkey_nodash = str_replace("-", "", $widgetkey);
?>
-<table id="iftbl" class="table table-striped table-hover">
+<table id="<?=$widgetkey?>-iftbl" class="table table-striped table-hover">
<tr><td><?=gettext("Retrieving interface data")?></td></tr>
</table>
<!-- close the body we're wrapped in and add a configuration-panel -->
-</div><div id="widget-<?=$widgetname?>_panel-footer" class="panel-footer collapse">
+</div><div id="<?=$widget_panel_footer_id?>" class="panel-footer collapse">
<form action="/widgets/widgets/interface_statistics.widget.php" method="post" class="form-horizontal">
<div class="panel panel-default col-sm-10">
<div class="panel-body">
+ <input type="hidden" name="widgetkey" value="<?=$widgetkey; ?>">
<div class="table responsive">
<table class="table table-striped table-hover table-condensed">
<thead>
@@ -131,7 +139,7 @@ $widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period
</thead>
<tbody>
<?php
- $skipinterfaces = explode(",", $user_settings['widgets']['interface_statistics']['iffilter']);
+ $skipinterfaces = explode(",", $user_settings['widgets'][$widgetkey]['iffilter']);
$idx = 0;
foreach ($ifdescrs as $ifdescr => $ifname):
@@ -152,7 +160,7 @@ $widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period
<div class="form-group">
<div class="col-sm-offset-3 col-sm-6">
<button type="submit" class="btn btn-primary"><i class="fa fa-save icon-embed-btn"></i><?=gettext('Save')?></button>
- <button id="showallinterfacesforstats" type="button" class="btn btn-info"><i class="fa fa-undo icon-embed-btn"></i><?=gettext('All')?></button>
+ <button id="<?=$widget_showallnone_id?>" type="button" class="btn btn-info"><i class="fa fa-undo icon-embed-btn"></i><?=gettext('All')?></button>
</div>
</div>
</form>
@@ -160,34 +168,30 @@ $widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period
<script type="text/javascript">
//<![CDATA[
- function get_if_stats() {
+ function get_if_stats_<?=$widgetkey_nodash?>() {
var ajaxRequest;
ajaxRequest = $.ajax({
url: "/widgets/widgets/interface_statistics.widget.php",
type: "post",
- data: { ajax: "ajax"}
+ data: { ajax: "ajax", widgetkey: "<?=$widgetkey?>"}
});
// Deal with the results of the above ajax call
ajaxRequest.done(function (response, textStatus, jqXHR) {
- $('#iftbl').html(response);
+ $('#<?=$widgetkey?>-iftbl').html(response);
// and do it again
- setTimeout(get_if_stats, "<?=$widgetperiod?>");
+ setTimeout(get_if_stats_<?=$widgetkey_nodash?>, "<?=$widgetperiod?>");
});
}
events.push(function(){
- $("#showallinterfacesforstats").click(function() {
- $("#widget-<?=$widgetname?>_panel-footer [id^=show]").each(function() {
- $(this).prop("checked", true);
- });
- });
+ set_widget_checkbox_events("#<?=$widget_panel_footer_id?> [id^=show]", "<?=$widget_showallnone_id?>");
// Start polling for updates some small random number of seconds from now (so that all the widgets don't
// hit the server at exactly the same time)
- setTimeout(get_if_stats, Math.floor((Math.random() * 10000) + 1000));
+ setTimeout(get_if_stats_<?=$widgetkey_nodash?>, Math.floor((Math.random() * 10000) + 1000));
});
//]]>
</script>
diff --git a/src/usr/local/www/widgets/widgets/interfaces.widget.php b/src/usr/local/www/widgets/widgets/interfaces.widget.php
index 69a2869..0528402 100644
--- a/src/usr/local/www/widgets/widgets/interfaces.widget.php
+++ b/src/usr/local/www/widgets/widgets/interfaces.widget.php
@@ -28,8 +28,10 @@ require_once("functions.inc");
require_once("/usr/local/www/widgets/include/interfaces.inc");
$ifdescrs = get_configured_interface_with_descr();
+// Update once per minute by default, instead of every 10 seconds
+$widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period'] * 1000 * 6 : 60000;
-if ($_POST) {
+if ($_POST['widgetkey']) {
$validNames = array();
@@ -38,28 +40,38 @@ if ($_POST) {
}
if (is_array($_POST['show'])) {
- $user_settings['widgets']['interfaces']['iffilter'] = implode(',', array_diff($validNames, $_POST['show']));
+ $user_settings['widgets'][$_POST['widgetkey']]['iffilter'] = implode(',', array_diff($validNames, $_POST['show']));
} else {
- $user_settings['widgets']['interfaces']['iffilter'] = "";
+ $user_settings['widgets'][$_POST['widgetkey']]['iffilter'] = implode(',', $validNames);
}
save_widget_settings($_SESSION['Username'], $user_settings["widgets"], gettext("Saved Interfaces Filter via Dashboard."));
header("Location: /index.php");
}
+// When this widget is included in the dashboard, $widgetkey is already defined before the widget is included.
+// When the ajax call is made to refresh the interfaces table, 'widgetkey' comes in $_REQUEST.
+if ($_REQUEST['widgetkey']) {
+ $widgetkey = $_REQUEST['widgetkey'];
+}
+
?>
-<div class="table-responsive">
+<div class="table-responsive" id="ifaces_status_<?=$widgetkey?>">
<table class="table table-striped table-hover table-condensed">
<tbody>
+
<?php
-$skipinterfaces = explode(",", $user_settings['widgets']['interfaces']['iffilter']);
+$skipinterfaces = explode(",", $user_settings['widgets'][$widgetkey]['iffilter']);
+$widgetkey_nodash = str_replace("-", "", $widgetkey);
+$interface_is_displayed = false;
foreach ($ifdescrs as $ifdescr => $ifname):
if (in_array($ifdescr, $skipinterfaces)) {
continue;
}
+ $interface_is_displayed = true;
$ifinfo = get_interface_info($ifdescr);
if ($ifinfo['pppoelink'] || $ifinfo['pptplink'] || $ifinfo['l2tplink']) {
/* PPP link (non-cell) - looks like a modem */
@@ -104,7 +116,7 @@ foreach ($ifdescrs as $ifdescr => $ifname):
<?php endif; ?>
</td>
<td>
- <?php if ($ifinfo['pppoelink'] == "up" || $ifinfo['pptplink'] == "up" || $ifinfo['l2tplink'] == "up"):?>
+ <?php if ($ifinfo['pppoelink'] == "up" || $ifinfo['pptplink'] == "up" || $ifinfo['l2tplink'] == "up"):?>
<?=sprintf(gettext("Uptime: %s"), htmlspecialchars($ifinfo['ppp_uptime']));?>
<?php else: ?>
<?=htmlspecialchars($ifinfo['media']);?>
@@ -127,16 +139,27 @@ foreach ($ifdescrs as $ifdescr => $ifname):
</tr>
<?php
endforeach;
+if (!$interface_is_displayed):
+?>
+ <tr>
+ <td class="text-center">
+ <?=gettext('All interfaces are hidden.');?>
+ </td>
+ </tr>
+
+<?php
+endif;
?>
</tbody>
</table>
</div>
<!-- close the body we're wrapped in and add a configuration-panel -->
-</div><div id="widget-<?=$widgetname?>_panel-footer" class="panel-footer collapse">
+</div><div id="<?=$widget_panel_footer_id?>" class="panel-footer collapse">
<form action="/widgets/widgets/interfaces.widget.php" method="post" class="form-horizontal">
- <div class="panel panel-default col-sm-10">
+ <div class="panel panel-default col-sm-10">
<div class="panel-body">
+ <input type="hidden" name="widgetkey" value="<?=$widgetkey; ?>">
<div class="table responsive">
<table class="table table-striped table-hover table-condensed">
<thead>
@@ -147,7 +170,7 @@ endforeach;
</thead>
<tbody>
<?php
- $skipinterfaces = explode(",", $user_settings['widgets']['interfaces']['iffilter']);
+ $skipinterfaces = explode(",", $user_settings['widgets'][$widgetkey]['iffilter']);
$idx = 0;
foreach ($ifdescrs as $ifdescr => $ifname):
@@ -168,20 +191,43 @@ endforeach;
<div class="form-group">
<div class="col-sm-offset-3 col-sm-6">
<button type="submit" class="btn btn-primary"><i class="fa fa-save icon-embed-btn"></i><?=gettext('Save')?></button>
- <button id="showallinterfaces" type="button" class="btn btn-info"><i class="fa fa-undo icon-embed-btn"></i><?=gettext('All')?></button>
+ <button id="<?=$widget_showallnone_id?>" type="button" class="btn btn-info"><i class="fa fa-undo icon-embed-btn"></i><?=gettext('All')?></button>
</div>
</div>
</form>
-<script>
+<?php
+
+/* for AJAX response, we only need the panels */
+if ($_REQUEST['widgetkey']) {
+ exit;
+}
+?>
+
+<script type="text/javascript">
//<![CDATA[
- events.push(function(){
- $("#showallinterfaces").click(function() {
- $("#widget-<?=$widgetname?>_panel-footer [id^=show]").each(function() {
- $(this).prop("checked", true);
- });
- });
+function getstatus_ifaces_<?=$widgetkey_nodash?>() {
+ $.ajax({
+ type: 'get',
+ url: '/widgets/widgets/interfaces.widget.php',
+ dataType: 'html',
+ data: { widgetkey: "<?=$widgetkey?>" },
+ dataFilter: function(raw){
+ // We reload the entire widget, strip this block of javascript from it
+ return raw.replace(/<script>([\s\S]*)<\/script>/gi, '');
+ },
+ success: function(data){
+ $('#ifaces_status_<?=$widgetkey?>').html(data);
+ },
+ error: function(){
+ $('#ifaces_status_<?=$widgetkey?>').html("<div class=\"alert alert-danger\"><?=gettext('Unable to retrieve status'); ?></div>");
+ }
+ });
+}
+ events.push(function(){
+ set_widget_checkbox_events("#<?=$widget_panel_footer_id?> [id^=show]", "<?=$widget_showallnone_id?>");
+ setInterval('getstatus_ifaces_<?=$widgetkey_nodash?>()', "<?=$widgetperiod?>");
});
//]]>
</script>
diff --git a/src/usr/local/www/widgets/widgets/ipsec.widget.php b/src/usr/local/www/widgets/widgets/ipsec.widget.php
index 766745b..62aa804 100644
--- a/src/usr/local/www/widgets/widgets/ipsec.widget.php
+++ b/src/usr/local/www/widgets/widgets/ipsec.widget.php
@@ -170,11 +170,13 @@ if ($_REQUEST && $_REQUEST['ajax']) {
exit;
}
+$widgetkey_nodash = str_replace("-", "", $widgetkey);
+
if (isset($config['ipsec']['phase1'])) {
$tab_array = array();
- $tab_array[] = array(gettext("Overview"), true, "ipsec-Overview");
- $tab_array[] = array(gettext("Tunnels"), false, "ipsec-tunnel");
- $tab_array[] = array(gettext("Mobile"), false, "ipsec-mobile");
+ $tab_array[] = array(gettext("Overview"), true, $widgetkey_nodash . "-Overview");
+ $tab_array[] = array(gettext("Tunnels"), false, $widgetkey_nodash . "-tunnel");
+ $tab_array[] = array(gettext("Mobile"), false, $widgetkey_nodash . "-mobile");
display_widget_tabs($tab_array);
}
@@ -183,7 +185,7 @@ $mobile = ipsec_dump_mobile();
$widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period'] * 1000 : 10000;
if (isset($config['ipsec']['phase2'])): ?>
-<div id="ipsec-Overview" style="display:block;" class="table-responsive">
+<div id="<?=$widgetkey_nodash?>-Overview" style="display:block;" class="table-responsive">
<table class="table table-striped table-hover">
<thead>
<tr>
@@ -197,7 +199,7 @@ if (isset($config['ipsec']['phase2'])): ?>
</tbody>
</table>
</div>
-<div class="table-responsive" id="ipsec-tunnel" style="display:none;">
+<div class="table-responsive" id="<?=$widgetkey_nodash?>-tunnel" style="display:none;">
<table class="table table-striped table-hover">
<thead>
<tr>
@@ -214,7 +216,7 @@ if (isset($config['ipsec']['phase2'])): ?>
</div>
<?php if (is_array($mobile['pool'])): ?>
-<div id="ipsec-mobile" style="display:none;" class="table-responsive">
+<div id="<?=$widgetkey_nodash?>-mobile" style="display:none;" class="table-responsive">
<table class="table table-striped table-hover">
<thead>
<tr>
@@ -288,7 +290,7 @@ function changeTabDIV(selectedDiv) {
}
}
-function get_ipsec_stats() {
+function get_ipsec_stats_<?=$widgetkey_nodash?>() {
var ajaxRequest;
ajaxRequest = $.ajax({
@@ -303,17 +305,17 @@ function get_ipsec_stats() {
// Deal with the results of the above ajax call
ajaxRequest.done(function (response, textStatus, jqXHR) {
- $('tbody', '#ipsec-' + curtab).html(response);
+ $('tbody', '#<?=$widgetkey_nodash?>-' + curtab).html(response);
// and do it again
- setTimeout(get_ipsec_stats, "<?=$widgetperiod?>");
+ setTimeout(get_ipsec_stats_<?=$widgetkey_nodash?>, "<?=$widgetperiod?>");
});
}
events.push(function(){
// Start polling for updates some small random number of seconds from now (so that all the widgets don't
// hit the server at exactly the same time)
- setTimeout(get_ipsec_stats, Math.floor((Math.random() * 10000) + 1000));
+ setTimeout(get_ipsec_stats_<?=$widgetkey_nodash?>, Math.floor((Math.random() * 10000) + 1000));
});
//]]>
</script>
diff --git a/src/usr/local/www/widgets/widgets/log.widget.php b/src/usr/local/www/widgets/widgets/log.widget.php
index fb9aae6..6d759e3 100644
--- a/src/usr/local/www/widgets/widgets/log.widget.php
+++ b/src/usr/local/www/widgets/widgets/log.widget.php
@@ -29,11 +29,11 @@ require_once("functions.inc");
/* In an effort to reduce duplicate code, many shared functions have been moved here. */
require_once("filter_log.inc");
-if ($_POST) {
+if ($_POST['widgetkey']) {
if (is_numeric($_POST['filterlogentries'])) {
- $user_settings['widgets']['filterlogentries'] = $_POST['filterlogentries'];
+ $user_settings['widgets'][$_POST['widgetkey']]['filterlogentries'] = $_POST['filterlogentries'];
} else {
- unset($user_settings['widgets']['filterlogentries']);
+ unset($user_settings['widgets'][$_POST['widgetkey']]['filterlogentries']);
}
$acts = array();
@@ -48,22 +48,22 @@ if ($_POST) {
}
if (!empty($acts)) {
- $user_settings['widgets']['filterlogentriesacts'] = implode(" ", $acts);
+ $user_settings['widgets'][$_POST['widgetkey']]['filterlogentriesacts'] = implode(" ", $acts);
} else {
- unset($user_settings['widgets']['filterlogentriesacts']);
+ unset($user_settings['widgets'][$_POST['widgetkey']]['filterlogentriesacts']);
}
unset($acts);
if (($_POST['filterlogentriesinterfaces']) and ($_POST['filterlogentriesinterfaces'] != "All")) {
- $user_settings['widgets']['filterlogentriesinterfaces'] = trim($_POST['filterlogentriesinterfaces']);
+ $user_settings['widgets'][$_POST['widgetkey']]['filterlogentriesinterfaces'] = trim($_POST['filterlogentriesinterfaces']);
} else {
- unset($user_settings['widgets']['filterlogentriesinterfaces']);
+ unset($user_settings['widgets'][$_POST['widgetkey']]['filterlogentriesinterfaces']);
}
if (is_numeric($_POST['filterlogentriesinterval'])) {
- $user_settings['widgets']['filterlogentriesinterval'] = $_POST['filterlogentriesinterval'];
+ $user_settings['widgets'][$_POST['widgetkey']]['filterlogentriesinterval'] = $_POST['filterlogentriesinterval'];
} else {
- unset($user_settings['widgets']['filterlogentriesinterval']);
+ unset($user_settings['widgets'][$_POST['widgetkey']]['filterlogentriesinterval']);
}
save_widget_settings($_SESSION['Username'], $user_settings["widgets"], gettext("Saved Filter Log Entries via Dashboard."));
@@ -71,32 +71,39 @@ if ($_POST) {
exit(0);
}
+// When this widget is included in the dashboard, $widgetkey is already defined before the widget is included.
+// When the ajax call is made to refresh the firewall log table, 'widgetkey' comes in $_REQUEST.
+if ($_REQUEST['widgetkey']) {
+ $widgetkey = $_REQUEST['widgetkey'];
+}
+
$iface_descr_arr = get_configured_interface_with_descr();
-$nentries = isset($user_settings['widgets']['filterlogentries']) ? $user_settings['widgets']['filterlogentries'] : 5;
+$nentries = isset($user_settings['widgets'][$widgetkey]['filterlogentries']) ? $user_settings['widgets'][$widgetkey]['filterlogentries'] : 5;
//set variables for log
-$nentriesacts = isset($user_settings['widgets']['filterlogentriesacts']) ? $user_settings['widgets']['filterlogentriesacts'] : 'All';
-$nentriesinterfaces = isset($user_settings['widgets']['filterlogentriesinterfaces']) ? $user_settings['widgets']['filterlogentriesinterfaces'] : 'All';
+$nentriesacts = isset($user_settings['widgets'][$widgetkey]['filterlogentriesacts']) ? $user_settings['widgets'][$widgetkey]['filterlogentriesacts'] : 'All';
+$nentriesinterfaces = isset($user_settings['widgets'][$widgetkey]['filterlogentriesinterfaces']) ? $user_settings['widgets'][$widgetkey]['filterlogentriesinterfaces'] : 'All';
$filterfieldsarray = array(
"act" => $nentriesacts,
"interface" => isset($iface_descr_arr[$nentriesinterfaces]) ? $iface_descr_arr[$nentriesinterfaces] : $nentriesinterfaces
);
-$nentriesinterval = isset($user_settings['widgets']['filterlogentriesinterval']) ? $user_settings['widgets']['filterlogentriesinterval'] : 60;
+$nentriesinterval = isset($user_settings['widgets'][$widgetkey]['filterlogentriesinterval']) ? $user_settings['widgets'][$widgetkey]['filterlogentriesinterval'] : 60;
$filter_logfile = "{$g['varlog_path']}/filter.log";
$filterlog = conv_log_filter($filter_logfile, $nentries, 50, $filterfieldsarray);
+
+$widgetkey_nodash = str_replace("-", "", $widgetkey);
?>
<script type="text/javascript">
//<![CDATA[
- var logWidgetLastRefresh = <?=time()?>;
+ var logWidgetLastRefresh<?=$widgetkey_nodash?> = <?=time()?>;
//]]>
</script>
-
<table class="table table-striped table-hover">
<thead>
<tr>
@@ -177,38 +184,39 @@ if (isset($_GET['lastsawtime'])) {
<script type="text/javascript">
//<![CDATA[
-function logWidgetUpdateFromServer() {
+function logWidgetUpdateFromServer<?=$widgetkey_nodash?>() {
$.ajax({
type: 'get',
url: '/widgets/widgets/log.widget.php',
- data: 'lastsawtime='+logWidgetLastRefresh,
+ data: { lastsawtime: logWidgetLastRefresh<?=$widgetkey_nodash?>, widgetkey: "<?=$widgetkey?>"},
dataFilter: function(raw){
// We reload the entire widget, strip this block of javascript from it
return raw.replace(/<script>([\s\S]*)<\/script>/gi, '');
},
dataType: 'html',
success: function(data){
- $('#widget-log .panel-body').html(data);
+ $('#widget-<?=$widgetkey?> .panel-body').html(data);
}
});
}
events.push(function(){
- setInterval('logWidgetUpdateFromServer()', <?=$nentriesinterval?>*1000);
+ setInterval('logWidgetUpdateFromServer<?=$widgetkey_nodash?>()', <?=$nentriesinterval?>*1000);
});
//]]>
</script>
<!-- close the body we're wrapped in and add a configuration-panel -->
</div>
-<div id="widget-<?=$widgetname?>_panel-footer" class="panel-footer collapse">
+<div id="<?=$widget_panel_footer_id?>" class="panel-footer collapse">
<?php
-$pconfig['nentries'] = isset($user_settings['widgets']['filterlogentries']) ? $user_settings['widgets']['filterlogentries'] : '';
-$pconfig['nentriesinterval'] = isset($user_settings['widgets']['filterlogentriesinterval']) ? $user_settings['widgets']['filterlogentriesinterval'] : '';
+$pconfig['nentries'] = isset($user_settings['widgets'][$widgetkey]['filterlogentries']) ? $user_settings['widgets'][$widgetkey]['filterlogentries'] : '';
+$pconfig['nentriesinterval'] = isset($user_settings['widgets'][$widgetkey]['filterlogentriesinterval']) ? $user_settings['widgets'][$widgetkey]['filterlogentriesinterval'] : '';
?>
<form action="/widgets/widgets/log.widget.php" method="post"
class="form-horizontal">
+ <input type="hidden" name="widgetkey" value="<?=$widgetkey; ?>">
<div class="form-group">
<label for="filterlogentries" class="col-sm-4 control-label"><?=gettext('Number of entries')?></label>
<div class="col-sm-6">
diff --git a/src/usr/local/www/widgets/widgets/ntp_status.widget.php b/src/usr/local/www/widgets/widgets/ntp_status.widget.php
index efe5675..9f0e964 100644
--- a/src/usr/local/www/widgets/widgets/ntp_status.widget.php
+++ b/src/usr/local/www/widgets/widgets/ntp_status.widget.php
@@ -194,7 +194,7 @@ if ($_REQUEST['updateme']) {
exit;
}
?>
-
+<?php if ($widget_first_instance): ?>
<script type="text/javascript">
//<![CDATA[
var d = new Date('<?=date_format(date_create(), 'c')?>');
@@ -210,11 +210,11 @@ setInterval(function() {
thisMinute = thisMinute < 10 ? "0" + thisMinute : thisMinute;
thisSecond = thisSecond < 10 ? "0" + thisSecond : thisSecond;
- $('#ntpStatusClock').html(thisHour +':' + thisMinute + ':' + thisSecond + ' ' + tz);
+ $('[id="ntpStatusClock"]').html(thisHour +':' + thisMinute + ':' + thisSecond + ' ' + tz);
}, 1000);
//]]>
</script>
-
+<?php endif; ?>
<table id="ntpstatus" class="table table-striped table-hover">
<tbody>
<tr>
@@ -224,7 +224,7 @@ setInterval(function() {
</tr>
</tbody>
</table>
-
+<?php if ($widget_first_instance): ?>
<script type="text/javascript">
//<![CDATA[
function ntp_getstatus() {
@@ -242,7 +242,7 @@ setInterval(function() {
function ntpstatuscallback(transport) {
// The server returns formatted html code
var responseStringNtp = transport.responseText
- $('#ntpstatus').prop('innerHTML',responseStringNtp);
+ $('[id="ntpstatus"]').prop('innerHTML',responseStringNtp);
// Refresh the status at the configured interval
setTimeout('ntp_getstatus()', "<?=$widgetperiod?>");
@@ -254,3 +254,4 @@ setInterval(function() {
//]]>
</script>
+<?php endif; ?> \ No newline at end of file
diff --git a/src/usr/local/www/widgets/widgets/openvpn.widget.php b/src/usr/local/www/widgets/widgets/openvpn.widget.php
index a3ad6e4..3956d62 100644
--- a/src/usr/local/www/widgets/widgets/openvpn.widget.php
+++ b/src/usr/local/www/widgets/widgets/openvpn.widget.php
@@ -24,6 +24,253 @@ $nocsrf = true;
require_once("guiconfig.inc");
require_once("openvpn.inc");
+// Output the widget panel from this function so that it can be called from the AJAX handler as well as
+// when first rendering the page
+if (!function_exists('printPanel')) {
+ function printPanel($widgetkey) {
+ global $user_settings;
+
+ $servers = openvpn_get_active_servers();
+ $sk_servers = openvpn_get_active_servers("p2p");
+ $clients = openvpn_get_active_clients();
+ $skipovpns = explode(",", $user_settings['widgets'][$widgetkey]['filter']);
+
+ $opstring = "";
+ $got_ovpn_server = false;
+
+ foreach ($servers as $server):
+ if (in_array($server['vpnid'], $skipovpns)) {
+ continue;
+ }
+
+ $got_ovpn_server = true;
+
+ $opstring .= "<div class=\"widget panel panel-default\">";
+ $opstring .= "<div class=\"panel-heading\"><h2 class=\"panel-title\">" . htmlspecialchars($server['name']) . "</h2></div>";
+ $opstring .= "<div class=\"table-responsive\">";
+ $opstring .= "<table class=\"table table-striped table-hover table-condensed sortable-theme-bootstrap\" data-sortable>";
+ $opstring .= "<thead>";
+ $opstring .= "<tr>";
+ $opstring .= "<th>" . gettext('Name/Time') . "</th>";
+ $opstring .= "<th>" . gettext('Real/Virtual IP') . "</th>";
+ $opstring .= "<th></th>";
+ $opstring .= "</tr>";
+ $opstring .= "</thead>";
+ $opstring .= "<tbody>";
+
+ $rowIndex = 0;
+ foreach ($server['conns'] as $conn):
+ $evenRowClass = $rowIndex % 2 ? " listMReven" : " listMRodd";
+ $rowIndex++;
+
+ $opstring .= "<tr name=\"" . "r:" . $server['mgmt'] . ":" . $conn['remote_host'] . "\" class=\"" . $evenRowClass . "\">";
+ $opstring .= "<td>";
+ $opstring .= $conn['common_name'];
+ $opstring .= "</td>";
+ $opstring .= "<td>";
+ $opstring .= $conn['remote_host'];
+ $opstring .= "</td>";
+ $opstring .= "<td>";
+ $opstring .= "<i class=\"fa fa-times-circle\" ";
+ $opstring .= "onclick=\"killClient('" . $server['mgmt'] . "', '" . $conn['remote_host'] . "');\" ";
+ $opstring .= "style=\"cursor:pointer;\" ";
+ $opstring .= "name=\"" . "i:" . $server['mgmt'] . ":" . $conn['remote_host'] . "\" ";
+ $opstring .= "title=\"" . sprintf(gettext('Kill client connection from %s'), $conn['remote_host']) . "\">";
+ $opstring .= "</i>";
+ $opstring .= "</td>";
+ $opstring .= "</tr>";
+ $opstring .= "<tr name=\"" . "r:" . $server['mgmt'] . ":" . $conn['remote_host'] . "\" class=\"" . $evenRowClass . "\">";
+ $opstring .= "<td>";
+ $opstring .= $conn['connect_time'];
+ $opstring .= "</td>";
+ $opstring .= "<td>";
+ $opstring .= $conn['virtual_addr'];
+ if (!empty($conn['virtual_addr']) && !empty($conn['virtual_addr6'])) {
+ $opstring .= "<br />";
+ }
+ $opstring .= $conn['virtual_addr6'];
+ $opstring .= "</td>";
+ $opstring .= "<td></td>";
+ $opstring .= "</tr>";
+
+ endforeach;
+
+ $opstring .= "</tbody>";
+ $opstring .= "</table>";
+ $opstring .= "</div>";
+ $opstring .= "</div>";
+
+ endforeach;
+
+ print($opstring);
+
+ $got_sk_server = false;
+
+ if (!empty($sk_servers)):
+ foreach ($sk_servers as $sk_server):
+ if (!in_array($sk_server['vpnid'], $skipovpns)) {
+ $got_sk_server = true;
+ break;
+ }
+ endforeach;
+ endif;
+
+ if ($got_sk_server):
+
+ $opstring = "";
+ $opstring .= "<div class=\"widget panel panel-default\">";
+ $opstring .= "<div class=\"panel-heading\"><h2 class=\"panel-title\">" . gettext("Peer to Peer Server Instance Statistics") . "</h2></div>";
+ $opstring .= "<div class=\"table-responsive\">";
+ $opstring .= "<table class=\"table table-striped table-hover table-condensed sortable-theme-bootstrap\" data-sortable>";
+ $opstring .= "<thead>";
+ $opstring .= "<tr>";
+ $opstring .= "<th>" . gettext('Name/Time') . "</th>";
+ $opstring .= "<th>" . gettext('Remote/Virtual IP') . "</th>";
+ $opstring .= "<th></th>";
+ $opstring .= "</tr>";
+ $opstring .= "</thead>";
+ $opstring .= "<tbody>";
+
+ foreach ($sk_servers as $sk_server):
+ if (in_array($sk_server['vpnid'], $skipovpns)) {
+ continue;
+ }
+
+ $opstring .= "<tr name=\"r:" . $sk_server['port'] . ":" . $sk_server['remote_host'] . "\">";
+ $opstring .= "<td>";
+ $opstring .= $sk_server['name'];
+ $opstring .= "</td>";
+ $opstring .= "<td>";
+ $opstring .= $sk_server['remote_host'];
+ $opstring .= "</td>";
+ $opstring .= "<td>";
+
+ if ($sk_server['status'] == "up") {
+ /* tunnel is up */
+ $opstring .= "<i class=\"fa fa-arrow-up text-success\"></i>";
+ } else {
+ /* tunnel is down */
+ $opstring .= "<i class=\"fa fa-arrow-down text-danger\"></i>";
+ }
+
+ $opstring .= "</td>";
+ $opstring .= "</tr>";
+ $opstring .= "<tr name=\"r:" . $sk_server['port'] . ":" . $sk_server['remote_host'] . "\">";
+ $opstring .= "<td>";
+ $opstring .= $sk_server['connect_time'];
+ $opstring .= "</td>";
+ $opstring .= "<td>";
+ $opstring .= $sk_server['virtual_addr'];
+ if (!empty($sk_server['virtual_addr']) && !empty($sk_server['virtual_addr6'])) {
+ $opstring .= "<br />";
+ }
+ $opstring .= $sk_server['virtual_addr6'];
+ $opstring .= "</td>";
+ $opstring .= "<td></td>";
+ $opstring .= "</tr>";
+
+ endforeach;
+
+ $opstring .= "</tbody>";
+ $opstring .= "</table>";
+ $opstring .= "</div>";
+ $opstring .= "</div>";
+
+ print($opstring);
+
+ endif;
+
+ $got_ovpn_client = false;
+
+ if (!empty($clients)):
+ foreach ($clients as $client):
+ if (!in_array($client['vpnid'], $skipovpns)) {
+ $got_ovpn_client = true;
+ break;
+ }
+ endforeach;
+ endif;
+
+ if ($got_ovpn_client):
+
+ $opstring = "";
+
+ $opstring .= "<div class=\"widget panel panel-default\">";
+ $opstring .= "<div class=\"panel-heading\"><h2 class=\"panel-title\">" . gettext("Client Instance Statistics") . "</h2></div>";
+ $opstring .= "<div class=\"table-responsive\">";
+ $opstring .= "<table class=\"table table-striped table-hover table-condensed sortable-theme-bootstrap\" data-sortable>";
+ $opstring .= "<thead>";
+ $opstring .= "<tr>";
+ $opstring .= "<th>" . gettext('Name/Time') . "</th>";
+ $opstring .= "<th>" . gettext('Remote/Virtual IP') . "</th>";
+ $opstring .= "<th></th>";
+ $opstring .= "</tr>";
+ $opstring .= "</thead>";
+ $opstring .= "<tbody>";
+
+ foreach ($clients as $client):
+ if (in_array($client['vpnid'], $skipovpns)) {
+ continue;
+ }
+
+ $opstring .= "<tr name=\"r:" . $client['port'] . ":" . $client['remote_host'] . "\">";
+ $opstring .= "<td>";
+ $opstring .= $client['name'];
+ $opstring .= "</td>";
+ $opstring .= "<td>";
+ $opstring .= $client['remote_host'];
+ $opstring .= "</td>";
+ $opstring .= "<td>";
+
+ if ($client['status'] == "up") {
+ /* tunnel is up */
+ $opstring .= "<i class=\"fa fa-arrow-up text-success\"></i>";
+ } else {
+ /* tunnel is down */
+ $opstring .= "<i class=\"fa fa-arrow-down text-danger\"></i>";
+ }
+
+ $opstring .= "</td>";
+ $opstring .= "</tr>";
+ $opstring .= "<tr name=\"r:" . $client['port'] . ":" . $client['remote_host'] . "\">";
+ $opstring .= "<td>";
+ $opstring .= $client['connect_time'];
+ $opstring .= "</td>";
+ $opstring .= "<td>";
+ $opstring .= $client['virtual_addr'];
+ if (!empty($client['virtual_addr']) && !empty($client['virtual_addr6'])) {
+ $opstring .= "<br />";
+ }
+ $opstring .= $client['virtual_addr6'];
+ $opstring .= "</td>";
+ $opstring .= "<td></td>";
+ $opstring .= "</tr>";
+
+ endforeach;
+
+ $opstring .= "</tbody>";
+ $opstring .= "</table>";
+ $opstring .= "</div>";
+ $opstring .= "</div>";
+
+ print($opstring);
+
+ endif;
+
+ if ((empty($clients)) && (empty($servers)) && (empty($sk_servers))) {
+ $none_to_display_text = gettext("No OpenVPN instances defined");
+ } else if (!$got_ovpn_server && !$got_sk_server && !$got_ovpn_client) {
+ $none_to_display_text = gettext("All OpenVPN instances are hidden");
+ } else {
+ $none_to_display_text = "";
+ }
+
+ if (strlen($none_to_display_text) > 0) {
+ print('<table class="table"><tbody><td class="text-center">' . $none_to_display_text . '</td></tbody></table>');
+ }
+ }
+}
+
/* Handle AJAX */
if ($_GET['action']) {
if ($_GET['action'] == "kill") {
@@ -41,9 +288,9 @@ if ($_GET['action']) {
// Compose the table contents and pass it back to the ajax caller
if ($_REQUEST && $_REQUEST['ajax']) {
- printPanel();
+ printPanel($_REQUEST['widgetkey']);
exit;
-} else if ($_POST) {
+} else if ($_POST['widgetkey']) {
$validNames = array();
$servers = openvpn_get_active_servers();
@@ -63,320 +310,33 @@ if ($_REQUEST && $_REQUEST['ajax']) {
}
if (is_array($_POST['show'])) {
- $user_settings['widgets']['openvpn']['filter'] = implode(',', array_diff($validNames, $_POST['show']));
+ $user_settings['widgets'][$_POST['widgetkey']]['filter'] = implode(',', array_diff($validNames, $_POST['show']));
} else {
- $user_settings['widgets']['openvpn']['filter'] = "";
+ $user_settings['widgets'][$_POST['widgetkey']]['filter'] = implode(',', $validNames);
}
save_widget_settings($_SESSION['Username'], $user_settings["widgets"], gettext("Saved OpenVPN Filter via Dashboard."));
header("Location: /index.php");
}
-// Output the widget panel from this function so that it can be called from the AJAX handler as well as
-// when first rendering the page
-function printPanel() {
- global $user_settings;
-
- $servers = openvpn_get_active_servers();
- $sk_servers = openvpn_get_active_servers("p2p");
- $clients = openvpn_get_active_clients();
- $skipovpns = explode(",", $user_settings['widgets']['openvpn']['filter']);
-
- $opstring = "";
-
- foreach ($servers as $server):
- if (in_array($server['vpnid'], $skipovpns)) {
- continue;
- }
-
- $opstring .= "<div class=\"widget panel panel-default\">";
- $opstring .= "<div class=\"panel-heading\"><h2 class=\"panel-title\">" . htmlspecialchars($server['name']) . "</h2></div>";
- $opstring .= "<div class=\"table-responsive\">";
- $opstring .= "<table class=\"table table-striped table-hover table-condensed sortable-theme-bootstrap\" data-sortable>";
- $opstring .= "<thead>";
- $opstring .= "<tr>";
- $opstring .= "<th>" . gettext('Name/Time') . "</th>";
- $opstring .= "<th>" . gettext('Real/Virtual IP') . "</th>";
- $opstring .= "<th></th>";
- $opstring .= "</tr>";
- $opstring .= "</thead>";
- $opstring .= "<tbody>";
-
- $rowIndex = 0;
- foreach ($server['conns'] as $conn):
- $evenRowClass = $rowIndex % 2 ? " listMReven" : " listMRodd";
- $rowIndex++;
-
- $opstring .= "<tr name=\"" . "r:" . $server['mgmt'] . ":" . $conn['remote_host'] . "\" class=\"" . $evenRowClass . "\">";
- $opstring .= "<td>";
- $opstring .= $conn['common_name'];
- $opstring .= "</td>";
- $opstring .= "<td>";
- $opstring .= $conn['remote_host'];
- $opstring .= "</td>";
- $opstring .= "<td>";
- $opstring .= "<i class=\"fa fa-times-circle\" ";
- $opstring .= "onclick=\"killClient('" . $server['mgmt'] . "', '" . $conn['remote_host'] . "');\" ";
- $opstring .= "style=\"cursor:pointer;\" ";
- $opstring .= "name=\"" . "i:" . $server['mgmt'] . ":" . $conn['remote_host'] . "\" ";
- $opstring .= "title=\"" . sprintf(gettext('Kill client connection from %s'), $conn['remote_host']) . "\">";
- $opstring .= "</i>";
- $opstring .= "</td>";
- $opstring .= "</tr>";
- $opstring .= "<tr name=\"" . "r:" . $server['mgmt'] . ":" . $conn['remote_host'] . "\" class=\"" . $evenRowClass . "\">";
- $opstring .= "<td>";
- $opstring .= $conn['connect_time'];
- $opstring .= "</td>";
- $opstring .= "<td>";
- $opstring .= $conn['virtual_addr'];
- if (!empty($conn['virtual_addr']) && !empty($conn['virtual_addr6'])) {
- $opstring .= "<br />";
- }
- $opstring .= $conn['virtual_addr6'];
- $opstring .= "</td>";
- $opstring .= "<td></td>";
- $opstring .= "</tr>";
-
- endforeach;
-
- $opstring .= "</tbody>";
- $opstring .= "</table>";
- $opstring .= "</div>";
- $opstring .= "</div>";
-
- endforeach;
-
- print($opstring);
-
- $got_sk_server = false;
-
- if (!empty($sk_servers)):
- foreach ($sk_servers as $sk_server):
- if (!in_array($sk_server['vpnid'], $skipovpns)) {
- $got_sk_server = true;
- break;
- }
- endforeach;
- endif;
-
- if ($got_sk_server):
-
- $opstring = "";
- $opstring .= "<div class=\"widget panel panel-default\">";
- $opstring .= "<div class=\"panel-heading\"><h2 class=\"panel-title\">" . gettext("Peer to Peer Server Instance Statistics") . "</h2></div>";
- $opstring .= "<div class=\"table-responsive\">";
- $opstring .= "<table class=\"table table-striped table-hover table-condensed sortable-theme-bootstrap\" data-sortable>";
- $opstring .= "<thead>";
- $opstring .= "<tr>";
- $opstring .= "<th>" . gettext('Name/Time') . "</th>";
- $opstring .= "<th>" . gettext('Remote/Virtual IP') . "</th>";
- $opstring .= "<th></th>";
- $opstring .= "</tr>";
- $opstring .= "</thead>";
- $opstring .= "<tbody>";
-
- foreach ($sk_servers as $sk_server):
- if (in_array($sk_server['vpnid'], $skipovpns)) {
- continue;
- }
-
- $opstring .= "<tr name=\"r:" . $sk_server['port'] . ":" . $sk_server['remote_host'] . "\">";
- $opstring .= "<td>";
- $opstring .= $sk_server['name'];
- $opstring .= "</td>";
- $opstring .= "<td>";
- $opstring .= $sk_server['remote_host'];
- $opstring .= "</td>";
- $opstring .= "<td>";
-
- if ($sk_server['status'] == "up") {
- /* tunnel is up */
- $opstring .= "<i class=\"fa fa-arrow-up text-success\"></i>";
- } else {
- /* tunnel is down */
- $opstring .= "<i class=\"fa fa-arrow-down text-danger\"></i>";
- }
-
- $opstring .= "</td>";
- $opstring .= "</tr>";
- $opstring .= "<tr name=\"r:" . $sk_server['port'] . ":" . $sk_server['remote_host'] . "\">";
- $opstring .= "<td>";
- $opstring .= $sk_server['connect_time'];
- $opstring .= "</td>";
- $opstring .= "<td>";
- $opstring .= $sk_server['virtual_addr'];
- if (!empty($sk_server['virtual_addr']) && !empty($sk_server['virtual_addr6'])) {
- $opstring .= "<br />";
- }
- $opstring .= $sk_server['virtual_addr6'];
- $opstring .= "</td>";
- $opstring .= "<td></td>";
- $opstring .= "</tr>";
-
- endforeach;
-
- $opstring .= "</tbody>";
- $opstring .= "</table>";
- $opstring .= "</div>";
- $opstring .= "</div>";
-
- print($opstring);
-
- endif;
-
- $got_ovpn_client = false;
-
- if (!empty($clients)):
- foreach ($clients as $client):
- if (!in_array($client['vpnid'], $skipovpns)) {
- $got_ovpn_client = true;
- break;
- }
- endforeach;
- endif;
-
- if ($got_ovpn_client):
-
- $opstring = "";
-
- $opstring .= "<div class=\"widget panel panel-default\">";
- $opstring .= "<div class=\"panel-heading\"><h2 class=\"panel-title\">" . gettext("Client Instance Statistics") . "</h2></div>";
- $opstring .= "<div class=\"table-responsive\">";
- $opstring .= "<table class=\"table table-striped table-hover table-condensed sortable-theme-bootstrap\" data-sortable>";
- $opstring .= "<thead>";
- $opstring .= "<tr>";
- $opstring .= "<th>" . gettext('Name/Time') . "</th>";
- $opstring .= "<th>" . gettext('Remote/Virtual IP') . "</th>";
- $opstring .= "<th></th>";
- $opstring .= "</tr>";
- $opstring .= "</thead>";
- $opstring .= "<tbody>";
-
- foreach ($clients as $client):
- if (in_array($client['vpnid'], $skipovpns)) {
- continue;
- }
-
- $opstring .= "<tr name=\"r:" . $client['port'] . ":" . $client['remote_host'] . "\">";
- $opstring .= "<td>";
- $opstring .= $client['name'];
- $opstring .= "</td>";
- $opstring .= "<td>";
- $opstring .= $client['remote_host'];
- $opstring .= "</td>";
- $opstring .= "<td>";
-
- if ($client['status'] == "up") {
- /* tunnel is up */
- $opstring .= "<i class=\"fa fa-arrow-up text-success\"></i>";
- } else {
- /* tunnel is down */
- $opstring .= "<i class=\"fa fa-arrow-down text-danger\"></i>";
- }
-
- $opstring .= "</td>";
- $opstring .= "</tr>";
- $opstring .= "<tr name=\"r:" . $client['port'] . ":" . $client['remote_host'] . "\">";
- $opstring .= "<td>";
- $opstring .= $client['connect_time'];
- $opstring .= "</td>";
- $opstring .= "<td>";
- $opstring .= $client['virtual_addr'];
- if (!empty($client['virtual_addr']) && !empty($client['virtual_addr6'])) {
- $opstring .= "<br />";
- }
- $opstring .= $client['virtual_addr6'];
- $opstring .= "</td>";
- $opstring .= "<td></td>";
- $opstring .= "</tr>";
-
- endforeach;
-
- $opstring .= "</tbody>";
- $opstring .= "</table>";
- $opstring .= "</div>";
- $opstring .= "</div>";
-
- print($opstring);
-
- endif;
-
- if ((empty($clients)) && (empty($servers)) && (empty($sk_servers))) {
- print(gettext("No OpenVPN instances defined"));
- }
-}
-
$widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period'] * 1000 : 10000;
+$widgetkey_nodash = str_replace("-", "", $widgetkey);
?>
-<script type="text/javascript">
-//<![CDATA[
- function killClient(mport, remipp) {
-
- $.ajax(
- "widgets/widgets/openvpn.widget.php" +
- "?action=kill&port=" + mport + "&remipp=" + remipp,
- { type: "get", complete: killComplete }
- );
- }
-
- function killComplete(req) {
- var values = req.responseText.split("|");
- if (values[3] != "0") {
- alert('<?=gettext("An error occurred.");?>' + ' (' + values[3] + ')');
- return;
- }
-
- $('tr[name="r:' + values[1] + ":" + values[2] + '"]').each(
- function(index,row) { $(row).fadeOut(1000); }
- );
- }
-
- // Refresh the panel
- function get_update() {
- var ajaxRequest;
-
- ajaxRequest = $.ajax({
- url: "/widgets/widgets/openvpn.widget.php",
- type: "post",
- data: { ajax: "ajax"}
- });
-
- // Deal with the results of the above ajax call
- ajaxRequest.done(function (response, textStatus, jqXHR) {
- $('#mainpanel').html(response);
-
- // and do it again
- setTimeout(get_update, "<?=$widgetperiod?>");
- });
- }
-
- events.push(function(){
- $("#showallovpns").click(function() {
- $("#widget-<?=$widgetname?>_panel-footer [id^=show]").each(function() {
- $(this).prop("checked", true);
- });
- });
-
- // Start polling for updates some small random number of seconds from now (so that all the widgets don't
- // hit the server at exactly the same time)
- setTimeout(get_update, Math.floor((Math.random() * 10000) + 1000));
- });
-//]]>
-</script>
-<div id="mainpanel" class="content">
+<div id="<?=$widgetkey?>-openvpn-mainpanel" class="content">
<?php
- printPanel();
+ printPanel($widgetkey);
?>
</div>
<!-- close the body we're wrapped in and add a configuration-panel -->
-</div><div id="widget-<?=$widgetname?>_panel-footer" class="panel-footer collapse">
+</div><div id="<?=$widget_panel_footer_id?>" class="panel-footer collapse">
<form action="/widgets/widgets/openvpn.widget.php" method="post" class="form-horizontal">
<div class="panel panel-default col-sm-10">
<div class="panel-body">
+ <input type="hidden" name="widgetkey" value="<?=$widgetkey; ?>">
<div class="table responsive">
<table class="table table-striped table-hover table-condensed">
<thead>
@@ -390,7 +350,7 @@ $widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period
$servers = openvpn_get_active_servers();
$sk_servers = openvpn_get_active_servers("p2p");
$clients = openvpn_get_active_clients();
- $skipovpns = explode(",", $user_settings['widgets']['openvpn']['filter']);
+ $skipovpns = explode(",", $user_settings['widgets'][$widgetkey]['filter']);
foreach ($servers as $server):
?>
<tr>
@@ -425,7 +385,59 @@ $widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period
<div class="form-group">
<div class="col-sm-offset-3 col-sm-6">
<button type="submit" class="btn btn-primary"><i class="fa fa-save icon-embed-btn"></i><?=gettext('Save')?></button>
- <button id="showallovpns" type="button" class="btn btn-info"><i class="fa fa-undo icon-embed-btn"></i><?=gettext('All')?></button>
+ <button id="<?=$widget_showallnone_id?>" type="button" class="btn btn-info"><i class="fa fa-undo icon-embed-btn"></i><?=gettext('All')?></button>
</div>
</div>
</form>
+
+<script type="text/javascript">
+//<![CDATA[
+ function killClient(mport, remipp) {
+
+ $.ajax(
+ "widgets/widgets/openvpn.widget.php" +
+ "?action=kill&port=" + mport + "&remipp=" + remipp,
+ { type: "get", complete: killComplete }
+ );
+ }
+
+ function killComplete(req) {
+ var values = req.responseText.split("|");
+ if (values[3] != "0") {
+ alert('<?=gettext("An error occurred.");?>' + ' (' + values[3] + ')');
+ return;
+ }
+
+ $('tr[name="r:' + values[1] + ":" + values[2] + '"]').each(
+ function(index,row) { $(row).fadeOut(1000); }
+ );
+ }
+
+ // Refresh the panel
+ function get_openvpn_update_<?=$widgetkey_nodash?>() {
+ var ajaxRequest;
+
+ ajaxRequest = $.ajax({
+ url: "/widgets/widgets/openvpn.widget.php",
+ type: "post",
+ data: { ajax: "ajax", widgetkey: "<?=$widgetkey?>"}
+ });
+
+ // Deal with the results of the above ajax call
+ ajaxRequest.done(function (response, textStatus, jqXHR) {
+ $('#<?=$widgetkey?>-openvpn-mainpanel').html(response);
+
+ // and do it again
+ setTimeout(get_openvpn_update_<?=$widgetkey_nodash?>, "<?=$widgetperiod?>");
+ });
+ }
+
+ events.push(function(){
+ set_widget_checkbox_events("#<?=$widget_panel_footer_id?> [id^=show]", "<?=$widget_showallnone_id?>");
+
+ // Start polling for updates some small random number of seconds from now (so that all the widgets don't
+ // hit the server at exactly the same time)
+ setTimeout(get_openvpn_update_<?=$widgetkey_nodash?>, Math.floor((Math.random() * 10000) + 1000));
+ });
+//]]>
+</script>
diff --git a/src/usr/local/www/widgets/widgets/picture.widget.php b/src/usr/local/www/widgets/widgets/picture.widget.php
index ae02f0f..41e9497 100644
--- a/src/usr/local/www/widgets/widgets/picture.widget.php
+++ b/src/usr/local/www/widgets/widgets/picture.widget.php
@@ -26,19 +26,19 @@ require_once("pfsense-utils.inc");
require_once("functions.inc");
if ($_GET['getpic']=="true") {
- $pic_type_s = explode(".", $user_settings['widgets']['picturewidget_filename']);
+ $pic_type_s = explode(".", $user_settings['widgets'][$_GET['widgetkey']]['picturewidget_filename']);
$pic_type = $pic_type_s[1];
- if ($user_settings['widgets']['picturewidget']) {
- $data = base64_decode($user_settings['widgets']['picturewidget']);
+ if ($user_settings['widgets'][$_GET['widgetkey']]['picturewidget']) {
+ $data = base64_decode($user_settings['widgets'][$_GET['widgetkey']]['picturewidget']);
}
- header("Content-Disposition: inline; filename=\"{$user_settings['widgets']['picturewidget_filename']}\"");
+ header("Content-Disposition: inline; filename=\"{$user_settings['widgets'][$_GET['widgetkey']]['picturewidget_filename']}\"");
header("Content-Type: image/{$pic_type}");
header("Content-Length: " . strlen($data));
echo $data;
exit;
}
-if ($_POST) {
+if ($_POST['widgetkey']) {
if (is_uploaded_file($_FILES['pictfile']['tmp_name'])) {
/* read the file contents */
$fd_pic = fopen($_FILES['pictfile']['tmp_name'], "rb");
@@ -52,8 +52,8 @@ if ($_POST) {
die("Could not read temporary file");
} else {
$picname = basename($_FILES['uploadedfile']['name']);
- $user_settings['widgets']['picturewidget'] = base64_encode($data);
- $user_settings['widgets']['picturewidget_filename'] = $_FILES['pictfile']['name'];
+ $user_settings['widgets'][$_POST['widgetkey']]['picturewidget'] = base64_encode($data);
+ $user_settings['widgets'][$_POST['widgetkey']]['picturewidget_filename'] = $_FILES['pictfile']['name'];
save_widget_settings($_SESSION['Username'], $user_settings["widgets"], gettext("Picture widget saved via Dashboard."));
header("Location: /index.php");
exit;
@@ -62,14 +62,15 @@ if ($_POST) {
}
?>
-<a href="/widgets/widgets/picture.widget.php?getpic=true" target="_blank">
- <img style="width:100%; height:100%" src="/widgets/widgets/picture.widget.php?getpic=true" alt="picture" />
+<a href="/widgets/widgets/picture.widget.php?getpic=true&widgetkey=<?=$widgetkey?>" target="_blank">
+ <img style="width:100%; height:100%" src="/widgets/widgets/picture.widget.php?getpic=true&widgetkey=<?=$widgetkey?>" alt="picture" />
</a>
<!-- close the body we're wrapped in and add a configuration-panel -->
-</div><div id="widget-<?=$widgetname?>_panel-footer" class="panel-footer collapse">
+</div><div id="<?=$widget_panel_footer_id?>" class="panel-footer collapse">
<form action="/widgets/widgets/picture.widget.php" method="post" enctype="multipart/form-data" class="form-inline">
+ <input type="hidden" name="widgetkey" value="<?=$widgetkey; ?>">
<label for="pictfile"><?=gettext('New picture:')?> </label>
<input id="pictfile" name="pictfile" type="file" class="form-control" />
<button type="submit" class="btn btn-primary btn-xs">
diff --git a/src/usr/local/www/widgets/widgets/rss.widget.php b/src/usr/local/www/widgets/widgets/rss.widget.php
index 9fdd254..7d5f0a7 100644
--- a/src/usr/local/www/widgets/widgets/rss.widget.php
+++ b/src/usr/local/www/widgets/widgets/rss.widget.php
@@ -25,36 +25,38 @@ require_once("guiconfig.inc");
require_once("pfsense-utils.inc");
require_once("functions.inc");
-if ($_POST['rssfeed']) {
- $user_settings['widgets']['rssfeed'] = str_replace("\n", ",", htmlspecialchars($_POST['rssfeed'], ENT_QUOTES | ENT_HTML401));
- $user_settings['widgets']['rssmaxitems'] = str_replace("\n", ",", htmlspecialchars($_POST['rssmaxitems'], ENT_QUOTES | ENT_HTML401));
- $user_settings['widgets']['rsswidgetheight'] = htmlspecialchars($_POST['rsswidgetheight'], ENT_QUOTES | ENT_HTML401);
- $user_settings['widgets']['rsswidgettextlength'] = htmlspecialchars($_POST['rsswidgettextlength'], ENT_QUOTES | ENT_HTML401);
+if ($_POST['widgetkey']) {
+ $user_settings['widgets'][$_POST['widgetkey']]['rssfeed'] = str_replace("\n", ",", htmlspecialchars($_POST['rssfeed'], ENT_QUOTES | ENT_HTML401));
+ $user_settings['widgets'][$_POST['widgetkey']]['rssmaxitems'] = str_replace("\n", ",", htmlspecialchars($_POST['rssmaxitems'], ENT_QUOTES | ENT_HTML401));
+ $user_settings['widgets'][$_POST['widgetkey']]['rsswidgetheight'] = htmlspecialchars($_POST['rsswidgetheight'], ENT_QUOTES | ENT_HTML401);
+ $user_settings['widgets'][$_POST['widgetkey']]['rsswidgettextlength'] = htmlspecialchars($_POST['rsswidgettextlength'], ENT_QUOTES | ENT_HTML401);
save_widget_settings($_SESSION['Username'], $user_settings["widgets"], gettext("Saved RSS Widget feed via Dashboard."));
header("Location: /");
}
// Use saved feed and max items
-if ($user_settings['widgets']['rssfeed']) {
- $rss_feed_s = explode(",", $user_settings['widgets']['rssfeed']);
+if ($user_settings['widgets'][$widgetkey]['rssfeed']) {
+ $rss_feed_s = explode(",", $user_settings['widgets'][$widgetkey]['rssfeed']);
}
-if ($user_settings['widgets']['rssmaxitems']) {
- $max_items = $user_settings['widgets']['rssmaxitems'];
+if ($user_settings['widgets'][$widgetkey]['rssmaxitems']) {
+ $max_items = $user_settings['widgets'][$widgetkey]['rssmaxitems'];
}
-if (is_numeric($user_settings['widgets']['rsswidgetheight'])) {
- $rsswidgetheight = $user_settings['widgets']['rsswidgetheight'];
+if (is_numeric($user_settings['widgets'][$widgetkey]['rsswidgetheight'])) {
+ $rsswidgetheight = $user_settings['widgets'][$widgetkey]['rsswidgetheight'];
}
-if (is_numeric($user_settings['widgets']['rsswidgettextlength'])) {
- $rsswidgettextlength = $user_settings['widgets']['rsswidgettextlength'];
+if (is_numeric($user_settings['widgets'][$widgetkey]['rsswidgettextlength'])) {
+ $rsswidgettextlength = $user_settings['widgets'][$widgetkey]['rsswidgettextlength'];
}
// Set a default feed if none exists
if (!$rss_feed_s) {
$rss_feed_s = "https://www.netgate.com/blog/";
- $user_settings['widgets']['rssfeed'] = "https://www.netgate.com/blog/";
+ if ($widgetkey != "") {
+ $user_settings['widgets'][$widgetkey]['rssfeed'] = $rss_feed_s;
+ }
}
if (!$max_items || !is_numeric($max_items)) {
@@ -69,8 +71,8 @@ if (!$rsswidgettextlength || !is_numeric($rsswidgettextlength)) {
$rsswidgettextlength = 140; // oh twitter, how do we love thee?
}
-if ($user_settings['widgets']['rssfeed']) {
- $textarea_txt = str_replace(",", "\n", $user_settings['widgets']['rssfeed']);
+if ($user_settings['widgets'][$widgetkey]['rssfeed']) {
+ $textarea_txt = str_replace(",", "\n", $user_settings['widgets'][$widgetkey]['rssfeed']);
} else {
$textarea_txt = "";
}
@@ -85,11 +87,13 @@ if ($user_settings['widgets']['rssfeed']) {
exec("chmod a+rw /tmp/simplepie/.");
exec("chmod a+rw /tmp/simplepie/cache/.");
require_once("simplepie/simplepie.inc");
- function textLimit($string, $length, $replacer = '...') {
- if (strlen($string) > $length) {
- return (preg_match('/^(.*)\W.*$/', substr($string, 0, $length+1), $matches) ? $matches[1] : substr($string, 0, $length)) . $replacer;
+ if (!function_exists('textLimit')) {
+ function textLimit($string, $length, $replacer = '...') {
+ if (strlen($string) > $length) {
+ return (preg_match('/^(.*)\W.*$/', substr($string, 0, $length+1), $matches) ? $matches[1] : substr($string, 0, $length)) . $replacer;
+ }
+ return $string;
}
- return $string;
}
$feed = new SimplePie();
$feed->set_cache_location("/tmp/simplepie/");
@@ -120,9 +124,10 @@ if ($user_settings['widgets']['rssfeed']) {
</div>
<!-- close the body we're wrapped in and add a configuration-panel -->
-</div><div id="widget-<?=$widgetname?>_panel-footer" class="panel-footer collapse">
+</div><div id="<?=$widget_panel_footer_id?>" class="panel-footer collapse">
<form action="/widgets/widgets/rss.widget.php" method="post" class="form-horizontal">
+ <input type="hidden" name="widgetkey" value="<?=$widgetkey; ?>">
<div class="form-group">
<label for="rssfeed" class="col-sm-3 control-label"><?=gettext('Feeds')?></label>
<div class="col-sm-6">
diff --git a/src/usr/local/www/widgets/widgets/services_status.widget.php b/src/usr/local/www/widgets/widgets/services_status.widget.php
index 4672b2e..62cfcf1 100644
--- a/src/usr/local/www/widgets/widgets/services_status.widget.php
+++ b/src/usr/local/www/widgets/widgets/services_status.widget.php
@@ -48,7 +48,7 @@ for ($idx=1; $idx < $numsvcs; $idx++) {
}
}
-if ($_POST) {
+if ($_POST['widgetkey']) {
$validNames = array();
@@ -57,9 +57,9 @@ if ($_POST) {
}
if (is_array($_POST['show'])) {
- $user_settings['widgets']['servicestatusfilter'] = implode(',', array_diff($validNames, $_POST['show']));
+ $user_settings['widgets'][$_POST['widgetkey']]['filter'] = implode(',', array_diff($validNames, $_POST['show']));
} else {
- $user_settings['widgets']['servicestatusfilter'] = "";
+ $user_settings['widgets'][$_POST['widgetkey']]['filter'] = implode(',', $validNames);
}
save_widget_settings($_SESSION['Username'], $user_settings["widgets"], gettext("Saved Service Status Filter via Dashboard."));
@@ -79,16 +79,19 @@ if ($_POST) {
</thead>
<tbody>
<?php
-$skipservices = explode(",", $user_settings['widgets']['servicestatusfilter']);
+$skipservices = explode(",", $user_settings['widgets'][$widgetkey]['filter']);
if (count($services) > 0) {
uasort($services, "service_dispname_compare");
+ $service_is_displayed = false;
foreach ($services as $service) {
if ((!$service['dispname']) || (in_array($service['dispname'], $skipservices)) || (!is_service_enabled($service['dispname']))) {
continue;
}
+ $service_is_displayed = true;
+
if (empty($service['description'])) {
$service['description'] = get_pkg_descr($service['name']);
}
@@ -103,19 +106,24 @@ if (count($services) > 0) {
</tr>
<?php
}
+
+ if (!$service_is_displayed) {
+ echo "<tr><td colspan=\"4\" class=\"text-center\">" . gettext("All services are hidden") . ". </td></tr>\n";
+ }
} else {
- echo "<tr><td colspan=\"3\" class=\"text-center\">" . gettext("No services found") . ". </td></tr>\n";
+ echo "<tr><td colspan=\"4\" class=\"text-center\">" . gettext("No services found") . ". </td></tr>\n";
}
?>
</tbody>
</table>
</div>
<!-- close the body we're wrapped in and add a configuration-panel -->
-</div><div id="widget-<?=$widgetname?>_panel-footer" class="panel-footer collapse">
+</div><div id="<?=$widget_panel_footer_id?>" class="panel-footer collapse">
<form action="/widgets/widgets/services_status.widget.php" method="post" class="form-horizontal">
<div class="panel panel-default col-sm-10">
<div class="panel-body">
+ <input type="hidden" name="widgetkey" value="<?=$widgetkey; ?>">
<div class="table responsive">
<table class="table table-striped table-hover table-condensed">
<thead>
@@ -126,7 +134,7 @@ if (count($services) > 0) {
</thead>
<tbody>
<?php
- $skipservices = explode(",", $user_settings['widgets']['servicestatusfilter']);
+ $skipservices = explode(",", $user_settings['widgets'][$widgetkey]['filter']);
$idx = 0;
foreach ($services as $service):
@@ -149,7 +157,7 @@ if (count($services) > 0) {
<div class="form-group">
<div class="col-sm-offset-3 col-sm-6">
<button type="submit" class="btn btn-primary"><i class="fa fa-save icon-embed-btn"></i><?=gettext('Save')?></button>
- <button id="showallservices" type="button" class="btn btn-info"><i class="fa fa-undo icon-embed-btn"></i><?=gettext('All')?></button>
+ <button id="<?=$widget_showallnone_id?>" type="button" class="btn btn-info"><i class="fa fa-undo icon-embed-btn"></i><?=gettext('All')?></button>
</div>
</div>
</form>
@@ -157,12 +165,7 @@ if (count($services) > 0) {
<script type="text/javascript">
//<![CDATA[
events.push(function(){
- $("#showallservices").click(function() {
- $("#widget-<?=$widgetname?>_panel-footer [id^=show]").each(function() {
- $(this).prop("checked", true);
- });
- });
-
+ set_widget_checkbox_events("#<?=$widget_panel_footer_id?> [id^=show]", "<?=$widget_showallnone_id?>");
});
//]]>
</script>
diff --git a/src/usr/local/www/widgets/widgets/smart_status.widget.php b/src/usr/local/www/widgets/widgets/smart_status.widget.php
index eae61c7..eec84b5 100644
--- a/src/usr/local/www/widgets/widgets/smart_status.widget.php
+++ b/src/usr/local/www/widgets/widgets/smart_status.widget.php
@@ -36,7 +36,7 @@ if ($specplatform['name'] != "Hyper-V") {
$devs = get_smart_drive_list();
}
-if ($_POST) {
+if ($_POST['widgetkey']) {
$validNames = array();
@@ -45,9 +45,9 @@ if ($_POST) {
}
if (is_array($_POST['show'])) {
- $user_settings['widgets']['smart_status']['filter'] = implode(',', array_diff($validNames, $_POST['show']));
+ $user_settings['widgets'][$_POST['widgetkey']]['filter'] = implode(',', array_diff($validNames, $_POST['show']));
} else {
- $user_settings['widgets']['smart_status']['filter'] = "";
+ $user_settings['widgets'][$_POST['widgetkey']]['filter'] = implode(',', $validNames);
}
save_widget_settings($_SESSION['Username'], $user_settings["widgets"], gettext("Saved SMART Status Filter via Dashboard."));
@@ -68,7 +68,8 @@ if ($_POST) {
</thead>
<tbody>
<?php
-$skipsmart = explode(",", $user_settings['widgets']['smart_status']['filter']);
+$skipsmart = explode(",", $user_settings['widgets'][$widgetkey]['filter']);
+$smartdrive_is_displayed = false;
if (count($devs) > 0) {
foreach ($devs as $dev) { ## for each found drive do
@@ -76,6 +77,7 @@ if (count($devs) > 0) {
continue;
}
+ $smartdrive_is_displayed = true;
$dev_ident = exec("diskinfo -v /dev/$dev | grep ident | awk '{print $1}'"); ## get identifier from drive
$dev_state = trim(exec("smartctl -H /dev/$dev | awk -F: '/^SMART overall-health self-assessment test result/ {print $2;exit}
/^SMART Health Status/ {print $2;exit}'")); ## get SMART state from drive
@@ -104,17 +106,28 @@ if (count($devs) > 0) {
</tr>
<?php
}
+
+ if (!$smartdrive_is_displayed) {
+?>
+ <tr>
+ <td colspan="4" class="text-center">
+ <?=gettext('All SMART drives are hidden.');?>
+ </td>
+ </tr>
+<?php
+ }
}
?>
</tbody>
</table>
</div>
<!-- close the body we're wrapped in and add a configuration-panel -->
-</div><div id="widget-<?=$widgetname?>_panel-footer" class="panel-footer collapse">
+</div><div id="<?=$widget_panel_footer_id?>" class="panel-footer collapse">
<form action="/widgets/widgets/smart_status.widget.php" method="post" class="form-horizontal">
<div class="panel panel-default col-sm-10">
<div class="panel-body">
+ <input type="hidden" name="widgetkey" value="<?=$widgetkey; ?>">
<div class="table responsive">
<table class="table table-striped table-hover table-condensed">
<thead>
@@ -143,19 +156,14 @@ if (count($devs) > 0) {
<div class="form-group">
<div class="col-sm-offset-3 col-sm-6">
<button type="submit" class="btn btn-primary"><i class="fa fa-save icon-embed-btn"></i><?=gettext('Save')?></button>
- <button id="showallsmartdrives" type="button" class="btn btn-info"><i class="fa fa-undo icon-embed-btn"></i><?=gettext('All')?></button>
+ <button id="<?=$widget_showallnone_id?>" type="button" class="btn btn-info"><i class="fa fa-undo icon-embed-btn"></i><?=gettext('All')?></button>
</div>
</div>
</form>
<script type="text/javascript">
//<![CDATA[
events.push(function(){
- $("#showallsmartdrives").click(function() {
- $("#widget-<?=$widgetname?>_panel-footer [id^=show]").each(function() {
- $(this).prop("checked", true);
- });
- });
-
+ set_widget_checkbox_events("#<?=$widget_panel_footer_id?> [id^=show]", "<?=$widget_showallnone_id?>");
});
//]]>
</script>
diff --git a/src/usr/local/www/widgets/widgets/system_information.widget.php b/src/usr/local/www/widgets/widgets/system_information.widget.php
index e55d611..789cef9 100644
--- a/src/usr/local/www/widgets/widgets/system_information.widget.php
+++ b/src/usr/local/www/widgets/widgets/system_information.widget.php
@@ -33,6 +33,7 @@ include_once("includes/functions.inc.php");
$sysinfo_items = array(
'name' => gettext('Name'),
'system' => gettext('System'),
+ 'bios' => gettext('BIOS'),
'version' => gettext('Version'),
'cpu_type' => gettext('CPU Type'),
'hwcrypto' => gettext('Hardware Crypto'),
@@ -96,7 +97,7 @@ if ($_REQUEST['getupdatestatus']) {
}
exit;
-} elseif ($_POST) {
+} elseif ($_POST['widgetkey']) {
$validNames = array();
@@ -105,9 +106,9 @@ if ($_REQUEST['getupdatestatus']) {
}
if (is_array($_POST['show'])) {
- $user_settings['widgets']['system_information']['filter'] = implode(',', array_diff($validNames, $_POST['show']));
+ $user_settings['widgets'][$_POST['widgetkey']]['filter'] = implode(',', array_diff($validNames, $_POST['show']));
} else {
- $user_settings['widgets']['system_information']['filter'] = "";
+ $user_settings['widgets'][$_POST['widgetkey']]['filter'] = implode(',', $validNames);
}
save_widget_settings($_SESSION['Username'], $user_settings["widgets"], gettext("Saved System Information Widget Filter via Dashboard."));
@@ -122,7 +123,8 @@ $widgetperiod += 1000;
$filesystems = get_mounted_filesystems();
-$skipsysinfoitems = explode(",", $user_settings['widgets']['system_information']['filter']);
+$skipsysinfoitems = explode(",", $user_settings['widgets'][$widgetkey]['filter']);
+$rows_displayed = false;
?>
<div class="table-responsive">
@@ -130,6 +132,7 @@ $skipsysinfoitems = explode(",", $user_settings['widgets']['system_information']
<tbody>
<?php
if (!in_array('name', $skipsysinfoitems)):
+ $rows_displayed = true;
?>
<tr>
<th><?=gettext("Name");?></th>
@@ -138,6 +141,7 @@ $skipsysinfoitems = explode(",", $user_settings['widgets']['system_information']
<?php
endif;
if (!in_array('system', $skipsysinfoitems)):
+ $rows_displayed = true;
?>
<tr>
<th><?=gettext("System");?></th>
@@ -156,7 +160,36 @@ $skipsysinfoitems = explode(",", $user_settings['widgets']['system_information']
</tr>
<?php
endif;
+ if (!in_array('bios', $skipsysinfoitems)):
+ $rows_displayed = true;
+ unset($biosvendor);
+ unset($biosversion);
+ unset($biosdate);
+ $_gb = exec('/bin/kenv -q smbios.bios.vendor 2>/dev/null', $biosvendor);
+ $_gb = exec('/bin/kenv -q smbios.bios.version 2>/dev/null', $biosversion);
+ $_gb = exec('/bin/kenv -q smbios.bios.reldate 2>/dev/null', $biosdate);
+ /* Only display BIOS information if there is any to show. */
+ if (!empty($biosvendor[0]) || !empty($biosversion[0]) || !empty($biosdate[0])):
+?>
+ <tr>
+ <th><?=gettext("BIOS");?></th>
+ <td>
+ <?php if (!empty($biosvendor[0])): ?>
+ <?=gettext("Vendor: ");?><strong><?=$biosvendor[0];?></strong><br/>
+ <?php endif; ?>
+ <?php if (!empty($biosversion[0])): ?>
+ <?=gettext("Version: ");?><strong><?=$biosversion[0];?></strong><br/>
+ <?php endif; ?>
+ <?php if (!empty($biosdate[0])): ?>
+ <?=gettext("Release Date: ");?><strong><?=$biosdate[0];?></strong><br/>
+ <?php endif; ?>
+ </td>
+ </tr>
+<?php
+ endif;
+ endif;
if (!in_array('version', $skipsysinfoitems)):
+ $rows_displayed = true;
?>
<tr>
<th><?=gettext("Version");?></th>
@@ -178,6 +211,7 @@ $skipsysinfoitems = explode(",", $user_settings['widgets']['system_information']
<?php
endif;
if (!in_array('cpu_type', $skipsysinfoitems)):
+ $rows_displayed = true;
?>
<tr>
<th><?=gettext("CPU Type");?></th>
@@ -195,6 +229,7 @@ $skipsysinfoitems = explode(",", $user_settings['widgets']['system_information']
<?php
endif;
if (!in_array('hwcrypto', $skipsysinfoitems)):
+ $rows_displayed = true;
?>
<?php if ($hwcrypto): ?>
<tr>
@@ -205,6 +240,7 @@ $skipsysinfoitems = explode(",", $user_settings['widgets']['system_information']
<?php
endif;
if (!in_array('uptime', $skipsysinfoitems)):
+ $rows_displayed = true;
?>
<tr>
<th><?=gettext("Uptime");?></th>
@@ -213,6 +249,7 @@ $skipsysinfoitems = explode(",", $user_settings['widgets']['system_information']
<?php
endif;
if (!in_array('current_datetime', $skipsysinfoitems)):
+ $rows_displayed = true;
?>
<tr>
<th><?=gettext("Current date/time");?></th>
@@ -221,6 +258,7 @@ $skipsysinfoitems = explode(",", $user_settings['widgets']['system_information']
<?php
endif;
if (!in_array('dns_servers', $skipsysinfoitems)):
+ $rows_displayed = true;
?>
<tr>
<th><?=gettext("DNS server(s)");?></th>
@@ -238,6 +276,7 @@ $skipsysinfoitems = explode(",", $user_settings['widgets']['system_information']
<?php
endif;
if (!in_array('last_config_change', $skipsysinfoitems)):
+ $rows_displayed = true;
?>
<?php if ($config['revision']): ?>
<tr>
@@ -248,6 +287,7 @@ $skipsysinfoitems = explode(",", $user_settings['widgets']['system_information']
<?php
endif;
if (!in_array('state_table_size', $skipsysinfoitems)):
+ $rows_displayed = true;
?>
<tr>
<th><?=gettext("State table size");?></th>
@@ -266,6 +306,7 @@ $skipsysinfoitems = explode(",", $user_settings['widgets']['system_information']
<?php
endif;
if (!in_array('mbuf_usage', $skipsysinfoitems)):
+ $rows_displayed = true;
?>
<tr>
<th><?=gettext("MBUF Usage");?></th>
@@ -284,6 +325,7 @@ $skipsysinfoitems = explode(",", $user_settings['widgets']['system_information']
<?php
endif;
if (!in_array('temperature', $skipsysinfoitems)):
+ $rows_displayed = true;
?>
<?php if (get_temp() != ""): ?>
<tr>
@@ -301,6 +343,7 @@ $skipsysinfoitems = explode(",", $user_settings['widgets']['system_information']
<?php
endif;
if (!in_array('load_average', $skipsysinfoitems)):
+ $rows_displayed = true;
?>
<tr>
<th><?=gettext("Load average");?></th>
@@ -311,6 +354,7 @@ $skipsysinfoitems = explode(",", $user_settings['widgets']['system_information']
<?php
endif;
if (!in_array('cpu_usage', $skipsysinfoitems)):
+ $rows_displayed = true;
?>
<tr>
<th><?=gettext("CPU usage");?></th>
@@ -326,6 +370,7 @@ $skipsysinfoitems = explode(",", $user_settings['widgets']['system_information']
<?php
endif;
if (!in_array('memory_usage', $skipsysinfoitems)):
+ $rows_displayed = true;
?>
<tr>
<th><?=gettext("Memory usage");?></th>
@@ -342,6 +387,7 @@ $skipsysinfoitems = explode(",", $user_settings['widgets']['system_information']
<?php
endif;
if (!in_array('swap_usage', $skipsysinfoitems)):
+ $rows_displayed = true;
?>
<?php if ($showswap == true): ?>
<tr>
@@ -360,6 +406,7 @@ $skipsysinfoitems = explode(",", $user_settings['widgets']['system_information']
<?php
endif;
if (!in_array('disk_usage', $skipsysinfoitems)):
+ $rows_displayed = true;
$diskidx = 0;
foreach ($filesystems as $fs):
?>
@@ -377,17 +424,27 @@ $skipsysinfoitems = explode(",", $user_settings['widgets']['system_information']
$diskidx++;
endforeach;
endif;
+ if (!$rows_displayed):
+?>
+ <tr>
+ <td class="text-center">
+ <?=gettext('All System Information items are hidden.');?>
+ </td>
+ </tr>
+<?php
+ endif;
?>
</tbody>
</table>
</div>
<!-- close the body we're wrapped in and add a configuration-panel -->
-</div><div id="widget-<?=$widgetname?>_panel-footer" class="panel-footer collapse">
+</div><div id="<?=$widget_panel_footer_id?>" class="panel-footer collapse">
<form action="/widgets/widgets/system_information.widget.php" method="post" class="form-horizontal">
<div class="panel panel-default col-sm-10">
<div class="panel-body">
+ <input type="hidden" name="widgetkey" value="<?=$widgetkey; ?>">
<div class="table responsive">
<table class="table table-striped table-hover table-condensed">
<thead>
@@ -416,13 +473,14 @@ $skipsysinfoitems = explode(",", $user_settings['widgets']['system_information']
<div class="form-group">
<div class="col-sm-offset-3 col-sm-6">
<button type="submit" class="btn btn-primary"><i class="fa fa-save icon-embed-btn"></i><?=gettext('Save')?></button>
- <button id="showallsysinfoitems" type="button" class="btn btn-info"><i class="fa fa-undo icon-embed-btn"></i><?=gettext('All')?></button>
+ <button id="<?=$widget_showallnone_id?>" type="button" class="btn btn-info"><i class="fa fa-undo icon-embed-btn"></i><?=gettext('All')?></button>
</div>
</div>
</form>
<script type="text/javascript">
//<![CDATA[
+<?php if ($widget_first_instance): ?>
<?php if (!isset($config['system']['firmware']['disablecheck'])): ?>
function systemStatusGetUpdateStatus() {
$.ajax({
@@ -435,7 +493,7 @@ function systemStatusGetUpdateStatus() {
},
dataType: 'html',
success: function(data){
- $('#widget-system_information #updatestatus').html(data);
+ $('[id^=widget-system_information] #updatestatus').html(data);
}
});
}
@@ -459,18 +517,10 @@ function updateMeters() {
}
-events.push(function(){
- $("#showallsysinfoitems").click(function() {
- $("#widget-<?=$widgetname?>_panel-footer [id^=show]").each(function() {
- $(this).prop("checked", true);
- });
- });
-});
-
var update_interval = "<?=$widgetperiod?>";
function setProgress(barName, percent) {
- $('#' + barName).css('width', percent + '%').attr('aria-valuenow', percent);
+ $('[id="' + barName + '"]').css('width', percent + '%').attr('aria-valuenow', percent);
}
function setTimer() {
@@ -503,7 +553,7 @@ function stats(x) {
function updateMemory(x) {
if ($('#memusagemeter')) {
- $("#memusagemeter").html(x);
+ $('[id="memusagemeter"]').html(x);
}
if ($('#memUsagePB')) {
setProgress('memUsagePB', parseInt(x));
@@ -512,13 +562,13 @@ function updateMemory(x) {
function updateMbuf(x) {
if ($('#mbuf')) {
- $("#mbuf").html('(' + x + ')');
+ $('[id="mbuf"]').html('(' + x + ')');
}
}
function updateMbufMeter(x) {
if ($('#mbufusagemeter')) {
- $("#mbufusagemeter").html(x + '%');
+ $('[id="mbufusagemeter"]').html(x + '%');
}
if ($('#mbufPB')) {
setProgress('mbufPB', parseInt(x));
@@ -528,7 +578,7 @@ function updateMbufMeter(x) {
function updateCPU(x) {
if ($('#cpumeter')) {
- $("#cpumeter").html(x + '%');
+ $('[id="cpumeter"]').html(x + '%');
}
if ($('#cpuPB')) {
setProgress('cpuPB', parseInt(x));
@@ -542,7 +592,7 @@ function updateCPU(x) {
function updateTemp(x) {
if ($("#tempmeter")) {
- $("#tempmeter").html(x + '&deg;' + 'C');
+ $('[id="tempmeter"]').html(x + '&deg;' + 'C');
}
if ($('#tempPB')) {
setProgress('tempPB', parseInt(x));
@@ -551,25 +601,25 @@ function updateTemp(x) {
function updateDateTime(x) {
if ($('#datetime')) {
- $("#datetime").html(x);
+ $('[id="datetime"]').html(x);
}
}
function updateUptime(x) {
if ($('#uptime')) {
- $("#uptime").html(x);
+ $('[id="uptime"]').html(x);
}
}
function updateState(x) {
if ($('#pfstate')) {
- $("#pfstate").html('(' + x + ')');
+ $('[id="pfstate"]').html('(' + x + ')');
}
}
function updateStateMeter(x) {
if ($('#pfstateusagemeter')) {
- $("#pfstateusagemeter").html(x + '%');
+ $('[id="pfstateusagemeter"]').html(x + '%');
}
if ($('#statePB')) {
setProgress('statePB', parseInt(x));
@@ -578,13 +628,13 @@ function updateStateMeter(x) {
function updateCpuFreq(x) {
if ($('#cpufreq')) {
- $("#cpufreq").html(x);
+ $('[id="cpufreq"]').html(x);
}
}
function updateLoadAverage(x) {
if ($('#load_average')) {
- $("#load_average").html(x);
+ $('[id="load_average"]').html(x);
}
}
@@ -594,7 +644,7 @@ function updateInterfaceStats(x) {
var counter = 1;
for (var y=0; y<statistics_split.length-1; y++) {
if ($('#stat' + counter)) {
- $('#stat' + counter).html(statistics_split[y]);
+ $('[id="stat' + counter + '"]').html(statistics_split[y]);
counter++;
}
}
@@ -613,25 +663,25 @@ function updateInterfaces(x) {
}
switch (details[1]) {
case "up":
- $('#' + details[0] + '-up').css("display","inline");
- $('#' + details[0] + '-down').css("display","none");
- $('#' + details[0] + '-block').css("display","none");
- $('#' + details[0] + '-ip').html(ipv4_details);
- $('#' + details[0] + '-ipv6').html(details[3]);
- $('#' + details[0] + '-media').html(details[4]);
+ $('[id="' + details[0] + '-up"]').css("display","inline");
+ $('[id="' + details[0] + '-down"]').css("display","none");
+ $('[id="' + details[0] + '-block"]').css("display","none");
+ $('[id="' + details[0] + '-ip"]').html(ipv4_details);
+ $('[id="' + details[0] + '-ipv6"]').html(details[3]);
+ $('[id="' + details[0] + '-media"]').html(details[4]);
break;
case "down":
- $('#' + details[0] + '-down').css("display","inline");
- $('#' + details[0] + '-up').css("display","none");
- $('#' + details[0] + '-block').css("display","none");
- $('#' + details[0] + '-ip').html(ipv4_details);
- $('#' + details[0] + '-ipv6').html(details[3]);
- $('#' + details[0] + '-media').html(details[4]);
+ $('[id="' + details[0] + '-down"]').css("display","inline");
+ $('[id="' + details[0] + '-up"]').css("display","none");
+ $('[id="' + details[0] + '-block"]').css("display","none");
+ $('[id="' + details[0] + '-ip"]').html(ipv4_details);
+ $('[id="' + details[0] + '-ipv6"]').html(details[3]);
+ $('[id="' + details[0] + '-media"]').html(details[4]);
break;
case "block":
- $('#' + details[0] + '-block').css("display","inline");
- $('#' + details[0] + '-down').css("display","none");
- $('#' + details[0] + '-up').css("display","none");
+ $('[id="' + details[0] + '-block"]').css("display","inline");
+ $('[id="' + details[0] + '-down"]').css("display","none");
+ $('[id="' + details[0] + '-up"]').css("display","none");
break;
}
});
@@ -651,5 +701,9 @@ function widgetActive(x) {
events.push(function(){
setTimer();
});
+<?php endif; // $widget_first_instance ?>
+events.push(function(){
+ set_widget_checkbox_events("#<?=$widget_panel_footer_id?> [id^=show]", "<?=$widget_showallnone_id?>");
+});
//]]>
</script>
diff --git a/src/usr/local/www/widgets/widgets/thermal_sensors.widget.php b/src/usr/local/www/widgets/widgets/thermal_sensors.widget.php
index e776e4e..2630993 100644
--- a/src/usr/local/www/widgets/widgets/thermal_sensors.widget.php
+++ b/src/usr/local/www/widgets/widgets/thermal_sensors.widget.php
@@ -33,7 +33,6 @@ if (isset($_GET["getThermalSensorsData"])) {
const WIDGETS_CONFIG_SECTION_KEY = "widgets";
-const THERMAL_SENSORS_WIDGET_SUBSECTION_KEY = "thermal_sensors_widget";
//default constants
const DEFAULT_WARNING_THRESHOLD = 60; //60 C
@@ -41,10 +40,71 @@ const DEFAULT_CRITICAL_THRESHOLD = 70; //70 C
const MIN_THRESHOLD_VALUE = 1; //deg C
const MAX_THRESHOLD_VALUE = 100; //deg C
+if (!function_exists('saveThresholdSettings')) {
+ function saveThresholdSettings(&$configArray, &$postArray, $warningValueKey, $criticalValueKey) {
+ $warningValue = 0;
+ $criticalValue = 0;
+
+ if (isset($postArray[$warningValueKey]) && is_numeric($postArray[$warningValueKey])) {
+ $warningValue = (int) $postArray[$warningValueKey];
+ }
+
+ if (isset($postArray[$criticalValueKey]) && is_numeric($postArray[$criticalValueKey])) {
+ $criticalValue = (int) $postArray[$criticalValueKey];
+ }
+
+ if (($warningValue >= MIN_THRESHOLD_VALUE && $warningValue <= MAX_THRESHOLD_VALUE) &&
+ ($criticalValue >= MIN_THRESHOLD_VALUE && $criticalValue <= MAX_THRESHOLD_VALUE) &&
+ ($warningValue < $criticalValue)) {
+ //all validated ok, save to config array
+ $configArray[WIDGETS_CONFIG_SECTION_KEY][$postArray['widgetkey']][$warningValueKey] = $warningValue;
+ $configArray[WIDGETS_CONFIG_SECTION_KEY][$postArray['widgetkey']][$criticalValueKey] = $criticalValue;
+ }
+ }
+}
+
+if (!function_exists('saveGraphDisplaySettings')) {
+ function saveGraphDisplaySettings(&$configArray, &$postArray, $valueKey) {
+ $configArray[WIDGETS_CONFIG_SECTION_KEY][$postArray['widgetkey']][$valueKey] = isset($postArray[$valueKey]) ? 1 : 0;
+ }
+}
+
+if (!function_exists('getThresholdValueFromConfig')) {
+ function getThresholdValueFromConfig(&$configArray, $valueKey, $defaultValue, $widgetKey) {
+
+ $thresholdValue = $defaultValue;
+
+ if (isset($configArray[WIDGETS_CONFIG_SECTION_KEY][$widgetKey][$valueKey])) {
+ $thresholdValue = (int) $configArray[WIDGETS_CONFIG_SECTION_KEY][$widgetKey][$valueKey];
+ }
+
+ if ($thresholdValue < MIN_THRESHOLD_VALUE || $thresholdValue > MAX_THRESHOLD_VALUE) {
+ //set to default if not in allowed range
+ $thresholdValue = $defaultValue;
+ }
+ return $thresholdValue;
+ }
+}
+
+if (!function_exists('getBoolValueFromConfig')) {
+ function getBoolValueFromConfig(&$configArray, $valueKey, $defaultValue, $widgetKey) {
+
+ $boolValue = false;
+
+ if (isset($configArray[WIDGETS_CONFIG_SECTION_KEY][$widgetKey][$valueKey])) {
+ $boolValue = (bool) $configArray[WIDGETS_CONFIG_SECTION_KEY][$widgetKey][$valueKey];
+ } else {
+ //set to default if not in allowed range
+ $boolValue = $defaultValue;
+ }
+ return $boolValue;
+ }
+}
+
//NOTE: keys used in $_POST and $config and $user_settings should match text and checkbox inputs' IDs/names in HTML code section
//=========================================================================
//save widget config settings on POST
-if ($_POST) {
+if ($_POST['widgetkey']) {
saveThresholdSettings($user_settings, $_POST, "thermal_sensors_widget_zone_warning_threshold", "thermal_sensors_widget_zone_critical_threshold");
saveThresholdSettings($user_settings, $_POST, "thermal_sensors_widget_core_warning_threshold", "thermal_sensors_widget_core_critical_threshold");
@@ -59,106 +119,55 @@ if ($_POST) {
header("Location: ../../index.php");
}
-function saveThresholdSettings(&$configArray, &$postArray, $warningValueKey, $criticalValueKey) {
- $warningValue = 0;
- $criticalValue = 0;
-
- if (isset($postArray[$warningValueKey]) && is_numeric($postArray[$warningValueKey])) {
- $warningValue = (int) $postArray[$warningValueKey];
- }
-
- if (isset($postArray[$criticalValueKey]) && is_numeric($postArray[$criticalValueKey])) {
- $criticalValue = (int) $postArray[$criticalValueKey];
- }
-
- if (($warningValue >= MIN_THRESHOLD_VALUE && $warningValue <= MAX_THRESHOLD_VALUE) &&
- ($criticalValue >= MIN_THRESHOLD_VALUE && $criticalValue <= MAX_THRESHOLD_VALUE) &&
- ($warningValue < $criticalValue)) {
- //all validated ok, save to config array
- $configArray[WIDGETS_CONFIG_SECTION_KEY][THERMAL_SENSORS_WIDGET_SUBSECTION_KEY][$warningValueKey] = $warningValue;
- $configArray[WIDGETS_CONFIG_SECTION_KEY][THERMAL_SENSORS_WIDGET_SUBSECTION_KEY][$criticalValueKey] = $criticalValue;
- }
-}
-
-function saveGraphDisplaySettings(&$configArray, &$postArray, $valueKey) {
- $configArray[WIDGETS_CONFIG_SECTION_KEY][THERMAL_SENSORS_WIDGET_SUBSECTION_KEY][$valueKey] = isset($postArray[$valueKey]) ? 1 : 0;
-}
+$widgetkey_nodash = str_replace("-", "", $widgetkey);
//=========================================================================
//get Threshold settings from config (apply defaults if missing)
-$thermal_sensors_widget_zoneWarningTempThreshold = getThresholdValueFromConfig($user_settings, "thermal_sensors_widget_zone_warning_threshold", DEFAULT_WARNING_THRESHOLD);
-$thermal_sensors_widget_zoneCriticalTempThreshold = getThresholdValueFromConfig($user_settings, "thermal_sensors_widget_zone_critical_threshold", DEFAULT_CRITICAL_THRESHOLD);
-$thermal_sensors_widget_coreWarningTempThreshold = getThresholdValueFromConfig($user_settings, "thermal_sensors_widget_core_warning_threshold", DEFAULT_WARNING_THRESHOLD);
-$thermal_sensors_widget_coreCriticalTempThreshold = getThresholdValueFromConfig($user_settings, "thermal_sensors_widget_core_critical_threshold", DEFAULT_CRITICAL_THRESHOLD);
+$thermal_sensors_widget_zoneWarningTempThreshold = getThresholdValueFromConfig($user_settings, "thermal_sensors_widget_zone_warning_threshold", DEFAULT_WARNING_THRESHOLD, $widgetkey);
+$thermal_sensors_widget_zoneCriticalTempThreshold = getThresholdValueFromConfig($user_settings, "thermal_sensors_widget_zone_critical_threshold", DEFAULT_CRITICAL_THRESHOLD, $widgetkey);
+$thermal_sensors_widget_coreWarningTempThreshold = getThresholdValueFromConfig($user_settings, "thermal_sensors_widget_core_warning_threshold", DEFAULT_WARNING_THRESHOLD, $widgetkey);
+$thermal_sensors_widget_coreCriticalTempThreshold = getThresholdValueFromConfig($user_settings, "thermal_sensors_widget_core_critical_threshold", DEFAULT_CRITICAL_THRESHOLD, $widgetkey);
//get display settings from config (apply defaults if missing)
-$thermal_sensors_widget_showRawOutput = getBoolValueFromConfig($user_settings, "thermal_sensors_widget_show_raw_output", false);
-$thermal_sensors_widget_showFullSensorName = getBoolValueFromConfig($user_settings, "thermal_sensors_widget_show_full_sensor_name", false);
-$thermal_sensors_widget_pulsateWarning = getBoolValueFromConfig($user_settings, "thermal_sensors_widget_pulsate_warning", true);
-$thermal_sensors_widget_pulsateCritical = getBoolValueFromConfig($user_settings, "thermal_sensors_widget_pulsate_critical", true);
-
-function getThresholdValueFromConfig(&$configArray, $valueKey, $defaultValue) {
-
- $thresholdValue = $defaultValue;
-
- if (isset($configArray[WIDGETS_CONFIG_SECTION_KEY][THERMAL_SENSORS_WIDGET_SUBSECTION_KEY][$valueKey])) {
- $thresholdValue = (int) $configArray[WIDGETS_CONFIG_SECTION_KEY][THERMAL_SENSORS_WIDGET_SUBSECTION_KEY][$valueKey];
- }
-
- if ($thresholdValue < MIN_THRESHOLD_VALUE || $thresholdValue > MAX_THRESHOLD_VALUE) {
- //set to default if not in allowed range
- $thresholdValue = $defaultValue;
- }
- return $thresholdValue;
-}
-
-function getBoolValueFromConfig(&$configArray, $valueKey, $defaultValue) {
-
- $boolValue = false;
-
- if (isset($configArray[WIDGETS_CONFIG_SECTION_KEY][THERMAL_SENSORS_WIDGET_SUBSECTION_KEY][$valueKey])) {
- $boolValue = (bool) $configArray[WIDGETS_CONFIG_SECTION_KEY][THERMAL_SENSORS_WIDGET_SUBSECTION_KEY][$valueKey];
- } else {
- //set to default if not in allowed range
- $boolValue = $defaultValue;
- }
- return $boolValue;
-}
+$thermal_sensors_widget_showRawOutput = getBoolValueFromConfig($user_settings, "thermal_sensors_widget_show_raw_output", false, $widgetkey);
+$thermal_sensors_widget_showFullSensorName = getBoolValueFromConfig($user_settings, "thermal_sensors_widget_show_full_sensor_name", false, $widgetkey);
+$thermal_sensors_widget_pulsateWarning = getBoolValueFromConfig($user_settings, "thermal_sensors_widget_pulsate_warning", true, $widgetkey);
+$thermal_sensors_widget_pulsateCritical = getBoolValueFromConfig($user_settings, "thermal_sensors_widget_pulsate_critical", true, $widgetkey);
//=========================================================================
?>
<script type="text/javascript">
//<![CDATA[
- //set Thresholds, to be used in thermal_sensors.js
- var thermal_sensors_widget_zoneWarningTempThreshold = <?= $thermal_sensors_widget_zoneWarningTempThreshold; ?>;
- var thermal_sensors_widget_zoneCriticalTempThreshold = <?= $thermal_sensors_widget_zoneCriticalTempThreshold; ?>;
- var thermal_sensors_widget_coreWarningTempThreshold = <?= $thermal_sensors_widget_coreWarningTempThreshold; ?>;
- var thermal_sensors_widget_coreCriticalTempThreshold = <?= $thermal_sensors_widget_coreCriticalTempThreshold; ?>;
-
- //set Graph display settings, to be used in thermal_sensors.js
- var thermal_sensors_widget_showRawOutput = <?= $thermal_sensors_widget_showRawOutput ? "true" : "false"; ?>;
- var thermal_sensors_widget_showFullSensorName = <?= $thermal_sensors_widget_showFullSensorName ? "true" : "false"; ?>;
- var thermal_sensors_widget_pulsateWarning = <?= $thermal_sensors_widget_pulsateWarning ? "true" : "false"; ?>;
- var thermal_sensors_widget_pulsateCritical = <?= $thermal_sensors_widget_pulsateCritical ? "true" : "false"; ?>;
-
//start showing temp data
//NOTE: the refresh interval will be reset to a proper value in showThermalSensorsData() (thermal_sensors.js).
events.push(function(){
- showThermalSensorsData();
+ var tsParams = {
+ zoneWarningTempThreshold:<?= $thermal_sensors_widget_zoneWarningTempThreshold; ?>,
+ zoneCriticalTempThreshold:<?= $thermal_sensors_widget_zoneCriticalTempThreshold; ?>,
+ coreWarningTempThreshold:<?= $thermal_sensors_widget_coreWarningTempThreshold; ?>,
+ coreCriticalTempThreshold:<?= $thermal_sensors_widget_coreCriticalTempThreshold; ?>,
+ showRawOutput:<?= $thermal_sensors_widget_showRawOutput ? "true" : "false"; ?>,
+ showFullSensorName:<?= $thermal_sensors_widget_showFullSensorName ? "true" : "false"; ?>,
+ pulsateWarning:<?= $thermal_sensors_widget_pulsateWarning ? "true" : "false"; ?>,
+ pulsateCritical:<?= $thermal_sensors_widget_pulsateCritical ? "true" : "false"; ?>
+ };
+ // showThermalSensorsData("<?=$widgetkey?>", true);
+ setTimeout(function(){showThermalSensorsData("<?=$widgetkey?>", tsParams, true);}, Math.floor((Math.random() * 10000) + 1000));
});
//]]>
</script>
<div style="padding: 5px">
- <div id="thermalSensorsContainer" class="listr">
+ <div id="thermalSensorsContainer-<?=$widgetkey?>" class="listr">
<?=gettext('(Updating...)')?><br /><br />
</div>
</div>
</div>
<input type="hidden" id="thermal_sensors-config" name="thermal_sensors-config" value="" />
-<div id="widget-<?=$widgetname?>_panel-footer" class="widgetconfigdiv panel-footer collapse" >
+<div id="<?=$widget_panel_footer_id?>" class="widgetconfigdiv panel-footer collapse" >
<form action="/widgets/widgets/thermal_sensors.widget.php" method="post" id="iform_thermal_sensors_settings" name="iform_thermal_sensors_settings">
+ <input type="hidden" name="widgetkey" value="<?=$widgetkey; ?>">
<table>
<tr>
<td class="text-left" colspan="2">
diff --git a/src/usr/local/www/widgets/widgets/traffic_graphs.widget.php b/src/usr/local/www/widgets/widgets/traffic_graphs.widget.php
index ebe2180..579bc32 100644
--- a/src/usr/local/www/widgets/widgets/traffic_graphs.widget.php
+++ b/src/usr/local/www/widgets/widgets/traffic_graphs.widget.php
@@ -26,16 +26,6 @@
* limitations under the License.
*/
-/* TODOs */
-//re-use on Status > traffic graphs
-//figure out why there is a missing datapoint at the start
-//name things/variables better
-//apply css change to Status > Monitoring
-//show interface name and latest in/out in upper left
-//add stacked overall graph?
- //also show pie graph of lastest precentages of total? (split 50/50 on width)
- //make this an option?
-
$nocsrf = true;
require_once("guiconfig.inc");
@@ -49,98 +39,72 @@ if (ipsec_enabled()) {
$ifdescrs['enc0'] = "IPsec";
}
-//there are no traffic graph widget defaults in config yet. so set them, but don't write the config
-if (!is_array($config["widgets"]["trafficgraphs"])) {
-
- $config["widgets"]["trafficgraphs"] = array();
- $config["widgets"]["trafficgraphs"]["refreshinterval"] = 1;
- $config["widgets"]["trafficgraphs"]["invert"] = "true";
- $config["widgets"]["trafficgraphs"]["size"] = 1;
- $config["widgets"]["trafficgraphs"]["backgroundupdate"] = "false";
- $config["widgets"]["trafficgraphs"]["shown"] = array();
- $config["widgets"]["trafficgraphs"]["shown"]["item"] = array();
-
- foreach($ifdescrs as $ifname => $ifdescr) {
-
- $ifinfo = get_interface_info($ifname);
-
- if ($ifinfo['status'] != "down") {
- $config["widgets"]["trafficgraphs"]["shown"]["item"][] = $ifname;
- }
+if ($_POST) {
+ if (!is_array($user_settings["widgets"]["traffic_graphs"])) {
+ $user_settings["widgets"]["traffic_graphs"] = array();
}
- //TODO silently write to config? (use a config message about saving defaults)
-
-}
-
-if(!isset($config["widgets"]["trafficgraphs"]["size"])) {
- $config["widgets"]["trafficgraphs"]["size"] = 1;
-}
-
-if(!isset($config["widgets"]["trafficgraphs"]["invert"])) {
- $config["widgets"]["trafficgraphs"]["invert"] = "true";
-}
-
-if(!isset($config["widgets"]["trafficgraphs"]["backgroundupdate"])) {
- $config["widgets"]["trafficgraphs"]["backgroundupdate"] = "true";
-}
-$a_config = &$config["widgets"]["trafficgraphs"];
-
-// save new default config options that have been submitted
-if ($_POST) {
-
- //TODO validate data and throw error
- $a_config["shown"]["item"] = $_POST["traffic-graph-interfaces"];
+ if (isset($_POST["refreshinterval"])) {
+ $user_settings["widgets"]["traffic_graphs"]["refreshinterval"] = $_POST["refreshinterval"];
+ }
- // TODO check if between 1 and 10
- if (isset($_POST["traffic-graph-interval"]) && is_numericint($_POST["traffic-graph-interval"])) {
- $a_config["refreshinterval"] = $_POST["traffic-graph-interval"];
- } else {
- die('{ "error" : "Refresh Interval is not a valid number between 1 and 10." }');
+ if (isset($_POST["invert"])) {
+ $user_settings["widgets"]["traffic_graphs"]["invert"] = $_POST["invert"];
}
- if($_POST["traffic-graph-invert"] === "true" || $_POST["traffic-graph-invert"] === "false") {
- $a_config["invert"] = $_POST["traffic-graph-invert"];
- } else {
- die('{ "error" : "Invert is not a boolean of true or false." }');
+ if (isset($_POST["backgroundupdate"])) {
+ $user_settings["widgets"]["traffic_graphs"]["backgroundupdate"] = $_POST["backgroundupdate"];
}
- if($_POST["traffic-graph-backgroundupdate"] === "true" || $_POST["traffic-graph-backgroundupdate"] === "false") {
- $a_config["backgroundupdate"] = $_POST["traffic-graph-backgroundupdate"];
- } else {
- die('{ "error" : "Backgroundupdate is not a boolean of true or false." }');
+ if (isset($_POST["size"])) {
+ $user_settings["widgets"]["traffic_graphs"]["size"] = $_POST["size"];
}
-
- //TODO validate data and throw error
- $a_config["size"] = $_POST["traffic-graph-size"];
- write_config(gettext("Updated traffic graph settings via dashboard."));
+ $validNames = array();
- header('Content-Type: application/json');
+ foreach ($ifdescrs as $ifdescr => $ifname) {
+ array_push($validNames, $ifdescr);
+ }
- die('{ "success" : "The changes have been applied successfully." }');
+ if (is_array($_POST['show'])) {
+ $user_settings["widgets"]["traffic_graphs"]["filter"] = implode(',', array_diff($validNames, $_POST['show']));
+ } else {
+ $user_settings["widgets"]["traffic_graphs"]["filter"] = implode(',', $validNames);
+ }
+ save_widget_settings($_SESSION['Username'], $user_settings["widgets"], gettext("Updated traffic graphs widget settings via dashboard."));
+ header("Location: /");
+ exit(0);
}
-$refreshinterval = $a_config["refreshinterval"];
-
-$ifsarray = [];
-
-foreach ($a_config["shown"]["item"] as $ifname) {
-
- $ifinfo = get_interface_info($ifname);
+if (isset($user_settings['widgets']['traffic_graphs']['refreshinterval'])) {
+ $tg_refreshinterval = $user_settings['widgets']['traffic_graphs']['refreshinterval'];
+} else {
+ $tg_refreshinterval = 1;
+}
- if ($ifinfo['status'] != "down") {
- $ifsarray[] = $ifname;
- } else {
- //TODO throw error?
- }
+if (isset($user_settings['widgets']['traffic_graphs']['size'])) {
+ $tg_size = $user_settings['widgets']['traffic_graphs']['size'];
+} else {
+ $tg_size = 1;
+}
+if (isset($user_settings['widgets']['traffic_graphs']['invert'])) {
+ $tg_invert = $user_settings['widgets']['traffic_graphs']['invert'];
+} else {
+ $tg_invert = 'true';
}
-$allifs = implode("|", $ifsarray);
+if (isset($user_settings['widgets']['traffic_graphs']['backgroundupdate'])) {
+ $tg_backgroundupdate = $user_settings['widgets']['traffic_graphs']['backgroundupdate'];
+} else {
+ $tg_backgroundupdate = 'true';
+}
+$skip_tg_items = explode(",", $user_settings['widgets']['traffic_graphs']['filter']);
+$tg_displayed = false;
+$tg_displayed_ifs_array = [];
?>
<script src="/vendor/d3/d3.min.js"></script>
<script src="/vendor/nvd3/nv.d3.js"></script>
@@ -149,17 +113,138 @@ $allifs = implode("|", $ifsarray);
<link href="/vendor/nvd3/nv.d3.css" media="screen, projection" rel="stylesheet" type="text/css">
<div id="traffic-chart-error" class="alert alert-danger" style="display: none;"></div>
+<?php
+ foreach ($ifdescrs as $ifdescr => $ifname) {
+ if (in_array($ifdescr, $skip_tg_items)) {
+ continue;
+ }
- <?php
- foreach($a_config["shown"]["item"] as $ifname) {
- echo '<div id="traffic-chart-' . $ifname . '" class="d3-chart traffic-widget-chart">';
+ $ifinfo = get_interface_info($ifdescr);
+
+ if ($ifinfo['status'] == "down") {
+ // Do not try to display the traffic graph of a down interface,
+ // even though it is selected for display.
+ continue;
+ }
+
+ $tg_displayed = true;
+ $tg_displayed_ifs_array[] = $ifdescr;
+ echo '<div id="traffic-chart-' . $ifdescr . '" class="d3-chart traffic-widget-chart">';
echo ' <svg></svg>';
echo '</div>';
}
+
+ if (!$tg_displayed) {
+ echo '<div id="traffic-chartnone" class="d3-chart traffic-widget-chart">';
+ echo gettext('All traffic graphs are hidden.');
+ echo '</div>';
+ }
+?>
+
+<!-- close the body we're wrapped in and add a configuration-panel -->
+</div>
+
+<div id="widget-<?=$widgetname?>_panel-footer" class="panel-footer collapse">
+
+ <form action="/widgets/widgets/traffic_graphs.widget.php" method="post" class="form-horizontal">
+ <div class="form-group">
+ <label for="traffic-graph-interval" class="col-sm-3 control-label"><?=gettext('Refresh Interval')?></label>
+ <div class="col-sm-9">
+ <input type="number" id="refreshinterval" name="refreshinterval" value="<?=$tg_refreshinterval?>" min="1" max="10" class="form-control" />
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label for="invert" class="col-sm-3 control-label"><?=gettext('Inverse')?></label>
+ <div class="col-sm-9">
+ <select class="form-control" id="invert" name="invert">
+ <?php
+ if ($tg_invert === "true") {
+ echo '<option value="true" selected>On</option>';
+ echo '<option value="false">Off</option>';
+ } else {
+ echo '<option value="true">On</option>';
+ echo '<option value="false" selected>Off</option>';
+ }
+ ?>
+ </select>
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label for="size" class="col-sm-3 control-label"><?=gettext('Unit Size')?></label>
+ <div class="col-sm-9">
+ <select class="form-control" id="size" name="size">
+ <?php
+ if ($tg_size === "8") {
+ echo '<option value="8" selected>Bits</option>';
+ echo '<option value="1">Bytes</option>';
+ } else {
+ echo '<option value="8">Bits</option>';
+ echo '<option value="1" selected>Bytes</option>';
+ }
+ ?>
+ </select>
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label for="backgroundupdate" class="col-sm-3 control-label"><?=gettext('Background updates')?></label>
+ <div class="col-sm-9">
+ <select class="form-control" id="backgroundupdate" name="backgroundupdate">
+ <?php
+ if ($tg_backgroundupdate === "true") {
+ echo '<option value="true" selected>Keep graphs updated on inactive tab. (increases cpu usage)</option>';
+ echo '<option value="false">Clear graphs when not visible.</option>';
+ } else {
+ echo '<option value="true">Keep graphs updated on inactive tab. (increases cpu usage)</option>';
+ echo '<option value="false" selected>Clear graphs when not visible.</option>';
+ }
+ ?>
+ </select>
+ </div>
+ </div>
+
+ <div class="panel panel-default col-sm-10">
+ <div class="panel-body">
+ <div class="table responsive">
+ <table class="table table-striped table-hover table-condensed">
+ <thead>
+ <tr>
+ <th><?=gettext("Interface")?></th>
+ <th><?=gettext("Show")?></th>
+ </tr>
+ </thead>
+ <tbody>
+ <?php
+ $idx = 0;
+
+ foreach ($ifdescrs as $ifdescr => $ifname):
+ ?>
+ <tr>
+ <td><?=$ifname?></td>
+ <td class="col-sm-2"><input id="show[]" name ="show[]" value="<?=$ifdescr?>" type="checkbox" <?=(!in_array($ifdescr, $skip_tg_items) ? 'checked':'')?>></td>
+ </tr>
+ <?php
+ endforeach;
?>
+ </tbody>
+ </table>
+ </div>
+ </div>
+ </div>
+
+ <div class="form-group">
+ <div class="col-sm-offset-3 col-sm-6">
+ <button type="submit" class="btn btn-primary"><i class="fa fa-save icon-embed-btn"></i><?=gettext('Save')?></button>
+ <button id="showalltgitems" type="button" class="btn btn-info"><i class="fa fa-undo icon-embed-btn"></i><?=gettext('All')?></button>
+ </div>
+ </div>
+ </form>
- <script type="text/javascript">
+<script type="text/javascript">
//<![CDATA[
+// Used by /js/traffic-graphs.js to display description from name
var graph_interfacenames = <?php
foreach ($ifdescrs as $ifname => $ifdescr) {
$iflist[$ifname] = $ifdescr;
@@ -169,16 +254,16 @@ var graph_interfacenames = <?php
events.push(function() {
- var InterfaceString = "<?=$allifs?>";
+ var InterfaceString = "<?=implode("|", $tg_displayed_ifs_array)?>";
//store saved settings in a fresh localstorage
localStorage.clear();
- localStorage.setItem('interval', <?=$refreshinterval?>);
- localStorage.setItem('invert', <?=$a_config["invert"]?>);
- localStorage.setItem('size', <?=$a_config["size"]?>);
- localStorage.setItem('backgroundupdate', <?=$a_config["backgroundupdate"]?>);
+ localStorage.setItem('interval', <?=$tg_refreshinterval?>);
+ localStorage.setItem('invert', <?=$tg_invert?>);
+ localStorage.setItem('size', <?=$tg_size?>);
+ localStorage.setItem('backgroundupdate', <?=$tg_backgroundupdate?>);
- window.interfaces = InterfaceString.split("|");
+ window.interfaces = InterfaceString.split("|").filter(function(entry) { return entry.trim() != ''; });
window.charts = {};
window.myData = {};
window.updateIds = 0;
@@ -203,27 +288,29 @@ events.push(function() {
var itemOut = new Object();
itemIn.key = value + " (in)";
- if(localStorage.getItem('invert') === "true") { itemIn.area = true; }
+ if (localStorage.getItem('invert') === "true") { itemIn.area = true; }
itemIn.first = true;
itemIn.values = [{x: nowTime, y: 0}];
myData[value].push(itemIn);
itemOut.key = value + " (out)";
- if(localStorage.getItem('invert') === "true") { itemOut.area = true; }
+ if (localStorage.getItem('invert') === "true") { itemOut.area = true; }
itemOut.first = true;
itemOut.values = [{x: nowTime, y: 0}];
myData[value].push(itemOut);
});
- draw_graph(refreshInterval, then, backgroundupdate);
+ if (window.interfaces.length > 0) {
+ draw_graph(refreshInterval, then, backgroundupdate);
+ }
//re-draw graph when the page goes from inactive (in it's window) to active
Visibility.change(function (e, state) {
- if($('#traffic-graph-backgroundupdate').val() === "true"){
+ if (backgroundupdate) {
return;
}
- if(state === "visible") {
+ if (state === "visible") {
now = then = new Date(Date.now());
@@ -240,242 +327,29 @@ events.push(function() {
var itemOut = new Object();
itemIn.key = value + " (in)";
- if(localStorage.getItem('invert') === "true") { itemIn.area = true; }
+ if (localStorage.getItem('invert') === "true") { itemIn.area = true; }
itemIn.first = true;
itemIn.values = [{x: nowTime, y: 0}];
myData[value].push(itemIn);
itemOut.key = value + " (out)";
- if(localStorage.getItem('invert') === "true") { itemOut.area = true; }
+ if (localStorage.getItem('invert') === "true") { itemOut.area = true; }
itemOut.first = true;
itemOut.values = [{x: nowTime, y: 0}];
myData[value].push(itemOut);
});
- draw_graph(refreshInterval, then, backgroundupdate);
+ if (window.interfaces.length > 0) {
+ draw_graph(refreshInterval, then, backgroundupdate);
+ }
}
});
- // save new config defaults
- $( '#traffic-graph-form' ).submit(function(event) {
-
- var error = false;
- $("#traffic-chart-error").hide();
-
- var interfaces = $( "#traffic-graph-interfaces" ).val();
- refreshInterval = parseInt($( "#traffic-graph-interval" ).val());
- var invert = $( "#traffic-graph-invert" ).val();
- var size = $( "#traffic-graph-size" ).val();
- var backgroundupdate = $( "#traffic-graph-backgroundupdate" ).val();
-
- //TODO validate interfaces data and throw error
-
- if(!Number.isInteger(refreshInterval) || refreshInterval < 1 || refreshInterval > 10) {
- error = 'Refresh Interval is not a valid number between 1 and 10.';
- }
-
- if(invert != "true" && invert != "false") {
-
- error = 'Invert is not a boolean of true or false.';
-
- }
-
- if(!error) {
-
- var formData = {
- 'traffic-graph-interfaces' : interfaces,
- 'traffic-graph-interval' : refreshInterval,
- 'traffic-graph-invert' : invert,
- 'traffic-graph-size' : size,
- 'traffic-graph-backgroundupdate' : backgroundupdate
- };
-
- $.ajax({
- type : 'POST',
- url : '/widgets/widgets/traffic_graphs.widget.php',
- data : formData,
- dataType : 'json',
- encode : true
- })
- .done(function(message) {
-
- if(message.success) {
-
- Visibility.stop(updateIds);
- clearInterval(updateTimerIds);
-
- //remove all old graphs (divs/svgs)
- $( ".traffic-widget-chart" ).remove();
-
- window.interfaces = interfaces;
- localStorage.setItem('interval', refreshInterval);
- localStorage.setItem('invert', invert);
- localStorage.setItem('size', size);
- localStorage.setItem('backgroundupdate', backgroundupdate);
-
- //redraw graph with new settings
- now = then = new Date(Date.now());
-
- var freshData = [];
-
- var nowTime = now.getTime();
-
- $.each( interfaces, function( key, value ) {
-
- //create new graphs (divs/svgs)
- $("#widget-traffic_graphs_panel-body").append('<div id="traffic-chart-' + value + '" class="d3-chart traffic-widget-chart"><svg></svg></div>');
-
- myData[value] = [];
-
- var itemIn = new Object();
- var itemOut = new Object();
-
- itemIn.key = value + " (in)";
- if(localStorage.getItem('invert') === "true") { itemIn.area = true; }
- itemIn.first = true;
- itemIn.values = [{x: nowTime, y: 0}];
- myData[value].push(itemIn);
-
- itemOut.key = value + " (out)";
- if(localStorage.getItem('invert') === "true") { itemOut.area = true; }
- itemOut.first = true;
- itemOut.values = [{x: nowTime, y: 0}];
- myData[value].push(itemOut);
-
- });
-
- draw_graph(refreshInterval, then, backgroundupdate);
-
- $( "#traffic-graph-message" ).removeClass("text-danger").addClass("text-success");
- $( "#traffic-graph-message" ).text(message.success);
-
- setTimeout(function() {
- $( "#traffic-graph-message" ).empty();
- $( "#traffic-graph-message" ).removeClass("text-success");
- }, 5000);
-
- } else {
-
- $( "#traffic-graph-message" ).addClass("text-danger");
- $( "#traffic-graph-message" ).text(message.error);
-
- console.warn(message.error);
-
- }
-
- })
- .fail(function() {
-
- console.warn( "The Traffic Graphs widget AJAX request failed." );
-
- });
-
- } else {
-
- $( "#traffic-graph-message" ).addClass("text-danger");
- $( "#traffic-graph-message" ).text(error);
-
- console.warn(error);
-
- }
-
- event.preventDefault();
- });
-
+ set_widget_checkbox_events("#widget-<?=$widgetname?>_panel-footer [id^=show]", "showalltgitems");
});
//]]>
</script>
<script src="/js/traffic-graphs.js"></script>
-
-<!-- close the body we're wrapped in and add a configuration-panel -->
-</div>
-
-<div id="widget-<?=$widgetname?>_panel-footer" class="panel-footer collapse">
-
- <form id="traffic-graph-form" action="/widgets/widgets/traffic_graphs.widget.php" method="post" class="form-horizontal">
- <div class="form-group">
- <label for="traffic-graph-interfaces" class="col-sm-3 control-label"><?=gettext('Show graphs')?></label>
- <div class="col-sm-9">
- <select name="traffic-graph-interfaces[]" id="traffic-graph-interfaces" multiple>
- <?php
- foreach ($ifdescrs as $ifname => $ifdescr) {
-
- $if_shown = "";
- if (in_array($ifname, $a_config["shown"]["item"])) { $if_shown = " selected"; };
- echo '<option value="' . $ifname . '"' . $if_shown . '>' . $ifdescr . "</option>\n";
-
- }
- ?>
- </select>
- </div>
- </div>
-
- <div class="form-group">
- <label for="traffic-graph-interval" class="col-sm-3 control-label"><?=gettext('Refresh Interval')?></label>
- <div class="col-sm-9">
- <input type="number" id="traffic-graph-interval" name="traffic-graph-interval" value="<?=$refreshinterval?>" min="1" max="10" class="form-control" />
- </div>
- </div>
-
- <div class="form-group">
- <label for="traffic-graph-invert" class="col-sm-3 control-label"><?=gettext('Inverse')?></label>
- <div class="col-sm-9">
- <select class="form-control" id="traffic-graph-invert" name="traffic-graph-invert">
- <?php
- if($a_config["invert"] === "true") {
- echo '<option value="true" selected>On</option>';
- echo '<option value="false">Off</option>';
- } else {
- echo '<option value="true">On</option>';
- echo '<option value="false" selected>Off</option>';
- }
- ?>
- </select>
- </div>
- </div>
-
- <div class="form-group">
- <label for="traffic-graph-size" class="col-sm-3 control-label"><?=gettext('Unit Size')?></label>
- <div class="col-sm-9">
- <select class="form-control" id="traffic-graph-size" name="traffic-graph-size">
- <?php
- if($a_config["size"] === "8") {
- echo '<option value="8" selected>Bits</option>';
- echo '<option value="1">Bytes</option>';
- } else {
- echo '<option value="8">Bits</option>';
- echo '<option value="1" selected>Bytes</option>';
- }
- ?>
- </select>
- </div>
- </div>
-
- <div class="form-group">
- <label for="traffic-graph-backgroundupdate" class="col-sm-3 control-label"><?=gettext('Background updates')?></label>
- <div class="col-sm-9">
- <select class="form-control" id="traffic-graph-backgroundupdate" name="traffic-graph-backgroundupdate">
- <?php
- if($a_config["backgroundupdate"] === "true") {
- echo '<option value="true" selected>Keep graphs updated on inactive tab. (increases cpu usage)</option>';
- echo '<option value="false">Clear graphs when not visible.</option>';
- } else {
- echo '<option value="true">Keep graphs updated on inactive tab. (increases cpu usage)</option>';
- echo '<option value="false" selected>Clear graphs when not visible.</option>';
- }
- ?>
- </select>
- </div>
- </div>
- <div class="form-group">
- <div class="col-sm-3 text-right">
- <button type="submit" class="btn btn-primary"><i class="fa fa-save icon-embed-btn"></i><?=gettext('Save')?></button>
- </div>
- <div class="col-sm-9">
- <div id="traffic-graph-message"></div>
- </div>
- </div>
- </form>
diff --git a/src/usr/local/www/widgets/widgets/wake_on_lan.widget.php b/src/usr/local/www/widgets/widgets/wake_on_lan.widget.php
index 3d528f4..a6a10a5 100644
--- a/src/usr/local/www/widgets/widgets/wake_on_lan.widget.php
+++ b/src/usr/local/www/widgets/widgets/wake_on_lan.widget.php
@@ -32,11 +32,13 @@ if (is_array($config['wol']['wolentry'])) {
}
// Constructs a unique key that will identify a WoL entry in the filter list.
-function get_wolent_key($wolent) {
- return ($wolent['interface'] . "|" . $wolent['mac']);
+if (!function_exists('get_wolent_key')) {
+ function get_wolent_key($wolent) {
+ return ($wolent['interface'] . "|" . $wolent['mac']);
+ }
}
-if ($_POST) {
+if ($_POST['widgetkey']) {
$validNames = array();
@@ -45,9 +47,9 @@ if ($_POST) {
}
if (is_array($_POST['show'])) {
- $user_settings['widgets']['wol']['filter'] = implode(',', array_diff($validNames, $_POST['show']));
+ $user_settings['widgets'][$_POST['widgetkey']]['filter'] = implode(',', array_diff($validNames, $_POST['show']));
} else {
- $user_settings['widgets']['wol']['filter'] = "";
+ $user_settings['widgets'][$_POST['widgetkey']]['filter'] = implode(',', $validNames);
}
save_widget_settings($_SESSION['Username'], $user_settings["widgets"], gettext("Saved Wake on LAN Filter via Dashboard."));
@@ -67,14 +69,17 @@ if ($_POST) {
</thead>
<tbody>
<?php
-$skipwols = explode(",", $user_settings['widgets']['wol']['filter']);
+$skipwols = explode(",", $user_settings['widgets'][$widgetkey]['filter']);
if (count($wolcomputers) > 0):
+ $wol_entry_is_displayed = false;
+
foreach ($wolcomputers as $wolent):
if (in_array(get_wolent_key($wolent), $skipwols)) {
continue;
}
+ $wol_entry_is_displayed = true;
$is_active = exec("/usr/sbin/arp -an |/usr/bin/grep {$wolent['mac']}| /usr/bin/wc -l|/usr/bin/awk '{print $1;}'");
$status = exec("/usr/sbin/arp -an | /usr/bin/awk '$4 == \"{$wolent['mac']}\" { print $7 }'");
?>
@@ -101,8 +106,15 @@ if (count($wolcomputers) > 0):
</a>
</td>
</tr>
-<?php endforeach;
-else: ?>
+<?php
+ endforeach;
+ if (!$wol_entry_is_displayed):
+?>
+ <tr><td colspan="4" class="text-center"><?=gettext("All WoL entries are hidden.")?></td></tr>
+<?php
+ endif;
+else:
+?>
<tr><td colspan="4" class="text-center"><?= gettext("No saved WoL addresses") ?></td></tr>
<?php
endif;
@@ -125,11 +137,12 @@ if (is_array($config['dhcpd'])) {
<?php endif; ?>
</div>
<!-- close the body we're wrapped in and add a configuration-panel -->
-</div><div id="widget-<?=$widgetname?>_panel-footer" class="panel-footer collapse">
+</div><div id="<?=$widget_panel_footer_id?>" class="panel-footer collapse">
<form action="/widgets/widgets/wake_on_lan.widget.php" method="post" class="form-horizontal">
<div class="panel panel-default col-sm-10">
<div class="panel-body">
+ <input type="hidden" name="widgetkey" value="<?=$widgetkey; ?>">
<div class="table responsive">
<table class="table table-striped table-hover table-condensed">
<thead>
@@ -142,7 +155,7 @@ if (is_array($config['dhcpd'])) {
</thead>
<tbody>
<?php
- $skipwols = explode(",", $user_settings['widgets']['wol']['filter']);
+ $skipwols = explode(",", $user_settings['widgets'][$widgetkey]['filter']);
$idx = 0;
foreach ($wolcomputers as $wolent):
@@ -165,7 +178,7 @@ if (is_array($config['dhcpd'])) {
<div class="form-group">
<div class="col-sm-offset-3 col-sm-6">
<button type="submit" class="btn btn-primary"><i class="fa fa-save icon-embed-btn"></i><?=gettext('Save')?></button>
- <button id="showallwols" type="button" class="btn btn-info"><i class="fa fa-undo icon-embed-btn"></i><?=gettext('All')?></button>
+ <button id="<?=$widget_showallnone_id?>" type="button" class="btn btn-info"><i class="fa fa-undo icon-embed-btn"></i><?=gettext('All')?></button>
</div>
</div>
</form>
@@ -173,12 +186,7 @@ if (is_array($config['dhcpd'])) {
<script>
//<![CDATA[
events.push(function(){
- $("#showallwols").click(function() {
- $("#widget-<?=$widgetname?>_panel-footer [id^=show]").each(function() {
- $(this).prop("checked", true);
- });
- });
-
+ set_widget_checkbox_events("#<?=$widget_panel_footer_id?> [id^=show]", "<?=$widget_showallnone_id?>");
});
//]]>
</script>
diff --git a/src/usr/local/www/wizard.php b/src/usr/local/www/wizard.php
index 3bc72da..2a6807b 100644
--- a/src/usr/local/www/wizard.php
+++ b/src/usr/local/www/wizard.php
@@ -116,7 +116,7 @@ if ($_POST && !$input_errors) {
eval($pkg['step'][$stepid]['stepsubmitphpaction']);
}
if (!$input_errors) {
- write_config();
+ write_config(gettext("Configuration changed via the pfSense wizard subsystem."));
}
$stepid++;
diff --git a/src/usr/local/www/wizards/openvpn_wizard.inc b/src/usr/local/www/wizards/openvpn_wizard.inc
index 259d279..a46f27d 100644
--- a/src/usr/local/www/wizards/openvpn_wizard.inc
+++ b/src/usr/local/www/wizards/openvpn_wizard.inc
@@ -19,7 +19,11 @@
* limitations under the License.
*/
+require_once("auth.inc");
+require_once("certs.inc");
+require_once("config.inc");
require_once("openvpn.inc");
+require_once("util.inc");
function has_special_chars($text) {
return preg_match('/[^A-Za-z0-9 _-]/', $text);
@@ -662,7 +666,7 @@ function step12_submitphpaction() {
$config['openvpn']['openvpn-server'][] = $server;
openvpn_resync('server', $server);
- write_config();
+ write_config(gettext("OpenVPN configuration saved via OpenVPN Remote Access Server setup wizard."));
header("Location: vpn_openvpn_server.php");
exit;
}
diff --git a/src/usr/local/www/wizards/setup_wizard.xml b/src/usr/local/www/wizards/setup_wizard.xml
index ba6382a..ba9148c 100644
--- a/src/usr/local/www/wizards/setup_wizard.xml
+++ b/src/usr/local/www/wizards/setup_wizard.xml
@@ -556,7 +556,7 @@
} else {
$_POST['ipaddress'] = $_POST['selectedtype'];
$config['interfaces']['wan']['ipaddr'] = $_POST['selectedtype'];
- write_config();
+ write_config(gettext("WAN interface configuration saved via pfSense setup wizard."));
}
if (!$config['interfaces']['lan']) {
header("Location: /wizard.php?xml=setup_wizard.xml&stepid=6&next=Next");
@@ -684,7 +684,7 @@
$admin_user =& getUserEntryByUID(0);
local_user_set_password($admin_user, $_POST['adminpassword']);
local_user_set($admin_user);
- write_config();
+ write_config(gettext("Admin WebGUI password saved via pfSense setup wizard."));
} else {
print_info_box("Passwords do not match! Please press back in the browser window and correct.");
die;
@@ -747,7 +747,7 @@
}
}
unset($config['wizardtemp']);
- write_config();
+ write_config(gettext("Configuration saved on completion of the pfSense setup wizard."));
reload_all();
mwexec_bg("/etc/rc.update_bogons.sh now");
]]>
diff --git a/src/usr/local/www/wizards/traffic_shaper_wizard_dedicated.inc b/src/usr/local/www/wizards/traffic_shaper_wizard_dedicated.inc
index 6bd7a05..f1b4a1a 100644
--- a/src/usr/local/www/wizards/traffic_shaper_wizard_dedicated.inc
+++ b/src/usr/local/www/wizards/traffic_shaper_wizard_dedicated.inc
@@ -19,6 +19,10 @@
* limitations under the License.
*/
+require_once("config.inc");
+require_once("interfaces.inc");
+require_once("util.inc");
+
function step1_stepbeforeformdisplay() {
global $stepid, $savemsg, $pkg;
@@ -1635,7 +1639,7 @@ function apply_all_chosen_items() {
}
}
}
- write_config();
+ write_config(gettext("Shaper configuration saved via pfSense traffic shaper wizard."));
}
function wizard_get_bandwidthtype_scale($type = "b") {
diff --git a/src/usr/local/www/wizards/traffic_shaper_wizard_multi_all.inc b/src/usr/local/www/wizards/traffic_shaper_wizard_multi_all.inc
index e14bc18..6c03ecd 100644
--- a/src/usr/local/www/wizards/traffic_shaper_wizard_multi_all.inc
+++ b/src/usr/local/www/wizards/traffic_shaper_wizard_multi_all.inc
@@ -19,6 +19,9 @@
* limitations under the License.
*/
+require_once("config.inc");
+require_once("interfaces.inc");
+require_once("util.inc");
function step1_stepbeforeformdisplay() {
global $stepid, $savemsg, $pkg;
@@ -1727,7 +1730,7 @@ function apply_all_chosen_items() {
}
}
}
- write_config();
+ write_config(gettext("Shaper configuration saved via pfSense traffic shaper wizard."));
}
function wizard_get_bandwidthtype_scale($type = "b") {
OpenPOWER on IntegriCloud