Merge branch 'master' into multiple-copies-of-widgets-1

This commit is contained in:
Phil Davis 2017-03-20 23:10:45 +05:45 committed by GitHub
commit 65ff7b82d2
45 changed files with 510 additions and 397 deletions

View File

@ -1583,6 +1583,7 @@ function get_user_settings($username) {
$settings['webgui']['dashboardavailablewidgetspanel'] = isset($config['system']['webgui']['dashboardavailablewidgetspanel']);
$settings['webgui']['webguifixedmenu'] = isset($config['system']['webgui']['webguifixedmenu']);
$settings['webgui']['webguileftcolumnhyper'] = isset($config['system']['webgui']['webguileftcolumnhyper']);
$settings['webgui']['disablealiaspopupdetail'] = isset($config['system']['webgui']['disablealiaspopupdetail']);
$settings['webgui']['systemlogsfilterpanel'] = isset($config['system']['webgui']['systemlogsfilterpanel']);
$settings['webgui']['systemlogsmanagelogpanel'] = isset($config['system']['webgui']['systemlogsmanagelogpanel']);
$settings['webgui']['statusmonitoringsettingspanel'] = isset($config['system']['webgui']['statusmonitoringsettingspanel']);
@ -1606,6 +1607,7 @@ function get_user_settings($username) {
$settings['webgui']['dashboardavailablewidgetspanel'] = isset($user['dashboardavailablewidgetspanel']);
$settings['webgui']['webguifixedmenu'] = isset($user['webguifixedmenu']);
$settings['webgui']['webguileftcolumnhyper'] = isset($user['webguileftcolumnhyper']);
$settings['webgui']['disablealiaspopupdetail'] = isset($user['disablealiaspopupdetail']);
$settings['webgui']['systemlogsfilterpanel'] = isset($user['systemlogsfilterpanel']);
$settings['webgui']['systemlogsmanagelogpanel'] = isset($user['systemlogsmanagelogpanel']);
$settings['webgui']['statusmonitoringsettingspanel'] = isset($user['statusmonitoringsettingspanel']);

View File

@ -2793,7 +2793,9 @@ function filter_generate_user_rule($rule) {
if ($rule['protocol'] == "icmp" && $rule['icmptype'] && ($rule['icmptype'] != 'any')) {
$icmptype_key = ($rule['ipprotocol'] == 'inet6' ? 'icmp6-type' : 'icmp-type');
$icmptype_text = (strpos($rule['icmptype'], ",") === false ? $rule['icmptype'] : '{ ' . $rule['icmptype'] . ' }');
// XXX: Bug #7372
$icmptype_text = replace_element_in_list($rule['icmptype'], ',', 'skip', '39');
$icmptype_text = (strpos($icmptype_text, ",") === false ? $icmptype_text : '{ ' . $icmptype_text . ' }');
$aline[$icmptype_key] = "{$icmptype_key} {$icmptype_text} ";
}

View File

@ -37,6 +37,7 @@ define('DMYPWD', "********");
global $g;
$g = array(
"base_packages" => "siproxd",
"event_address" => "unix:///var/run/check_reload_status",
"factory_shipped_username" => "admin",
"factory_shipped_password" => "pfsense",
@ -70,7 +71,7 @@ $g = array(
"disablecrashreporter" => false,
"crashreporterurl" => "https://crashreporter.pfsense.org/crash_reporter.php",
"debug" => false,
"latest_config" => "16.2",
"latest_config" => "16.3",
"minimum_ram_warning" => "101",
"minimum_ram_warning_text" => "128 MB",
"wan_interface_name" => "wan",

View File

@ -630,6 +630,9 @@ function return_gateways_array($disabled = false, $localhost = false, $inactive
}
}
unset($gateway);
//Sort the array by GW name before moving on.
ksort($gateways_arr, SORT_STRING | SORT_FLAG_CASE);
/* Loop through all interfaces with a gateway and add it to a array */
if ($disabled == false) {

View File

@ -320,6 +320,25 @@ function gen_webguileftcolumnhyper_field(&$section, $value) {
))->setHelp('If selected, clicking a label in the left column will select/toggle the first item of the group.');
}
/****f* pfsense-utils/gen_disablealiaspopupdetail_field
* NAME
* gen_disablealiaspopupdetail_field
* INPUTS
* Pointer to section object
* Initial value for the field
* RESULT
* no return value, section object is updated
******/
function gen_disablealiaspopupdetail_field(&$section, $value) {
$section->addInput(new Form_Checkbox(
'disablealiaspopupdetail',
'Alias Popups',
'Disable details in alias popups',
$value
))->setHelp('If selected, the details in alias popups will not be shown, just the alias description (e.g. in Firewall Rules).');
}
/****f* pfsense-utils/gen_pagenamefirst_field
* NAME
* gen_pagenamefirst_field
@ -363,6 +382,7 @@ function gen_user_settings_fields(&$section, $pconfig) {
$pconfig['systemlogsmanagelogpanel'],
$pconfig['statusmonitoringsettingspanel']);
gen_webguileftcolumnhyper_field($section, $pconfig['webguileftcolumnhyper']);
gen_disablealiaspopupdetail_field($section, $pconfig['disablealiaspopupdetail']);
gen_pagenamefirst_field($section, $pconfig['pagenamefirst']);
}
@ -3011,6 +3031,7 @@ function huawei_service_to_string($state) {
$modes[2] = gettext("Valid Service");
$modes[3] = gettext("Restricted Regional Service");
$modes[4] = gettext("Powersaving Service");
$modes[255] = gettext("Unknown Service");
$string = $modes[$state];
return $string;
}

View File

@ -5157,4 +5157,39 @@ function upgrade_161_to_162() {
$config['system']['crypto_hardware'] = "cryptodev";
}
}
/* Traffic graphs widget settings are now stored in a layout similar
* to other widgets. Migrate any old settings.
*/
function upgrade_162_to_163() {
require_once("ipsec.inc");
global $config;
foreach (array('refreshinterval', 'invert', 'size', 'backgroundupdate') as $setting) {
if (isset($config['widgets']['trafficgraphs'][$setting])) {
$config['widgets']['traffic_graphs'][$setting] = $config['widgets']['trafficgraphs'][$setting];
unset($config['widgets']['trafficgraphs'][$setting]);
}
}
if (isset($config['widgets']['trafficgraphs']['shown'])) {
if (is_array($config['widgets']['trafficgraphs']['shown']['item'])) {
$ifdescrs = get_configured_interface_with_descr();
if (ipsec_enabled()) {
$ifdescrs['enc0'] = "IPsec";
}
$validNames = array();
foreach ($ifdescrs as $ifdescr => $ifname) {
array_push($validNames, $ifdescr);
}
$config['widgets']['traffic_graphs']['filter'] = implode(',', array_diff($validNames, $config['widgets']['trafficgraphs']['shown']['item']));
}
unset($config['widgets']['trafficgraphs']['shown']);
}
}
?>

View File

@ -1420,7 +1420,8 @@ function get_configured_interface_with_descr($only_opt = false, $withdisabled =
}
}
}
asort($iflist);
return $iflist;
}
@ -2368,6 +2369,23 @@ function explode_assoc($delimiter, $string) {
return $result;
}
/*
* Given a string of text with some delimiter, look for occurrences
* of some string and replace all of those.
* $text - the text string (e.g. "abc,defg,x123,ipv4,xyz")
* $delimiter - the delimiter (e.g. ",")
* $element - the element to match (e.g. "defg")
* $replacement - the string to replace it with (e.g. "42")
* Returns the resulting delimited string (e.g. "abc,42,x123,ipv4,xyz")
*/
function replace_element_in_list($text, $delimiter, $element, $replacement) {
$textArray = explode($delimiter, $text);
while (($entry = array_search($element, $textArray)) !== false) {
$textArray[$entry] = $replacement;
}
return implode(',', $textArray);
}
/* Try to change a static route, if it doesn't exist, add it */
function route_add_or_change($args) {
global $config;

View File

@ -512,8 +512,8 @@ if (!$upgrading) {
echo "===> Checkout complete.\n";
echo "\n";
if (!$upgrading) {
echo "Your system is now sync'd and PHP and nginx will be restarted in 5 seconds.\n\n";
echo "The system is now sync'd and PHP and nginx will be restarted in 5 seconds.\n\n";
} else {
echo "Your system is now sync'd.\n\n";
echo "The system is now sync'd.\n\n";
}

View File

@ -22,7 +22,7 @@
ini_set("max_execution_time", "0");
if(empty($argv[1])) {
if (empty($argv[1])) {
echo "No modem device given \n";
exit(0);
}
@ -37,7 +37,7 @@ $i = 0;
$record = array();
$handle = fopen($device, "r");
if(! $handle) {
if (!$handle) {
echo "Can not open modem stats device\n";
exit(1);
}
@ -51,8 +51,8 @@ $record['sent'] = 0;
$record['received'] = 0;
$record['bwupstream'] = 0;
$record['bwdownstream'] = 0;
$record['simstate'] = 0;
$record['service'] = 0;
$record['simstate'] = 255;
$record['service'] = 255;
while (true) {
$string = "";

View File

@ -117,6 +117,7 @@ if (isset($_POST['create_alias']) && (is_hostname($host) || is_ipaddr($host))) {
} else {
$a_aliases[] = $newalias;
}
write_config(gettext("Created an alias from Diagnostics - DNS Lookup page."));
write_config();
$createdalias = true;
}

View File

@ -104,6 +104,10 @@ if ($_POST['save']) {
* cannot think he is slick and perform a XSS attack on the unwilling
*/
foreach ($_POST as $key => $value) {
if ($key == 'descr') {
continue;
}
$temp = str_replace(">", "", $value);
$newpost = htmlentities($temp);

View File

@ -114,6 +114,10 @@ if (isset($_REQUEST['dup']) && is_numericint($_REQUEST['dup'])) {
unset($input_errors);
foreach ($_REQUEST as $key => $value) {
if ($key == 'descr') {
continue;
}
$temp = $value;
$newpost = htmlentities($temp);
@ -584,14 +588,16 @@ function build_dsttype_list() {
$list[$ifent . 'ip'] = $ifdesc . ' address';
}
}
//Temporary array so we can sort IPs
$templist = array();
if (is_array($config['virtualip']['vip'])) {
foreach ($config['virtualip']['vip'] as $sn) {
if (is_ipaddrv6($sn['subnet'])) {
continue;
}
if (($sn['mode'] == "proxyarp" || $sn['mode'] == "other") && $sn['type'] == "network") {
$list[$sn['subnet'] . '/' . $sn['subnet_bits']] = 'Subnet: ' . $sn['subnet'] . '/' . $sn['subnet_bits'] . ' (' . $sn['descr'] . ')';
$templist[$sn['subnet'] . '/' . $sn['subnet_bits']] = 'Subnet: ' . $sn['subnet'] . '/' . $sn['subnet_bits'] . ' (' . $sn['descr'] . ')';
if (isset($sn['noexpand'])) {
continue;
}
@ -602,13 +608,18 @@ function build_dsttype_list() {
for ($i = 0; $i <= $len; $i++) {
$snip = long2ip32($start+$i);
$list[$snip] = $snip . ' (' . $sn['descr'] . ')';
$templist[$snip] = $snip . ' (' . $sn['descr'] . ')';
}
} else {
$list[$sn['subnet']] = $sn['subnet'] . ' (' . $sn['descr'] . ')';
$templist[$sn['subnet']] = $sn['subnet'] . ' (' . $sn['descr'] . ')';
}
}
}
//Sort temp IP array and append onto main array
asort($templist);
$list = array_merge($list, $templist);
unset($templist);
return($list);
}

View File

@ -146,6 +146,10 @@ if ($_POST['save']) {
* cannot think he is slick and perform a XSS attack on the unwilling
*/
foreach ($_POST as $key => $value) {
if ($key == 'descr') {
continue;
}
$temp = str_replace(">", "", $value);
$newpost = htmlentities($temp);
if ($newpost <> $temp) {
@ -406,10 +410,12 @@ function build_target_list() {
$list[""] = gettext('Interface Address');
//Temporary array so we can sort IPs
$templist = array();
if (is_array($config['virtualip']['vip'])) {
foreach ($config['virtualip']['vip'] as $sn) {
if (($sn['mode'] == "proxyarp" || $sn['mode'] == "other") && $sn['type'] == "network") {
$list['S' . $sn['subnet'] . '/' . $sn['subnet_bits']] = gettext('Subnet: ') . $sn['subnet'] . '/' . $sn['subnet_bits'] . ' (' . $sn['descr'] . ')';
$templist['S' . $sn['subnet'] . '/' . $sn['subnet_bits']] = gettext('Subnet: ') . $sn['subnet'] . '/' . $sn['subnet_bits'] . ' (' . $sn['descr'] . ')';
if (isset($sn['noexpand'])) {
continue;
}
@ -419,13 +425,17 @@ function build_target_list() {
for ($i = 0; $i <= $len; $i++) {
$snip = long2ip32($start+$i);
$list['I' . $snip] = $snip . ' (' . $sn['descr'] . ')';
$templist['I' . $snip] = $snip . ' (' . $sn['descr'] . ')';
}
} else {
$list['I' . $sn['subnet']] = $sn['subnet'] . ' (' . $sn['descr'] . ')';
$templist['I' . $sn['subnet']] = $sn['subnet'] . ' (' . $sn['descr'] . ')';
}
}
}
asort($templist);
//Append sorted IP array onto main array
$list = array_merge($list, $templist);
unset($templist);
foreach ($a_aliases as $alias) {
if ($alias['type'] != "host") {

View File

@ -940,7 +940,7 @@ events.push(function() {
}
});
// If so, change the icon to show the insetion point
// If so, change the icon to show the insertion point
if (ruleselected) {
if (e.shiftKey) {
$(this).removeClass().addClass("fa fa-lg fa-arrow-down text-danger");

View File

@ -42,6 +42,7 @@ function get_country_providers($country) {
return is_array($sp['provider'][0]) ? $sp['provider'] : array($sp['provider']);
}
}
$provider_list = (is_array($provider_list)) ? $provider_list : array();
return $provider_list;
}
@ -59,8 +60,12 @@ function country_list() {
function providers_list($country) {
$serviceproviders = get_country_providers($country);
foreach ($serviceproviders as $sp) {
echo $sp['name']['value'] . "\n";
if (is_array($serviceproviders)) {
foreach ($serviceproviders as $sp) {
echo $sp['name']['value'] . "\n";
}
} else {
$serviceproviders = array();
}
}

View File

@ -1110,7 +1110,7 @@ function add_package_tabs($tabgroup, &$tab_array) {
}
function alias_info_popup($alias_id) {
global $config;
global $config, $user_settings;
if (!is_array($config['aliases']['alias'][$alias_id])) {
return;
@ -1120,7 +1120,13 @@ function alias_info_popup($alias_id) {
$alias = $config['aliases']['alias'][$alias_id];
$content = "";
if ($alias['url']) {
if ($user_settings['webgui']['disablealiaspopupdetail']) {
if (strlen($alias['descr']) >= $maxlength) {
$alias['descr'] = substr($alias['descr'], 0, $maxlength) . '&hellip;';
}
$content .= $alias['descr'];
} else if ($alias['url']) {
// TODO: Change it when pf supports tables with ports
if ($alias['type'] == "urltable") {
exec("/sbin/pfctl -t {$alias['name']} -T show | wc -l", $total_entries);
@ -1164,10 +1170,6 @@ function alias_info_popup($alias_id) {
$content .= "<table>\n";
}
if (strlen($alias['descr']) >= $maxlength) {
$alias['descr'] = substr($alias['descr'], 0, $maxlength) . '&hellip;';
}
return $content;
}

View File

@ -241,9 +241,6 @@ if ($_POST['save']) {
if ($_POST['type'] == "ppp" && count($_POST['interfaces']) > 1) {
$input_errors[] = gettext("Multilink connections (MLPPP) using the PPP link type is not currently supported. Please select only one Link Interface.");
}
if ($_POST['provider'] && !is_domain($_POST['provider'])) {
$input_errors[] = gettext("The Service name contains invalid characters.");
}
if ($_POST['provider'] && $_POST['null_service']) {
$input_errors[] = gettext("Do not specify both a Service name and a NULL Service name.");
}
@ -1235,4 +1232,3 @@ events.push(function() {
<?php
include("foot.inc");

View File

@ -93,24 +93,24 @@ $evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['con
if ($_REQUEST['act'] == "update") {
if (is_array($config['installedpackages'][$pkg['name']]) && $pkg['name'] != "" && $_REQUEST['ids'] !="") {
#get current values
// get current values
$current_values=$config['installedpackages'][$pkg['name']]['config'];
#get updated ids
// get updated ids
parse_str($_REQUEST['ids'], $update_list);
#sort ids to know what to change
#useful to do not lose data when using sorting and paging
// sort ids to know what to change
// useful to do not lose data when using sorting and paging
$sort_list=$update_list['ids'];
sort($sort_list);
#apply updates
// apply updates
foreach ($update_list['ids'] as $key=> $value) {
$config['installedpackages'][$pkg['name']]['config'][$sort_list[$key]]=$current_values[$update_list['ids'][$key]];
}
#save current config
write_config();
#sync package
// save current config
write_config(gettext("Package configuration changes saved from package settings page."));
// sync package
eval ("{$pkg['custom_php_resync_config_command']}");
}
#function called via jquery, no need to continue after save changes.
// function called via jquery, no need to continue after save changes.
exit;
}
if ($_REQUEST['act'] == "del") {
@ -129,7 +129,7 @@ if ($_REQUEST['act'] == "del") {
if ($a_pkg[$_REQUEST['id']]) {
unset($a_pkg[$_REQUEST['id']]);
write_config();
write_config(gettext("Package configuration item deleted from package settings page."));
if ($pkg['custom_delete_php_command'] != "") {
if ($pkg['custom_php_command_before_form'] != "") {
eval($pkg['custom_php_command_before_form']);

View File

@ -33,6 +33,7 @@ require_once("functions.inc");
require_once("filter.inc");
require_once("shaper.inc");
require_once("pkg-utils.inc");
require_once("util.inc");
/* dummy stubs needed by some code that was MFC'd */
function pfSenseHeader($location) {
@ -159,7 +160,6 @@ if ($_POST) {
}
}
// donotsave is enabled. lets simply exit.
if (empty($pkg['donotsave'])) {
// store values in xml configuration file.
@ -175,11 +175,24 @@ if ($_POST) {
foreach ($_POST as $key => $value) {
$matches = array();
if (preg_match("/^{$rowhelperfield['fieldname']}(\d+)$/", $key, $matches)) {
$pkgarr[$rowhelpername][$matches[1]][$rowhelperfield['fieldname']] = $value;
if ($rowhelperfield['type'] == "textarea") {
$pkgarr[$rowhelpername][$matches[1]][$rowhelperfield['fieldname']] = unixnewlines($value);
} else {
$pkgarr[$rowhelpername][$matches[1]][$rowhelperfield['fieldname']] = $value;
}
}
}
}
break;
case "textarea":
$fieldname = $fields['fieldname'];
$fieldvalue = unixnewlines(trim($_POST[$fieldname]));
if ($fields['encoding'] == 'base64') {
$fieldvalue = base64_encode($fieldvalue);
}
if ($fieldname) {
$pkgarr[$fieldname] = $fieldvalue;
}
default:
$fieldname = $fields['fieldname'];
if ($fieldname == "interface_array") {
@ -243,6 +256,7 @@ if ($_POST) {
$get_from_post = true;
}
} elseif (!$input_errors) {
// donotsave is enabled. lets simply exit.
exit;
}
}

View File

@ -37,26 +37,31 @@ $a_checkipservice = &$config['checkipservices']['checkipservice'];
$dirty = false;
if ($_POST['act'] == "del") {
unset($a_checkipservice[$_POST['id']]);
$wc_msg = gettext('Deleted a check IP service.');
$dirty = true;
} else if ($_POST['act'] == "toggle") {
if ($a_checkipservice[$_POST['id']]) {
if (isset($a_checkipservice[$_POST['id']]['enable'])) {
unset($a_checkipservice[$_POST['id']]['enable']);
$wc_msg = gettext('Disabled a check IP service.');
} else {
$a_checkipservice[$_POST['id']]['enable'] = true;
$wc_msg = gettext('Enabled a check IP service.');
}
$dirty = true;
} else if ($_POST['id'] == count($a_checkipservice)) {
if (isset($config['checkipservices']['disable_factory_default'])) {
unset($config['checkipservices']['disable_factory_default']);
$wc_msg = gettext('Enabled the default check IP service.');
} else {
$config['checkipservices']['disable_factory_default'] = true;
$wc_msg = gettext('Disabled the default check IP service.');
}
$dirty = true;
}
}
if ($dirty) {
write_config();
write_config($wc_msg);
header("Location: services_checkip.php");
exit;

View File

@ -441,8 +441,8 @@ events.push(function() {
<thead>
<tr>
<th><?=gettext("Host")?></th>
<th><?=gettext("Domain")?></th>
<th><?=gettext("IP")?></th>
<th><?=gettext("Parent domain of host")?></th>
<th><?=gettext("IP to return for host")?></th>
<th><?=gettext("Description")?></th>
<th><?=gettext("Actions")?></th>
</tr>
@ -504,6 +504,14 @@ endforeach;
</div>
</div>
<span class="help-block">
Enter any individual hosts for which the resolver's standard DNS lookup process should be overridden and a specific
IPv4 or IPv6 address should automatically be returned by the resolver. Standard and also non-standard names and parent domains
can be entered, such as 'test', 'mycompany.localdomain', '1.168.192.in-addr.arpa', or 'somesite.com'. Any lookup attempt for
the host will automatically return the given IP address, and the usual lookup server for the domain will not be queried for
the host's records.
</span>
<nav class="action-buttons">
<a href="services_unbound_host_edit.php" class="btn btn-sm btn-success">
<i class="fa fa-plus icon-embed-btn"></i>
@ -518,7 +526,7 @@ endforeach;
<thead>
<tr>
<th><?=gettext("Domain")?></th>
<th><?=gettext("IP")?></th>
<th><?=gettext("Lookup Server IP Address")?></th>
<th><?=gettext("Description")?></th>
<th><?=gettext("Actions")?></th>
</tr>
@ -553,6 +561,13 @@ endforeach;
</div>
</div>
<span class="help-block">
Enter any domains for which the resolver's standard DNS lookup process should be overridden and a different (non-standard)
lookup server should be queried instead. Non-standard, 'invalid' and local domains, and subdomains, can also be entered,
such as 'test', 'mycompany.localdomain', '1.168.192.in-addr.arpa', or 'somesite.com'. The IP address is treated as the
authoritative lookup server for the domain (including all of its subdomains), and other lookup servers will not be queried.
</span>
<nav class="action-buttons">
<a href="services_unbound_domainoverride_edit.php" class="btn btn-sm btn-success">
<i class="fa fa-plus icon-embed-btn"></i>

View File

@ -114,20 +114,20 @@ if ($input_errors) {
$form = new Form();
$section = new Form_Section('Domain Override');
$section = new Form_Section('Domains to Override with Custom Lookup Servers');
$section->addInput(new Form_Input(
'domain',
'*Domain',
'text',
$pconfig['domain']
))->setHelp('Domain to override (NOTE: this does not have to be a valid TLD!) e.g.: test or mycompany.localdomain or 1.168.192.in-addr.arpa');
))->setHelp('Domain whose lookups will be directed to a user-specified DNS lookup server.');
$section->addInput(new Form_IpAddress(
'ip',
'*IP Address',
$pconfig['ip']
))->setHelp('IP address of the authoritative DNS server for this domain. e.g.: 192.168.100.100%1$s' .
))->setHelp('IPv4 or IPv6 address of the authoritative DNS server for this domain. e.g.: 192.168.100.100%1$s' .
'To use a non-default port for communication, append an \'@\' with the port number.', '<br />')->setPattern('[a-zA-Z0-9@.:]+');
$section->addInput(new Form_Input(
@ -146,6 +146,17 @@ if (isset($id) && $a_domainOverrides[$id]) {
));
}
$section->addInput(new Form_StaticText(
'',
'<span class="help-block">' .
gettext("This page is used to specify domains for which the resolver's standard DNS lookup process will be overridden, " .
"and the resolver will query a different (non-standard) lookup server instead. It is possible to enter 'non-standard', 'invalid' " .
"and 'local' domains such as 'test', 'mycompany.localdomain', or '1.168.192.in-addr.arpa', as well as usual publicly resolvable " .
"domains such as 'org', 'info', or 'google.co.uk'. The IP address entered will be treated as the IP address of an authoritative " .
"lookup server for the domain (including all of its subdomains), and other lookup servers will not be queried.") .
'</span>'
));
$form->add($section);
print $form;

View File

@ -192,21 +192,21 @@ $section->addInput(new Form_Input(
'text',
$pconfig['host']
))->setHelp('Name of the host, without the domain part%1$s' .
'e.g.: "myhost"', '<br />');
'e.g. enter "myhost" if the full domain name is "myhost.example.com"', '<br />');
$section->addInput(new Form_Input(
'domain',
'*Domain',
'text',
$pconfig['domain']
))->setHelp('Domain of the host%1$s' .
'e.g.: "example.com"', '<br />');
))->setHelp('Parent domain of the host%1$s' .
'e.g. enter "example.com" for "myhost.example.com"', '<br />');
$section->addInput(new Form_IpAddress(
'ip',
'*IP Address',
$pconfig['ip']
))->setHelp('IP address of the host%1$s' .
))->setHelp('IPv4 or IPv6 address to be returned for the host%1$s' .
'e.g.: 192.168.100.100 or fd00:abcd::1', '<br />');
$section->addInput(new Form_Input(
@ -225,6 +225,18 @@ if (isset($id) && $a_hosts[$id]) {
));
}
$section->addInput(new Form_StaticText(
'',
'<span class="help-block">' .
gettext("This page is used to override the usual lookup process for a specific host. A host is defined by its name " .
"and parent domain (e.g., 'somesite.google.com' is entered as host='somesite' and parent domain='google.com'). Any " .
"attempt to lookup that host will automatically return the given IP address, and any usual external lookup server for " .
"the domain will not be queried. Both the name and parent domain can contain 'non-standard', 'invalid' and 'local' " .
"domains such as 'test', 'mycompany.localdomain', or '1.168.192.in-addr.arpa', as well as usual publicly resolvable names ".
"such as 'www' or 'google.co.uk'.") .
'</span>'
));
$form->add($section);
$section = new Form_Section('Additional Names for this Host');
@ -281,6 +293,13 @@ $form->addGlobal(new Form_Button(
'fa-plus'
))->removeClass('btn-primary')->addClass('btn-success addbtn');
$section->addInput(new Form_StaticText(
'',
'<span class="help-block">'.
gettext("If the host can be accessed using multiple names, then enter any other names for the host which should also be overridden.") .
'</span>'
));
$form->add($section);
print($form);

View File

@ -160,7 +160,7 @@ if ($_POST['resetlogs'] == gettext("Reset Log Files")) {
unset($config['syslog']['remoteserver3']);
}
write_config();
write_config(gettext("Changed system logging options."));
$changes_applied = true;
$retval = 0;

View File

@ -63,6 +63,7 @@ $pconfig['webguicss'] = $config['system']['webgui']['webguicss'];
$pconfig['webguifixedmenu'] = $config['system']['webgui']['webguifixedmenu'];
$pconfig['dashboardcolumns'] = $config['system']['webgui']['dashboardcolumns'];
$pconfig['webguileftcolumnhyper'] = isset($config['system']['webgui']['webguileftcolumnhyper']);
$pconfig['disablealiaspopupdetail'] = isset($config['system']['webgui']['disablealiaspopupdetail']);
$pconfig['dashboardavailablewidgetspanel'] = isset($config['system']['webgui']['dashboardavailablewidgetspanel']);
$pconfig['systemlogsfilterpanel'] = isset($config['system']['webgui']['systemlogsfilterpanel']);
$pconfig['systemlogsmanagelogpanel'] = isset($config['system']['webgui']['systemlogsmanagelogpanel']);
@ -274,6 +275,9 @@ if ($_POST) {
unset($config['system']['webgui']['webguileftcolumnhyper']);
$config['system']['webgui']['webguileftcolumnhyper'] = $_POST['webguileftcolumnhyper'] ? true : false;
unset($config['system']['webgui']['disablealiaspopupdetail']);
$config['system']['webgui']['disablealiaspopupdetail'] = $_POST['disablealiaspopupdetail'] ? true : false;
unset($config['system']['webgui']['dashboardavailablewidgetspanel']);
$config['system']['webgui']['dashboardavailablewidgetspanel'] = $_POST['dashboardavailablewidgetspanel'] ? true : false;
@ -580,6 +584,7 @@ gen_associatedpanels_fields(
$pconfig['statusmonitoringsettingspanel']);
gen_requirestatefilter_field($section, $pconfig['requirestatefilter']);
gen_webguileftcolumnhyper_field($section, $pconfig['webguileftcolumnhyper']);
gen_disablealiaspopupdetail_field($section, $pconfig['disablealiaspopupdetail']);
$section->addInput(new Form_Checkbox(
'loginshowhost',

View File

@ -348,7 +348,7 @@ if ($_POST) {
$config['system']['bogons']['interval'] = $_POST['bogonsinterval'];
}
write_config();
write_config(gettext("Changed Advanced Firewall/NAT settings."));
// Kill filterdns when value changes, filter_configure() will restart it
if (($old_aliasesresolveinterval != $config['system']['aliasesresolveinterval']) &&

View File

@ -200,7 +200,7 @@ if($_POST['save']) {
$a_routes = $a_routes_new;
}
if (write_config()) {
if (write_config(gettext("Saved static routes configuration."))) {
mark_subsystem_dirty('staticroutes');
}
header("Location: system_routes.php");

View File

@ -209,7 +209,7 @@ if ($_POST['save']) {
mark_subsystem_dirty('staticroutes');
write_config();
write_config(gettext("Saved static route configuration."));
header("Location: system_routes.php");
exit;

View File

@ -96,7 +96,7 @@ if ($_POST) {
unset($config['system']['gitsync']['dryrun']);
}
write_config();
write_config(gettext("Saved system update settings."));
$savemsg = gettext("Changes have been saved successfully");
}

View File

@ -47,6 +47,7 @@ if (isset($id) && $a_user[$id]) {
$pconfig['systemlogsmanagelogpanel'] = isset($a_user[$id]['systemlogsmanagelogpanel']);
$pconfig['statusmonitoringsettingspanel'] = isset($a_user[$id]['statusmonitoringsettingspanel']);
$pconfig['webguileftcolumnhyper'] = isset($a_user[$id]['webguileftcolumnhyper']);
$pconfig['disablealiaspopupdetail'] = isset($a_user[$id]['disablealiaspopupdetail']);
$pconfig['pagenamefirst'] = isset($a_user[$id]['pagenamefirst']);
} else {
echo gettext("The settings cannot be managed for a non-local user.");
@ -118,6 +119,13 @@ if (isset($_POST['save'])) {
unset($userent['webguileftcolumnhyper']);
}
if ($_POST['disablealiaspopupdetail']) {
$pconfig['disablealiaspopupdetail'] = $userent['disablealiaspopupdetail'] = true;
} else {
$pconfig['disablealiaspopupdetail'] = false;
unset($userent['disablealiaspopupdetail']);
}
if ($_POST['pagenamefirst']) {
$pconfig['pagenamefirst'] = $userent['pagenamefirst'] = true;
} else {

View File

@ -68,6 +68,7 @@ if (isset($id) && $a_user[$id]) {
$pconfig['systemlogsmanagelogpanel'] = isset($a_user[$id]['systemlogsmanagelogpanel']);
$pconfig['statusmonitoringsettingspanel'] = isset($a_user[$id]['statusmonitoringsettingspanel']);
$pconfig['webguileftcolumnhyper'] = isset($a_user[$id]['webguileftcolumnhyper']);
$pconfig['disablealiaspopupdetail'] = isset($a_user[$id]['disablealiaspopupdetail']);
$pconfig['pagenamefirst'] = isset($a_user[$id]['pagenamefirst']);
$pconfig['groups'] = local_user_get_groups($a_user[$id]);
$pconfig['utype'] = $a_user[$id]['scope'];
@ -359,6 +360,12 @@ if ($_POST['save']) {
unset($userent['webguileftcolumnhyper']);
}
if ($_POST['disablealiaspopupdetail']) {
$userent['disablealiaspopupdetail'] = true;
} else {
unset($userent['disablealiaspopupdetail']);
}
if ($_POST['pagenamefirst']) {
$userent['pagenamefirst'] = true;
} else {
@ -974,6 +981,7 @@ events.push(function() {
hideCheckbox('systemlogsmanagelogpanel', !adv);
hideCheckbox('statusmonitoringsettingspanel', !adv);
hideCheckbox('webguileftcolumnhyper', !adv);
hideCheckbox('disablealiaspopupdetail', !adv);
hideCheckbox('pagenamefirst', !adv);
}

View File

@ -65,7 +65,7 @@ if ($_POST['apply']) {
foreach ($_POST['p1entry'] as $p1entrydel) {
unset($a_phase1[$p1entrydel]);
}
if (write_config()) {
if (write_config(gettext("Deleted selected IPsec Phase 1 entries."))) {
mark_subsystem_dirty('ipsec');
}
}
@ -75,7 +75,7 @@ if ($_POST['apply']) {
foreach ($_POST['p2entry'] as $p2entrydel) {
unset($a_phase2[$p2entrydel]);
}
if (write_config()) {
if (write_config(gettext("Deleted selected IPsec Phase 2 entries."))) {
mark_subsystem_dirty('ipsec');
}
}
@ -209,7 +209,7 @@ if ($_POST['apply']) {
}
if ($save === 1) {
if (write_config()) {
if (write_config(gettext("Saved configuration changes for IPsec tunnels."))) {
mark_subsystem_dirty('ipsec');
}
}

View File

@ -294,7 +294,7 @@ if ($_POST['save']) {
$a_client = $client;
write_config();
write_config(gettext("Saved IPsec Mobile Clients configuration."));
mark_subsystem_dirty('ipsec');
header("Location: vpn_ipsec_mobile.php");

View File

@ -508,7 +508,7 @@ if ($_POST['save']) {
$a_phase1[] = $ph1ent;
}
write_config();
write_config(gettext("Saved IPsec tunnel Phase 1 configuration."));
mark_subsystem_dirty('ipsec');
header("Location: vpn_ipsec.php");

View File

@ -392,7 +392,7 @@ if ($_POST['save']) {
$a_phase2[] = $ph2ent;
}
write_config();
write_config(gettext("Saved IPsec tunnel Phase 2 configuration."));
mark_subsystem_dirty('ipsec');
header("Location: vpn_ipsec.php");

View File

@ -163,7 +163,7 @@ if ($_POST['save']) {
}
}
write_config();
write_config(gettext("Saved IPsec advanced settings."));
$changes_applied = true;
$retval = 0;

View File

@ -140,8 +140,8 @@ if (!function_exists('compose_table_body_contents')) {
$bgcolor = "info"; // lightblue
}
$rtnstr .= "<td>" . ($gateways_status[$gname] ? htmlspecialchars($gateways_status[$gname]['delay']) : gettext("Pending")) . "</td>\n";
$rtnstr .= "<td>" . ($gateways_status[$gname] ? htmlspecialchars($gateways_status[$gname]['stddev']) : gettext("Pending")) . "</td>\n";
$rtnstr .= "<td>" . ($gateways_status[$gname] ? ($gateways_status[$gname]['delay'] ? htmlspecialchars(number_format((float)rtrim($gateways_status[$gname]['delay'], "ms"), 1)) . "ms" : '') : gettext("Pending")) . "</td>\n";
$rtnstr .= "<td>" . ($gateways_status[$gname] ? ($gateways_status[$gname]['stddev'] ? htmlspecialchars(number_format((float)rtrim($gateways_status[$gname]['stddev'], "ms"), 1)) . "ms" : '') : gettext("Pending")) . "</td>\n";
$rtnstr .= "<td>" . ($gateways_status[$gname] ? htmlspecialchars($gateways_status[$gname]['loss']) : gettext("Pending")) . "</td>\n";
$rtnstr .= '<td class="bg-' . $bgcolor . '">' . $online . "</td>\n";
$rtnstr .= "</tr>\n";

View File

@ -47,6 +47,9 @@ function gmirrorStatusUpdateFromServer() {
},
success: function(data){
$('[id="gmirror_status"]').html(data);
},
error: function(){
$('[id="gmirror_status"]').html("<div class=\"alert alert-danger\"><?=gettext('Unable to retrieve status'); ?></div>");
}
});
}

View File

@ -28,6 +28,8 @@ require_once("functions.inc");
require_once("/usr/local/www/widgets/include/interfaces.inc");
$ifdescrs = get_configured_interface_with_descr();
// Update once per minute by default, instead of every 10 seconds
$widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period'] * 1000 * 6 : 60000;
if ($_POST['widgetkey']) {
@ -49,9 +51,10 @@ if ($_POST['widgetkey']) {
?>
<div class="table-responsive">
<div class="table-responsive" id="ifaces_status">
<table class="table table-striped table-hover table-condensed">
<tbody>
<?php
$skipinterfaces = explode(",", $user_settings['widgets'][$widgetkey]['iffilter']);
$interface_is_displayed = false;
@ -106,7 +109,7 @@ foreach ($ifdescrs as $ifdescr => $ifname):
<?php endif; ?>
</td>
<td>
<?php if ($ifinfo['pppoelink'] == "up" || $ifinfo['pptplink'] == "up" || $ifinfo['l2tplink'] == "up"):?>
<?php if ($ifinfo['pppoelink'] == "up" || $ifinfo['pptplink'] == "up" || $ifinfo['l2tplink'] == "up"):?>
<?=sprintf(gettext("Uptime: %s"), htmlspecialchars($ifinfo['ppp_uptime']));?>
<?php else: ?>
<?=htmlspecialchars($ifinfo['media']);?>
@ -147,7 +150,7 @@ endif;
</div><div id="<?=$widget_panel_footer_id?>" class="panel-footer collapse">
<form action="/widgets/widgets/interfaces.widget.php" method="post" class="form-horizontal">
<div class="panel panel-default col-sm-10">
<div class="panel panel-default col-sm-10">
<div class="panel-body">
<input type="hidden" name="widgetkey" value="<?=$widgetkey; ?>">
<div class="table responsive">
@ -193,3 +196,29 @@ endif;
});
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
function getstatus_ifaces() {
$.ajax({
type: 'get',
url: '/widgets/widgets/interfaces.widget.php',
dataType: 'html',
dataFilter: function(raw){
// We reload the entire widget, strip this block of javascript from it
return raw.replace(/<script>([\s\S]*)<\/script>/gi, '');
},
success: function(data){
$('#ifaces_status').html(data);
},
error: function(){
$('#ifaces_status').html("<div class=\"alert alert-danger\"><?=gettext('Unable to retrieve status'); ?></div>");
}
});
}
events.push(function(){
setInterval('getstatus_ifaces()', "<?=$widgetperiod?>");
});
//]]>
</script>

View File

@ -26,16 +26,6 @@
* limitations under the License.
*/
/* TODOs */
//re-use on Status > traffic graphs
//figure out why there is a missing datapoint at the start
//name things/variables better
//apply css change to Status > Monitoring
//show interface name and latest in/out in upper left
//add stacked overall graph?
//also show pie graph of lastest precentages of total? (split 50/50 on width)
//make this an option?
$nocsrf = true;
require_once("guiconfig.inc");
@ -49,98 +39,72 @@ if (ipsec_enabled()) {
$ifdescrs['enc0'] = "IPsec";
}
//there are no traffic graph widget defaults in config yet. so set them, but don't write the config
if (!is_array($config["widgets"]["trafficgraphs"])) {
$config["widgets"]["trafficgraphs"] = array();
$config["widgets"]["trafficgraphs"]["refreshinterval"] = 1;
$config["widgets"]["trafficgraphs"]["invert"] = "true";
$config["widgets"]["trafficgraphs"]["size"] = 1;
$config["widgets"]["trafficgraphs"]["backgroundupdate"] = "false";
$config["widgets"]["trafficgraphs"]["shown"] = array();
$config["widgets"]["trafficgraphs"]["shown"]["item"] = array();
foreach($ifdescrs as $ifname => $ifdescr) {
$ifinfo = get_interface_info($ifname);
if ($ifinfo['status'] != "down") {
$config["widgets"]["trafficgraphs"]["shown"]["item"][] = $ifname;
}
}
//TODO silently write to config? (use a config message about saving defaults)
}
if(!isset($config["widgets"]["trafficgraphs"]["size"])) {
$config["widgets"]["trafficgraphs"]["size"] = 1;
}
if(!isset($config["widgets"]["trafficgraphs"]["invert"])) {
$config["widgets"]["trafficgraphs"]["invert"] = "true";
}
if(!isset($config["widgets"]["trafficgraphs"]["backgroundupdate"])) {
$config["widgets"]["trafficgraphs"]["backgroundupdate"] = "true";
}
$a_config = &$config["widgets"]["trafficgraphs"];
// save new default config options that have been submitted
if ($_POST) {
//TODO validate data and throw error
$a_config["shown"]["item"] = $_POST["traffic-graph-interfaces"];
// 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 (!is_array($user_settings["widgets"]["traffic_graphs"])) {
$user_settings["widgets"]["traffic_graphs"] = array();
}
if($_POST["traffic-graph-invert"] === "true" || $_POST["traffic-graph-invert"] === "false") {
$a_config["invert"] = $_POST["traffic-graph-invert"];
} else {
die('{ "error" : "Invert is not a boolean of true or false." }');
if (isset($_POST["refreshinterval"])) {
$user_settings["widgets"]["traffic_graphs"]["refreshinterval"] = $_POST["refreshinterval"];
}
if($_POST["traffic-graph-backgroundupdate"] === "true" || $_POST["traffic-graph-backgroundupdate"] === "false") {
$a_config["backgroundupdate"] = $_POST["traffic-graph-backgroundupdate"];
} else {
die('{ "error" : "Backgroundupdate is not a boolean of true or false." }');
if (isset($_POST["invert"])) {
$user_settings["widgets"]["traffic_graphs"]["invert"] = $_POST["invert"];
}
//TODO validate data and throw error
$a_config["size"] = $_POST["traffic-graph-size"];
write_config(gettext("Updated traffic graph settings via dashboard."));
if (isset($_POST["backgroundupdate"])) {
$user_settings["widgets"]["traffic_graphs"]["backgroundupdate"] = $_POST["backgroundupdate"];
}
header('Content-Type: application/json');
if (isset($_POST["size"])) {
$user_settings["widgets"]["traffic_graphs"]["size"] = $_POST["size"];
}
die('{ "success" : "The changes have been applied successfully." }');
$validNames = array();
foreach ($ifdescrs as $ifdescr => $ifname) {
array_push($validNames, $ifdescr);
}
if (is_array($_POST['show'])) {
$user_settings["widgets"]["traffic_graphs"]["filter"] = implode(',', array_diff($validNames, $_POST['show']));
} else {
$user_settings["widgets"]["traffic_graphs"]["filter"] = implode(',', $validNames);
}
save_widget_settings($_SESSION['Username'], $user_settings["widgets"], gettext("Updated traffic graphs widget settings via dashboard."));
header("Location: /");
exit(0);
}
$refreshinterval = $a_config["refreshinterval"];
$ifsarray = [];
foreach ($a_config["shown"]["item"] as $ifname) {
$ifinfo = get_interface_info($ifname);
if ($ifinfo['status'] != "down") {
$ifsarray[] = $ifname;
} else {
//TODO throw error?
}
if (isset($user_settings['widgets']['traffic_graphs']['refreshinterval'])) {
$tg_refreshinterval = $user_settings['widgets']['traffic_graphs']['refreshinterval'];
} else {
$tg_refreshinterval = 1;
}
$allifs = implode("|", $ifsarray);
if (isset($user_settings['widgets']['traffic_graphs']['size'])) {
$tg_size = $user_settings['widgets']['traffic_graphs']['size'];
} else {
$tg_size = 1;
}
if (isset($user_settings['widgets']['traffic_graphs']['invert'])) {
$tg_invert = $user_settings['widgets']['traffic_graphs']['invert'];
} else {
$tg_invert = 'true';
}
if (isset($user_settings['widgets']['traffic_graphs']['backgroundupdate'])) {
$tg_backgroundupdate = $user_settings['widgets']['traffic_graphs']['backgroundupdate'];
} else {
$tg_backgroundupdate = 'true';
}
$skip_tg_items = explode(",", $user_settings['widgets']['traffic_graphs']['filter']);
$tg_displayed = false;
$tg_displayed_ifs_array = [];
?>
<script src="/vendor/d3/d3.min.js"></script>
<script src="/vendor/nvd3/nv.d3.js"></script>
@ -149,17 +113,138 @@ $allifs = implode("|", $ifsarray);
<link href="/vendor/nvd3/nv.d3.css" media="screen, projection" rel="stylesheet" type="text/css">
<div id="traffic-chart-error" class="alert alert-danger" style="display: none;"></div>
<?php
foreach ($ifdescrs as $ifdescr => $ifname) {
if (in_array($ifdescr, $skip_tg_items)) {
continue;
}
<?php
foreach($a_config["shown"]["item"] as $ifname) {
echo '<div id="traffic-chart-' . $ifname . '" class="d3-chart traffic-widget-chart">';
$ifinfo = get_interface_info($ifdescr);
if ($ifinfo['status'] == "down") {
// Do not try to display the traffic graph of a down interface,
// even though it is selected for display.
continue;
}
$tg_displayed = true;
$tg_displayed_ifs_array[] = $ifdescr;
echo '<div id="traffic-chart-' . $ifdescr . '" class="d3-chart traffic-widget-chart">';
echo ' <svg></svg>';
echo '</div>';
}
?>
<script type="text/javascript">
if (!$tg_displayed) {
echo '<div id="traffic-chartnone" class="d3-chart traffic-widget-chart">';
echo gettext('All traffic graphs are hidden.');
echo '</div>';
}
?>
<!-- close the body we're wrapped in and add a configuration-panel -->
</div>
<div id="widget-<?=$widgetname?>_panel-footer" class="panel-footer collapse">
<form action="/widgets/widgets/traffic_graphs.widget.php" method="post" class="form-horizontal">
<div class="form-group">
<label for="traffic-graph-interval" class="col-sm-3 control-label"><?=gettext('Refresh Interval')?></label>
<div class="col-sm-9">
<input type="number" id="refreshinterval" name="refreshinterval" value="<?=$tg_refreshinterval?>" min="1" max="10" class="form-control" />
</div>
</div>
<div class="form-group">
<label for="invert" class="col-sm-3 control-label"><?=gettext('Inverse')?></label>
<div class="col-sm-9">
<select class="form-control" id="invert" name="invert">
<?php
if ($tg_invert === "true") {
echo '<option value="true" selected>On</option>';
echo '<option value="false">Off</option>';
} else {
echo '<option value="true">On</option>';
echo '<option value="false" selected>Off</option>';
}
?>
</select>
</div>
</div>
<div class="form-group">
<label for="size" class="col-sm-3 control-label"><?=gettext('Unit Size')?></label>
<div class="col-sm-9">
<select class="form-control" id="size" name="size">
<?php
if ($tg_size === "8") {
echo '<option value="8" selected>Bits</option>';
echo '<option value="1">Bytes</option>';
} else {
echo '<option value="8">Bits</option>';
echo '<option value="1" selected>Bytes</option>';
}
?>
</select>
</div>
</div>
<div class="form-group">
<label for="backgroundupdate" class="col-sm-3 control-label"><?=gettext('Background updates')?></label>
<div class="col-sm-9">
<select class="form-control" id="backgroundupdate" name="backgroundupdate">
<?php
if ($tg_backgroundupdate === "true") {
echo '<option value="true" selected>Keep graphs updated on inactive tab. (increases cpu usage)</option>';
echo '<option value="false">Clear graphs when not visible.</option>';
} else {
echo '<option value="true">Keep graphs updated on inactive tab. (increases cpu usage)</option>';
echo '<option value="false" selected>Clear graphs when not visible.</option>';
}
?>
</select>
</div>
</div>
<div class="panel panel-default col-sm-10">
<div class="panel-body">
<div class="table responsive">
<table class="table table-striped table-hover table-condensed">
<thead>
<tr>
<th><?=gettext("Interface")?></th>
<th><?=gettext("Show")?></th>
</tr>
</thead>
<tbody>
<?php
$idx = 0;
foreach ($ifdescrs as $ifdescr => $ifname):
?>
<tr>
<td><?=$ifname?></td>
<td class="col-sm-2"><input id="show[]" name ="show[]" value="<?=$ifdescr?>" type="checkbox" <?=(!in_array($ifdescr, $skip_tg_items) ? 'checked':'')?>></td>
</tr>
<?php
endforeach;
?>
</tbody>
</table>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-6">
<button type="submit" class="btn btn-primary"><i class="fa fa-save icon-embed-btn"></i><?=gettext('Save')?></button>
<button id="showalltgitems" type="button" class="btn btn-info"><i class="fa fa-undo icon-embed-btn"></i><?=gettext('All')?></button>
</div>
</div>
</form>
<script type="text/javascript">
//<![CDATA[
// Used by /js/traffic-graphs.js to display description from name
var graph_interfacenames = <?php
foreach ($ifdescrs as $ifname => $ifdescr) {
$iflist[$ifname] = $ifdescr;
@ -169,16 +254,16 @@ var graph_interfacenames = <?php
events.push(function() {
var InterfaceString = "<?=$allifs?>";
var InterfaceString = "<?=implode("|", $tg_displayed_ifs_array)?>";
//store saved settings in a fresh localstorage
localStorage.clear();
localStorage.setItem('interval', <?=$refreshinterval?>);
localStorage.setItem('invert', <?=$a_config["invert"]?>);
localStorage.setItem('size', <?=$a_config["size"]?>);
localStorage.setItem('backgroundupdate', <?=$a_config["backgroundupdate"]?>);
localStorage.setItem('interval', <?=$tg_refreshinterval?>);
localStorage.setItem('invert', <?=$tg_invert?>);
localStorage.setItem('size', <?=$tg_size?>);
localStorage.setItem('backgroundupdate', <?=$tg_backgroundupdate?>);
window.interfaces = InterfaceString.split("|");
window.interfaces = InterfaceString.split("|").filter(function(entry) { return entry.trim() != ''; });
window.charts = {};
window.myData = {};
window.updateIds = 0;
@ -203,27 +288,29 @@ events.push(function() {
var itemOut = new Object();
itemIn.key = value + " (in)";
if(localStorage.getItem('invert') === "true") { itemIn.area = true; }
if (localStorage.getItem('invert') === "true") { itemIn.area = true; }
itemIn.first = true;
itemIn.values = [{x: nowTime, y: 0}];
myData[value].push(itemIn);
itemOut.key = value + " (out)";
if(localStorage.getItem('invert') === "true") { itemOut.area = true; }
if (localStorage.getItem('invert') === "true") { itemOut.area = true; }
itemOut.first = true;
itemOut.values = [{x: nowTime, y: 0}];
myData[value].push(itemOut);
});
draw_graph(refreshInterval, then, backgroundupdate);
if (window.interfaces.length > 0) {
draw_graph(refreshInterval, then, backgroundupdate);
}
//re-draw graph when the page goes from inactive (in it's window) to active
Visibility.change(function (e, state) {
if($('#traffic-graph-backgroundupdate').val() === "true"){
if (backgroundupdate) {
return;
}
if(state === "visible") {
if (state === "visible") {
now = then = new Date(Date.now());
@ -240,242 +327,29 @@ events.push(function() {
var itemOut = new Object();
itemIn.key = value + " (in)";
if(localStorage.getItem('invert') === "true") { itemIn.area = true; }
if (localStorage.getItem('invert') === "true") { itemIn.area = true; }
itemIn.first = true;
itemIn.values = [{x: nowTime, y: 0}];
myData[value].push(itemIn);
itemOut.key = value + " (out)";
if(localStorage.getItem('invert') === "true") { itemOut.area = true; }
if (localStorage.getItem('invert') === "true") { itemOut.area = true; }
itemOut.first = true;
itemOut.values = [{x: nowTime, y: 0}];
myData[value].push(itemOut);
});
draw_graph(refreshInterval, then, backgroundupdate);
if (window.interfaces.length > 0) {
draw_graph(refreshInterval, then, backgroundupdate);
}
}
});
// save new config defaults
$( '#traffic-graph-form' ).submit(function(event) {
var error = false;
$("#traffic-chart-error").hide();
var interfaces = $( "#traffic-graph-interfaces" ).val();
refreshInterval = parseInt($( "#traffic-graph-interval" ).val());
var invert = $( "#traffic-graph-invert" ).val();
var size = $( "#traffic-graph-size" ).val();
var backgroundupdate = $( "#traffic-graph-backgroundupdate" ).val();
//TODO validate interfaces data and throw error
if(!Number.isInteger(refreshInterval) || refreshInterval < 1 || refreshInterval > 10) {
error = 'Refresh Interval is not a valid number between 1 and 10.';
}
if(invert != "true" && invert != "false") {
error = 'Invert is not a boolean of true or false.';
}
if(!error) {
var formData = {
'traffic-graph-interfaces' : interfaces,
'traffic-graph-interval' : refreshInterval,
'traffic-graph-invert' : invert,
'traffic-graph-size' : size,
'traffic-graph-backgroundupdate' : backgroundupdate
};
$.ajax({
type : 'POST',
url : '/widgets/widgets/traffic_graphs.widget.php',
data : formData,
dataType : 'json',
encode : true
})
.done(function(message) {
if(message.success) {
Visibility.stop(updateIds);
clearInterval(updateTimerIds);
//remove all old graphs (divs/svgs)
$( ".traffic-widget-chart" ).remove();
window.interfaces = interfaces;
localStorage.setItem('interval', refreshInterval);
localStorage.setItem('invert', invert);
localStorage.setItem('size', size);
localStorage.setItem('backgroundupdate', backgroundupdate);
//redraw graph with new settings
now = then = new Date(Date.now());
var freshData = [];
var nowTime = now.getTime();
$.each( interfaces, function( key, value ) {
//create new graphs (divs/svgs)
$("#widget-traffic_graphs_panel-body").append('<div id="traffic-chart-' + value + '" class="d3-chart traffic-widget-chart"><svg></svg></div>');
myData[value] = [];
var itemIn = new Object();
var itemOut = new Object();
itemIn.key = value + " (in)";
if(localStorage.getItem('invert') === "true") { itemIn.area = true; }
itemIn.first = true;
itemIn.values = [{x: nowTime, y: 0}];
myData[value].push(itemIn);
itemOut.key = value + " (out)";
if(localStorage.getItem('invert') === "true") { itemOut.area = true; }
itemOut.first = true;
itemOut.values = [{x: nowTime, y: 0}];
myData[value].push(itemOut);
});
draw_graph(refreshInterval, then, backgroundupdate);
$( "#traffic-graph-message" ).removeClass("text-danger").addClass("text-success");
$( "#traffic-graph-message" ).text(message.success);
setTimeout(function() {
$( "#traffic-graph-message" ).empty();
$( "#traffic-graph-message" ).removeClass("text-success");
}, 5000);
} else {
$( "#traffic-graph-message" ).addClass("text-danger");
$( "#traffic-graph-message" ).text(message.error);
console.warn(message.error);
}
})
.fail(function() {
console.warn( "The Traffic Graphs widget AJAX request failed." );
});
} else {
$( "#traffic-graph-message" ).addClass("text-danger");
$( "#traffic-graph-message" ).text(error);
console.warn(error);
}
event.preventDefault();
});
set_widget_checkbox_events("#widget-<?=$widgetname?>_panel-footer [id^=show]", "showalltgitems");
});
//]]>
</script>
<script src="/js/traffic-graphs.js"></script>
<!-- close the body we're wrapped in and add a configuration-panel -->
</div>
<div id="widget-<?=$widgetname?>_panel-footer" class="panel-footer collapse">
<form id="traffic-graph-form" action="/widgets/widgets/traffic_graphs.widget.php" method="post" class="form-horizontal">
<div class="form-group">
<label for="traffic-graph-interfaces" class="col-sm-3 control-label"><?=gettext('Show graphs')?></label>
<div class="col-sm-9">
<select name="traffic-graph-interfaces[]" id="traffic-graph-interfaces" multiple>
<?php
foreach ($ifdescrs as $ifname => $ifdescr) {
$if_shown = "";
if (in_array($ifname, $a_config["shown"]["item"])) { $if_shown = " selected"; };
echo '<option value="' . $ifname . '"' . $if_shown . '>' . $ifdescr . "</option>\n";
}
?>
</select>
</div>
</div>
<div class="form-group">
<label for="traffic-graph-interval" class="col-sm-3 control-label"><?=gettext('Refresh Interval')?></label>
<div class="col-sm-9">
<input type="number" id="traffic-graph-interval" name="traffic-graph-interval" value="<?=$refreshinterval?>" min="1" max="10" class="form-control" />
</div>
</div>
<div class="form-group">
<label for="traffic-graph-invert" class="col-sm-3 control-label"><?=gettext('Inverse')?></label>
<div class="col-sm-9">
<select class="form-control" id="traffic-graph-invert" name="traffic-graph-invert">
<?php
if($a_config["invert"] === "true") {
echo '<option value="true" selected>On</option>';
echo '<option value="false">Off</option>';
} else {
echo '<option value="true">On</option>';
echo '<option value="false" selected>Off</option>';
}
?>
</select>
</div>
</div>
<div class="form-group">
<label for="traffic-graph-size" class="col-sm-3 control-label"><?=gettext('Unit Size')?></label>
<div class="col-sm-9">
<select class="form-control" id="traffic-graph-size" name="traffic-graph-size">
<?php
if($a_config["size"] === "8") {
echo '<option value="8" selected>Bits</option>';
echo '<option value="1">Bytes</option>';
} else {
echo '<option value="8">Bits</option>';
echo '<option value="1" selected>Bytes</option>';
}
?>
</select>
</div>
</div>
<div class="form-group">
<label for="traffic-graph-backgroundupdate" class="col-sm-3 control-label"><?=gettext('Background updates')?></label>
<div class="col-sm-9">
<select class="form-control" id="traffic-graph-backgroundupdate" name="traffic-graph-backgroundupdate">
<?php
if($a_config["backgroundupdate"] === "true") {
echo '<option value="true" selected>Keep graphs updated on inactive tab. (increases cpu usage)</option>';
echo '<option value="false">Clear graphs when not visible.</option>';
} else {
echo '<option value="true">Keep graphs updated on inactive tab. (increases cpu usage)</option>';
echo '<option value="false" selected>Clear graphs when not visible.</option>';
}
?>
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-3 text-right">
<button type="submit" class="btn btn-primary"><i class="fa fa-save icon-embed-btn"></i><?=gettext('Save')?></button>
</div>
<div class="col-sm-9">
<div id="traffic-graph-message"></div>
</div>
</div>
</form>

View File

@ -116,7 +116,7 @@ if ($_POST && !$input_errors) {
eval($pkg['step'][$stepid]['stepsubmitphpaction']);
}
if (!$input_errors) {
write_config();
write_config(gettext("Configuration changed via the pfSense wizard subsystem."));
}
$stepid++;

View File

@ -19,7 +19,11 @@
* limitations under the License.
*/
require_once("auth.inc");
require_once("certs.inc");
require_once("config.inc");
require_once("openvpn.inc");
require_once("util.inc");
function has_special_chars($text) {
return preg_match('/[^A-Za-z0-9 _-]/', $text);
@ -662,7 +666,7 @@ function step12_submitphpaction() {
$config['openvpn']['openvpn-server'][] = $server;
openvpn_resync('server', $server);
write_config();
write_config(gettext("OpenVPN configuration saved via OpenVPN Remote Access Server setup wizard."));
header("Location: vpn_openvpn_server.php");
exit;
}

View File

@ -556,7 +556,7 @@
} else {
$_POST['ipaddress'] = $_POST['selectedtype'];
$config['interfaces']['wan']['ipaddr'] = $_POST['selectedtype'];
write_config();
write_config(gettext("WAN interface configuration saved via pfSense setup wizard."));
}
if (!$config['interfaces']['lan']) {
header("Location: /wizard.php?xml=setup_wizard.xml&stepid=6&next=Next");
@ -684,7 +684,7 @@
$admin_user =& getUserEntryByUID(0);
local_user_set_password($admin_user, $_POST['adminpassword']);
local_user_set($admin_user);
write_config();
write_config(gettext("Admin WebGUI password saved via pfSense setup wizard."));
} else {
print_info_box("Passwords do not match! Please press back in the browser window and correct.");
die;
@ -747,7 +747,7 @@
}
}
unset($config['wizardtemp']);
write_config();
write_config(gettext("Configuration saved on completion of the pfSense setup wizard."));
reload_all();
mwexec_bg("/etc/rc.update_bogons.sh now");
]]>

View File

@ -19,6 +19,10 @@
* limitations under the License.
*/
require_once("config.inc");
require_once("interfaces.inc");
require_once("util.inc");
function step1_stepbeforeformdisplay() {
global $stepid, $savemsg, $pkg;
@ -1635,7 +1639,7 @@ function apply_all_chosen_items() {
}
}
}
write_config();
write_config(gettext("Shaper configuration saved via pfSense traffic shaper wizard."));
}
function wizard_get_bandwidthtype_scale($type = "b") {

View File

@ -19,6 +19,9 @@
* limitations under the License.
*/
require_once("config.inc");
require_once("interfaces.inc");
require_once("util.inc");
function step1_stepbeforeformdisplay() {
global $stepid, $savemsg, $pkg;
@ -1727,7 +1730,7 @@ function apply_all_chosen_items() {
}
}
}
write_config();
write_config(gettext("Shaper configuration saved via pfSense traffic shaper wizard."));
}
function wizard_get_bandwidthtype_scale($type = "b") {