diff options
Diffstat (limited to 'src')
36 files changed, 471 insertions, 244 deletions
diff --git a/src/etc/inc/authgui.inc b/src/etc/inc/authgui.inc index c3536c8..47616ee 100644 --- a/src/etc/inc/authgui.inc +++ b/src/etc/inc/authgui.inc @@ -277,7 +277,7 @@ if (isset($config['system']['webgui']['webguicss'])) { <div class="form-group"> <label for="usernamefld" class="col-sm-3 control-label">Username</label> <div class="col-sm-9 col-md-7"> - <input type="text" class="form-control" name="usernamefld" id="usernamefld" placeholder="Enter your username"> + <input type="text" class="form-control" name="usernamefld" id="usernamefld" placeholder="Enter your username" autocorrect="off" autocapitalize="none" spellcheck="false"> </div> </div> diff --git a/src/etc/inc/smtp.inc b/src/etc/inc/smtp.inc index 54aa8cf..de5522c 100644 --- a/src/etc/inc/smtp.inc +++ b/src/etc/inc/smtp.inc @@ -2,7 +2,7 @@ /* * smtp.php * - * @(#) $Header: /opt2/ena/metal/smtp/smtp.php,v 1.48 2014/11/23 22:45:30 mlemos Exp $ + * @(#) $Header: /opt2/ena/metal/smtp/smtp.php,v 1.50 2016/01/19 00:16:06 mlemos Exp $ * */ @@ -12,7 +12,7 @@ <package>net.manuellemos.smtp</package> - <version>@(#) $Id: smtp.php,v 1.48 2014/11/23 22:45:30 mlemos Exp $</version> + <version>@(#) $Id: smtp.php,v 1.50 2016/01/19 00:16:06 mlemos Exp $</version> <copyright>Copyright (C) Manuel Lemos 1999-2011</copyright> <title>Sending e-mail messages via SMTP protocol</title> <author>Manuel Lemos</author> @@ -261,7 +261,7 @@ class smtp_class <variable> <name>user_agent</name> <type>STRING</type> - <value>SMTP Class (http://www.phpclasses.org/smtpclass $Revision: 1.48 $)</value> + <value>SMTP Class (http://www.phpclasses.org/smtpclass $Revision: 1.50 $)</value> <documentation> <purpose>Set the user agent used when connecting via an HTTP proxy.</purpose> <usage>Change this value only if for some reason you want emulate a @@ -270,7 +270,7 @@ class smtp_class </variable> {/metadocument} */ - var $user_agent='SMTP Class (http://www.phpclasses.org/smtpclass $Revision: 1.48 $)'; + var $user_agent='SMTP Class (http://www.phpclasses.org/smtpclass $Revision: 1.50 $)'; /* {metadocument} @@ -1265,12 +1265,14 @@ class smtp_class elseif($success = ($this->PutLine('STARTTLS') && $this->VerifyResultLines('220',$responses)>0)) { - $this->OutputDebug('Starting TLS cryptograpic protocol'); + if($this->debug) + $this->OutputDebug('Starting TLS cryptograpic protocol'); if(!($success = @stream_socket_enable_crypto($this->connection, 1, STREAM_CRYPTO_METHOD_TLS_CLIENT))) $this->error = 'could not start TLS connection encryption protocol'; else { - $this->OutputDebug('TLS started'); + if($this->debug) + $this->OutputDebug('TLS started'); $success = $this->StartSMTP($localhost); } } @@ -1887,4 +1889,4 @@ class smtp_class */ -?> +?>
\ No newline at end of file diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc index 6d869e5..1a137d1 100644 --- a/src/etc/inc/system.inc +++ b/src/etc/inc/system.inc @@ -159,11 +159,11 @@ function system_resolvconf_generate($dynupdate = false) { $syscfg = $config['system']; if ((((isset($config['dnsmasq']['enable'])) && - (!isset($config['dnsmasq']['port']) || $config['dnsmasq']['port'] == "53") && + (empty($config['dnsmasq']['port']) || $config['dnsmasq']['port'] == "53") && (empty($config['dnsmasq']['interface']) || in_array("lo0", explode(",", $config['dnsmasq']['interface'])))) || ((isset($config['unbound']['enable'])) && - (!isset($config['unbound']['port']) || $config['unbound']['port'] == "53") && + (empty($config['unbound']['port']) || $config['unbound']['port'] == "53") && (empty($config['unbound']['active_interface']) || in_array("lo0", explode(",", $config['unbound']['active_interface'])) || in_array("all", explode(",", $config['unbound']['active_interface']), true)))) && diff --git a/src/etc/inc/upgrade_config.inc b/src/etc/inc/upgrade_config.inc index dedab7c..d627f11 100644 --- a/src/etc/inc/upgrade_config.inc +++ b/src/etc/inc/upgrade_config.inc @@ -654,7 +654,7 @@ function upgrade_039_to_040() { $config['system']['user'][0]['priv'][2]['descr'] = gettext("Indicates whether this user is able to login for example via SSH."); $config['system']['user'][0]['priv'][3]['id'] = "copyfiles"; $config['system']['user'][0]['priv'][3]['name'] = "Is allowed to copy files"; - $config['system']['user'][0]['priv'][3]['descr'] = sprintf(gettext("Indicates whether this user is allowed to copy files onto the %s appliance via SCP/SFTP. If you are going to use this privilege, you must install scponly on the appliance (Hint: pkg_add -r scponly)."), $g['product_name']); + $config['system']['user'][0]['priv'][3]['descr'] = sprintf(gettext("Indicates whether this user is allowed to copy files onto the %s appliance via SCP/SFTP."), $g['product_name']); $config['system']['user'][0]['priv'][4]['id'] = "isroot"; $config['system']['user'][0]['priv'][4]['name'] = "Is root user"; $config['system']['user'][0]['priv'][4]['descr'] = gettext("This user is associated with the UNIX root user (you should associate this privilege only with one single user)."); diff --git a/src/etc/inc/util.inc b/src/etc/inc/util.inc index b542566..c767f25 100644 --- a/src/etc/inc/util.inc +++ b/src/etc/inc/util.inc @@ -847,36 +847,44 @@ function subnetv4_expand($subnet) { return $result; } -/* find out whether two subnets overlap */ +/* find out whether two IPv4/IPv6 CIDR subnets overlap. + Note: CIDR overlap implies one is identical or included so largest sn will be the same */ function check_subnets_overlap($subnet1, $bits1, $subnet2, $bits2) { - - if (!is_numeric($bits1)) { - $bits1 = 32; - } - if (!is_numeric($bits2)) { - $bits2 = 32; - } - - if ($bits1 < $bits2) { - $relbits = $bits1; + if (is_ipaddrv4($subnet1)) { + return check_subnetsv4_overlap($subnet1, $bits1, $subnet2, $bits2); } else { - $relbits = $bits2; + return check_subnetsv6_overlap($subnet1, $bits1, $subnet2, $bits2); } +} - $sn1 = gen_subnet_mask_long($relbits) & ip2long($subnet1); - $sn2 = gen_subnet_mask_long($relbits) & ip2long($subnet2); - - return ($sn1 == $sn2); +/* find out whether two IPv4 CIDR subnets overlap. + Note: CIDR overlap means sn1/sn2 are identical or one is included in other. So sn using largest $bits will be the same */ +function check_subnetsv4_overlap($subnet1, $bits1, $subnet2, $bits2) { + $largest_sn = min($bits1, $bits2); + $subnetv4_start1 = gen_subnetv4($subnet1, $largest_sn); + $subnetv4_start2 = gen_subnetv4($subnet2, $largest_sn); + + if($subnetv4_start1 == '' || $subnetv4_start2 == '') { + // One or both args is not a valid IPv4 subnet + //FIXME: needs to return "bad data" not true/false if bad. For now return false, best we can do until fixed + return false; + } + return ($subnetv4_start1 == $subnetv4_start2); } -/* find out whether two IPv6 subnets overlap */ +/* find out whether two IPv6 CIDR subnets overlap. + Note: CIDR overlap means sn1/sn2 are identical or one is included in other. So sn using largest $bits will be the same */ function check_subnetsv6_overlap($subnet1, $bits1, $subnet2, $bits2) { - $sub1_min = gen_subnetv6($subnet1, $bits1); - $sub1_max = gen_subnetv6_max($subnet1, $bits1); - $sub2_min = gen_subnetv6($subnet2, $bits2); - $sub2_max = gen_subnetv6_max($subnet2, $bits2); - - return (is_inrange_v6($sub1_min, $sub2_min, $sub2_max) || is_inrange_v6($sub1_max, $sub2_min, $sub2_max) || is_inrange_v6($sub2_min, $sub1_min, $sub1_max)); + $largest_sn = min($bits1, $bits2); + $subnetv6_start1 = gen_subnetv6($subnet1, $largest_sn); + $subnetv6_start2 = gen_subnetv6($subnet2, $largest_sn); + + if($subnetv6_start1 == '' || $subnetv6_start2 == '') { + // One or both args is not a valid IPv6 subnet + //FIXME: needs to return "bad data" not true/false if bad. For now return false, best we can do until fixed + return false; + } + return ($subnetv6_start1 == $subnetv6_start2); } /* return true if $addr is in $subnet, false if not */ diff --git a/src/etc/pfSense.obsoletedfiles b/src/etc/pfSense.obsoletedfiles index 4f6f453..f389efc 100644 --- a/src/etc/pfSense.obsoletedfiles +++ b/src/etc/pfSense.obsoletedfiles @@ -445,7 +445,6 @@ /usr/local/bin/spawn-fcgi /usr/local/bin/tickadj /usr/local/bin/verifysig -/usr/local/etc/lighttpd /usr/local/etc/pkg.conf /usr/local/info /usr/local/lib/engines @@ -518,7 +517,66 @@ /usr/local/lib/libsyslog-ng-3.4.7.so /usr/local/lib/libsyslog-ng-3.5.4.1.so /usr/local/lib/libxml2.so.5 -/usr/local/lib/lighttpd +/usr/local/lib/lighttpd/mod_access.a +/usr/local/lib/lighttpd/mod_access.la +/usr/local/lib/lighttpd/mod_accesslog.a +/usr/local/lib/lighttpd/mod_accesslog.la +/usr/local/lib/lighttpd/mod_alias.a +/usr/local/lib/lighttpd/mod_alias.la +/usr/local/lib/lighttpd/mod_auth.a +/usr/local/lib/lighttpd/mod_auth.la +/usr/local/lib/lighttpd/mod_cgi.a +/usr/local/lib/lighttpd/mod_cgi.la +/usr/local/lib/lighttpd/mod_cml.a +/usr/local/lib/lighttpd/mod_cml.la +/usr/local/lib/lighttpd/mod_compress.a +/usr/local/lib/lighttpd/mod_compress.la +/usr/local/lib/lighttpd/mod_dirlisting.a +/usr/local/lib/lighttpd/mod_dirlisting.la +/usr/local/lib/lighttpd/mod_evasive.a +/usr/local/lib/lighttpd/mod_evasive.la +/usr/local/lib/lighttpd/mod_evhost.a +/usr/local/lib/lighttpd/mod_evhost.la +/usr/local/lib/lighttpd/mod_expire.a +/usr/local/lib/lighttpd/mod_expire.la +/usr/local/lib/lighttpd/mod_fastcgi.a +/usr/local/lib/lighttpd/mod_fastcgi.la +/usr/local/lib/lighttpd/mod_flv_streaming.a +/usr/local/lib/lighttpd/mod_flv_streaming.la +/usr/local/lib/lighttpd/mod_indexfile.a +/usr/local/lib/lighttpd/mod_indexfile.la +/usr/local/lib/lighttpd/mod_mysql_vhost.a +/usr/local/lib/lighttpd/mod_mysql_vhost.la +/usr/local/lib/lighttpd/mod_proxy.a +/usr/local/lib/lighttpd/mod_proxy.la +/usr/local/lib/lighttpd/mod_redirect.a +/usr/local/lib/lighttpd/mod_redirect.la +/usr/local/lib/lighttpd/mod_rewrite.a +/usr/local/lib/lighttpd/mod_rewrite.la +/usr/local/lib/lighttpd/mod_rrdtool.a +/usr/local/lib/lighttpd/mod_rrdtool.la +/usr/local/lib/lighttpd/mod_scgi.a +/usr/local/lib/lighttpd/mod_scgi.la +/usr/local/lib/lighttpd/mod_secdownload.a +/usr/local/lib/lighttpd/mod_secdownload.la +/usr/local/lib/lighttpd/mod_setenv.a +/usr/local/lib/lighttpd/mod_setenv.la +/usr/local/lib/lighttpd/mod_simple_vhost.a +/usr/local/lib/lighttpd/mod_simple_vhost.la +/usr/local/lib/lighttpd/mod_ssi.a +/usr/local/lib/lighttpd/mod_ssi.la +/usr/local/lib/lighttpd/mod_staticfile.a +/usr/local/lib/lighttpd/mod_staticfile.la +/usr/local/lib/lighttpd/mod_status.a +/usr/local/lib/lighttpd/mod_status.la +/usr/local/lib/lighttpd/mod_trigger_b4_dl.a +/usr/local/lib/lighttpd/mod_trigger_b4_dl.la +/usr/local/lib/lighttpd/mod_userdir.a +/usr/local/lib/lighttpd/mod_userdir.la +/usr/local/lib/lighttpd/mod_usertrack.a +/usr/local/lib/lighttpd/mod_usertrack.la +/usr/local/lib/lighttpd/mod_webdav.a +/usr/local/lib/lighttpd/mod_webdav.la /usr/local/lib/mysql/libmysqlclient.so.15 /usr/local/lib/olsrd_dot_draw.so.0.3 /usr/local/lib/olsrd_dyn_gw.so.0.4 @@ -578,8 +636,6 @@ /usr/local/sbin/ipfw_context /usr/local/sbin/ipfw-classifyd /usr/local/sbin/kbdcheck -/usr/local/sbin/lighttpd -/usr/local/sbin/lighttpd-angel /usr/local/sbin/mdnsd /usr/local/sbin/mini_httpd /usr/local/sbin/mpd @@ -968,7 +1024,5 @@ /var/db/rrd/index.html /var/dhcpd/lib/libc.so.6 /var/etc/pppoe-vpn -/var/log/lighttpd -/var/log/lighttpd.log /var/mail/_relayd /var/mail/unbound diff --git a/src/usr/local/www/classes/Form/Group.class.php b/src/usr/local/www/classes/Form/Group.class.php index 64d1db3..e1ddaac 100644 --- a/src/usr/local/www/classes/Form/Group.class.php +++ b/src/usr/local/www/classes/Form/Group.class.php @@ -132,11 +132,11 @@ EOT; foreach ($missingWidth as $input) $input->setWidth($spaceLeft / count($missingWidth)); - if (strtolower($this->_labelTarget->get_Type()) == 'hidden') + if (strtolower($this->_labelTarget->getType()) == 'hidden') $hidden = true; $form_controls = array('input', 'select', 'button', 'textarea', 'option', 'optgroup', 'fieldset', 'label'); - if (in_array(strtolower($this->_labelTarget->gettagName()), $form_controls) && !$hidden) + if (in_array(strtolower($this->_labelTarget->getTagName()), $form_controls) && !$hidden) $target = $this->_labelTarget->getId(); $inputs = implode('', $this->_inputs); diff --git a/src/usr/local/www/classes/Form/Input.class.php b/src/usr/local/www/classes/Form/Input.class.php index e8dd000..4cdfb28 100644 --- a/src/usr/local/www/classes/Form/Input.class.php +++ b/src/usr/local/www/classes/Form/Input.class.php @@ -106,12 +106,12 @@ class Form_Input extends Form_Element return $this->_attributes['id']; } - public function get_Type() + public function getType() { return $this->_attributes['type']; } - public function gettagName() + public function getTagName() { return $this->_tagName; } @@ -245,7 +245,12 @@ class Form_Input extends Form_Element if (isset($this->_help)) { - $help = gettext($this->_help); + /* Strings longer than this will break gettext. */ + if (strlen($this->_help) < 7620) { + $help = gettext($this->_help); + } else { + $help = $this->_help; + } if (!empty($this->_helpParams)) $help = call_user_func_array('sprintf', array_merge([$help], $this->_helpParams)); diff --git a/src/usr/local/www/classes/Form/Textarea.class.php b/src/usr/local/www/classes/Form/Textarea.class.php index 1f4938a..f38fd85 100644 --- a/src/usr/local/www/classes/Form/Textarea.class.php +++ b/src/usr/local/www/classes/Form/Textarea.class.php @@ -51,7 +51,7 @@ class Form_Textarea extends Form_Input public function setNoWrap() { - $this->_attributes['style'] = 'white-space: nowrap; width: auto;'; + $this->_attributes['style'] = 'white-space: pre;'; return $this; } diff --git a/src/usr/local/www/diag_routes.php b/src/usr/local/www/diag_routes.php index 36048e1..cc68313 100644 --- a/src/usr/local/www/diag_routes.php +++ b/src/usr/local/www/diag_routes.php @@ -212,7 +212,7 @@ events.push(function() { </script> <div class="panel panel-default"> - <div class="panel-heading"><h2 class="panel-title">IPv4 Routes</h2></div> + <div class="panel-heading"><h2 class="panel-title"><?=gettext("IPv4 Routes")?></h2></div> <div class="panel panel-body"> <table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" id="IPv4"> <thead> @@ -230,7 +230,7 @@ events.push(function() { </div> <div class="panel panel-default"> - <div class="panel-heading"><h2 class="panel-title">IPv6 Routes</h2></div> + <div class="panel-heading"><h2 class="panel-title"><?=gettext("IPv6 Routes")?></h2></div> <div class="panel panel-body"> <table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" id="IPv6"> <thead> diff --git a/src/usr/local/www/diag_sockets.php b/src/usr/local/www/diag_sockets.php index 517e8c7..55c1b17 100644 --- a/src/usr/local/www/diag_sockets.php +++ b/src/usr/local/www/diag_sockets.php @@ -67,7 +67,7 @@ $pgtitle = array(gettext("Diagnostics"), gettext("Sockets")); include('head.inc'); $showAll = isset($_GET['showAll']); -$showAllText = $showAll ? "Show only listening sockets" : "Show all socket connections"; +$showAllText = $showAll ? gettext("Show only listening sockets") : gettext("Show all socket connections"); $showAllOption = $showAll ? "" : "?showAll"; ?> diff --git a/src/usr/local/www/diag_tables.php b/src/usr/local/www/diag_tables.php index 07aa2b8..b2f100d 100644 --- a/src/usr/local/www/diag_tables.php +++ b/src/usr/local/www/diag_tables.php @@ -129,7 +129,7 @@ if ($savemsg) { if ($tablename == "webConfiguratorlockout") { $displayname = gettext("Web configurator lockout table"); } else { - $displayname = ucfirst($tablename) . " " . gettext("table"); + $displayname = sprintf(gettext("%s table"), ucfirst($tablename)); } $form = new Form(false); @@ -230,7 +230,7 @@ events.push(function() { </td> <td> <?php if (!$bogons): ?> - <a class="btn btn-xs btn-default" data-entry="<?=htmlspecialchars($entry)?>">Remove</a> + <a class="btn btn-xs btn-default" data-entry="<?=htmlspecialchars($entry)?>"><?=gettext("Remove")?></a> <?php endif ?> </td> </tr> diff --git a/src/usr/local/www/diag_testport.php b/src/usr/local/www/diag_testport.php index 63e55c9..ccdb41e 100644 --- a/src/usr/local/www/diag_testport.php +++ b/src/usr/local/www/diag_testport.php @@ -221,30 +221,29 @@ include("head.inc"); // Handle the display of all messages here where the user can readily see them if ($input_errors) { print_input_errors($input_errors); -} else { - // New page - if (empty($result) && $retval != 0 && !$showtext) { - print('<div class="alert alert-warning" role="alert">This page allows you to perform a simple TCP connection test to determine if a host is up and accepting connections on a given port.' . - ' This test does not function for UDP since there is no way to reliably determine if a UDP port accepts connections in this manner.</div>'); - } - - // Good host & port - if ($retval == 0 && $do_testport == 1) { - if (!$showtext) { - print('<div class="alert alert-success" role="alert">'.gettext("Port test to host: " . $host . " Port: " . $port . " successful").'</div>'); - } else { - print('<div class="alert alert-success" role="alert">'.gettext("Port test to host: " . $host . " Port: " . $port . " successful") . '. Any text received from the host will be shown below the form.</div>'); +} elseif ($do_testport) { + // User asked for a port test + if ($retval == 0) { + // Good host & port + $alert_text = '<div class="alert alert-success" role="alert">' . sprintf(gettext('Port test to host: %1$s Port: %2$s successful'), $host, $port); + if ($showtext) { + $alert_text .= ' ' . gettext('Any text received from the host will be shown below the form.'); } - } - - // netcat exit value != 0 - if ($retval != 0 && !empty($result)) { + } else { + // netcat exit value != 0 + $alert_text = '<div class="alert alert-danger" role="alert">'; if ($showtext) { - print('<div class="alert alert-danger" role="alert">'.gettext('No output received, or connection failed. Try with "Show Remote Text" unchecked first.').'</div>'); + $alert_text .= gettext('No output received, or connection failed. Try with "Show Remote Text" unchecked first.'); } else { - print('<div class="alert alert-danger" role="alert">'.gettext('Connection failed.').'</div>'); + $alert_text .= gettext('Connection failed.'); } } + print ($alert_text . '</div>'); +} else { + // First time, new page + print('<div class="alert alert-warning" role="alert">' . + gettext('This page allows you to perform a simple TCP connection test to determine if a host is up and accepting connections on a given port.') . " " . + gettext('This test does not function for UDP since there is no way to reliably determine if a UDP port accepts connections in this manner.') . '</div>'); } $form = new Form('Test'); @@ -300,15 +299,18 @@ $section->addInput(new Form_Select( $form->add($section); print $form; -if ($ncoutput && !empty($result) && $showtext && $retval == 0): ?> +// If the command succeeded, the user asked to see the output and there is output, then show it. +if ($retval == 0 && $showtext && !empty($ncoutput)): +?> <div class="panel panel-default"> <div class="panel-heading"> - <h2 class="panel-title">Received Remote Text</h2> + <h2 class="panel-title"><?=gettext('Received Remote Text')?></h2> </div> <div class="panel-body"> <pre><?= $ncoutput ?></pre> </div> </div> -<?php endif; +<?php +endif; include("foot.inc"); diff --git a/src/usr/local/www/diag_traceroute.php b/src/usr/local/www/diag_traceroute.php index 7253019..2ccd98e 100644 --- a/src/usr/local/www/diag_traceroute.php +++ b/src/usr/local/www/diag_traceroute.php @@ -73,12 +73,12 @@ include("head.inc"); define('MAX_TTL', 64); define('DEFAULT_TTL', 18); +// Set defaults in case they are not supplied. $do_traceroute = false; $host = ''; $ttl = DEFAULT_TTL; -$pconfig['ttl'] = DEFAULT_TTL; -$pconfig['ipproto'] = 'IPv4'; -$pconfig['sourceip'] = 'Any'; +$ipproto = 'ipv4'; +$sourceip = 'any'; function create_sourceaddresslist() { $list = array('any' => 'Any'); @@ -94,7 +94,6 @@ function create_sourceaddresslist() { if ($_POST || $_REQUEST['host']) { unset($input_errors); - unset($do_traceroute); /* input validation */ $reqdfields = explode(" ", "host ttl"); @@ -113,16 +112,12 @@ if ($_POST || $_REQUEST['host']) { $input_errors[] = gettext("When using IPv6, the target host must be an IPv6 address or hostname."); } - if (!$input_errors) { - $host = $_REQUEST['host']; - } - $sourceip = $_REQUEST['sourceip']; $ttl = $_REQUEST['ttl']; $resolve = $_REQUEST['resolve']; $useicmp = $_REQUEST['useicmp']; - if ($_POST) { + if ($_POST && !$input_errors) { $do_traceroute = true; } @@ -135,6 +130,31 @@ if ($input_errors) { print_input_errors($input_errors); } +/* Do the traceroute and show any error */ +if ($do_traceroute) { + $useicmpparam = isset($useicmp) ? "-I" : ""; + $n = isset($resolve) ? "" : "-n"; + + $command = "/usr/sbin/traceroute"; + if ($ipproto == "ipv6") { + $command .= "6"; + $ifaddr = is_ipaddr($sourceip) ? $sourceip : get_interface_ipv6($sourceip); + } else { + $ifaddr = is_ipaddr($sourceip) ? $sourceip : get_interface_ip($sourceip); + } + + if ($ifaddr && (is_ipaddr($host) || is_hostname($host))) { + $srcip = "-s " . escapeshellarg($ifaddr); + } + + $cmd = "{$command} {$n} {$srcip} -w 2 {$useicmpparam} -m " . escapeshellarg($ttl) . " " . escapeshellarg($host); + $result = shell_exec($cmd); + + if (!$result) { + print_info_box(sprintf(gettext('Error: %s could not be traced/resolved'), $host)); + } +} + $form = new Form('Traceroute'); $section = new Form_Section('Traceroute'); @@ -150,14 +170,14 @@ $section->addInput(new Form_Input( $section->addInput(new Form_Select( 'ipproto', 'IP Protocol', - $pconfig['ipproto'], + $ipproto, array('ipv4' => 'IPv4', 'ipv6' => 'IPv6') ))->setHelp('Select the protocol to use'); $section->addInput(new Form_Select( 'sourceip', 'Source Address', - $pconfig['sourceip'], + $sourceip, create_sourceaddresslist() ))->setHelp('Select source address for the trace'); @@ -186,34 +206,13 @@ $form->add($section); print $form; /* Show the traceroute results */ -if (!$input_errors && $do_traceroute) { - - $useicmp = isset($_REQUEST['useicmp']) ? "-I" : ""; - $n = isset($resolve) ? "" : "-n"; - - $command = "/usr/sbin/traceroute"; - if ($ipproto == "ipv6") { - $command .= "6"; - $ifaddr = is_ipaddr($sourceip) ? $sourceip : get_interface_ipv6($sourceip); - } else { - $ifaddr = is_ipaddr($sourceip) ? $sourceip : get_interface_ip($sourceip); - } - - if ($ifaddr && (is_ipaddr($host) || is_hostname($host))) { - $srcip = "-s " . escapeshellarg($ifaddr); - } - - $cmd = "{$command} {$n} {$srcip} -w 2 {$useicmp} -m " . escapeshellarg($ttl) . " " . escapeshellarg($host); +if ($do_traceroute && $result) { ?> <div class="panel panel-default"> - <div class="panel-heading"><h2 class="panel-title">Results</h2></div> + <div class="panel-heading"><h2 class="panel-title"><?=gettext('Results')?></h2></div> <div class="panel-body"> <?php - if ($result = shell_exec($cmd)) { - print('<pre>'.$result.'</pre>'); - } else { - print('Error: ' . $host . ' ' . gettext("could not be traced/resolved")); - } + print('<pre>' . $result . '</pre>'); ?> </div> </div> diff --git a/src/usr/local/www/easyrule.php b/src/usr/local/www/easyrule.php index 5363adc..ceca6f7 100644 --- a/src/usr/local/www/easyrule.php +++ b/src/usr/local/www/easyrule.php @@ -87,9 +87,7 @@ if (stristr($retval, "error") == true) { $message = $retval; } -include("head.inc"); ?> - -include("fbegin.inc"); +include("head.inc"); ?> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> @@ -99,17 +97,22 @@ if ($input_errors) { print_input_errors($input_errors); } -if ($message) { ?> +if ($message) { +?> <br /> <?=gettext("Message"); ?>: <?=$message;?> <br /> -<?php } else { ?> -<?=gettext("This is the Easy Rule status page, mainly used to display errors when adding rules. " . -"If you are seeing this, there apparently was not an error, and you navigated to the " . -"page directly without telling it what to do"); ?>.<br /><br /> -<?=gettext("This page is meant to be called from the block/pass buttons on the Firewall Logs page"); ?>, <a href="status_logs_filter.php"><?=gettext("Status"); ?> > <?=gettext("System Logs, " . -"Firewall Tab"); ?></a>. -<br /> -<?php } ?> -</td></tr></table> +<?php +} else { + print_info_box( + gettext('This is the Easy Rule status page, mainly used to display errors when adding rules.') . ' ' . + gettext('If you are seeing this, there apparently was not an error, and you navigated to the page directly without telling it what to do.') . + '<br /><br />' . + gettext('This page is meant to be called from the block/pass buttons on the Firewall Logs page') . + ', <a href="status_logs_filter.php">' . gettext("Status") . ' > ' . gettext('System Logs') . ', ' . gettext('Firewall Tab') . '</a>.<br />'); +} +?> + </td> + </tr> +</table> <?php include("foot.inc"); ?> diff --git a/src/usr/local/www/edit.php b/src/usr/local/www/edit.php index ada73d1..45fa6c1 100644 --- a/src/usr/local/www/edit.php +++ b/src/usr/local/www/edit.php @@ -69,9 +69,9 @@ if ($_POST['action']) { switch ($_POST['action']) { case 'load': if (strlen($_POST['file']) < 1) { - print('|5|' . '<div class="alert alert-danger" role="alert">'.gettext("No file name specified").'</div>' . '|'); + print('|5|' . '<div class="alert alert-danger" role="alert">' . gettext("No file name specified") . '</div>' . '|'); } elseif (is_dir($_POST['file'])) { - print('|4|' . '<div class="alert alert-danger" role="alert">' . gettext("Loading a directory is not supported") .'</div>' . '|'); + print('|4|' . '<div class="alert alert-danger" role="alert">' . gettext("Loading a directory is not supported") . '</div>' . '|'); } elseif (!is_file($_POST['file'])) { print('|3|' . '<div class="alert alert-danger" role="alert">' . gettext("File does not exist or is not a regular file") . '</div>' . '|'); } else { @@ -87,7 +87,7 @@ if ($_POST['action']) { case 'save': if (strlen($_POST['file']) < 1) { - print('|' . '<div class="alert alert-danger" role="alert">'.gettext("No file name specified").'</div>' . '|'); + print('|' . '<div class="alert alert-danger" role="alert">' . gettext("No file name specified") . '</div>' . '|'); } else { conf_mount_rw(); $_POST['data'] = str_replace("\r", "", base64_decode($_POST['data'])); @@ -116,7 +116,7 @@ require("head.inc"); ?> <!-- file status box --> <div style="display:none; background:#eeeeee;" id="fileStatusBox"> - <strong id="fileStatus"></strong> + <strong id="fileStatus"></strong> </div> <div class="panel panel-default"> @@ -128,6 +128,9 @@ require("head.inc"); <input type="button" class="btn btn-default btn-sm" onclick="loadFile();" value="<?=gettext('Load')?>" /> <input type="button" class="btn btn-default btn-sm" id="fbOpen" value="<?=gettext('Browse')?>" /> <input type="button" class="btn btn-default btn-sm" onclick="saveFile();" value="<?=gettext('Save')?>" /> + <span class="pull-right"> + <button id="btngoto" class="btn btn-default btn-sm"><?=gettext("GoTo Line #")?></button> <input type="number" id="gotoline" width="6"></input> + </span> </form> <div id="fbBrowser" style="display:none; border:1px dashed gray; width:98%;"></div> @@ -148,6 +151,58 @@ require("head.inc"); <script type="text/javascript"> //<![CDATA[ + events.push(function(){ + + function showLine(tarea, lineNum) { + + lineNum--; // array starts at 0 + var lines = tarea.value.split("\n"); + + // calculate start/end + var startPos = 0, endPos = tarea.value.length; + for(var x = 0; x < lines.length; x++) { + if(x == lineNum) { + break; + } + startPos += (lines[x].length+1); + + } + + var endPos = lines[lineNum].length+startPos; + + // do selection + // Chrome / Firefox + + if(typeof(tarea.selectionStart) != "undefined") { + tarea.focus(); + tarea.selectionStart = startPos; + tarea.selectionEnd = endPos; + return true; + } + + // IE + if (document.selection && document.selection.createRange) { + tarea.focus(); + tarea.select(); + var range = document.selection.createRange(); + range.collapse(true); + range.moveEnd("character", endPos); + range.moveStart("character", startPos); + range.select(); + return true; + } + + return false; + } + + $("#btngoto").prop('type','button'); + + $('#btngoto').click(function() { + var tarea = document.getElementById("fileContent"); + showLine(tarea, $('#gotoline').val()); + }); + }); + function loadFile() { jQuery("#fileStatus").html(""); jQuery("#fileStatusBox").show(500); diff --git a/src/usr/local/www/exec.php b/src/usr/local/www/exec.php index b7ebca0..618eb23 100644 --- a/src/usr/local/www/exec.php +++ b/src/usr/local/www/exec.php @@ -90,7 +90,7 @@ if (($_POST['submit'] == "DOWNLOAD") && file_exists($_POST['dlPath'])) { exit; } else if (($_POST['submit'] == "UPLOAD") && is_uploaded_file($_FILES['ulfile']['tmp_name'])) { move_uploaded_file($_FILES['ulfile']['tmp_name'], "/tmp/" . $_FILES['ulfile']['name']); - $ulmsg = "Uploaded file to /tmp/" . htmlentities($_FILES['ulfile']['name']); + $ulmsg = sprintf(gettext('Uploaded file to /tmp/%s'), htmlentities($_FILES['ulfile']['name'])); unset($_POST['txtCommand']); } @@ -218,12 +218,12 @@ if (isBlank($_POST['txtRecallBuffer'])) { <?php if (isBlank($_POST['txtCommand']) && isBlank($_POST['txtPHPCommand']) && isBlank($ulmsg)) { - print('<div class="alert alert-warning" role="alert">'.gettext("The capabilities offered here can be dangerous. No support is available. Use them at your own risk!").'</div>'); + print('<div class="alert alert-warning" role="alert">' . gettext("The capabilities offered here can be dangerous. No support is available. Use them at your own risk!") . '</div>'); } if (!isBlank($_POST['txtCommand'])):?> <div class="panel panel-success responsive"> - <div class="panel-heading"><h2 class="panel-title">Shell Output - <?=htmlspecialchars($_POST['txtCommand'])?></h2></div> + <div class="panel-heading"><h2 class="panel-title"><?=sprintf(gettext('Shell Output - %s'), htmlspecialchars($_POST['txtCommand']))?></h2></div> <div class="panel-body"> <div class="content"> <?php @@ -269,7 +269,7 @@ if (!isBlank($_POST['txtCommand'])):?> <?php if ($ulmsg) { - print('<div class="alert alert-success" role="alert">' . $ulmsg .'</div>'); + print('<div class="alert alert-success" role="alert">' . $ulmsg . '</div>'); } ?> <div class="panel panel-default"> diff --git a/src/usr/local/www/firewall_aliases.php b/src/usr/local/www/firewall_aliases.php index 8a5b675..ffecc25 100644 --- a/src/usr/local/www/firewall_aliases.php +++ b/src/usr/local/www/firewall_aliases.php @@ -212,7 +212,7 @@ display_top_tabs($tab_array); ?> <div class="panel panel-default"> - <div class="panel-heading"><h2 class="panel-title"><?=gettext('Firewall Aliases') . " " . $bctab?></h2></div> + <div class="panel-heading"><h2 class="panel-title"><?=sprintf(gettext('Firewall Aliases %s'), $bctab)?></h2></div> <div class="panel-body"> <div class="table-responsive"> diff --git a/src/usr/local/www/firewall_aliases_edit.php b/src/usr/local/www/firewall_aliases_edit.php index 89ee9dc..128335d 100755 --- a/src/usr/local/www/firewall_aliases_edit.php +++ b/src/usr/local/www/firewall_aliases_edit.php @@ -106,6 +106,16 @@ if ($debug) { unlink_if_exists("{$g['tmp_path']}/alias_rename_log.txt"); } +$singular_types = array( + 'host' => gettext("host"), + 'network' => gettext("network"), + 'port' => gettext("port"), + 'url' => gettext("URL (IP)"), + 'url_ports' => gettext("URL (Port)"), + 'urltable' => gettext("URL Table (IP)"), + 'urltable_ports' => gettext("URL Table (Port)"), +); + function alias_same_type($name, $type) { global $config; @@ -172,7 +182,7 @@ if ($_POST) { $input_errors[] = gettext("Reserved word used for alias name."); } else { if (is_validaliasname($_POST['name']) == false) { - $input_errors[] = gettext("The alias name must be less than 32 characters long, may not consist of only numbers, and may only contain the following characters") . " a-z, A-Z, 0-9, _."; + $input_errors[] = sprintf(gettext("The alias name must be less than 32 characters long, may not consist of only numbers, may not consist of only underscores, and may only contain the following characters: %s"), 'a-z, A-Z, 0-9, _'); } } /* check for name conflicts */ @@ -186,7 +196,7 @@ if ($_POST) { /* Check for reserved keyword names */ foreach ($reserved_keywords as $rk) { if ($rk == $_POST['name']) { - $input_errors[] = sprintf(gettext("Cannot use a reserved keyword as alias name %s"), $rk); + $input_errors[] = sprintf(gettext("Cannot use a reserved keyword as an alias name: %s"), $rk); } } @@ -428,18 +438,18 @@ if ($_POST) { } } else if ($_POST['type'] == "port") { if (!is_port($input_address) && !is_portrange($input_address)) { - $input_errors[] = $input_address . " " . gettext("is not a valid port or alias."); + $input_errors[] = sprintf(gettext("%s is not a valid port or alias."), $input_address); } } else if ($_POST['type'] == "host" || $_POST['type'] == "network") { if (is_subnet($input_address) || (!is_ipaddr($input_address) && !is_hostname($input_address))) { - $input_errors[] = sprintf(gettext('%1$s is not a valid %2$s address, FQDN or alias.'), $input_address, $_POST['type']); + $input_errors[] = sprintf(gettext('%1$s is not a valid %2$s address, FQDN or alias.'), $input_address, $singular_types[$_POST['type']]); } } $tmpaddress = $input_address; if ($_POST['type'] != "host" && is_ipaddr($input_address) && $input_address_subnet[$idx] <> "") { if (!is_subnet($input_address . "/" . $input_address_subnet[$idx])) { - $input_errors[] = sprintf(gettext('%s/%s is not a valid subnet.'), $input_address, $input_address_subnet[$idx]); + $input_errors[] = sprintf(gettext('%1$s/%2$s is not a valid subnet.'), $input_address, $input_address_subnet[$idx]); } else { $tmpaddress .= "/" . $input_address_subnet[$idx]; } @@ -557,7 +567,7 @@ $section_str = array( 'url_ports' => gettext("URL (Ports)"), 'urltable' => gettext("URL Table (IPs)"), 'urltable_ports' => gettext("URL Table (Ports)") - ); +); $btn_str = array( 'network' => gettext("Add Network"), @@ -567,7 +577,7 @@ $btn_str = array( 'url_ports' => gettext("Add URL"), 'urltable' => gettext("Add URL Table"), 'urltable_ports' => gettext("Add URL Table") - ); +); $label_str = array( 'network' => gettext("Network or FQDN"), @@ -577,28 +587,43 @@ $label_str = array( 'url_ports' => gettext("URL (Ports)"), 'urltable' => gettext("URL Table (IPs)"), 'urltable_ports' => gettext("URL Table (Ports)") - ); +); + +$special_cidr_usage_text = gettext("The value after the \"/\" is the update frequency in days."); $help = array( - 'network' => "Networks are specified in CIDR format. Select the CIDR mask that pertains to each entry. /32 specifies a single IPv4 host, /128 specifies a single IPv6 host, /24 specifies 255.255.255.0, /64 specifies a normal IPv6 network, etc. Hostnames (FQDNs) may also be specified, using a /32 mask for IPv4 or /128 for IPv6. You may also enter an IP range such as 192.168.1.1-192.168.1.254 and a list of CIDR networks will be derived to fill the range.", - 'host' => "Enter as many hosts as you would like. Hosts must be specified by their IP address or fully qualified domain name (FQDN). FQDN hostnames are periodically re-resolved and updated. If multiple IPs are returned by a DNS query, all are used. You may also enter an IP range such as 192.168.1.1-192.168.1.10 or a small subnet such as 192.168.1.16/28 and a list of individual IP addresses will be generated.", - 'port' => "Enter as many ports as you wish. Port ranges can be expressed by separating with a colon.", - 'url' => "Enter as many URLs as you wish. After saving we will download the URL and import the items into the alias. Use only with small sets of IP addresses (less than 3000).", - 'url_ports' => "Enter as many URLs as you wish. After saving we will download the URL and import the items into the alias. Use only with small sets of Ports (less than 3000).", - 'urltable' => "Enter a single URL containing a large number of IPs and/or Subnets. After saving we will download the URL and create a table file containing these addresses. This will work with large numbers of addresses (30,000+) or small numbers." . "<br /><b>The value after the \"/\" is the " . - "update frequency in days.</b>", - 'urltable_ports' => "Enter a single URL containing a list of Port numbers and/or Port ranges. After saving we will download the URL." . "<br /><b>The value after the \"/\" is the " . - "update frequency in days.</b>" + 'network' => gettext("Networks are specified in CIDR format. Select the CIDR mask that pertains to each entry. /32 specifies a single IPv4 host, /128 specifies a single IPv6 host, /24 specifies 255.255.255.0, /64 specifies a normal IPv6 network, etc. Hostnames (FQDNs) may also be specified, using a /32 mask for IPv4 or /128 for IPv6. You may also enter an IP range such as 192.168.1.1-192.168.1.254 and a list of CIDR networks will be derived to fill the range."), + 'host' => gettext("Enter as many hosts as you would like. Hosts must be specified by their IP address or fully qualified domain name (FQDN). FQDN hostnames are periodically re-resolved and updated. If multiple IPs are returned by a DNS query, all are used. You may also enter an IP range such as 192.168.1.1-192.168.1.10 or a small subnet such as 192.168.1.16/28 and a list of individual IP addresses will be generated."), + 'port' => gettext("Enter as many ports as you wish. Port ranges can be expressed by separating with a colon."), + 'url' => gettext("Enter as many URLs as you wish. After saving we will download the URL and import the items into the alias. Use only with small sets of IP addresses (less than 3000)."), + 'url_ports' => gettext("Enter as many URLs as you wish. After saving we will download the URL and import the items into the alias. Use only with small sets of Ports (less than 3000)."), + 'urltable' => gettext("Enter a single URL containing a large number of IPs and/or Subnets. After saving we will download the URL and create a table file containing these addresses. This will work with large numbers of addresses (30,000+) or small numbers.") . + "<br /><b>" . $special_cidr_usage_text . "</b>", + 'urltable_ports' => gettext("Enter a single URL containing a list of Port numbers and/or Port ranges. After saving we will download the URL.") . + "<br /><b>" . $special_cidr_usage_text . "</b>", +); + +// Tab type specific patterns. +// Intentionally loose (valid character check only, no pattern recognition). +// Can be tightend up with pattern recognition as desired for each tab type. +$pattern_str = array( + 'network' => '[a-zA-Z0-9_:.-]+', // Alias Name, Host Name, IP Address, FQDN, Network or IP Address Range + 'host' => '[a-zA-Z0-9_:.-]+', // Alias Name, Host Name, IP Address, FQDN + 'port' => '[a-zA-Z0-9_:]+', // Alias Name, Port Number, or Port Number Range + 'url' => '.*', // Alias Name or URL + 'url_ports' => '.*', // Alias Name or URL + 'urltable' => '.*', // Alias Name or URL + 'urltable_ports' => '.*' // Alias Name or URL ); $types = array( - 'host' => 'Host(s)', - 'network' => 'Network(s)', - 'port' => 'Port(s)', - 'url' => 'URL (IPs)', - 'url_ports' => 'URL (Ports)', - 'urltable' => 'URL Table (IPs)', - 'urltable_ports' => 'URL Table (Ports)', + 'host' => gettext("Host(s)"), + 'network' => gettext("Network(s)"), + 'port' => gettext("Port(s)"), + 'url' => gettext("URL (IPs)"), + 'url_ports' => gettext("URL (Ports)"), + 'urltable' => gettext("URL Table (IPs)"), + 'urltable_ports' => gettext("URL Table (Ports)"), ); if (empty($tab)) { @@ -689,7 +714,13 @@ while ($counter < count($addresses)) { list($address, $address_subnet) = explode("/", $addresses[$counter]); } else { $address = $addresses[$counter]; - $address_subnet = ""; + if (isset($pconfig['updatefreq'])) { + // Note: There is only 1 updatefreq possible. + // The alias types that use updatefreq only allow a single entry. + $address_subnet = $pconfig['updatefreq']; + } else { + $address_subnet = ""; + } } $group = new Form_Group($counter == 0 ? $label_str[$tab]:''); @@ -699,7 +730,7 @@ while ($counter < count($addresses)) { 'address' . $counter, 'Address', $address - ))->addMask('address_subnet' . $counter, $address_subnet)->setWidth(4)->setPattern('[a-zA-Z0-9\-\.\:]+'); + ))->addMask('address_subnet' . $counter, $address_subnet)->setWidth(4)->setPattern($pattern_str[$tab]); $group->add(new Form_Input( 'detail' . $counter, @@ -757,10 +788,16 @@ events.push(function() { var labelstr = <?=json_encode($label_str);?>; $('.repeatable:first').find('label').text(labelstr[tab]); + // 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]); + } + // Hide and disable rows other than the first hideRowsAfter(1, (tab == 'urltable') || (tab == 'urltable_ports')); - // The add button and delete buttons must not show on URL Table IP or URL table ports + // The add button and delete buttons must not show on URL Table IP or URL table ports if ((tab == 'urltable') || (tab == 'urltable_ports')) { hideClass('addbtn', true); $('[id^=deleterow]').hide(); diff --git a/src/usr/local/www/firewall_aliases_import.php b/src/usr/local/www/firewall_aliases_import.php index 7260412..094211a 100755 --- a/src/usr/local/www/firewall_aliases_import.php +++ b/src/usr/local/www/firewall_aliases_import.php @@ -95,7 +95,7 @@ if ($_POST['aliasimport'] != "") { do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); if (is_validaliasname($_POST['name']) == false) { - $input_errors[] = gettext("The alias name may only consist of the characters") . " a-z, A-Z, 0-9, _."; + $input_errors[] = sprintf(gettext("The alias name may only consist of the characters %s"), "a-z, A-Z, 0-9, _."); } /* check for name duplicates */ @@ -107,7 +107,7 @@ if ($_POST['aliasimport'] != "") { /* Check for reserved keyword names */ foreach ($reserved_keywords as $rk) { if ($rk == $_POST['name']) { - $input_errors[] = sprintf(gettext("Cannot use a reserved keyword as alias name %s"), $rk); + $input_errors[] = sprintf(gettext("Cannot use a reserved keyword as an alias name: %s"), $rk); } } diff --git a/src/usr/local/www/firewall_nat.php b/src/usr/local/www/firewall_nat.php index 4a6f2f2..ec7a708 100644 --- a/src/usr/local/www/firewall_nat.php +++ b/src/usr/local/www/firewall_nat.php @@ -239,7 +239,7 @@ foreach ($a_nat as $natent): <?php elseif (!empty($natent['associated-rule-id'])): ?> - <i class="fa fa-random" title="<?=gettext("Firewall rule ID ")?><?=htmlspecialchars($natent['associated-rule-id'])?> . <?=gettext('is managed by this rule')?>"></i> + <i class="fa fa-random" title="<?=sprintf(gettext("Firewall rule ID %s is managed by this rule"), htmlspecialchars($natent['associated-rule-id']))?>"></i> <?php endif; ?> @@ -266,7 +266,7 @@ foreach ($a_nat as $natent): <?php if (isset($alias['src'])): ?> - <a href="/firewall_aliases_edit.php?id=<?=$alias['src']?>" data-toggle="popover" data-trigger="hover focus" title="Alias details" data-content="<?=alias_info_popup($alias['src'])?>" data-html="true"> + <a href="/firewall_aliases_edit.php?id=<?=$alias['src']?>" data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Alias details')?>" data-content="<?=alias_info_popup($alias['src'])?>" data-html="true"> <?php endif; ?> @@ -283,7 +283,7 @@ foreach ($a_nat as $natent): <?php if (isset($alias['srcport'])): ?> - <a href="/firewall_aliases_edit.php?id=<?=$alias['srcport']?>" data-toggle="popover" data-trigger="hover focus" title="Alias details" data-content="<?=alias_info_popup($alias['srcport'])?>" data-html="true"> + <a href="/firewall_aliases_edit.php?id=<?=$alias['srcport']?>" data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Alias details')?>" data-content="<?=alias_info_popup($alias['srcport'])?>" data-html="true"> <?php endif; ?> @@ -301,7 +301,7 @@ foreach ($a_nat as $natent): <?php if (isset($alias['dst'])): ?> - <a href="/firewall_aliases_edit.php?id=<?=$alias['dst']?>" data-toggle="popover" data-trigger="hover focus" title="Alias details" data-content="<?=alias_info_popup($alias['dst'])?>" data-html="true"> + <a href="/firewall_aliases_edit.php?id=<?=$alias['dst']?>" data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Alias details')?>" data-content="<?=alias_info_popup($alias['dst'])?>" data-html="true"> <?php endif; ?> @@ -318,7 +318,7 @@ foreach ($a_nat as $natent): <?php if (isset($alias['dstport'])): ?> - <a href="/firewall_aliases_edit.php?id=<?=$alias['dstport']?>" data-toggle="popover" data-trigger="hover focus" title="Alias details" data-content="<?=alias_info_popup($alias['dstport'])?>" data-html="true"> + <a href="/firewall_aliases_edit.php?id=<?=$alias['dstport']?>" data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Alias details')?>" data-content="<?=alias_info_popup($alias['dstport'])?>" data-html="true"> <?php endif; ?> diff --git a/src/usr/local/www/firewall_nat_1to1.php b/src/usr/local/www/firewall_nat_1to1.php index 4be8a9e..f336433 100644 --- a/src/usr/local/www/firewall_nat_1to1.php +++ b/src/usr/local/www/firewall_nat_1to1.php @@ -75,7 +75,7 @@ if (!is_array($config['nat']['onetoone'])) { $a_1to1 = &$config['nat']['onetoone']; /* update rule order, POST[rule] is an array of ordered IDs */ -if ($_POST['order-store']) { +if (array_key_exists('order-store', $_POST)) { if (is_array($_POST['rule']) && !empty($_POST['rule'])) { $a_1to1_new = array(); @@ -144,7 +144,7 @@ if (isset($_POST['del_x'])) { } else { $a_1to1[$_GET['id']]['disabled'] = true; } - if (write_config("Firewall: NAT: Outbound, enable/disable NAT rule")) { + if (write_config(gettext("Firewall: NAT: 1 to 1, enable/disable NAT rule"))) { mark_subsystem_dirty('natconf'); } header("Location: firewall_nat_1to1.php"); @@ -269,11 +269,11 @@ display_top_tabs($tab_array); <i class="fa fa-plus icon-embed-btn"></i> <?=gettext('Add')?> </a> - <button name="del_x" type="submit" class="btn btn-danger btn-sm" value="<?=gettext("Delete selected rule"); ?>"> + <button name="del_x" type="submit" class="btn btn-danger btn-sm" title="<?=gettext('Delete selected mappings')?>"> <i class="fa fa-trash icon-embed-btn"></i> <?=gettext("Delete"); ?> </button> - <button type="submit" id="order-store" name="order-store" class="btn btn-primary btn-sm" value="Save changes" disabled> + <button type="submit" id="order-store" name="order-store" class="btn btn-primary btn-sm" disabled title="<?=gettext('Save rule order')?>"> <i class="fa fa-save icon-embed-btn"></i> <?=gettext("Save")?> </button> diff --git a/src/usr/local/www/firewall_nat_1to1_edit.php b/src/usr/local/www/firewall_nat_1to1_edit.php index 4d5c865..4b6178f 100644 --- a/src/usr/local/www/firewall_nat_1to1_edit.php +++ b/src/usr/local/www/firewall_nat_1to1_edit.php @@ -284,16 +284,16 @@ include("head.inc"); function build_srctype_list() { global $pconfig, $ifdisp; - $list = array('any' => 'Any', 'single' => 'Single host or alias', 'network' => 'Network'); + $list = array('any' => gettext('Any'), 'single' => gettext('Single host or alias'), 'network' => gettext('Network')); $sel = is_specialnet($pconfig['src']); if (have_ruleint_access("pppoe")) { - $list['pppoe'] = 'PPPoE clients'; + $list['pppoe'] = gettext('PPPoE clients'); } if (have_ruleint_access("l2tp")) { - $list['l2tp'] = 'L2TP clients'; + $list['l2tp'] = gettext('L2TP clients'); } foreach ($ifdisp as $ifent => $ifdesc) { @@ -326,14 +326,14 @@ function build_dsttype_list() { global $pconfig, $config, $ifdisp; $sel = is_specialnet($pconfig['dst']); - $list = array('any' => 'Any', 'single' => 'Single host or alias', 'network' => 'Network', '(self)' => 'This Firewall (self)'); + $list = array('any' => gettext('Any'), 'single' => gettext('Single host or alias'), 'network' => gettext('Network'), '(self)' => gettext('This Firewall (self)')); if (have_ruleint_access("pppoe")) { - $list['pppoe'] = 'PPPoE clients'; + $list['pppoe'] = gettext('PPPoE clients'); } if (have_ruleint_access("l2tp")) { - $list['l2tp'] = 'L2TP clients'; + $list['l2tp'] = gettext('L2TP clients'); } foreach ($ifdisp as $if => $ifdesc) { @@ -423,22 +423,22 @@ foreach ($iflist as $if => $ifdesc) { if ($config['l2tp']['mode'] == "server") { if (have_ruleint_access("l2tp")) { - $interfaces['l2tp'] = "L2TP VPN"; + $interfaces['l2tp'] = gettext("L2TP VPN"); } } if (is_pppoe_server_enabled() && have_ruleint_access("pppoe")) { - $interfaces['pppoe'] = "PPPoE Server"; + $interfaces['pppoe'] = gettext("PPPoE Server"); } /* add ipsec interfaces */ if (ipsec_enabled() && have_ruleint_access("enc0")) { - $interfaces["enc0"] = "IPsec"; + $interfaces["enc0"] = gettext("IPsec"); } /* add openvpn/tun interfaces */ if ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"]) { - $interfaces["openvpn"] = "OpenVPN"; + $interfaces["openvpn"] = gettext("OpenVPN"); } $section->addInput(new Form_Select( @@ -520,9 +520,9 @@ $section->addInput(new Form_Select( 'NAT reflection', $pconfig['natreflection'], array( - 'default' => 'Use system default', - 'enable' => 'Enable', - 'disable' => 'Disable' + 'default' => gettext('Use system default'), + 'enable' => gettext('Enable'), + 'disable' => gettext('Disable') ) )); diff --git a/src/usr/local/www/firewall_nat_edit.php b/src/usr/local/www/firewall_nat_edit.php index d64c308..65316f0 100644 --- a/src/usr/local/www/firewall_nat_edit.php +++ b/src/usr/local/www/firewall_nat_edit.php @@ -531,16 +531,16 @@ if ($_POST) { function build_srctype_list() { global $pconfig, $ifdisp, $config; - $list = array('any' => 'Any', 'single' => 'Single host or alias', 'network' => 'Network'); + $list = array('any' => gettext('Any'), 'single' => gettext('Single host or alias'), 'network' => gettext('Network')); $sel = is_specialnet($pconfig['src']); if (have_ruleint_access("pppoe")) { - $list['pppoe'] = 'PPPoE clients'; + $list['pppoe'] = gettext('PPPoE clients'); } if (have_ruleint_access("l2tp")) { - $list['l2tp'] = 'L2TP clients'; + $list['l2tp'] = gettext('L2TP clients'); } foreach ($ifdisp as $ifent => $ifdesc) { @@ -577,14 +577,14 @@ function build_dsttype_list() { global $pconfig, $config, $ifdisp; $sel = is_specialnet($pconfig['dst']); - $list = array('any' => 'Any', 'single' => 'Single host or alias', 'network' => 'Network', '(self)' => 'This Firewall (self)'); + $list = array('any' => gettext('Any'), 'single' => gettext('Single host or alias'), 'network' => gettext('Network'), '(self)' => gettext('This Firewall (self)')); if (have_ruleint_access("pppoe")) { - $list['pppoe'] = 'PPPoE clients'; + $list['pppoe'] = gettext('PPPoE clients'); } if (have_ruleint_access("l2tp")) { - $list['l2tp'] = 'L2TP clients'; + $list['l2tp'] = gettext('L2TP clients'); } foreach ($ifdisp as $if => $ifdesc) { @@ -681,22 +681,22 @@ foreach ($iflist as $if => $ifdesc) { if ($config['l2tp']['mode'] == "server") { if (have_ruleint_access("l2tp")) { - $interfaces['l2tp'] = "L2TP VPN"; + $interfaces['l2tp'] = gettext("L2TP VPN"); } } if (is_pppoe_server_enabled() && have_ruleint_access("pppoe")) { - $interfaces['pppoe'] = "PPPoE Server"; + $interfaces['pppoe'] = gettext("PPPoE Server"); } /* add ipsec interfaces */ if (ipsec_enabled() && have_ruleint_access("enc0")) { - $interfaces["enc0"] = "IPsec"; + $interfaces["enc0"] = gettext("IPsec"); } /* add openvpn/tun interfaces */ if ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"]) { - $interfaces["openvpn"] = "OpenVPN"; + $interfaces["openvpn"] = gettext("OpenVPN"); } $section->addInput(new Form_Select( @@ -752,7 +752,7 @@ $group->add(new Form_IpAddress( $section->add($group); -$portlist = array("" => 'Other', 'any' => 'Any'); +$portlist = array("" => gettext('Other'), 'any' => gettext('Any')); foreach ($wkports as $wkport => $wkportdesc) { $portlist[$wkport] = $wkportdesc; @@ -906,24 +906,24 @@ $section->addInput(new Form_Select( 'NAT reflection', $pconfig['natreflection'], array( - 'default' => 'Use system default', - 'enable' => 'Enable (NAT + Proxy)', - 'purenat' => 'Enable (Pure NAT)', - 'disable' => 'Disable' + 'default' => gettext('Use system default'), + 'enable' => gettext('Enable (NAT + Proxy)'), + 'purenat' => gettext('Enable (Pure NAT)'), + 'disable' => gettext('Disable') ) )); if (isset($id) && $a_nat[$id] && (!isset($_GET['dup']) || !is_numericint($_GET['dup']))) { $hlpstr = ''; - $rulelist = array('' => 'None', 'pass' => 'Pass'); + $rulelist = array('' => gettext('None'), 'pass' => gettext('Pass')); if (is_array($config['filter']['rule'])) { filter_rules_sort(); foreach ($config['filter']['rule'] as $filter_id => $filter_rule) { if (isset($filter_rule['associated-rule-id'])) { - $rulelist[$filter_rule['associated-rule-id']] = 'Rule ' . $filter_rule['descr']; + $rulelist[$filter_rule['associated-rule-id']] = sprintf(gettext('Rule %s'), $filter_rule['descr']); if ($filter_rule['associated-rule-id'] == $pconfig['associated-rule-id']) { $hlpstr = '<a href="firewall_rules_edit.php?id=' . $filter_id . '">' . gettext("View the filter rule") . '</a><br />'; @@ -933,7 +933,7 @@ if (isset($id) && $a_nat[$id] && (!isset($_GET['dup']) || !is_numericint($_GET[' } if (isset($pconfig['associated-rule-id'])) { - $rulelist['new'] = 'Create new associated filter rule'; + $rulelist['new'] = gettext('Create new associated filter rule'); } $section->addInput(new Form_Select( @@ -949,9 +949,9 @@ if (isset($id) && $a_nat[$id] && (!isset($_GET['dup']) || !is_numericint($_GET[' 'add-associated', array( '' => 'None', - 'add-associated' => 'Add associated filter rule', - 'add-unassociated' => 'Add unassociated filter rule', - 'pass' => 'Pass' + 'add-associated' => gettext('Add associated filter rule'), + 'add-unassociated' => gettext('Add unassociated filter rule'), + 'pass' => gettext('Pass') ) ))->setHelp('The "pass" selection does not work properly with Multi-WAN. It will only work on an interface containing the default gateway.'); } diff --git a/src/usr/local/www/firewall_rules.php b/src/usr/local/www/firewall_rules.php index ae65db4..f416353 100644 --- a/src/usr/local/www/firewall_rules.php +++ b/src/usr/local/www/firewall_rules.php @@ -276,7 +276,7 @@ display_top_tabs($tab_array); <div class="panel panel-default"> <div class="panel-heading"><h2 class="panel-title"><?=gettext("Rules (Drag to change order)")?></h2></div> <div id="mainarea" class="table-responsive panel-body"> - <table class="table table-hover table-striped table-condensed"> + <table id="ruletable" class="table table-hover table-striped table-condensed"> <thead> <tr> <th><!-- checkbox --></th> @@ -528,7 +528,7 @@ for ($i = 0; isset($a_filter[$i]); $i++): $image = ""; if (!isset($filterent['disabled'])) { if ($schedstatus) { - if ($iconfn == "block" || $iconfn == "reject") { + if ($filterent['type'] == "block" || $filterent['type'] == "reject") { $image = "times-circle"; $dispcolor = "text-danger"; $alttext = gettext("Traffic matching this rule is currently being denied"); @@ -539,13 +539,13 @@ for ($i = 0; isset($a_filter[$i]); $i++): } $printicon = true; } else if ($filterent['sched']) { - if ($iconfn == "block" || $iconfn == "reject") { + if ($filterent['type'] == "block" || $filterent['type'] == "reject") { $image = "times-circle"; } else { - $image = "times-circle"; + $image = "play-circle"; } $alttext = gettext("This rule is not currently active because its period has expired"); - $dispcolor = "text-danger"; + $dispcolor = "text-warning"; $printicon = true; } } @@ -692,6 +692,10 @@ for ($i = 0; isset($a_filter[$i]); $i++): <i class="fa fa-save icon-embed-btn"></i> <?=gettext("Save")?> </button> + <button type="submit" id="addsep" name="addsep" class="btn btn-sm btn-warning" title="<?=gettext('Add separator')?>"> + <i class="fa fa-plus icon-embed-btn"></i> + <?=gettext("Separator")?> + </button> </nav> </form> @@ -743,6 +747,35 @@ events.push(function() { $('#order-store').click(function () { $('[id^=frc]').prop('checked', true); }); + + // Separator bar stuff + $("#addsep").prop('type' ,'button'); + + $("#addsep").click(function() { + alert("This feature is not yet complete. (Nothing is saved)\nIncluded for review only."); + $('#ruletable > tbody:last').append('<tr>' + + '<td bgcolor="#cce5ff" colspan="10"><input id="newsep" placeholder="<?=gettext("Enter a description, Save, then drag to final location.")?>" class="col-md-12" type="text"></input></td>' + + '<td bgcolor="#cce5ff" colspan="2"><button class="btn btn-default btn-sm" id="btnnewsep"><?=gettext("Save")?></button></td>' + + '</tr>'); + + $("#btnnewsep").prop('type' ,'button'); + + $("#btnnewsep").click(function() { + var septext = $('#newsep').val(); + $('#ruletable > tbody:last >tr:last').remove(); + $('#ruletable > tbody:last').append('<tr class="ui-sortable-handle">' + + '<td bgcolor="#cce5ff" colspan="11">' + '<font color="#002699">' + septext + '</font></td>' + + '<td bgcolor="#cce5ff"><a href="#"><i class="fa fa-trash"></i></a></td>' + + '</tr>'); + }); + }); + + $(function(){ + $('table').on('click','tr a',function(e){ + e.preventDefault(); + $(this).parents('tr').remove(); + }); + }); }); //]]> </script> diff --git a/src/usr/local/www/firewall_rules_edit.php b/src/usr/local/www/firewall_rules_edit.php index 3918866..b46a1d8 100644 --- a/src/usr/local/www/firewall_rules_edit.php +++ b/src/usr/local/www/firewall_rules_edit.php @@ -645,22 +645,22 @@ if ($_POST) { if ($_POST['statetype'] == "none") { if (!empty($_POST['max'])) { - $input_errors[] = gettext("You cannot specify the maximum state entries (advanced option) if statetype is none and no L7 container is selected."); + $input_errors[] = gettext("You cannot specify the maximum state entries (advanced option) if statetype is none."); } if (!empty($_POST['max-src-nodes'])) { - $input_errors[] = gettext("You cannot specify the maximum number of unique source hosts (advanced option) if statetype is none and no L7 container is selected."); + $input_errors[] = gettext("You cannot specify the maximum number of unique source hosts (advanced option) if statetype is none."); } if (!empty($_POST['max-src-conn'])) { - $input_errors[] = gettext("You cannot specify the maximum number of established connections per host (advanced option) if statetype is none and no L7 container is selected."); + $input_errors[] = gettext("You cannot specify the maximum number of established connections per host (advanced option) if statetype is none."); } if (!empty($_POST['max-src-states'])) { - $input_errors[] = gettext("You cannot specify the maximum state entries per host (advanced option) if statetype is none and no L7 container is selected."); + $input_errors[] = gettext("You cannot specify the maximum state entries per host (advanced option) if statetype is none."); } if (!empty($_POST['max-src-conn-rate']) || !empty($_POST['max-src-conn-rates'])) { - $input_errors[] = gettext("You cannot specify the maximum new connections per host / per second(s) (advanced option) if statetype is none and no L7 container is selected."); + $input_errors[] = gettext("You cannot specify the maximum new connections per host / per second(s) (advanced option) if statetype is none."); } if (!empty($_POST['statetimeout'])) { - $input_errors[] = gettext("You cannot specify the state timeout (advanced option) if statetype is none and no L7 container is selected."); + $input_errors[] = gettext("You cannot specify the state timeout (advanced option) if statetype is none."); } } diff --git a/src/usr/local/www/firewall_schedule_edit.php b/src/usr/local/www/firewall_schedule_edit.php index 31238d0..5a867b2 100644 --- a/src/usr/local/www/firewall_schedule_edit.php +++ b/src/usr/local/www/firewall_schedule_edit.php @@ -130,7 +130,7 @@ if ($_POST) { $input_errors[] = gettext("Reserved word used for schedule name."); } else { if (is_validaliasname($_POST['name']) == false) { - $input_errors[] = gettext("The schedule name may only consist of the characters a-z, A-Z, 0-9"); + $input_errors[] = gettext("The schedule name must be less than 32 characters long, may not consist of only numbers, may not consist of only underscores, and may only contain the following characters:") . ' a-z, A-Z, 0-9, _'; } } @@ -395,7 +395,7 @@ $input = new Form_Input( $pconfig['name'] ); -$input->setHelp((is_schedule_inuse($pconfig['name']) != true) ? 'The name of the alias may only consist of the characters a-z, A-Z and 0-9': +$input->setHelp((is_schedule_inuse($pconfig['name']) != true) ? 'The name of the schedule may only consist of the characters "a-z, A-Z, 0-9 and _".': 'This schedule is in use so the name may not be modified!'); if (is_schedule_inuse($pconfig['name']) == true) { @@ -436,7 +436,7 @@ $group->add(new Form_Select( 'starttimemin', null, null, - array('00' => '00', '15' => '15', '30' => '30', '59' => '59') + array('00' => '00', '15' => '15', '30' => '30', '45' => '45', '59' => '59') ))->setHelp('Start Mins'); $group->add(new Form_Select( @@ -450,7 +450,7 @@ $group->add(new Form_Select( 'stoptimemin', null, '59', - array('00' => '00', '15' => '15', '30' => '30', '59' => '59') + array('00' => '00', '15' => '15', '30' => '30', '45' => '45', '59' => '59') ))->setHelp('Stop Mins'); $group->setHelp('Select the time range for the day(s) selected on the Month(s) above. A full day is 0:00-23:59.'); diff --git a/src/usr/local/www/firewall_virtual_ip_edit.php b/src/usr/local/www/firewall_virtual_ip_edit.php index 9556b53..9df1f98 100644 --- a/src/usr/local/www/firewall_virtual_ip_edit.php +++ b/src/usr/local/www/firewall_virtual_ip_edit.php @@ -176,7 +176,7 @@ if ($_POST) { /* ipalias and carp should not use network or broadcast address */ if ($_POST['mode'] == "ipalias" || $_POST['mode'] == "carp") { - if (is_ipaddrv4($_POST['subnet']) && $_POST['subnet_bits'] != "32") { + if (is_ipaddrv4($_POST['subnet']) && $_POST['subnet_bits'] != "32" && $_POST['subnet_bits'] != "31") { $network_addr = gen_subnet($_POST['subnet'], $_POST['subnet_bits']); $broadcast_addr = gen_subnet_max($_POST['subnet'], $_POST['subnet_bits']); } else if (is_ipaddrv6($_POST['subnet']) && $_POST['subnet_bits'] != "128") { diff --git a/src/usr/local/www/guiconfig.inc b/src/usr/local/www/guiconfig.inc index 170215a..b97ae0f 100644 --- a/src/usr/local/www/guiconfig.inc +++ b/src/usr/local/www/guiconfig.inc @@ -560,16 +560,21 @@ function dump_clog_no_table($logfile, $tail, $withorig = true, $grepfor = "", $g $specific_log = basename($logfile, '.log') . '_settings'; if ($config['syslog'][$specific_log]['cronorder'] == 'forward') $sor = ""; if ($config['syslog'][$specific_log]['cronorder'] == 'reverse') $sor = "-r"; - $logarr = ""; + $logarr = array(); $grepline = " "; if (is_array($grepfor)) { - $grepline .= " | /usr/bin/egrep " . escapeshellarg(implode("|", $grepfor)); + $invert = ''; + if ((strpos($grepfor[0], '!') === 0)) { + $grepfor[0] = substr($grepfor[0], 1); + $invert = '-v'; + } + $grepline .= " | /usr/bin/egrep {$invert} " . escapeshellarg(implode("|", $grepfor)); } if (is_array($grepinvert)) { $grepline .= " | /usr/bin/egrep -v " . escapeshellarg(implode("|", $grepinvert)); } if (is_dir($logfile)) { - $logarr = array("File $logfile is a directory."); + $logarr = array("File {$logfile} is a directory."); } elseif (file_exists($logfile) && filesize($logfile) == 0) { $logarr = array("Log file started."); } else { @@ -606,16 +611,21 @@ function dump_clog($logfile, $tail, $withorig = true, $grepfor = "", $grepinvert $specific_log = basename($logfile, '.log') . '_settings'; if ($config['syslog'][$specific_log]['cronorder'] == 'forward') $sor = ""; if ($config['syslog'][$specific_log]['cronorder'] == 'reverse') $sor = "-r"; - $logarr = ""; + $logarr = array(); $grepline = " "; if (is_array($grepfor)) { - $grepline .= " | /usr/bin/egrep " . escapeshellarg(implode("|", $grepfor)); + $invert = ''; + if ((strpos($grepfor[0], '!') === 0)) { + $grepfor[0] = substr($grepfor[0], 1); + $invert = '-v'; + } + $grepline .= " | /usr/bin/egrep {$invert} " . escapeshellarg(implode("|", $grepfor)); } if (is_array($grepinvert)) { $grepline .= " | /usr/bin/egrep -v " . escapeshellarg(implode("|", $grepinvert)); } if (is_dir($logfile)) { - $logarr = array("File $logfile is a directory."); + $logarr = array("File {$logfile} is a directory."); } elseif (file_exists($logfile) && filesize($logfile) == 0) { $logarr = array("Log file started."); } else { @@ -651,7 +661,7 @@ function return_clog($logfile, $tail, $withorig = true, $grepfor = "", $grepinve $specific_log = basename($logfile, '.log') . '_settings'; if (($config['syslog'][$specific_log]['cronorder'] == 'forward') && !$grepreverse) $sor = ""; if (($config['syslog'][$specific_log]['cronorder'] == 'reverse') || $grepreverse) $sor = "-r"; - $logarr = ""; + $logarr = array(); $grepline = " "; if (is_array($grepfor)) { $grepline .= " | /usr/bin/egrep " . escapeshellarg(implode("|", $grepfor)); diff --git a/src/usr/local/www/index.php b/src/usr/local/www/index.php index 3d7a0d0..c9b60a8 100644 --- a/src/usr/local/www/index.php +++ b/src/usr/local/www/index.php @@ -120,15 +120,15 @@ $dirhandle = opendir($directory); $filename = ""; while (false !== ($filename = readdir($dirhandle))) { + if (!stristr($filename, ".inc")) { + continue; + } $phpincludefiles[] = $filename; } ## Include each widget include file. ## These define vars that specify the widget title and title link. foreach ($phpincludefiles as $includename) { - if (!stristr($includename, ".inc")) { - continue; - } if (file_exists($directory . $includename)) { include($directory . $includename); } @@ -140,7 +140,7 @@ foreach (glob("/usr/local/www/widgets/widgets/*.widget.php") as $file) { // Get the widget title that should be in a var defined in the widget's inc file. $widgettitle = ${$name . '_title'}; - if ((strlen($widgettitle) == 0)) { + if (empty(trim($widgettitle))) { // Fall back to constructing a title from the file name of the widget. $widgettitle = ucwords(str_replace('_', ' ', $name)); } @@ -277,7 +277,7 @@ if ($config['widgets'] && $config['widgets']['sequence'] != "") { // Get the widget title that should be in a var defined in the widget's inc file. $widgettitle = ${$file . '_title'}; - if ((strlen($widgettitle) == 0)) { + if (empty(trim($widgettitle))) { // Fall back to constructing a title from the file name of the widget. $widgettitle = ucwords(str_replace('_', ' ', $file)); } @@ -328,13 +328,8 @@ pfSense_handle_custom_code("/usr/local/pkg/dashboard/pre_dashboard"); <?php // Build the Available Widgets table using a sorted copy of the $widgets array -// Can't just ksort because the "Firewall Logs" widget has a key of "logs" $available = $widgets; -function widgetcompare($w1, $w2) { - return ($w1['name'] < $w2['name']) ? -1:1; -} - -usort($available, 'widgetcompare'); +uasort($available, function($a, $b){ return strcasecmp($a['name'], $b['name']); }); foreach ($available as $widgetname => $widgetconfig): if ($widgetconfig['display'] == 'none'): diff --git a/src/usr/local/www/interfaces.php b/src/usr/local/www/interfaces.php index 0d82dd5..84824be 100644 --- a/src/usr/local/www/interfaces.php +++ b/src/usr/local/www/interfaces.php @@ -283,7 +283,7 @@ $pconfig['enable'] = isset($wancfg['enable']); if (is_array($config['aliases']['alias'])) { foreach ($config['aliases']['alias'] as $alias) { if ($alias['name'] == $wancfg['descr']) { - $input_errors[] = sprintf(gettext("Sorry, an alias with the name %s already exists."), $wancfg['descr']); + $input_errors[] = sprintf(gettext("Sorry, an alias with the name %s already exists. Interfaces cannot have the same name as an alias."), $wancfg['descr']); } } } @@ -540,6 +540,16 @@ if ($_POST['apply']) { 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']); + } + } + } + if (is_numeric($_POST['descr'])) { $input_errors[] = gettext("The interface description cannot contain only numbers."); } @@ -1630,7 +1640,7 @@ foreach ($mediaopts as $mediaopt) { } } -$pgtitle = array(gettext("Interfaces"), $pconfig['descr']); +$pgtitle = array(gettext("Interfaces"), $wancfg['descr']); $shortcut_section = "interfaces"; $types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP")); diff --git a/src/usr/local/www/jquery/pfSenseHelpers.js b/src/usr/local/www/jquery/pfSenseHelpers.js index d9a599f..476cc4f 100644 --- a/src/usr/local/www/jquery/pfSenseHelpers.js +++ b/src/usr/local/www/jquery/pfSenseHelpers.js @@ -274,10 +274,21 @@ function renumber() { }); } -function delete_row(row) { - $('#' + row).parent('div').parent('div').remove(); +function delete_row(rowDelBtn) { + var rowLabel; + + // If we are deleting row zero, we need to save/restore the label + if (rowDelBtn == "deleterow0") { + rowLabel = $('#' + rowDelBtn).parent('div').parent('div').find('label').text(); + } + + $('#' + rowDelBtn).parent('div').parent('div').remove(); renumber(); checkLastRow(); + + if (rowDelBtn == "deleterow0") { + $('#' + rowDelBtn).parent('div').parent('div').find('label').text(rowLabel); + } } function checkLastRow() { diff --git a/src/usr/local/www/pkg_edit.php b/src/usr/local/www/pkg_edit.php index e6e089a..5dac18f 100644 --- a/src/usr/local/www/pkg_edit.php +++ b/src/usr/local/www/pkg_edit.php @@ -900,6 +900,9 @@ foreach ($pkg['fields']['field'] as $pkga) { eval("\$pkg_source_txt = &$source_url;"); #check if show disable option is present on xml + if (!is_array($pkg_source_txt)) { + $pkg_source_txt = array(); + } if (isset($pkga['show_disable_value'])) { array_push($pkg_source_txt, array(($pkga['source_name']? $pkga['source_name'] : $pkga['name'])=> $pkga['show_disable_value'], ($pkga['source_value']? $pkga['source_value'] : $pkga['value'])=> $pkga['show_disable_value'])); diff --git a/src/usr/local/www/services_captiveportal.php b/src/usr/local/www/services_captiveportal.php index ce4c96c..663e7c6 100644 --- a/src/usr/local/www/services_captiveportal.php +++ b/src/usr/local/www/services_captiveportal.php @@ -1083,10 +1083,10 @@ list($host) = explode(":", $_SERVER['HTTP_HOST']); $zoneid = $pconfig['zoneid'] ? $pconfig['zoneid'] : 8000; if ($pconfig['httpslogin_enable']) { $port = $pconfig['listenporthttps'] ? $pconfig['listenporthttps'] : ($zoneid + 8001); - $href = "https://{$host}:{$port}"; + $href = "https://{$host}:{$port}/?zone={$cpzone}"; } else { $port = $pconfig['listenporthttp'] ? $pconfig['listenporthttp'] : ($zoneid + 8000); - $href = "http://{$host}:{$port}"; + $href = "http://{$host}:{$port}/?zone={$cpzone}"; } if ($pconfig['page']['htmltext']) { diff --git a/src/usr/local/www/services_dhcp.php b/src/usr/local/www/services_dhcp.php index d13305c..4513d94 100644 --- a/src/usr/local/www/services_dhcp.php +++ b/src/usr/local/www/services_dhcp.php @@ -937,7 +937,7 @@ if (!is_numeric($pool) && !($act == "newpool")) { 'failover_peerip', 'Failover peer IP', $pconfig['failover_peerip'] - ))->setHelp('Leave blank to disable. Enter the interface IP address of the other machine. Machines must be using CARP.' . + ))->setHelp('Leave blank to disable. Enter the interface IP address of the other machine. Machines must be using CARP. ' . 'Interface\'s advskew determines whether the DHCPd process is Primary or Secondary. Ensure one machine\'s advskew < 20 (and the other is > 20).'); } 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 dbcedf8..ffed30f 100644 --- a/src/usr/local/www/widgets/widgets/traffic_graphs.widget.php +++ b/src/usr/local/www/widgets/widgets/traffic_graphs.widget.php @@ -167,7 +167,7 @@ foreach ($ifdescrs as $ifname => $ifdescr): <?php foreach ($ifdescrs as $ifname => $ifdescr): ?> <label> <input type="checkbox" name="shown[<?= $ifname?>]" value="<?=$ifname?>" <?= ($shown[$ifname]) ? "checked":""?> /> - <?=$ifname?> + <?=$ifdescr?> </label> <?php endforeach; ?> </div> |