diff options
40 files changed, 582 insertions, 414 deletions
diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index f2d2e30..43af567 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -3830,7 +3830,7 @@ function interface_6to4_configure($interface = "wan", $wancfg) { foreach ($stfbrbinarr as $bin) { $stfbrarr[] = dechex(bindec($bin)); } - $stfbrgw = Net_IPv6::compress(implode(":", $stfbrarr)); + $stfbrgw = text_to_compressed_ip6(implode(":", $stfbrarr)); /* convert the 128 bits for the broker address back into a valid IPv6 address */ $stflanarr = array(); @@ -3839,9 +3839,9 @@ function interface_6to4_configure($interface = "wan", $wancfg) { foreach ($stflanbinarr as $bin) { $stflanarr[] = dechex(bindec($bin)); } - $stflanpr = Net_IPv6::compress(implode(":", $stflanarr)); + $stflanpr = text_to_compressed_ip6(implode(":", $stflanarr)); $stflanarr[7] = 1; - $stflan = Net_IPv6::compress(implode(":", $stflanarr)); + $stflan = text_to_compressed_ip6(implode(":", $stflanarr)); /* setup the stf interface */ if (!is_module_loaded("if_stf")) { diff --git a/src/etc/inc/ipsec.inc b/src/etc/inc/ipsec.inc index 5b4cbcc..50442c3 100644 --- a/src/etc/inc/ipsec.inc +++ b/src/etc/inc/ipsec.inc @@ -206,6 +206,9 @@ $p2_pfskeygroups = array( 19 => gettext('19 (nist ecp256)'), 20 => gettext('20 (nist ecp384)'), 21 => gettext('21 (nist ecp521)'), + 22 => gettext('22 (1024(sub 160) bit)'), + 23 => gettext('23 (2048(sub 224) bit)'), + 24 => gettext('24 (2048(sub 256) bit)'), 28 => gettext('28 (brainpool ecp256)'), 29 => gettext('29 (brainpool ecp384)'), 30 => gettext('30 (brainpool ecp512)') @@ -602,7 +605,7 @@ function ipsec_dump_mobile() { if(!isset($config['ipsec']['client']['enable'])) { return array(); } - + $_gb = exec("/usr/local/sbin/ipsec leases 2>/dev/null", $output, $rc); if ($rc != 0) { @@ -714,7 +717,7 @@ function ipsec_get_phase1($ikeid) { function ipsec_fixup_ip($ipaddr) { if (is_ipaddrv6($ipaddr) || is_subnetv6($ipaddr)) { - return Net_IPv6::compress(Net_IPv6::uncompress($ipaddr)); + return text_to_compressed_ip6($ipaddr); } else { return $ipaddr; } diff --git a/src/etc/inc/openvpn.inc b/src/etc/inc/openvpn.inc index 5987358..39bcdaf 100644 --- a/src/etc/inc/openvpn.inc +++ b/src/etc/inc/openvpn.inc @@ -1863,8 +1863,8 @@ function openvpn_get_interface_ipv6($ipv6, $prefix) { // Is there a better way to do this math? $ipv6_arr = explode(':', $basev6); $last = hexdec(array_pop($ipv6_arr)); - $ipv6_1 = Net_IPv6::compress(Net_IPv6::uncompress(implode(':', $ipv6_arr) . ':' . dechex($last + 1))); - $ipv6_2 = Net_IPv6::compress(Net_IPv6::uncompress(implode(':', $ipv6_arr) . ':' . dechex($last + 2))); + $ipv6_1 = text_to_compressed_ip6(implode(':', $ipv6_arr) . ':' . dechex($last + 1)); + $ipv6_2 = text_to_compressed_ip6(implode(':', $ipv6_arr) . ':' . dechex($last + 2)); return array($ipv6_1, $ipv6_2); } diff --git a/src/etc/inc/pfsense-utils.inc b/src/etc/inc/pfsense-utils.inc index de0b998..2d090ef 100644 --- a/src/etc/inc/pfsense-utils.inc +++ b/src/etc/inc/pfsense-utils.inc @@ -2728,6 +2728,10 @@ function where_is_ipaddr_configured($ipaddr, $ignore_if = "", $check_localip = f $isipv6 = is_ipaddrv6($ipaddr); + if ($isipv6) { + $ipaddr = text_to_compressed_ip6($ipaddr); + } + if ($check_subnets) { $cidrprefix = intval($cidrprefix); if ($isipv6) { @@ -2786,7 +2790,7 @@ function where_is_ipaddr_configured($ipaddr, $ignore_if = "", $check_localip = f } if ($check_localip) { - if (!is_array($config['l2tp']) && !empty($config['l2tp']['localip']) && (strcasecmp($ipaddr, $config['l2tp']['localip']) == 0)) { + if (!is_array($config['l2tp']) && !empty($config['l2tp']['localip']) && (strcasecmp($ipaddr, text_to_compressed_ip6($config['l2tp']['localip'])) == 0)) { $where_entry = array(); $where_entry['if'] = 'l2tp'; $where_entry['ip_or_subnet'] = $config['l2tp']['localip']; @@ -2883,7 +2887,7 @@ function convert_128bit_to_ipv6($ip6bin) { foreach ($ip6binarr as $binpart) { $ip6arr[] = dechex(bindec($binpart)); } - $ip6addr = Net_IPv6::compress(implode(":", $ip6arr)); + $ip6addr = text_to_compressed_ip6(implode(":", $ip6arr)); return($ip6addr); } @@ -2965,7 +2969,7 @@ function merge_ipv6_delegated_prefix($prefix, $suffix, $len = 64) { break; } - return Net_IPv6::compress(substr($prefix, 0, $prefix_len) . + return text_to_compressed_ip6(substr($prefix, 0, $prefix_len) . substr($suffix, $prefix_len)); } diff --git a/src/etc/inc/util.inc b/src/etc/inc/util.inc index 2176423..2876df9 100644 --- a/src/etc/inc/util.inc +++ b/src/etc/inc/util.inc @@ -114,7 +114,7 @@ function config_unlock() { /* lock configuration file */ function lock($lock, $op = LOCK_SH) { - global $g, $cfglckkeyconsumers; + global $g; if (!$lock) { die(gettext("WARNING: A name must be given as parameter to lock() function.")); } @@ -122,7 +122,6 @@ function lock($lock, $op = LOCK_SH) { @touch("{$g['tmp_path']}/{$lock}.lock"); @chmod("{$g['tmp_path']}/{$lock}.lock", 0666); } - $cfglckkeyconsumers++; if ($fp = fopen("{$g['tmp_path']}/{$lock}.lock", "w")) { if (flock($fp, $op)) { return $fp; @@ -133,7 +132,7 @@ function lock($lock, $op = LOCK_SH) { } function try_lock($lock, $timeout = 5) { - global $g, $cfglckkeyconsumers; + global $g; if (!$lock) { die(gettext("WARNING: A name must be given as parameter to try_lock() function.")); } @@ -141,7 +140,6 @@ function try_lock($lock, $timeout = 5) { @touch("{$g['tmp_path']}/{$lock}.lock"); @chmod("{$g['tmp_path']}/{$lock}.lock", 0666); } - $cfglckkeyconsumers++; if ($fp = fopen("{$g['tmp_path']}/{$lock}.lock", "w")) { $trycounter = 0; while (!flock($fp, LOCK_EX | LOCK_NB)) { @@ -161,7 +159,7 @@ function try_lock($lock, $timeout = 5) { /* unlock configuration file */ function unlock($cfglckkey = 0) { - global $g, $cfglckkeyconsumers; + global $g; flock($cfglckkey, LOCK_UN); fclose($cfglckkey); return; @@ -268,7 +266,7 @@ function gen_subnetv4($ipaddr, $bits) { /* same as gen_subnet() but accepts IPv6 only */ function gen_subnetv6($ipaddr, $bits) { if (is_ipaddrv6($ipaddr) && is_numericint($bits) && $bits <= 128) { - return Net_IPv6::compress(Net_IPv6::getNetmask($ipaddr, $bits)); + return text_to_compressed_ip6(Net_IPv6::getNetmask($ipaddr, $bits)); } return ""; } @@ -396,7 +394,22 @@ function bin_to_ip6($bin) { * Convert IPv6 binary to compressed address */ function bin_to_compressed_ip6($bin) { - return Net_IPv6::compress(bin_to_ip6($bin)); + return text_to_compressed_ip6(bin_to_ip6($bin)); +} + +/* + * Convert textual IPv6 address string to compressed address + */ +function text_to_compressed_ip6($text) { + // Force re-compression by passing parameter 2 (force) true. + // This ensures that supposedly-compressed formats are uncompressed + // first then re-compressed into strictly correct form. + // e.g. 2001:0:0:4:0:0:0:1 + // 2001::4:0:0:0:1 is a strictly-incorrect compression, + // but maybe the user entered it like that. + // The "force" parameter will ensure it is returned as: + // 2001:0:0:4::1 + return Net_IPv6::compress($text, true); } /* Find out how many IPs are contained within a given IP range @@ -1434,14 +1447,14 @@ function get_configured_ipv6_addresses($linklocal_fallback = false) { $interfaces = get_configured_interface_list(); if (is_array($interfaces)) { foreach ($interfaces as $int) { - $ipaddrv6 = get_interface_ipv6($int, false, $linklocal_fallback); + $ipaddrv6 = text_to_compressed_ip6(get_interface_ipv6($int, false, $linklocal_fallback)); $ipv6_array[$int] = $ipaddrv6; } } $interfaces = get_configured_vip_list('inet6'); if (is_array($interfaces)) { foreach ($interfaces as $int => $ipaddrv6) { - $ipv6_array[$int] = $ipaddrv6; + $ipv6_array[$int] = text_to_compressed_ip6($ipaddrv6); } } return $ipv6_array; diff --git a/src/usr/local/www/css/pfSense.css b/src/usr/local/www/css/pfSense.css index 968bf9d..10be63d 100644 --- a/src/usr/local/www/css/pfSense.css +++ b/src/usr/local/www/css/pfSense.css @@ -978,6 +978,11 @@ svg { background-color: #eeeeee; } +/* Checkboxes in groups need to be aligned with text (or other) inputs in the same group */ +.form-group .checkbox { + top: -6px; +} + /* Required input elements have a title that begins with "*". This causes Group.class.php to add <span class="element-required" to the title, which can then be used to style required input here. Example below uses a custom diff --git a/src/usr/local/www/diag_authentication.php b/src/usr/local/www/diag_authentication.php index e03bd55..8d416cc 100644 --- a/src/usr/local/www/diag_authentication.php +++ b/src/usr/local/www/diag_authentication.php @@ -95,7 +95,7 @@ $section->addInput(new Form_Select( $section->addInput(new Form_Input( 'username', - 'Username', + '*Username', 'text', $pconfig['username'], ['placeholder' => 'Username'] @@ -103,7 +103,7 @@ $section->addInput(new Form_Input( $section->addInput(new Form_Input( 'password', - 'Password', + '*Password', 'password', $pconfig['password'], ['placeholder' => 'Password'] diff --git a/src/usr/local/www/diag_dns.php b/src/usr/local/www/diag_dns.php index bb44e73..de1b8bb 100644 --- a/src/usr/local/www/diag_dns.php +++ b/src/usr/local/www/diag_dns.php @@ -219,7 +219,7 @@ $section = new Form_Section('DNS Lookup'); $section->addInput(new Form_Input( 'host', - 'Hostname', + '*Hostname', 'text', $host, ['placeholder' => 'Hostname to look up.'] diff --git a/src/usr/local/www/diag_ping.php b/src/usr/local/www/diag_ping.php index 492e98a..0e87f2e 100644 --- a/src/usr/local/www/diag_ping.php +++ b/src/usr/local/www/diag_ping.php @@ -128,7 +128,7 @@ $section = new Form_Section('Ping'); $section->addInput(new Form_Input( 'host', - 'Hostname', + '*Hostname', 'text', $host, ['placeholder' => 'Hostname to ping'] diff --git a/src/usr/local/www/diag_testport.php b/src/usr/local/www/diag_testport.php index 68e3a60..af38e17 100644 --- a/src/usr/local/www/diag_testport.php +++ b/src/usr/local/www/diag_testport.php @@ -218,7 +218,7 @@ $section = new Form_Section('Test Port'); $section->addInput(new Form_Input( 'host', - 'Hostname', + '*Hostname', 'text', $host, ['placeholder' => 'Hostname to look up.'] @@ -226,7 +226,7 @@ $section->addInput(new Form_Input( $section->addInput(new Form_Input( 'port', - 'Port', + '*Port', 'text', $port, ['placeholder' => 'Port to test.'] diff --git a/src/usr/local/www/diag_traceroute.php b/src/usr/local/www/diag_traceroute.php index efb0d85..6ede87b 100644 --- a/src/usr/local/www/diag_traceroute.php +++ b/src/usr/local/www/diag_traceroute.php @@ -122,7 +122,7 @@ $section = new Form_Section('Traceroute'); $section->addInput(new Form_Input( 'host', - 'Hostname', + '*Hostname', 'text', $host, ['placeholder' => 'Hostname to trace.'] diff --git a/src/usr/local/www/firewall_aliases_edit.php b/src/usr/local/www/firewall_aliases_edit.php index 7053390..161960b 100644 --- a/src/usr/local/www/firewall_aliases_edit.php +++ b/src/usr/local/www/firewall_aliases_edit.php @@ -175,7 +175,7 @@ if ($_POST) { /* check for name interface description conflicts */ foreach ($config['interfaces'] as $interface) { - if ($interface['descr'] == $_POST['name']) { + if (strcasecmp($interface['descr'], $_POST['name']) == 0) { $input_errors[] = gettext("An interface description with this name already exists."); break; } diff --git a/src/usr/local/www/firewall_aliases_import.php b/src/usr/local/www/firewall_aliases_import.php index 0921a21..753a1d8 100644 --- a/src/usr/local/www/firewall_aliases_import.php +++ b/src/usr/local/www/firewall_aliases_import.php @@ -60,9 +60,9 @@ if (!is_array($config['aliases']['alias'])) { } $a_aliases = &$config['aliases']['alias']; -if ($_POST['aliasimport'] != "") { +if ($_POST) { $reqdfields = explode(" ", "name aliasimport"); - $reqdfieldsn = array(gettext("Name"), gettext("Aliases")); + $reqdfieldsn = array(gettext("Name"), gettext("Aliases to import")); do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); @@ -233,7 +233,7 @@ $section = new Form_Section($sectiontext); $section->addInput(new Form_Input( 'name', - 'Alias Name', + '*Alias Name', 'text', $_POST['name'] ))->setPattern('[a-zA-Z0-9_]+')->setHelp('The name of the alias may only consist '. @@ -248,7 +248,7 @@ $section->addInput(new Form_Input( $section->addInput(new Form_Textarea( 'aliasimport', - 'Aliases to import', + '*Aliases to import', $_POST["aliasimport"] ))->setHelp($helptext); diff --git a/src/usr/local/www/firewall_nat_1to1_edit.php b/src/usr/local/www/firewall_nat_1to1_edit.php index 9306ee2..49f572b 100644 --- a/src/usr/local/www/firewall_nat_1to1_edit.php +++ b/src/usr/local/www/firewall_nat_1to1_edit.php @@ -459,19 +459,19 @@ if ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"] $section->addInput(new Form_Select( 'interface', - 'Interface', + '*Interface', $pconfig['interface'], $interfaces ))->setHelp('Choose which interface this rule applies to. In most cases "WAN" is specified.'); $section->addInput(new Form_IpAddress( 'external', - 'External subnet IP', + '*External subnet IP', $pconfig['external'] ))->setHelp('Enter the external (usually on a WAN) subnet\'s starting address for the 1:1 mapping. ' . 'The subnet mask from the internal address below will be applied to this IP address.'); -$group = new Form_Group('Internal IP'); +$group = new Form_Group('*Internal IP'); $group->add(new Form_Checkbox( 'srcnot', @@ -498,7 +498,7 @@ $group->setHelp('Enter the internal (LAN) subnet for the 1:1 mapping. ' . $section->add($group); -$group = new Form_Group('Destination'); +$group = new Form_Group('*Destination'); $group->add(new Form_Checkbox( 'dstnot', diff --git a/src/usr/local/www/firewall_nat_edit.php b/src/usr/local/www/firewall_nat_edit.php index c1cc5b8..b4ba61a 100644 --- a/src/usr/local/www/firewall_nat_edit.php +++ b/src/usr/local/www/firewall_nat_edit.php @@ -691,7 +691,7 @@ if ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"] $section->addInput(new Form_Select( 'interface', - 'Interface', + '*Interface', $pconfig['interface'], $interfaces ))->setHelp('Choose which interface this rule applies to. In most cases "WAN" is specified.'); @@ -700,7 +700,7 @@ $protocols = "TCP UDP TCP/UDP ICMP ESP AH GRE IPV6 IGMP PIM OSPF"; $section->addInput(new Form_Select( 'proto', - 'Protocol', + '*Protocol', $pconfig['proto'], array_combine(explode(" ", strtolower($protocols)), explode(" ", $protocols)) ))->setHelp('Choose which protocol this rule should match. In most cases "TCP" is specified.'); @@ -788,7 +788,7 @@ $group->setHelp('Specify the source port or port range for this rule. This is us $section->add($group); -$group = new Form_Group('Destination'); +$group = new Form_Group('*Destination'); $group->add(new Form_Checkbox( 'dstnot', @@ -813,7 +813,7 @@ $group->add(new Form_IpAddress( $section->add($group); -$group = new Form_Group('Destination port range'); +$group = new Form_Group('*Destination port range'); $group->addClass('dstportrange'); $group->add(new Form_Select( @@ -851,13 +851,13 @@ $section->add($group); $section->addInput(new Form_IpAddress( 'localip', - 'Redirect target IP', + '*Redirect target IP', $pconfig['localip'], 'ALIASV4V6' ))->setHelp('Enter the internal IP address of the server on which to map the ports.' . '<br />' . 'e.g.: 192.168.1.12'); -$group = new Form_Group('Redirect target port'); +$group = new Form_Group('*Redirect target port'); $group->addClass('lclportrange'); $group->add(new Form_Select( @@ -1111,7 +1111,7 @@ events.push(function() { disableInput('localbeginport', true); disableInput('localbeginport_cust', true); disableInput('dstendport_cust', false); - ddisableInput('localbeginport', false); + disableInput('localbeginport', false); disableInput('localbeginport_cust', false); } diff --git a/src/usr/local/www/firewall_nat_npt_edit.php b/src/usr/local/www/firewall_nat_npt_edit.php index 49e5cfe..470e3c1 100644 --- a/src/usr/local/www/firewall_nat_npt_edit.php +++ b/src/usr/local/www/firewall_nat_npt_edit.php @@ -196,7 +196,7 @@ $section->addInput(new Form_Checkbox( $section->addInput(new Form_Select( 'interface', - 'Interface', + '*Interface', $pconfig['interface'], build_if_list() ))->setHelp('Choose which interface this rule applies to.' . '<br />' . @@ -211,7 +211,7 @@ $section->addInput(new Form_Checkbox( $section->addInput(new Form_IpAddress( 'src', - 'Address', + '*Address', $pconfig['src'], 'V6' ))->addMask('srcmask', $pconfig['srcmask'])->setHelp('Internal (LAN) ULA IPv6 Prefix for the Network Prefix translation. ' . @@ -226,7 +226,7 @@ $section->addInput(new Form_Checkbox( $section->addInput(new Form_IpAddress( 'dst', - 'Address', + '*Address', $pconfig['dst'], 'V6' ))->addMask('dstmask', $pconfig['dstmask'])->setHelp('Global Unicast routable IPv6 prefix'); diff --git a/src/usr/local/www/firewall_nat_out_edit.php b/src/usr/local/www/firewall_nat_out_edit.php index 302bf36..b09efb8 100644 --- a/src/usr/local/www/firewall_nat_out_edit.php +++ b/src/usr/local/www/firewall_nat_out_edit.php @@ -471,7 +471,7 @@ if ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"] $section->addInput(new Form_Select( 'interface', - 'Interface', + '*Interface', $pconfig['interface'], $interfaces ))->setHelp('The interface on which traffic is matched as it exits the firewall. In most cases this is "WAN" or another externally-connected interface.'); @@ -480,12 +480,12 @@ $protocols = "any TCP UDP TCP/UDP ICMP ESP AH GRE IPV6 IGMP carp pfsync"; $section->addInput(new Form_Select( 'protocol', - 'Protocol', + '*Protocol', $pconfig['protocol'], array_combine(explode(" ", strtolower($protocols)), explode(" ", $protocols)) ))->setHelp('Choose which protocol this rule should match. In most cases "any" is specified.'); -$group = new Form_Group('Source'); +$group = new Form_Group('*Source'); $group->add(new Form_Select( 'source_type', @@ -510,7 +510,7 @@ $group->add(new Form_Input( $section->add($group); -$group = new Form_Group('Destination'); +$group = new Form_Group('*Destination'); $group->add(new Form_Select( 'destination_type', @@ -549,7 +549,7 @@ $section->addClass('translation'); $section->addInput(new Form_Select( 'target', - 'Address', + '*Address', $pconfig['target'], build_target_list() ))->setHelp( 'Connections matching this rule will be mapped to the specified <b>Address</b>.' . '<br />' . diff --git a/src/usr/local/www/help.php b/src/usr/local/www/help.php index 9954067..9c4b9a6 100644 --- a/src/usr/local/www/help.php +++ b/src/usr/local/www/help.php @@ -346,9 +346,11 @@ if (empty($pagename)) { $pagename = $uri_split[1]; } - /* If the page name is still empty, the user must have requested / (index.php) */ - if (empty($pagename)) { - $pagename = "index.php"; + /* If the referrer was index.php then this was a redirect to help.php + because help.php was the first page the user has priv to. + In that case we do not want to redirect off to the dashboard help. */ + if ($pagename == "index.php") { + $pagename = ""; } /* If the filename is pkg_edit.php or wizard.php, reparse looking @@ -365,18 +367,31 @@ if (empty($pagename)) { } /* Using the derived page name, attempt to find in the URL mapping hash */ -if (array_key_exists($pagename, $helppages)) { - $helppage = $helppages[$pagename]; +if (strlen($pagename) > 0) { + if (array_key_exists($pagename, $helppages)) { + $helppage = $helppages[$pagename]; + } else { + // If no specific page was found, use a generic help page + $helppage = 'https://doc.pfsense.org/index.php/No_Help_Found'; + } + + /* Redirect to help page. */ + header("Location: {$helppage}"); } -/* If we haven't determined a proper page, use a generic help page - stating that a given page does not have help yet. */ +// No page name was determined, so show a message. +$pgtitle = array(gettext("Help"), gettext("About this Page")); +require_once("head.inc"); -if (empty($helppage)) { - $helppage = 'https://doc.pfsense.org/index.php/No_Help_Found'; +if (is_array($allowedpages) && str_replace('*', '', $allowedpages[0]) == "help.php") { + if (count($allowedpages) == 1) { + print_info_box(gettext("The Help page is the only page this user has privilege for.")); + } else { + print_info_box(gettext("Displaying the Help page because it is the first page this user has privilege for.")); + } +} else { + print_info_box(gettext("Help page accessed directly without any page parameter.")); } -/* Redirect to help page. */ -header("Location: {$helppage}"); - +include("foot.inc"); ?> diff --git a/src/usr/local/www/interfaces.php b/src/usr/local/www/interfaces.php index 6010b95..f19ee43 100755 --- a/src/usr/local/www/interfaces.php +++ b/src/usr/local/www/interfaces.php @@ -488,36 +488,44 @@ if ($_POST['apply']) { unset($_POST['pppoe_resetdate']); unset($_POST['pppoe_pr_preset_val']); } - /* description unique? */ - foreach ($ifdescrs as $ifent => $ifdescr) { - if ($if != $ifent && $ifdescr == $_POST['descr']) { - $input_errors[] = gettext("An interface with the specified description already exists."); - break; + + /* input validation */ + $reqdfields = explode(" ", "descr"); + $reqdfieldsn = array(gettext("Description")); + do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); + + if (!$input_errors) { + /* description unique? */ + foreach ($ifdescrs as $ifent => $ifdescr) { + if ($if != $ifent && (strcasecmp($ifdescr, $_POST['descr']) == 0)) { + $input_errors[] = gettext("An interface with the specified description already exists."); + break; + } } - } - /* Is the description already used as an alias name? */ - if (is_array($config['aliases']['alias'])) { - foreach ($config['aliases']['alias'] as $alias) { - if ($alias['name'] == $_POST['descr']) { - $input_errors[] = sprintf(gettext("Sorry, an alias with the name %s already exists."), $_POST['descr']); + /* Is the description already used as an alias name? */ + if (is_array($config['aliases']['alias'])) { + foreach ($config['aliases']['alias'] as $alias) { + if (strcasecmp($alias['name'], $_POST['descr']) == 0) { + $input_errors[] = sprintf(gettext("Sorry, an alias with the name %s already exists."), $_POST['descr']); + } } } - } - /* Is the description already used as an interface group name? */ - if (is_array($config['ifgroups']['ifgroupentry'])) { - foreach ($config['ifgroups']['ifgroupentry'] as $ifgroupentry) { - if ($ifgroupentry['ifname'] == $_POST['descr']) { - $input_errors[] = sprintf(gettext("Sorry, an interface group with the name %s already exists."), $wancfg['descr']); + /* Is the description already used as an interface group name? */ + if (is_array($config['ifgroups']['ifgroupentry'])) { + foreach ($config['ifgroups']['ifgroupentry'] as $ifgroupentry) { + if (strcasecmp($ifgroupentry['ifname'], $_POST['descr']) == 0) { + $input_errors[] = sprintf(gettext("Sorry, an interface group with the name %s already exists."), $_POST['descr']); + } } } - } - if (is_numeric($_POST['descr'])) { - $input_errors[] = gettext("The interface description cannot contain only numbers."); + if (is_numeric($_POST['descr'])) { + $input_errors[] = gettext("The interface description cannot contain only numbers."); + } } - /* input validation */ + if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable'])) { if (!preg_match("/^staticv4/", $_POST['type'])) { $input_errors[] = gettext("The DHCP Server is active " . @@ -621,7 +629,7 @@ if ($_POST['apply']) { } } if (!is_ipaddrv4($_POST['gateway-6rd'])) { - $input_errors[] = gettext("6RD Border Gateway must be an IPv4 address."); + $input_errors[] = gettext("6RD Border Relay must be an IPv4 address."); } if (in_array($wancfg['ipaddrv6'], array())) { $input_errors[] = sprintf(gettext("The interface must be reassigned to configure as %s."), $_POST['type6']); @@ -1716,7 +1724,7 @@ $section->addInput(new Form_Checkbox( $section->addInput(new Form_Input( 'descr', - 'Description', + '*Description', 'text', $pconfig['descr'] ))->setHelp('Enter a description (name) for the interface here.'); @@ -1792,7 +1800,7 @@ $section->addClass('staticv4'); $section->addInput(new Form_IpAddress( 'ipaddr', - 'IPv4 Address', + '*IPv4 Address', $pconfig['ipaddr'], 'V4' ))->addMask('subnet', $pconfig['subnet'], 32); @@ -1826,7 +1834,7 @@ $section->addClass('staticv6'); $section->addInput(new Form_IpAddress( 'ipaddrv6', - 'IPv6 address', + '*IPv6 address', $pconfig['ipaddrv6'], 'V6' ))->addMask('subnetv6', $pconfig['subnetv6'], 128); @@ -2402,7 +2410,7 @@ $section->addInput(new Form_Input( $section->addInput(new Form_Input( 'gateway-6rd', - '6RD Border relay', + '*6RD Border relay', 'text', $pconfig['gateway-6rd'] ))->sethelp('6RD IPv4 gateway address assigned by the ISP'); @@ -2459,7 +2467,7 @@ function build_ipv6interface_list() { $section->addInput(new Form_Select( 'track6-interface', - 'IPv6 Interface', + '*IPv6 Interface', $pconfig['track6-interface'], build_ipv6interface_list() ))->setHelp('Selects the dynamic IPv6 WAN interface to track for configuration.'); @@ -2526,7 +2534,7 @@ $section->addPassword(new Form_Input( $section->addInput(new Form_Input( 'phone', - 'Phone number', + '*Phone number', 'text', $pconfig['phone'] ))->setHelp('Typically *99# for GSM networks and #777 for CDMA networks.'); @@ -2559,7 +2567,7 @@ function build_port_list() { $section->addInput(new Form_Select( 'port', - "Modem port", + "*Modem port", $pconfig['port'], build_port_list() )); @@ -2704,28 +2712,28 @@ $section->addClass('pptp'); $section->addInput(new Form_Input( 'pptp_username', - 'Username', + '*Username', 'text', $pconfig['pptp_username'] )); $section->addPassword(new Form_Input( 'pptp_password', - 'Password', + '*Password', 'password', $pconfig['pptp_password'] )); $section->addInput(new Form_IpAddress( 'pptp_local0', - 'Local IP address', + '*Local IP address', $pconfig['pptp_localip'][0], 'V4' ))->addMask('pptp_subnet0', $pconfig['pptp_subnet'][0]); $section->addInput(new Form_IpAddress( 'pptp_remote0', - 'Remote IP address', + '*Remote IP address', $pconfig['pptp_remote'][0], 'HOSTV4' )); @@ -3598,10 +3606,14 @@ events.push(function() { $('#adv_dhcp_pt_initial_interval').val(initialinterval); } - function setDialOnDemandItems() { + function setPPPoEDialOnDemandItems() { setRequired('pppoe_idletimeout', $('#pppoe_dialondemand').prop('checked')); } + function setPPTPDialOnDemandItems() { + setRequired('pptp_idletimeout', $('#pptp_dialondemand').prop('checked')); + } + // ---------- On initial page load ------------------------------------------------------------ updateType($('#type').val()); @@ -3611,7 +3623,8 @@ events.push(function() { hideClass('dhcpadvanced', true); show_dhcp6adv(); setDHCPoptions(); - setDialOnDemandItems(); + setPPPoEDialOnDemandItems(); + setPPTPDialOnDemandItems(); // Set preset buttons on page load var sv = "<?=htmlspecialchars($pconfig['adv_dhcp_pt_values']);?>"; @@ -3684,7 +3697,11 @@ events.push(function() { // On click . . $('#pppoe_dialondemand').click(function () { - setDialOnDemandItems(); + setPPPoEDialOnDemandItems(); + }); + + $('#pptp_dialondemand').click(function () { + setPPTPDialOnDemandItems(); }); $('[name=adv_dhcp_pt_values]').click(function () { diff --git a/src/usr/local/www/interfaces_bridge_edit.php b/src/usr/local/www/interfaces_bridge_edit.php index 66dfa01..3f5caff 100644 --- a/src/usr/local/www/interfaces_bridge_edit.php +++ b/src/usr/local/www/interfaces_bridge_edit.php @@ -398,7 +398,7 @@ $memberslist = build_port_list($pconfig['members']); $section->addInput(new Form_Select( 'members', - 'Member Interfaces', + '*Member Interfaces', $memberslist['selected'], $memberslist['list'], true // Allow multiples diff --git a/src/usr/local/www/interfaces_gif_edit.php b/src/usr/local/www/interfaces_gif_edit.php index 5e5433a..630a058 100644 --- a/src/usr/local/www/interfaces_gif_edit.php +++ b/src/usr/local/www/interfaces_gif_edit.php @@ -177,32 +177,32 @@ $section = new Form_Section('GIF Configuration'); $section->addInput(new Form_Select( 'if', - 'Parent Interface', + '*Parent Interface', $pconfig['if'], build_parent_list() ))->setHelp('This interface serves as the local address to be used for the GIF tunnel.'); $section->addInput(new Form_IpAddress( 'remote-addr', - 'GIF Remote Address', + '*GIF Remote Address', $pconfig['remote-addr'] ))->setHelp('Peer address where encapsulated gif packets will be sent.'); $section->addInput(new Form_IpAddress( 'tunnel-local-addr', - 'GIF tunnel local address', + '*GIF tunnel local address', $pconfig['tunnel-local-addr'] ))->setHelp('Local gif tunnel endpoint.'); $section->addInput(new Form_IpAddress( 'tunnel-remote-addr', - 'GIF tunnel remote address', + '*GIF tunnel remote address', $pconfig['tunnel-remote-addr'] ))->setHelp('Remote GIF address endpoint.'); $section->addInput(new Form_Select( 'tunnel-remote-net', - 'GIF tunnel subnet', + '*GIF tunnel subnet', $pconfig['tunnel-remote-net'], array_combine(range(128, 1, -1), range(128, 1, -1)) ))->setHelp('The subnet is used for determining the network that is tunnelled.'); diff --git a/src/usr/local/www/interfaces_gre_edit.php b/src/usr/local/www/interfaces_gre_edit.php index 3e2648c..5899927 100644 --- a/src/usr/local/www/interfaces_gre_edit.php +++ b/src/usr/local/www/interfaces_gre_edit.php @@ -171,32 +171,32 @@ $section = new Form_Section('GRE Configuration'); $section->addInput(new Form_Select( 'if', - 'Parent Interface', + '*Parent Interface', $pconfig['if'], build_parent_list() ))->setHelp('This interface serves as the local address to be used for the GRE tunnel.'); $section->addInput(new Form_IpAddress( 'remote-addr', - 'GRE Remote Address', + '*GRE Remote Address', $pconfig['remote-addr'] ))->setHelp('Peer address where encapsulated GRE packets will be sent.'); $section->addInput(new Form_IpAddress( 'tunnel-local-addr', - 'GRE tunnel local address', + '*GRE tunnel local address', $pconfig['tunnel-local-addr'] ))->setHelp('Local GRE tunnel endpoint.'); $section->addInput(new Form_IpAddress( 'tunnel-remote-addr', - 'GRE tunnel remote address', + '*GRE tunnel remote address', $pconfig['tunnel-remote-addr'] ))->setHelp('Remote GRE address endpoint.'); $section->addInput(new Form_Select( 'tunnel-remote-net', - 'GRE tunnel subnet', + '*GRE tunnel subnet', $pconfig['tunnel-remote-net'], array_combine(range(128, 1, -1), range(128, 1, -1)) ))->setHelp('The subnet is used for determining the network that is tunnelled.'); diff --git a/src/usr/local/www/interfaces_groups_edit.php b/src/usr/local/www/interfaces_groups_edit.php index b8f4449..2bb1842 100644 --- a/src/usr/local/www/interfaces_groups_edit.php +++ b/src/usr/local/www/interfaces_groups_edit.php @@ -55,50 +55,60 @@ if (isset($id) && $a_ifgroups[$id]) { $interface_list = get_configured_interface_with_descr(); $interface_list_disabled = get_configured_interface_with_descr(false, true); +$ifname_allowed_chars_text = gettext("Only letters (A-Z), digits (0-9), '-' and '_' are allowed."); +$ifname_no_digit_text = gettext("The group name cannot end with a digit."); + if ($_POST) { unset($input_errors); $pconfig = $_POST; - if (!isset($id)) { - foreach ($a_ifgroups as $groupentry) { - if ($groupentry['ifname'] == $_POST['ifname']) { - $input_errors[] = gettext("Group name already exists!"); + /* input validation */ + $reqdfields = explode(" ", "ifname"); + $reqdfieldsn = array(gettext("Group Name")); + do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); + + if (!$input_errors) { + if (!isset($id)) { + foreach ($a_ifgroups as $groupentry) { + if ($groupentry['ifname'] == $_POST['ifname']) { + $input_errors[] = gettext("Group name already exists!"); + } } } - } - if (strlen($_POST['ifname']) > 16) { - $input_errors[] = gettext("Group name cannot have more than 16 characters."); - } + if (strlen($_POST['ifname']) > 16) { + $input_errors[] = gettext("Group name cannot have more than 16 characters."); + } - if (preg_match("/([^a-zA-Z0-9-_])+/", $_POST['ifname'])) { - $input_errors[] = gettext("Only letters (A-Z), digits (0-9), '-' and '_' are allowed as the group name."); - } + if (preg_match("/([^a-zA-Z0-9-_])+/", $_POST['ifname'])) { + $input_errors[] = $ifname_allowed_chars_text . " " . gettext("Please choose another group name."); + } - if (preg_match("/[0-9]$/", $_POST['ifname'])) { - $input_errors[] = gettext("Group name cannot end with digit."); - } + if (preg_match("/[0-9]$/", $_POST['ifname'])) { + $input_errors[] = $ifname_no_digit_text; + } - /* - * Packages (e.g. tinc) creates interface groups, reserve this - * namespace pkg- for them - */ - if (substr($_POST['ifname'], 0, 4) == 'pkg-') { - $input_errors[] = gettext("Group name cannot start with pkg-"); - } + /* + * Packages (e.g. tinc) creates interface groups, reserve this + * namespace pkg- for them + */ + if (substr($_POST['ifname'], 0, 4) == 'pkg-') { + $input_errors[] = gettext("Group name cannot start with pkg-"); + } - foreach ($interface_list_disabled as $gif => $gdescr) { - if ($gdescr == $_POST['ifname'] || $gif == $_POST['ifname']) { - $input_errors[] = "The specified group name is already used by an interface. Please choose another name."; + foreach ($interface_list_disabled as $gif => $gdescr) { + if ((strcasecmp($gdescr, $_POST['ifname']) == 0) || (strcasecmp($gif, $_POST['ifname']) == 0)) { + $input_errors[] = "The specified group name is already used by an interface. Please choose another name."; + } } - } - /* Is the description already used as an alias name? */ - if (is_array($config['aliases']['alias'])) { - foreach ($config['aliases']['alias'] as $alias) { - if ($alias['name'] == $_POST['ifname']) { - $input_errors[] = gettext("An alias with this name already exists."); + /* Is the description already used as an alias name? */ + if (is_array($config['aliases']['alias'])) { + foreach ($config['aliases']['alias'] as $alias) { + if ($alias['name'] == $_POST['ifname']) { + $input_errors[] = gettext("An alias with this name already exists."); + } } } } @@ -203,12 +213,11 @@ $section = new Form_Section('Interface Group Configuration'); $section->addInput(new Form_Input( 'ifname', - 'Group Name', + '*Group Name', 'text', $pconfig['ifname'], ['placeholder' => 'Group Name', 'maxlength' => "16"] -))->setWidth(6)->setHelp('No numbers or spaces are allowed. '. - 'Only characters: a-zA-Z'); +))->setWidth(6)->setHelp($ifname_allowed_chars_text . " " . $ifname_no_digit_text); $section->addInput(new Form_Input( 'descr', diff --git a/src/usr/local/www/interfaces_lagg_edit.php b/src/usr/local/www/interfaces_lagg_edit.php index 9b6b250..ad24d53 100644 --- a/src/usr/local/www/interfaces_lagg_edit.php +++ b/src/usr/local/www/interfaces_lagg_edit.php @@ -237,7 +237,7 @@ $memberslist = build_member_list(); $section->addInput(new Form_Select( 'members', - 'Parent Interfaces', + '*Parent Interfaces', $memberslist['selected'], $memberslist['list'], true // Allow multiples @@ -245,7 +245,7 @@ $section->addInput(new Form_Select( $section->addInput(new Form_Select( 'proto', - 'LAGG Protocol', + '*LAGG Protocol', $pconfig['proto'], array_combine($laggprotos, $laggprotosuc) ))->setHelp($protohelp); diff --git a/src/usr/local/www/interfaces_ppps_edit.php b/src/usr/local/www/interfaces_ppps_edit.php index 8bb30c7..dc3ebc5 100644 --- a/src/usr/local/www/interfaces_ppps_edit.php +++ b/src/usr/local/www/interfaces_ppps_edit.php @@ -574,7 +574,7 @@ $section = new Form_Section('PPP Configuration'); $section->addInput(new Form_Select( 'type', - 'Link Type', + '*Link Type', $pconfig['type'], $types )); @@ -583,7 +583,7 @@ $linklist = build_link_list(); $section->addInput(new Form_Select( 'interfaces', - 'Link Interface(s)', + '*Link Interface(s)', $linklist['selected'], $linklist['list'], true // Allow multiples @@ -617,16 +617,25 @@ $section->addInput(new Form_Select( [] ))->setHelp('Select to fill in service provider data.'); +$username_label = gettext('Username'); +$password_label = gettext('Password'); + +if ($pconfig['type'] != 'ppp') { + // Username and Password fields are required for types other than ppp. + $username_label = "*" . $username_label; + $password_label = "*" . $password_label; +} + $section->addInput(new Form_Input( 'username', - 'Username', + $username_label, 'text', $pconfig['username'] )); $section->addPassword(new Form_Input( 'passwordfld', - 'Password', + $password_label, 'password', $pconfig['password'] )); @@ -661,7 +670,7 @@ if ($pconfig['type'] == 'pptp' || $pconfig['type'] == 'l2tp') { if ($pconfig['type'] == 'ppp') { $section->addInput(new Form_Input( 'phone', - 'Phone number', + '*Phone number', 'text', $pconfig['phone'] ))->setHelp('Typically *99# for GSM networks and #777 for CDMA networks'); @@ -1155,6 +1164,10 @@ events.push(function() { }); } + function setDialOnDemandItems() { + setRequired('idletimeout', $('#ondemand').prop('checked')); + } + $('#pppoe-reset-type').on('change', function() { hideResetDisplay(false); }); @@ -1184,6 +1197,10 @@ events.push(function() { prefill_provider(); }); + $('#ondemand').click(function () { + setDialOnDemandItems(); + }); + // Set element visibility on initial page load show_advopts(true); @@ -1204,6 +1221,8 @@ events.push(function() { providers_list(); hideInput('provider', false); } + + setDialOnDemandItems(); }); //]]> diff --git a/src/usr/local/www/interfaces_qinq_edit.php b/src/usr/local/www/interfaces_qinq_edit.php index e088732..93ea87d 100644 --- a/src/usr/local/www/interfaces_qinq_edit.php +++ b/src/usr/local/www/interfaces_qinq_edit.php @@ -229,14 +229,14 @@ $section = new Form_Section('QinQ Configuration'); $section->addInput(new Form_Select( 'if', - 'Parent interface', + '*Parent interface', $pconfig['if'], build_parent_list() ))->setHelp('Only QinQ capable interfaces will be shown.'); $section->addInput(new Form_Input( 'tag', - 'First level tag', + '*First level tag', 'number', $pconfig['tag'], ['max' => '4094', 'min' => '1'] diff --git a/src/usr/local/www/interfaces_vlan_edit.php b/src/usr/local/www/interfaces_vlan_edit.php index 70d5271..067de87 100644 --- a/src/usr/local/www/interfaces_vlan_edit.php +++ b/src/usr/local/www/interfaces_vlan_edit.php @@ -183,14 +183,14 @@ $section = new Form_Section('VLAN Configuration'); $section->addInput(new Form_Select( 'if', - 'Parent Interface', + '*Parent Interface', $pconfig['if'], build_interfaces_list() ))->setWidth(6)->setHelp('Only VLAN capable interfaces will be shown.'); $section->addInput(new Form_Input( 'tag', - 'VLAN Tag', + '*VLAN Tag', 'text', $pconfig['tag'], ['placeholder' => '1'] diff --git a/src/usr/local/www/interfaces_wireless_edit.php b/src/usr/local/www/interfaces_wireless_edit.php index f0d6458..a37e817 100644 --- a/src/usr/local/www/interfaces_wireless_edit.php +++ b/src/usr/local/www/interfaces_wireless_edit.php @@ -176,14 +176,14 @@ $section = new Form_Section('Wireless Interface Configuration'); $section->addInput(new Form_Select( 'if', - 'Parent Interface', + '*Parent Interface', $pconfig['if'], build_parent_list() )); $section->addInput(new Form_Select( 'mode', - 'Mode', + '*Mode', $pconfig['mode'], array( 'bss' => gettext('Infrastructure (BSS)'), diff --git a/src/usr/local/www/js/traffic-graphs.js b/src/usr/local/www/js/traffic-graphs.js index fcda786..0dd7b67 100644 --- a/src/usr/local/www/js/traffic-graphs.js +++ b/src/usr/local/www/js/traffic-graphs.js @@ -16,7 +16,7 @@ * limitations under the License. */ -function draw_graph(refreshInterval, then) { +function draw_graph(refreshInterval, then, backgroundupdate) { d3.select("div[id^=nvtooltip-]").remove(); d3.select(".interface-label").remove(); @@ -28,8 +28,8 @@ function draw_graph(refreshInterval, then) { then.setSeconds(then.getSeconds() - startTime); var thenTime = then.getTime(); - $.each( JSON.parse(localStorage.getItem('interfaces')), function( key, value ) { - + $.each( window.interfaces, function( key, value ) { + myData[value]['interfacename'] = graph_interfacenames[value]; latest[value + 'in'] = 0; latest[value + 'out'] = 0; @@ -65,7 +65,6 @@ function draw_graph(refreshInterval, then) { return d3.time.format('%M:%S')(new Date(d)); }); - //TODO change to localStorage.getItem('sizeLabel'); var sizeLabel = $( "#traffic-graph-size option:selected" ).text(); d3.select('#traffic-chart-' + value + ' svg') @@ -74,7 +73,7 @@ function draw_graph(refreshInterval, then) { .attr("x", 20) .attr("y", 20) .attr("font-size", 18) - .text(value); + .text(myData[value]['interfacename']); charts[value].yAxis .tickFormat(d3.format('.2s')) @@ -126,16 +125,15 @@ function draw_graph(refreshInterval, then) { }); - //only update the graphs when tab is active in window to save resources and prevent build up - updateIds = Visibility.every(refreshInterval * 1000, function(){ - + var refreshGraphFunction = function(){ d3.json("ifstats.php") .header("Content-Type", "application/x-www-form-urlencoded") - .post('if='+JSON.parse(localStorage.getItem('interfaces')).join('|'), function(error, json) { //TODO all ifs again + .post('if='+window.interfaces.join('|'), function(error, json) { //TODO all ifs again if (error) { Visibility.stop(updateIds); + clearInterval(updateTimerIds); $(".traffic-widget-chart").remove(); $("#traffic-chart-error").show().html('<strong>Error</strong>: ' + error); return console.warn(error); @@ -145,6 +143,7 @@ function draw_graph(refreshInterval, then) { if (json.error) { Visibility.stop(updateIds); + clearInterval(updateTimerIds); $(".traffic-widget-chart").remove(); $("#traffic-chart-error").show().html('<strong>Error</strong>: ' + json.error); return console.warn(json.error); @@ -154,6 +153,8 @@ function draw_graph(refreshInterval, then) { now = new Date(Date.now()); $.each(json, function( key, ifVals ) { + label = $('#traffic-chart-' + key + ' svg > .interface-label'); + $(label).text(ifVals.name); if(!myData[key][0].first) { @@ -202,6 +203,12 @@ function draw_graph(refreshInterval, then) { }); - }); - + } + + if(backgroundupdate) { + updateTimerIds = setInterval(refreshGraphFunction, refreshInterval * 1000); + } else { + //only update the graphs when tab is active in window to save resources and prevent build up + updateIds = Visibility.every(refreshInterval * 1000, refreshGraphFunction); + } } diff --git a/src/usr/local/www/load_balancer_monitor_edit.php b/src/usr/local/www/load_balancer_monitor_edit.php index f1bcedf..8637f89 100644 --- a/src/usr/local/www/load_balancer_monitor_edit.php +++ b/src/usr/local/www/load_balancer_monitor_edit.php @@ -268,14 +268,14 @@ $section = new Form_Section('Edit Load Balancer - Monitor Entry'); $section->addInput(new Form_Input( 'name', - 'Name', + '*Name', 'text', $pconfig['name'] )); $section->addInput(new Form_Input( 'descr', - 'Description', + '*Description', 'text', $pconfig['descr'] )); diff --git a/src/usr/local/www/load_balancer_pool_edit.php b/src/usr/local/www/load_balancer_pool_edit.php index c7b795a..6e1d0fb 100644 --- a/src/usr/local/www/load_balancer_pool_edit.php +++ b/src/usr/local/www/load_balancer_pool_edit.php @@ -303,7 +303,7 @@ $section = new Form_Section('Add/Edit Load Balancer - Pool Entry'); $section->addInput(new Form_Input( 'name', - 'Name', + '*Name', 'text', $pconfig['name'] )); @@ -327,7 +327,7 @@ $section->addInput(new Form_Input( $section->addInput(new Form_Input( 'port', - 'Port', + '*Port', 'text', $pconfig['port'] ))->setHelp('This is the port the servers are listening on. A port alias listed in Firewall -> Aliases may also be specified here.'); @@ -385,7 +385,7 @@ $form->add($section); $section = new Form_Section('Current Pool Members'); -$group = new Form_Group('Members'); +$group = new Form_Group('*Members'); $list = array(); 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 eb75338..c3e1d1e 100644 --- a/src/usr/local/www/load_balancer_virtual_server_edit.php +++ b/src/usr/local/www/load_balancer_virtual_server_edit.php @@ -174,7 +174,7 @@ $section = new Form_Section('Edit Load Balancer - Virtual Server Entry'); $section->addInput(new Form_Input( 'name', - 'Name', + '*Name', 'text', $pconfig['name'] )); @@ -188,7 +188,7 @@ $section->addInput(new Form_Input( $section->addInput(new Form_Input( 'ipaddr', - 'IP Address', + '*IP Address', 'text', $pconfig['ipaddr'] ))->setHelp('This is normally the WAN IP address for the server to listen on. ' . diff --git a/src/usr/local/www/services_dhcp_relay.php b/src/usr/local/www/services_dhcp_relay.php index fc8e367..3677079 100644 --- a/src/usr/local/www/services_dhcp_relay.php +++ b/src/usr/local/www/services_dhcp_relay.php @@ -74,32 +74,32 @@ if ($_POST) { /* input validation */ if ($_POST['enable']) { - $reqdfields = explode(" ", "server interface"); - $reqdfieldsn = array(gettext("Destination Server"), gettext("Interface")); + $reqdfields = explode(" ", "interface"); + $reqdfieldsn = array(gettext("Interface")); do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); $svrlist = ''; - if ($_POST['server']) { - foreach ($_POST['server'] as $checksrv => $srv) { - if (!empty($srv[0])) { // Filter out any empties - if (!is_ipaddrv4($srv[0])) { - $input_errors[] = sprintf(gettext("Destination Server IP address %s is not a valid IPv4 address."), $srv[0]); + for ($idx=0; $idx<count($_POST); $idx++) { + if ($_POST['server' . $idx]) { + if (!empty($_POST['server' . $idx])) { // Filter out any empties + if (!is_ipaddrv4($_POST['server' . $idx])) { + $input_errors[] = sprintf(gettext("Destination Server IP address %s is not a valid IPv4 address."), $_POST['server' . $idx]); } if (!empty($svrlist)) { $svrlist .= ','; } - $svrlist .= $srv[0]; + $svrlist .= $_POST['server' . $idx]; } } + } - // Check that the user input something in one of the Destination Server fields - if (empty($svrlist)) { - $input_errors[] = gettext("At least one Destination Server IP address must be specified."); - } + // Check that the user input something in one of the Destination Server fields + if (empty($svrlist)) { + $input_errors[] = gettext("At least one Destination Server IP address must be specified."); } } @@ -148,11 +148,11 @@ $section->addInput(new Form_Checkbox( 'Enable', 'Enable DHCP relay on interface', $pconfig['enable'] -))->toggles('.form-group:not(:first-child)'); +)); $section->addInput(new Form_Select( 'interface', - 'Interface(s)', + '*Interface(s)', $pconfig['interface'], $iflist, true @@ -166,34 +166,69 @@ $section->addInput(new Form_Checkbox( ))->setHelp( 'If this is checked, the DHCP relay will append the circuit ID (%s interface number) and the agent ID to the DHCP request.', [$g['product_name']] -); + ); -//Small function to prevent duplicate code -function createDestinationServerInputGroup($value = null) { - $group = new Form_Group('Destination server'); +$counter = 0; +foreach (explode(',', $pconfig['server']) as $server) { + $group = new Form_Group($counter == 0 ? gettext("*Destination server"):''); + $group->addClass('repeatable'); $group->add(new Form_IpAddress( - 'server', + 'server' . $counter, 'Destination server', - $value, + $server, 'V4' ))->setWidth(4) - ->setHelp('This is the IPv4 address of the server to which DHCP requests are relayed.') - ->setIsRepeated(); + ->setHelp('This is the IPv4 address of the server to which DHCP requests are relayed.'); - $group->enableDuplication(null, true); // Buttons are in-line with the input - return $group; -} + $group->add(new Form_Button( + 'deleterow' . $counter, + 'Delete', + null, + 'fa-trash' + ))->addClass('btn-warning'); -if (!isset($pconfig['server'])) { - $section->add(createDestinationServerInputGroup()); -} else { - foreach (explode(',', $pconfig['server']) as $server) { - $section->add(createDestinationServerInputGroup($server)); - } + $section->add($group); + $counter++; } $form->add($section); + +$form->addGlobal(new Form_Button( + 'addrow', + "Add server", + null, + 'fa-plus' +))->addClass('btn-success addbtn'); + print $form; +?> +<script type="text/javascript"> +//<![CDATA[ + events.push(function() { + + function updateSection(hide) { + if (hide) { + $('[name="interface[]"]').parent().parent('div').addClass('hidden'); + } else { + $('[name="interface[]"]').parent().parent('div').removeClass('hidden'); + } + + hideCheckbox('agentoption', hide); + hideClass('repeatable', hide); + } + + $('#enable').click(function () { + updateSection(!this.checked); + }); + updateSection(!$('#enable').prop('checked')); + + // Suppress "Delete row" button if there are fewer than two rows + checkLastRow(); + }); +//]]> +</script> + +<?php include("foot.inc"); diff --git a/src/usr/local/www/services_dhcpv6.php b/src/usr/local/www/services_dhcpv6.php index e26ba8b..aed8e15 100644 --- a/src/usr/local/www/services_dhcpv6.php +++ b/src/usr/local/www/services_dhcpv6.php @@ -228,9 +228,9 @@ if (isset($_POST['apply'])) { $_POST['prefixrange_length']) { $netmask = Net_IPv6::getNetmask($_POST['prefixrange_from'], $_POST['prefixrange_length']); - $netmask = Net_IPv6::compress($netmask); + $netmask = text_to_compressed_ip6($netmask); - if ($netmask != Net_IPv6::compress(strtolower( + if ($netmask != text_to_compressed_ip6(strtolower( $_POST['prefixrange_from']))) { $input_errors[] = sprintf(gettext( "Prefix Delegation From address is not a valid IPv6 Netmask for %s"), @@ -239,9 +239,9 @@ if (isset($_POST['apply'])) { $netmask = Net_IPv6::getNetmask($_POST['prefixrange_to'], $_POST['prefixrange_length']); - $netmask = Net_IPv6::compress($netmask); + $netmask = text_to_compressed_ip6($netmask); - if ($netmask != Net_IPv6::compress(strtolower( + if ($netmask != text_to_compressed_ip6(strtolower( $_POST['prefixrange_to']))) { $input_errors[] = sprintf(gettext( "Prefix Delegation To address is not a valid IPv6 Netmask for %s"), diff --git a/src/usr/local/www/services_ntpd_gps.php b/src/usr/local/www/services_ntpd_gps.php index dc13aad..b89a548 100644 --- a/src/usr/local/www/services_ntpd_gps.php +++ b/src/usr/local/www/services_ntpd_gps.php @@ -52,6 +52,76 @@ function set_default_gps() { write_config(gettext("Setting default NTPd settings")); } +function parse_ublox(&$nmeaset, $splitline) { + $id_idx = 1; + $msg_idx = 2; + $ddc_idx = 3; + if ($splitline[$id_idx] == '40' && $splitline[$ddc_idx]) { + $nmeaset['GP' . $splitline[$msg_idx]] = 1; + } +} + +function parse_garmin(&$nmeaset, $splitline) { + $msg_idx = 1; + $mode_idx = 2; + if ($splitline[$mode_idx] == '1') { + $nmeaset[$splitline[$msg_idx]] = 1; + } +} + +function parse_mtk(&$nmeaset, $splitline) { + $nmeamap = [ + 1 => 'GPGLL', + 2 => 'GPRMC', + 3 => 'GPVTG', + 4 => 'GPGGA', + 5 => 'GPGSA', + 6 => 'GPGSV', + 7 => 'GPGRS', + 8 => 'GPGST', + ]; + for ($x = 1; $x < 9; $x++) { + if($splitline[$x]) { + $nmeaset[$nmeamap[$x]] = 1; + } + } +} + +function parse_sirf(&$nmeaset, $splitline) { + $msg_idx = 1; + $mode_idx = 2; + $rate_idx = 3; + $nmeamap = [ + 0 => 'GPGGA', + 1 => 'GPGLL', + 2 => 'GPGSA', + 3 => 'GPGSV', + 4 => 'GPRMC', + 5 => 'GPVTG', + ]; + if (!(int)$splitline[$mode_idx] && (int)$splitline[$rate_idx]) { + $nmeaset[$nmeamap[(int)$splitline[$msg_idx]]] = 1; + } +} + +function parse_initcmd(&$nmeaset, $initcmd) { + $type_idx = 0; + $nmeaset = []; + $split_initcmd = preg_split('/[\s]+/', $initcmd); + foreach ($split_initcmd as $line) { + $splitline = preg_split('/[,\*]+/', $line); + if ($splitline[$type_idx] == '$PUBX') { + parse_ublox($nmeaset, $splitline); + } elseif ($splitline[$type_idx] == '$PGRMO') { + parse_garmin($nmeaset, $splitline); + } elseif ($splitline[$type_idx] == '$PMTK314') { + parse_mtk($nmeaset, $splitline); + } elseif ($splitline[$type_idx] == '$PSRF103') { + parse_sirf($nmeaset, $splitline); + } + } +} + if ($_POST) { unset($input_errors); @@ -146,10 +216,18 @@ if ($_POST) { unset($config['ntpd']['gps']['refid']); } + if (!empty($_POST['extstatus'])) { + $config['ntpd']['gps']['extstatus'] = $_POST['extstatus']; + } elseif (isset($config['ntpd']['gps']['extstatus'])) { + unset($config['ntpd']['gps']['extstatus']); + } + if (!empty($_POST['gpsinitcmd'])) { $config['ntpd']['gps']['initcmd'] = base64_encode($_POST['gpsinitcmd']); + parse_initcmd($config['ntpd']['gps']['nmeaset'], $_POST['gpsinitcmd']); } elseif (isset($config['ntpd']['gps']['initcmd'])) { unset($config['ntpd']['gps']['initcmd']); + unset($config['ntpd']['gps']['nmeaset']); } write_config(gettext("Updated NTP GPS Settings")); @@ -335,6 +413,13 @@ $section->addInput(new Form_Checkbox( $pconfig['subsec'] ))->setHelp('Enabling this will rapidly fill the log, but is useful for tuning Fudge time 2.'); +$section->addInput(new Form_Checkbox( + 'extstatus', + null, + 'Display extended GPS status (default: checked).', + $pconfig['extstatus'] +))->setHelp('Enable extended GPS status if GPGSV or GPGGA are explicitly enabled by GPS initialization commands.'); + $section->addInput(new Form_Input( 'gpsrefid', 'Clock ID', @@ -509,6 +594,7 @@ events.push(function() { $('#gpsflag3').prop('checked', true); $('#gpsflag4').prop('checked', false); $('#gpssubsec').prop('checked', false); + $('#extstatus').prop('checked', true); } // Show advanced GPS options ============================================== diff --git a/src/usr/local/www/status_graph.php b/src/usr/local/www/status_graph.php index 4a36037..f7a3cc6 100644 --- a/src/usr/local/www/status_graph.php +++ b/src/usr/local/www/status_graph.php @@ -104,6 +104,11 @@ if ($_POST['hostipformat']) { } else { $curhostipformat = ""; } +if ($_POST['backgroundupdate']) { + $curbackgroundupdate = $_POST['backgroundupdate']; +} else { + $curbackgroundupdate = ""; +} function iflist() { global $ifdescrs; @@ -168,6 +173,16 @@ $group->add(new Form_Select( ) ))->setHelp('Display'); +$group->add(new Form_Select( + 'backgroundupdate', + null, + $curbackgroundupdate, + array ( + 'false' => gettext('Clear graphs when not visible.'), + 'true' => gettext('Keep graphs updated on inactive tab. (increases cpu usage)'), + ) +))->setHelp('Background updates'); + $section->add($group); $form->add($section); @@ -190,14 +205,14 @@ events.push(function() { //store saved settings in a fresh localstorage localStorage.clear(); - localStorage.setItem('interfaces', JSON.stringify(InterfaceString.split("|"))); //TODO see if can be switched to interfaces localStorage.setItem('interval', 1); localStorage.setItem('invert', "true"); localStorage.setItem('size', 1); - + window.interfaces = InterfaceString.split("|"); window.charts = {}; window.myData = {}; window.updateIds = 0; + window.updateTimerIds = 0; window.latest = []; var refreshInterval = localStorage.getItem('interval'); @@ -206,10 +221,11 @@ events.push(function() { var nowTime = now.getTime(); - $.each( JSON.parse(localStorage.getItem('interfaces')), function( key, value ) { + $.each( window.interfaces, function( key, value ) { myData[value] = []; updateIds = 0; + updateTimerIds = 0; var itemIn = new Object(); var itemOut = new Object(); @@ -228,19 +244,24 @@ events.push(function() { }); - draw_graph(refreshInterval, then); + var backgroundupdate = $('#backgroundupdate').val() === "true"; + 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($('#backgroundupdate').val() === "true"){ + return; + } if(state === "visible") { now = then = new Date(Date.now()); var nowTime = now.getTime(); - $.each( JSON.parse(localStorage.getItem('interfaces')), function( key, value ) { + $.each( window.interfaces, function( key, value ) { Visibility.stop(updateIds); + clearInterval(updateTimerIds); myData[value] = []; @@ -261,133 +282,11 @@ events.push(function() { }); - draw_graph(refreshInterval, then); + draw_graph(refreshInterval, then, false); } }); - // 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(); - - //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 - }; - - $.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); - - //remove all old graphs (divs/svgs) - $( ".traffic-widget-chart" ).remove(); - - localStorage.setItem('interfaces', JSON.stringify(interfaces)); - localStorage.setItem('interval', refreshInterval); - localStorage.setItem('invert', invert); - localStorage.setItem('size', size); - - //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); - - $( "#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(); - }); - }); //]]> </script> @@ -397,6 +296,12 @@ events.push(function() { <script type="text/javascript"> //<![CDATA[ +var graph_interfacenames = <?php + foreach ($ifdescrs as $ifname => $ifdescr) { + $iflist[$ifname] = $ifdescr; + } + echo json_encode($iflist); +?>; function updateBandwidth() { $.ajax( '/bandwidth_by_ip.php', diff --git a/src/usr/local/www/status_ntpd.php b/src/usr/local/www/status_ntpd.php index c37052d..eb73922 100644 --- a/src/usr/local/www/status_ntpd.php +++ b/src/usr/local/www/status_ntpd.php @@ -103,59 +103,65 @@ if (!isset($config['ntpd']['noquery'])) { $gps_vars = explode(",", $tmp); $gps_ok = ($gps_vars[2] == "A"); $gps_lat_deg = substr($gps_vars[3], 0, 2); - $gps_lat_min = substr($gps_vars[3], 2) / 60.0; + $gps_lat_min = substr($gps_vars[3], 2); $gps_lon_deg = substr($gps_vars[5], 0, 3); - $gps_lon_min = substr($gps_vars[5], 3) / 60.0; - $gps_lat = $gps_lat_deg + $gps_lat_min; + $gps_lon_min = substr($gps_vars[5], 3); + $gps_lat = $gps_lat_deg + $gps_lat_min / 60.0; $gps_lat = $gps_lat * (($gps_vars[4] == "N") ? 1 : -1); - $gps_lon = $gps_lon_deg + $gps_lon_min; + $gps_lon = $gps_lon_deg + $gps_lon_min / 60.0; $gps_lon = $gps_lon * (($gps_vars[6] == "E") ? 1 : -1); - $gps_la = $gps_vars[4]; - $gps_lo = $gps_vars[6]; + $gps_lat_dir = $gps_vars[4]; + $gps_lon_dir = $gps_vars[6]; } elseif (substr($tmp, 0, 6) == '$GPGGA') { $gps_vars = explode(",", $tmp); $gps_ok = $gps_vars[6]; $gps_lat_deg = substr($gps_vars[2], 0, 2); - $gps_lat_min = substr($gps_vars[2], 2) / 60.0; + $gps_lat_min = substr($gps_vars[2], 2); $gps_lon_deg = substr($gps_vars[4], 0, 3); - $gps_lon_min = substr($gps_vars[4], 3) / 60.0; - $gps_lat = $gps_lat_deg + $gps_lat_min; + $gps_lon_min = substr($gps_vars[4], 3); + $gps_lat = $gps_lat_deg + $gps_lat_min / 60.0; $gps_lat = $gps_lat * (($gps_vars[3] == "N") ? 1 : -1); - $gps_lon = $gps_lon_deg + $gps_lon_min; + $gps_lon = $gps_lon_deg + $gps_lon_min / 60.0; $gps_lon = $gps_lon * (($gps_vars[5] == "E") ? 1 : -1); $gps_alt = $gps_vars[9]; $gps_alt_unit = $gps_vars[10]; $gps_sat = (int)$gps_vars[7]; - $gps_la = $gps_vars[3]; - $gps_lo = $gps_vars[5]; + $gps_lat_dir = $gps_vars[3]; + $gps_lon_dir = $gps_vars[5]; } elseif (substr($tmp, 0, 6) == '$GPGLL') { $gps_vars = preg_split('/[,\*]+/', $tmp); $gps_ok = ($gps_vars[6] == "A"); $gps_lat_deg = substr($gps_vars[1], 0, 2); - $gps_lat_min = substr($gps_vars[1], 2) / 60.0; + $gps_lat_min = substr($gps_vars[1], 2); $gps_lon_deg = substr($gps_vars[3], 0, 3); - $gps_lon_min = substr($gps_vars[3], 3) / 60.0; - $gps_lat = $gps_lat_deg + $gps_lat_min; + $gps_lon_min = substr($gps_vars[3], 3); + $gps_lat = $gps_lat_deg + $gps_lat_min / 60.0; $gps_lat = $gps_lat * (($gps_vars[2] == "N") ? 1 : -1); - $gps_lon = $gps_lon_deg + $gps_lon_min; + $gps_lon = $gps_lon_deg + $gps_lon_min / 60.0; $gps_lon = $gps_lon * (($gps_vars[4] == "E") ? 1 : -1); - $gps_la = $gps_vars[2]; - $gps_lo = $gps_vars[4]; + $gps_lat_dir = $gps_vars[2]; + $gps_lon_dir = $gps_vars[4]; } } } } -if (isset($config['ntpd']['gps']['type']) && ($config['ntpd']['gps']['type'] == 'SureGPS') && (isset($gps_ok))) { - //GSV message is only enabled by init commands in services_ntpd_gps.php for SureGPS board - $gpsport = fopen("/dev/gps0", "r+"); - while ($gpsport) { +if (isset($gps_ok) && isset($config['ntpd']['gps']['extstatus']) && ($config['ntpd']['gps']['nmeaset']['gpgsv'] || $config['ntpd']['gps']['nmeaset']['gpgga'])) { + $lookfor['GPGSV'] = $config['ntpd']['gps']['nmeaset']['gpgsv']; + $lookfor['GPGGA'] = !isset($gps_sat) && $config['ntpd']['gps']['nmeaset']['gpgga']; + $gpsport = fopen('/dev/gps0', 'r+'); + while ($gpsport && ($lookfor['GPGSV'] || $lookfor['GPGGA'])) { $buffer = fgets($gpsport); - if (substr($buffer, 0, 6) == '$GPGSV') { - //echo $buffer."\n"; + if ($lookfor['GPGSV'] && substr($buffer, 0, 6) == '$GPGSV') { $gpgsv = explode(',', $buffer); - $gps_satview = $gpgsv[3]; - break; + $gps_satview = (int)$gpgsv[3]; + $lookfor['GPGSV'] = 0; + } elseif ($lookfor['GPGGA'] && substr($buffer, 0, 6) == '$GPGGA') { + $gpgga = explode(',', $buffer); + $gps_sat = (int)$gpgga[7]; + $gps_alt = $gpgga[9]; + $gps_alt_unit = $gpgga[10]; + $lookfor['GPGGA'] = 0; } } } @@ -211,7 +217,7 @@ function print_status() { } function print_gps() { - global $gps_lat, $gps_lon, $gps_lat_deg, $gps_lon_deg, $gps_lat_min, $gps_lon_min, $gps_la, $gps_lo, + global $gps_lat, $gps_lon, $gps_lat_deg, $gps_lon_deg, $gps_lat_min, $gps_lon_min, $gps_lat_dir, $gps_lon_dir, $gps_alt, $gps_alt_unit, $gps_sat, $gps_satview, $gps_goo_lnk; print("<tr>\n"); @@ -219,16 +225,16 @@ function print_gps() { printf("%.5f", $gps_lat); print(" ("); printf("%d%s", $gps_lat_deg, "°"); - printf("%.5f", $gps_lat_min*60); - print($gps_la); + printf("%.5f", $gps_lat_min); + print($gps_lat_dir); print(")"); print("</td>\n"); print("<td>\n"); printf("%.5f", $gps_lon); print(" ("); printf("%d%s", $gps_lon_deg, "°"); - printf("%.5f", $gps_lon_min*60); - print($gps_lo); + printf("%.5f", $gps_lon_min); + print($gps_lon_dir); print(")"); print("</td>\n"); 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 e29f381..04ef6c4 100644 --- a/src/usr/local/www/widgets/widgets/ntp_status.widget.php +++ b/src/usr/local/www/widgets/widgets/ntp_status.widget.php @@ -83,58 +83,64 @@ if ($_REQUEST['updateme']) { $gps_vars = explode(",", $tmp); $gps_ok = ($gps_vars[2] == "A"); $gps_lat_deg = substr($gps_vars[3], 0, 2); - $gps_lat_min = substr($gps_vars[3], 2) / 60.0; + $gps_lat_min = substr($gps_vars[3], 2); $gps_lon_deg = substr($gps_vars[5], 0, 3); - $gps_lon_min = substr($gps_vars[5], 3) / 60.0; - $gps_lat = $gps_lat_deg + $gps_lat_min; + $gps_lon_min = substr($gps_vars[5], 3); + $gps_lat = $gps_lat_deg + $gps_lat_min / 60.0; $gps_lat = $gps_lat * (($gps_vars[4] == "N") ? 1 : -1); - $gps_lon = $gps_lon_deg + $gps_lon_min; + $gps_lon = $gps_lon_deg + $gps_lon_min / 60.0; $gps_lon = $gps_lon * (($gps_vars[6] == "E") ? 1 : -1); - $gps_la = $gps_vars[4]; - $gps_lo = $gps_vars[6]; + $gps_lat_dir = $gps_vars[4]; + $gps_lon_dir = $gps_vars[6]; } elseif (substr($tmp, 0, 6) == '$GPGGA') { $gps_vars = explode(",", $tmp); $gps_ok = $gps_vars[6]; $gps_lat_deg = substr($gps_vars[2], 0, 2); - $gps_lat_min = substr($gps_vars[2], 2) / 60.0; + $gps_lat_min = substr($gps_vars[2], 2); $gps_lon_deg = substr($gps_vars[4], 0, 3); - $gps_lon_min = substr($gps_vars[4], 3) / 60.0; - $gps_lat = $gps_lat_deg + $gps_lat_min; + $gps_lon_min = substr($gps_vars[4], 3); + $gps_lat = $gps_lat_deg + $gps_lat_min / 60.0; $gps_lat = $gps_lat * (($gps_vars[3] == "N") ? 1 : -1); - $gps_lon = $gps_lon_deg + $gps_lon_min; + $gps_lon = $gps_lon_deg + $gps_lon_min / 60.0; $gps_lon = $gps_lon * (($gps_vars[5] == "E") ? 1 : -1); $gps_alt = $gps_vars[9]; $gps_alt_unit = $gps_vars[10]; $gps_sat = (int)$gps_vars[7]; - $gps_la = $gps_vars[3]; - $gps_lo = $gps_vars[5]; + $gps_lat_dir = $gps_vars[3]; + $gps_lon_dir = $gps_vars[5]; } elseif (substr($tmp, 0, 6) == '$GPGLL') { $gps_vars = preg_split('/[,\*]+/', $tmp); $gps_ok = ($gps_vars[6] == "A"); $gps_lat_deg = substr($gps_vars[1], 0, 2); - $gps_lat_min = substr($gps_vars[1], 2) / 60.0; + $gps_lat_min = substr($gps_vars[1], 2); $gps_lon_deg = substr($gps_vars[3], 0, 3); - $gps_lon_min = substr($gps_vars[3], 3) / 60.0; - $gps_lat = $gps_lat_deg + $gps_lat_min; + $gps_lon_min = substr($gps_vars[3], 3); + $gps_lat = $gps_lat_deg + $gps_lat_min / 60.0; $gps_lat = $gps_lat * (($gps_vars[2] == "N") ? 1 : -1); - $gps_lon = $gps_lon_deg + $gps_lon_min; + $gps_lon = $gps_lon_deg + $gps_lon_min / 60.0; $gps_lon = $gps_lon * (($gps_vars[4] == "E") ? 1 : -1); - $gps_la = $gps_vars[2]; - $gps_lo = $gps_vars[4]; + $gps_lat_dir = $gps_vars[2]; + $gps_lon_dir = $gps_vars[4]; } } } - if (isset($config['ntpd']['gps']['type']) && ($config['ntpd']['gps']['type'] == 'SureGPS') && (isset($gps_ok))) { - //GSV message is only enabled by init commands in services_ntpd_gps.php for SureGPS board - $gpsport = fopen("/dev/gps0", "r+"); - while ($gpsport) { + if (isset($gps_ok) && isset($config['ntpd']['gps']['extstatus']) && ($config['ntpd']['gps']['nmeaset']['gpgsv'] || $config['ntpd']['gps']['nmeaset']['gpgga'])) { + $lookfor['GPGSV'] = $config['ntpd']['gps']['nmeaset']['gpgsv']; + $lookfor['GPGGA'] = !isset($gps_sat) && $config['ntpd']['gps']['nmeaset']['gpgga']; + $gpsport = fopen('/dev/gps0', 'r+'); + while ($gpsport && ($lookfor['GPGSV'] || $lookfor['GPGGA'])) { $buffer = fgets($gpsport); - if (substr($buffer, 0, 6) == '$GPGSV') { - //echo $buffer."\n"; + if ($lookfor['GPGSV'] && substr($buffer, 0, 6) == '$GPGSV') { $gpgsv = explode(',', $buffer); - $gps_satview = $gpgsv[3]; - break; + $gps_satview = (int)$gpgsv[3]; + $lookfor['GPGSV'] = 0; + } elseif ($lookfor['GPGGA'] && substr($buffer, 0, 6) == '$GPGGA') { + $gpgga = explode(',', $buffer); + $gps_sat = (int)$gpgga[7]; + $gps_alt = $gpgga[9]; + $gps_alt_unit = $gpgga[10]; + $lookfor['GPGGA'] = 0; } } } @@ -169,7 +175,7 @@ if ($_REQUEST['updateme']) { <td> <a target="_gmaps" href="http://maps.google.com/?q=<?=$gps_lat;?>,<?=$gps_lon;?>"> <?php - echo sprintf("%.5f", $gps_lat) . " " . $gps_la . ", " . sprintf("%.5f", $gps_lon) . " " . $gps_lo; ?> + echo sprintf("%.5f", $gps_lat) . " " . $gps_lat_dir . ", " . sprintf("%.5f", $gps_lon) . " " . $gps_lon_dir; ?> </a> <?php if (isset($gps_alt)) {echo " (" . $gps_alt . " " . $gps_alt_unit . " alt.)";} ?> </td> 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 2d1af03..ebe2180 100644 --- a/src/usr/local/www/widgets/widgets/traffic_graphs.widget.php +++ b/src/usr/local/www/widgets/widgets/traffic_graphs.widget.php @@ -56,6 +56,7 @@ if (!is_array($config["widgets"]["trafficgraphs"])) { $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(); @@ -81,6 +82,9 @@ 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 @@ -91,25 +95,23 @@ if ($_POST) { // 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($_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($_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." }'); + } + //TODO validate data and throw error $a_config["size"] = $_POST["traffic-graph-size"]; @@ -157,34 +159,45 @@ $allifs = implode("|", $ifsarray); ?> <script type="text/javascript"> - //<![CDATA[ +var graph_interfacenames = <?php + foreach ($ifdescrs as $ifname => $ifdescr) { + $iflist[$ifname] = $ifdescr; + } + echo json_encode($iflist); +?>; + events.push(function() { var InterfaceString = "<?=$allifs?>"; //store saved settings in a fresh localstorage localStorage.clear(); - localStorage.setItem('interfaces', JSON.stringify(InterfaceString.split("|"))); //TODO see if can be switched to interfaces localStorage.setItem('interval', <?=$refreshinterval?>); localStorage.setItem('invert', <?=$a_config["invert"]?>); localStorage.setItem('size', <?=$a_config["size"]?>); + localStorage.setItem('backgroundupdate', <?=$a_config["backgroundupdate"]?>); + window.interfaces = InterfaceString.split("|"); window.charts = {}; window.myData = {}; window.updateIds = 0; + window.updateTimerIds = 0; window.latest = []; var refreshInterval = localStorage.getItem('interval'); + var backgroundupdate = localStorage.getItem('backgroundupdate'); + var refreshInterval = localStorage.getItem('interval'); //TODO make it fall on a second value so it increments better var now = then = new Date(Date.now()); var nowTime = now.getTime(); - $.each( JSON.parse(localStorage.getItem('interfaces')), function( key, value ) { + $.each(window.interfaces, function( key, value ) { myData[value] = []; updateIds = 0; + updateTimerIds = 0; var itemIn = new Object(); var itemOut = new Object(); @@ -203,19 +216,23 @@ events.push(function() { }); - draw_graph(refreshInterval, then); + 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"){ + return; + } if(state === "visible") { now = then = new Date(Date.now()); var nowTime = now.getTime(); - $.each( JSON.parse(localStorage.getItem('interfaces')), function( key, value ) { + $.each(window.interfaces, function( key, value ) { Visibility.stop(updateIds); + clearInterval(updateTimerIds); myData[value] = []; @@ -236,7 +253,7 @@ events.push(function() { }); - draw_graph(refreshInterval, then); + draw_graph(refreshInterval, then, backgroundupdate); } }); @@ -251,6 +268,7 @@ events.push(function() { 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 @@ -267,10 +285,11 @@ events.push(function() { if(!error) { var formData = { - 'traffic-graph-interfaces' : interfaces, - 'traffic-graph-interval' : refreshInterval, - 'traffic-graph-invert' : invert, - 'traffic-graph-size' : size + 'traffic-graph-interfaces' : interfaces, + 'traffic-graph-interval' : refreshInterval, + 'traffic-graph-invert' : invert, + 'traffic-graph-size' : size, + 'traffic-graph-backgroundupdate' : backgroundupdate }; $.ajax({ @@ -285,14 +304,16 @@ events.push(function() { if(message.success) { Visibility.stop(updateIds); + clearInterval(updateTimerIds); //remove all old graphs (divs/svgs) $( ".traffic-widget-chart" ).remove(); - localStorage.setItem('interfaces', JSON.stringify(interfaces)); + 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()); @@ -325,7 +346,7 @@ events.push(function() { }); - draw_graph(refreshInterval, then); + draw_graph(refreshInterval, then, backgroundupdate); $( "#traffic-graph-message" ).removeClass("text-danger").addClass("text-success"); $( "#traffic-graph-message" ).text(message.success); @@ -434,6 +455,22 @@ events.push(function() { </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> diff --git a/tools/conf/pfPorts/poudriere_bulk b/tools/conf/pfPorts/poudriere_bulk index ae4b2ee..e13820d 100644 --- a/tools/conf/pfPorts/poudriere_bulk +++ b/tools/conf/pfPorts/poudriere_bulk @@ -38,6 +38,7 @@ sysutils/%%PRODUCT_NAME%%-pkg-Backup sysutils/%%PRODUCT_NAME%%-pkg-Cron sysutils/%%PRODUCT_NAME%%-pkg-LCDproc security/%%PRODUCT_NAME%%-pkg-snort +security/%%PRODUCT_NAME%%-pkg-acme sysutils/%%PRODUCT_NAME%%-pkg-Shellcmd net/%%PRODUCT_NAME%%-pkg-routed net/%%PRODUCT_NAME%%-pkg-siproxd |