commit 44c423566b6eff18ec43ee77edddb94e3a3aa858
Author: Phil Davis <phil.davis@inf.org>
Date:   Tue Jan 3 10:50:22 2017 +0545

    Report problems applying changes
    
    1) Strictly keep track of the accumulating $retval from calls to various
    functions that apply changes.
    2) Use new function print_apply_result_box() to print a suitable message
    in a suitable severity based on $retval

diff --git a/src/usr/local/www/firewall_aliases.php b/src/usr/local/www/firewall_aliases.php
index 55069d8f23..ec98e151b9 100644
--- a/src/usr/local/www/firewall_aliases.php
+++ b/src/usr/local/www/firewall_aliases.php
@@ -48,15 +48,8 @@ if ($_POST) {
 		$retval = 0;
 
 		/* reload all components that use aliases */
-		$retval = filter_configure();
+		$retval |= filter_configure();
 
-		if (stristr($retval, "error") <> true) {
-			$savemsg = get_std_save_message($retval);
-			$class = "success";
-		} else {
-			$savemsg = $retval;
-			$class = "danger";
-		}
 		if ($retval == 0) {
 			clear_subsystem_dirty('aliases');
 		}
@@ -99,8 +92,7 @@ if ($_GET['act'] == "del") {
 		// Static routes
 		find_alias_reference(array('staticroutes', 'route'), array('network'), $alias_name, $is_alias_referenced, $referenced_by);
 		if ($is_alias_referenced == true) {
-			$savemsg = sprintf(gettext("Cannot delete alias. Currently in use by %s."), htmlspecialchars($referenced_by));
-			$class = "danger";
+			$delete_error = sprintf(gettext("Cannot delete alias. Currently in use by %s."), htmlspecialchars($referenced_by));
 		} else {
 			if (preg_match("/urltable/i", $a_aliases[$_GET['id']]['type'])) {
 				// this is a URL table type alias, delete its file as well
@@ -173,8 +165,11 @@ $shortcut_section = "aliases";
 
 include("head.inc");
 
-if ($savemsg) {
-	print_info_box($savemsg, $class);
+if ($delete_error) {
+	print_info_box($delete_error, 'danger');
+}
+if ($_POST['apply']) {
+	print_apply_result_box($retval);
 }
 
 if (is_subsystem_dirty('aliases')) {
diff --git a/src/usr/local/www/firewall_nat.php b/src/usr/local/www/firewall_nat.php
index 3fd7c36212..681c98149e 100644
--- a/src/usr/local/www/firewall_nat.php
+++ b/src/usr/local/www/firewall_nat.php
@@ -86,7 +86,6 @@ if ($_POST) {
 		$retval = 0;
 
 		$retval |= filter_configure();
-		$savemsg = get_std_save_message($retval);
 
 		pfSense_handle_custom_code("/usr/local/pkg/firewall_nat/apply");
 
@@ -186,8 +185,8 @@ if (isset($_POST['del_x'])) {
 $pgtitle = array(gettext("Firewall"), gettext("NAT"), gettext("Port Forward"));
 include("head.inc");
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($_POST['apply']) {
+	print_apply_result_box($retval);
 }
 
 if (is_subsystem_dirty('natconf')) {
diff --git a/src/usr/local/www/firewall_nat_1to1.php b/src/usr/local/www/firewall_nat_1to1.php
index 5ae075bf52..87f9169873 100644
--- a/src/usr/local/www/firewall_nat_1to1.php
+++ b/src/usr/local/www/firewall_nat_1to1.php
@@ -68,7 +68,6 @@ if ($_POST) {
 	if ($_POST['apply']) {
 		$retval = 0;
 		$retval |= filter_configure();
-		$savemsg = get_std_save_message($retval);
 
 		if ($retval == 0) {
 			clear_subsystem_dirty('natconf');
@@ -122,8 +121,8 @@ if (isset($_POST['del_x'])) {
 $pgtitle = array(gettext("Firewall"), gettext("NAT"), gettext("1:1"));
 include("head.inc");
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($_POST['apply']) {
+	print_apply_result_box($retval);
 }
 
 if (is_subsystem_dirty('natconf')) {
diff --git a/src/usr/local/www/firewall_nat_npt.php b/src/usr/local/www/firewall_nat_npt.php
index b585d99acf..e2d785694f 100644
--- a/src/usr/local/www/firewall_nat_npt.php
+++ b/src/usr/local/www/firewall_nat_npt.php
@@ -69,7 +69,6 @@ if ($_POST) {
 	if ($_POST['apply']) {
 		$retval = 0;
 		$retval |= filter_configure();
-		$savemsg = get_std_save_message($retval);
 
 		if ($retval == 0) {
 			clear_subsystem_dirty('natconf');
@@ -122,8 +121,8 @@ if (isset($_POST['del_x'])) {
 $pgtitle = array(gettext("Firewall"), gettext("NAT"), gettext("NPt"));
 include("head.inc");
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($_POST['apply']) {
+	print_apply_result_box($retval);
 }
 
 if (is_subsystem_dirty('natconf')) {
diff --git a/src/usr/local/www/firewall_nat_out.php b/src/usr/local/www/firewall_nat_out.php
index 6915780e62..a09988c54d 100644
--- a/src/usr/local/www/firewall_nat_out.php
+++ b/src/usr/local/www/firewall_nat_out.php
@@ -82,12 +82,6 @@ if ($_POST['apply']) {
 	$retval = 0;
 	$retval |= filter_configure();
 
-	if (stristr($retval, "error") <> true) {
-			$savemsg = get_std_save_message($retval);
-	} else {
-		$savemsg = $retval;
-	}
-
 	if ($retval == 0) {
 		clear_subsystem_dirty('natconf');
 		clear_subsystem_dirty('filter');
@@ -139,7 +133,7 @@ if ($_POST['save']) {
 				}
 			}
 		}
-		$savemsg = gettext("Default rules for each interface have been created.");
+		$default_rules_msg = gettext("Default rules for each interface have been created.");
 		unset($FilterIflist, $GatewaysList);
 	}
 
@@ -206,8 +200,12 @@ if (isset($_POST['del_x'])) {
 $pgtitle = array(gettext("Firewall"), gettext("NAT"), gettext("Outbound"));
 include("head.inc");
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($default_rules_msg) {
+	print_info_box($default_rules_msg, 'success');
+}
+
+if ($_POST['apply']) {
+	print_apply_result_box($retval);
 }
 
 if (is_subsystem_dirty('natconf')) {
diff --git a/src/usr/local/www/firewall_shaper.php b/src/usr/local/www/firewall_shaper.php
index 82410ccd4b..77850ed4cd 100644
--- a/src/usr/local/www/firewall_shaper.php
+++ b/src/usr/local/www/firewall_shaper.php
@@ -121,19 +121,11 @@ if ($_GET) {
 			}
 
 			if (write_config()) {
+				$changes_applied = true;
 				$retval = 0;
 				$retval |= filter_configure();
-
-				if (stristr($retval, "error") <> true) {
-					$savemsg = get_std_save_message($retval);
-					$class = 'success';
-				} else {
-					$savemsg = $retval;
-					$class = 'warning';
-				}
 			} else {
-				$savemsg = gettext("Unable to write config.xml (Access Denied?).");
-				$class = 'warning';
+				$no_write_config_msg = gettext("Unable to write config.xml (Access Denied?).");
 			}
 
 			$dfltmsg = true;
@@ -280,17 +272,9 @@ if ($_POST) {
 		}
 	} else if ($_POST['apply']) {
 		write_config();
-
+		$changes_applied = true;
 		$retval = 0;
-		$retval = filter_configure();
-
-		if (stristr($retval, "error") <> true) {
-			$savemsg = get_std_save_message($retval);
-			$class = 'success';
-		} else {
-			$savemsg = $retval;
-			$class = 'warning';
-		}
+		$retval |= filter_configure();
 
 		/* reset rrd queues */
 		system("rm -f /var/db/rrd/*queuedrops.rrd");
@@ -369,8 +353,12 @@ if ($input_errors) {
 	print_input_errors($input_errors);
 }
 
-if ($savemsg) {
-	print_info_box($savemsg, $class);
+if ($no_write_config_msg) {
+	print_info_box($no_write_config_msg, 'danger');
+}
+
+if ($changes_applied) {
+	print_apply_result_box($retval);
 }
 
 if (is_subsystem_dirty('shaper')) {
diff --git a/src/usr/local/www/firewall_shaper_queues.php b/src/usr/local/www/firewall_shaper_queues.php
index 0bdb99e5a2..e148150576 100644
--- a/src/usr/local/www/firewall_shaper_queues.php
+++ b/src/usr/local/www/firewall_shaper_queues.php
@@ -167,15 +167,7 @@ if ($_POST['apply']) {
 
 	$retval = 0;
 	/* Setup pf rules since the user may have changed the optimization value */
-	$retval = filter_configure();
-	$savemsg = get_std_save_message($retval);
-	if (stristr($retval, "error") <> true) {
-		$savemsg = get_std_save_message($retval);
-		$class = 'alert-success';
-	} else {
-		$savemsg = $retval;
-		$class = 'alert-danger';
-	}
+	$retval |= filter_configure();
 
 	/* reset rrd queues */
 	system("rm -f /var/db/rrd/*queuedrops.rrd");
@@ -198,8 +190,8 @@ if ($input_errors) {
 	print_input_errors($input_errors);
 }
 
-if ($savemsg) {
-	print_info_box($savemsg, $class);
+if ($_POST['apply']) {
+	print_apply_result_box($retval);
 }
 
 if (is_subsystem_dirty('shaper')) {
diff --git a/src/usr/local/www/firewall_shaper_vinterface.php b/src/usr/local/www/firewall_shaper_vinterface.php
index 74526e9a14..5de573f4b4 100644
--- a/src/usr/local/www/firewall_shaper_vinterface.php
+++ b/src/usr/local/www/firewall_shaper_vinterface.php
@@ -134,20 +134,11 @@ if ($_GET) {
 				}
 			}
 			if (write_config()) {
+				$changes_applied = true;
 				$retval = 0;
-				$retval = filter_configure();
-
-				if (stristr($retval, "error") != true) {
-					$savemsg = get_std_save_message($retval);
-					$class = 'success';
-				} else {
-					$savemsg = $retval;
-					$class = 'danger';
-				}
-
+				$retval |= filter_configure();
 			} else {
-				$savemsg = gettext("Unable to write config.xml (Access Denied?).");
-				$class = 'danger';
+				$no_write_config_msg = gettext("Unable to write config.xml (Access Denied?).");
 			}
 
 			$dfltmsg = true;
@@ -271,16 +262,9 @@ if ($_POST) {
 	} else if ($_POST['apply']) {
 		write_config();
 
+		$changes_applied = true;
 		$retval = 0;
-		$retval = filter_configure();
-
-		if (stristr($retval, "error") != true) {
-			$savemsg = get_std_save_message($retval);
-			$class = 'success';
-		} else {
-			$savemsg = $retval;
-			$class = 'danger';
-		}
+		$retval |= filter_configure();
 
 		/* XXX: TODO Make dummynet pretty graphs */
 		//	enable_rrd_graphing();
@@ -369,8 +353,12 @@ if ($input_errors) {
 	print_input_errors($input_errors);
 }
 
-if ($savemsg) {
-	print_info_box($savemsg, $class);
+if ($no_write_config_msg) {
+	print_info_box($no_write_config_msg, 'danger');
+}
+
+if ($changes_applied) {
+	print_apply_result_box($retval);
 }
 
 if (is_subsystem_dirty('shaper')) {
diff --git a/src/usr/local/www/firewall_shaper_wizards.php b/src/usr/local/www/firewall_shaper_wizards.php
index 594ed63e57..b9d647e128 100644
--- a/src/usr/local/www/firewall_shaper_wizards.php
+++ b/src/usr/local/www/firewall_shaper_wizards.php
@@ -42,14 +42,7 @@ if ($_POST['apply']) {
 
 	$retval = 0;
 	/* Setup pf rules since the user may have changed the optimization value */
-	$retval = filter_configure();
-	if (stristr($retval, "error") <> true) {
-		$savemsg = get_std_save_message($retval);
-		$class = 'success';
-	} else {
-		$savemsg = $retval;
-		$class = 'warning';
-	}
+	$retval |= filter_configure();
 
 	/* reset rrd queues */
 	unlink_if_exists("/var/db/rrd/*queuedrops.rrd");
@@ -82,8 +75,8 @@ $tab_array[] = array(gettext("Limiters"), false, "firewall_shaper_vinterface.php
 $tab_array[] = array(gettext("Wizards"), true, "firewall_shaper_wizards.php");
 display_top_tabs($tab_array);
 
-if ($savemsg) {
-	print_info_box($savemsg, $class);
+if ($_POST['apply']) {
+	print_apply_result_box($retval);
 }
 
 if (is_subsystem_dirty('shaper')) {
diff --git a/src/usr/local/www/firewall_virtual_ip.php b/src/usr/local/www/firewall_virtual_ip.php
index 33a1f4f074..a15a60b9fb 100644
--- a/src/usr/local/www/firewall_virtual_ip.php
+++ b/src/usr/local/www/firewall_virtual_ip.php
@@ -79,7 +79,6 @@ if ($_POST) {
 
 		$retval = 0;
 		$retval |= filter_configure();
-		$savemsg = get_std_save_message($retval);
 
 		clear_subsystem_dirty('vip');
 	}
@@ -240,8 +239,8 @@ include("head.inc");
 
 if ($input_errors) {
 	print_input_errors($input_errors);
-} else if ($savemsg) {
-	print_info_box($savemsg, 'success');
+} else if ($_POST['apply']) {
+	print_apply_result_box($retval);
 } else if (is_subsystem_dirty('vip')) {
 	print_apply_box(gettext("The VIP configuration has been changed.") . "<br />" . gettext("The changes must be applied for them to take effect."));
 }
diff --git a/src/usr/local/www/guiconfig.inc b/src/usr/local/www/guiconfig.inc
index d4fc383d60..7fa8e5d062 100644
--- a/src/usr/local/www/guiconfig.inc
+++ b/src/usr/local/www/guiconfig.inc
@@ -323,6 +323,27 @@ function print_apply_box($msg) {
 	print_info_box($msg, "warning", "apply", gettext("Apply Changes"), 'fa-check', 'success');
 }
 
+// Format and print a box reporting that changes have been applied
+// $retval = status value from the functions called to apply the changes
+// 0 is good
+// non-zero is a problem
+// $extra_text = optional extra text to display after the standard message
+function print_apply_result_box($retval, $extra_text="") {
+	$result_msg = get_std_save_message($retval);
+	if ($retval === 0) {
+		// 0 is success
+		$severity = "success";
+	} else {
+		// non-zero means there was some problem
+		$severity = "warning";
+	}
+
+	if (strlen($extra_text) > 0) {
+		$result_msg .= " " . $extra_text;
+	}
+	print_info_box($result_msg, $severity);
+}
+
 /*
  * Print Bootstrap callout
  *
@@ -350,10 +371,16 @@ function print_callout($msg, $class = 'info', $heading = '') {
 	echo $callout;
 }
 
-function get_std_save_message($ok) {
+function get_std_save_message($retval) {
 	$filter_related = false;
 	$filter_pages = array("nat", "filter");
-	$to_return = gettext("The changes have been applied successfully.");
+	if ($retval === 0) {
+		// 0 is success
+		$to_return = gettext("The changes have been applied successfully.");
+	} else {
+		// non-zero means there was some problem
+		$to_return = gettext("There was a problem applying the changes. See the <a href=\"status_logs.php\">System Logs</a>.");
+	}
 	foreach ($filter_pages as $fp) {
 		if (stristr($_SERVER['SCRIPT_FILENAME'], $fp)) {
 			$filter_related = true;
diff --git a/src/usr/local/www/interfaces.php b/src/usr/local/www/interfaces.php
index a63144d7b9..6f206fc7a6 100755
--- a/src/usr/local/www/interfaces.php
+++ b/src/usr/local/www/interfaces.php
@@ -407,11 +407,14 @@ if (isset($wancfg['wireless'])) {
 
 }
 
+$changes_applied = false;
+
 if ($_POST['apply']) {
 	unset($input_errors);
 	if (!is_subsystem_dirty('interfaces')) {
 		$input_errors[] = gettext("The settings have already been applied!");
 	} else {
+		$retval = 0;
 		unlink_if_exists("{$g['tmp_path']}/config.cache");
 		clear_subsystem_dirty('interfaces');
 
@@ -440,24 +443,24 @@ if ($_POST['apply']) {
 			}
 		}
 		/* restart snmp so that it binds to correct address */
-		services_snmpd_configure();
+		$retval |= services_snmpd_configure();
 
 		/* sync filter configuration */
 		setup_gateways_monitor();
 
 		clear_subsystem_dirty('interfaces');
 
-		filter_configure();
+		$retval |= filter_configure();
 
 		enable_rrd_graphing();
 
+		$changes_applied = true;
+
 		if (is_subsystem_dirty('staticroutes') && (system_routing_configure() == 0)) {
 			clear_subsystem_dirty('staticroutes');
 		}
 	}
 	@unlink("{$g['tmp_path']}/.interfaces.apply");
-	header("Location: interfaces.php?if={$if}");
-	exit;
 } else if ($_POST) {
 
 	unset($input_errors);
@@ -1695,11 +1698,10 @@ if (is_subsystem_dirty('interfaces')) {
 					gettext("Don't forget to adjust the DHCP Server range if needed after applying."));
 }
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($changes_applied) {
+	print_apply_result_box($retval);
 }
 
-
 $form = new Form();
 
 $section = new Form_Section('General Configuration');
diff --git a/src/usr/local/www/interfaces_assign.php b/src/usr/local/www/interfaces_assign.php
index b647feaab4..26b7a88fa1 100644
--- a/src/usr/local/www/interfaces_assign.php
+++ b/src/usr/local/www/interfaces_assign.php
@@ -244,7 +244,7 @@ if (isset($_POST['add']) && isset($_POST['if_add'])) {
 
 		write_config();
 
-		$savemsg = gettext("Interface has been added.");
+		$action_msg = gettext("Interface has been added.");
 		$class = "success";
 	}
 
@@ -255,15 +255,9 @@ if (isset($_POST['add']) && isset($_POST['if_add'])) {
 	} else {
 		write_config();
 
-		$retval = filter_configure();
-
-		if (stristr($retval, "error") <> true) {
-			$savemsg = get_std_save_message($retval);
-			$class = "success";
-		} else {
-			$savemsg = $retval;
-			$class = "danger";
-		}
+		$changes_applied = true;
+		$retval = 0;
+		$retval |= filter_configure();
 	}
 
 } else if (isset($_POST['Submit'])) {
@@ -438,7 +432,7 @@ if (isset($_POST['add']) && isset($_POST['if_add'])) {
 
 			link_interface_to_vlans($realid, "update");
 
-			$savemsg = gettext("Interface has been deleted.");
+			$action_msg = gettext("Interface has been deleted.");
 			$class = "success";
 		}
 	}
@@ -464,14 +458,14 @@ include("head.inc");
 if (file_exists("/var/run/interface_mismatch_reboot_needed")) {
 	if ($_POST) {
 		if ($rebootingnow) {
-			$savemsg = gettext("The system is now rebooting. Please wait.");
+			$action_msg = gettext("The system is now rebooting. Please wait.");
 			$class = "success";
 		} else {
 			$applymsg = gettext("Reboot is needed. Please apply the settings in order to reboot.");
 			$class = "warning";
 		}
 	} else {
-		$savemsg = gettext("Interface mismatch detected. Please resolve the mismatch, save and then click 'Apply Changes'. The firewall will reboot afterwards.");
+		$action_msg = gettext("Interface mismatch detected. Please resolve the mismatch, save and then click 'Apply Changes'. The firewall will reboot afterwards.");
 		$class = "warning";
 	}
 }
@@ -482,8 +476,10 @@ if (file_exists("/tmp/reload_interfaces")) {
 	echo "<br /></p>\n";
 } elseif ($applymsg) {
 	print_apply_box($applymsg);
-} elseif ($savemsg) {
-	print_info_box($savemsg, $class);
+} elseif ($action_msg) {
+	print_info_box($action_msg, $class);
+} elseif ($changes_applied) {
+	print_apply_result_box($retval);
 }
 
 pfSense_handle_custom_code("/usr/local/pkg/interfaces_assign/pre_input_errors");
diff --git a/src/usr/local/www/load_balancer_monitor.php b/src/usr/local/www/load_balancer_monitor.php
index a6875cabfa..f85f972811 100644
--- a/src/usr/local/www/load_balancer_monitor.php
+++ b/src/usr/local/www/load_balancer_monitor.php
@@ -43,7 +43,6 @@ if ($_POST) {
 		$retval |= filter_configure();
 		$retval |= relayd_configure();
 
-		$savemsg = get_std_save_message($retval);
 		clear_subsystem_dirty('loadbalancer');
 	}
 }
@@ -79,8 +78,8 @@ if ($input_errors) {
 	print_input_errors($input_errors);
 }
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($_POST['apply']) {
+	print_apply_result_box($retval);
 }
 
 if (is_subsystem_dirty('loadbalancer')) {
diff --git a/src/usr/local/www/load_balancer_pool.php b/src/usr/local/www/load_balancer_pool.php
index d9788cd919..48b33eede7 100644
--- a/src/usr/local/www/load_balancer_pool.php
+++ b/src/usr/local/www/load_balancer_pool.php
@@ -47,7 +47,6 @@ if ($_POST) {
 		$retval |= filter_configure();
 		$retval |= relayd_configure();
 
-		$savemsg = get_std_save_message($retval);
 		clear_subsystem_dirty('loadbalancer');
 	}
 }
@@ -93,8 +92,8 @@ if ($input_errors) {
 	print_input_errors($input_errors);
 }
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($_POST['apply']) {
+	print_apply_result_box($retval);
 }
 
 if (is_subsystem_dirty('loadbalancer')) {
diff --git a/src/usr/local/www/load_balancer_setting.php b/src/usr/local/www/load_balancer_setting.php
index 9ae4a951c5..a8470c3ef9 100644
--- a/src/usr/local/www/load_balancer_setting.php
+++ b/src/usr/local/www/load_balancer_setting.php
@@ -46,7 +46,6 @@ if ($_POST) {
 		$retval |= filter_configure();
 		$retval |= relayd_configure();
 
-		$savemsg = get_std_save_message($retval);
 		clear_subsystem_dirty('loadbalancer');
 	} else {
 		unset($input_errors);
@@ -92,8 +91,8 @@ if ($input_errors) {
 	print_input_errors($input_errors);
 }
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($_POST['apply']) {
+	print_apply_result_box($retval);
 }
 
 if (is_subsystem_dirty('loadbalancer')) {
diff --git a/src/usr/local/www/load_balancer_virtual_server.php b/src/usr/local/www/load_balancer_virtual_server.php
index f07c7acb87..808220360f 100644
--- a/src/usr/local/www/load_balancer_virtual_server.php
+++ b/src/usr/local/www/load_balancer_virtual_server.php
@@ -45,7 +45,6 @@ if ($_POST) {
 		$retval = 0;
 		$retval |= filter_configure();
 		$retval |= relayd_configure();
-		$savemsg = get_std_save_message($retval);
 		/* Wipe out old relayd anchors no longer in use. */
 		cleanup_lb_marked();
 		clear_subsystem_dirty('loadbalancer');
@@ -113,8 +112,8 @@ if ($input_errors) {
 	print_input_errors($input_errors);
 }
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($_POST['apply']) {
+	print_apply_result_box($retval);
 }
 
 if (is_subsystem_dirty('loadbalancer')) {
diff --git a/src/usr/local/www/services_captiveportal_mac.php b/src/usr/local/www/services_captiveportal_mac.php
index 8e37a1e3cc..79cfee3f6e 100644
--- a/src/usr/local/www/services_captiveportal_mac.php
+++ b/src/usr/local/www/services_captiveportal_mac.php
@@ -76,7 +76,6 @@ if ($_POST) {
 				mwexec("/sbin/ipfw {$g['tmp_path']}/passthrumac_gui");
 				@unlink("{$g['tmp_path']}/passthrumac_gui");
 			}
-			$savemsg = get_std_save_message($retval);
 			if ($retval == 0) {
 				clear_subsystem_dirty('passthrumac');
 			}
@@ -152,8 +151,8 @@ if ($_GET['act'] == "del") {
 
 include("head.inc");
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($_POST['apply']) {
+	print_apply_result_box($retval);
 }
 
 if (is_subsystem_dirty('passthrumac')) {
diff --git a/src/usr/local/www/services_dhcp.php b/src/usr/local/www/services_dhcp.php
index 426f1c3ab9..db5ce1c332 100644
--- a/src/usr/local/www/services_dhcp.php
+++ b/src/usr/local/www/services_dhcp.php
@@ -610,39 +610,38 @@ if (isset($_POST['save'])) {
 }
 
 if ((isset($_POST['save']) || isset($_POST['apply'])) && (!$input_errors)) {
+	$changes_applied = true;
 	$retval = 0;
 	$retvaldhcp = 0;
 	$retvaldns = 0;
 	/* dnsmasq_configure calls dhcpd_configure */
 	/* no need to restart dhcpd twice */
 	if (isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcpstatic']))	{
-		$retvaldns = services_dnsmasq_configure();
+		$retvaldns |= services_dnsmasq_configure();
 		if ($retvaldns == 0) {
 			clear_subsystem_dirty('hosts');
 			clear_subsystem_dirty('staticmaps');
 		}
 	} else if (isset($config['unbound']['enable']) && isset($config['unbound']['regdhcpstatic'])) {
-		$retvaldns = services_unbound_configure();
+		$retvaldns |= services_unbound_configure();
 		if ($retvaldns == 0) {
 			clear_subsystem_dirty('unbound');
 			clear_subsystem_dirty('hosts');
 			clear_subsystem_dirty('staticmaps');
 		}
 	} else {
-		$retvaldhcp = services_dhcpd_configure();
+		$retvaldhcp |= services_dhcpd_configure();
 		if ($retvaldhcp == 0) {
 			clear_subsystem_dirty('staticmaps');
 		}
 	}
 	if ($dhcpd_enable_changed) {
-		$retvalfc = filter_configure();
+		$retvalfc |= filter_configure();
 	}
 
 	if ($retvaldhcp == 1 || $retvaldns == 1 || $retvalfc == 1) {
 		$retval = 1;
 	}
-
-	$savemsg = get_std_save_message($retval);
 }
 
 if ($act == "delpool") {
@@ -733,8 +732,8 @@ if ($input_errors) {
 	print_input_errors($input_errors);
 }
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($changes_applied) {
+	print_apply_result_box($retval);
 }
 
 if (is_subsystem_dirty('staticmaps')) {
diff --git a/src/usr/local/www/services_dhcp_relay.php b/src/usr/local/www/services_dhcp_relay.php
index e824b44864..fc8e367009 100644
--- a/src/usr/local/www/services_dhcp_relay.php
+++ b/src/usr/local/www/services_dhcp_relay.php
@@ -114,10 +114,10 @@ if ($_POST) {
 
 		write_config();
 
+		$changes_applied = true;
 		$retval = 0;
-		$retval = services_dhcrelay_configure();
-		$savemsg = get_std_save_message($retval);
-		filter_configure();
+		$retval |= services_dhcrelay_configure();
+		$retval |= filter_configure();
 	}
 }
 
@@ -135,8 +135,8 @@ if ($input_errors) {
 	print_input_errors($input_errors);
 }
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($changes_applied) {
+	print_apply_result_box($retval);
 }
 
 $form = new Form;
diff --git a/src/usr/local/www/services_dhcpv6.php b/src/usr/local/www/services_dhcpv6.php
index 44afcc48aa..820f89b396 100644
--- a/src/usr/local/www/services_dhcpv6.php
+++ b/src/usr/local/www/services_dhcpv6.php
@@ -44,30 +44,30 @@ function dhcpv6_apply_changes($dhcpdv6_enable_changed) {
 	/* dnsmasq_configure calls dhcpd_configure */
 	/* no need to restart dhcpd twice */
 	if (isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcpstatic']))	{
-		$retvaldns = services_dnsmasq_configure();
+		$retvaldns |= services_dnsmasq_configure();
 		if ($retvaldns == 0) {
 			clear_subsystem_dirty('hosts');
 			clear_subsystem_dirty('staticmaps');
 		}
 	} else if (isset($config['unbound']['enable']) && isset($config['unbound']['regdhcpstatic'])) {
-		$retvaldns = services_unbound_configure();
+		$retvaldns |= services_unbound_configure();
 		if ($retvaldns == 0) {
 			clear_subsystem_dirty('unbound');
 			clear_subsystem_dirty('staticmaps');
 		}
 	} else {
-		$retvaldhcp = services_dhcpd_configure();
+		$retvaldhcp |= services_dhcpd_configure();
 		if ($retvaldhcp == 0) {
 			clear_subsystem_dirty('staticmaps');
 		}
 	}
 	if ($dhcpdv6_enable_changed) {
-		$retvalfc = filter_configure();
+		$retvalfc |= filter_configure();
 	}
 	if ($retvaldhcp == 1 || $retvaldns == 1 || $retvalfc == 1) {
 		$retval = 1;
 	}
-	return get_std_save_message($retval);
+	return $retval;
 }
 
 if (!$g['services_dhcp_server_enable']) {
@@ -184,7 +184,8 @@ if (is_array($dhcrelaycfg) && isset($dhcrelaycfg['enable']) && isset($dhcrelaycf
 }
 
 if (isset($_POST['apply'])) {
-	$savemsg = dhcpv6_apply_changes(false);
+	$changes_applied = true;
+	$retval = dhcpv6_apply_changes(false);
 } elseif (isset($_POST['save'])) {
 	unset($input_errors);
 
@@ -459,7 +460,8 @@ if (isset($_POST['apply'])) {
 
 		write_config();
 
-		$savemsg = dhcpv6_apply_changes($dhcpdv6_enable_changed);
+		$changes_applied = true;
+		$retval = dhcpv6_apply_changes($dhcpdv6_enable_changed);
 	}
 }
 
@@ -492,8 +494,8 @@ if ($input_errors) {
 	print_input_errors($input_errors);
 }
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($changes_applied) {
+	print_apply_result_box($retval);
 }
 
 if (is_subsystem_dirty('staticmaps')) {
diff --git a/src/usr/local/www/services_dhcpv6_relay.php b/src/usr/local/www/services_dhcpv6_relay.php
index b6f1964ea1..8f4135b840 100644
--- a/src/usr/local/www/services_dhcpv6_relay.php
+++ b/src/usr/local/www/services_dhcpv6_relay.php
@@ -115,9 +115,9 @@ if ($_POST) {
 
 		write_config();
 
+		$changes_applied = true;
 		$retval = 0;
-		$retval = services_dhcrelay6_configure();
-		$savemsg = get_std_save_message($retval);
+		$retval |= services_dhcrelay6_configure();
 	}
 }
 
@@ -135,8 +135,8 @@ if ($input_errors) {
 	print_input_errors($input_errors);
 }
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($changes_applied) {
+	print_apply_result_box($retval);
 }
 
 $form = new Form;
diff --git a/src/usr/local/www/services_dnsmasq.php b/src/usr/local/www/services_dnsmasq.php
index fb74e7baa7..2885edd5de 100644
--- a/src/usr/local/www/services_dnsmasq.php
+++ b/src/usr/local/www/services_dnsmasq.php
@@ -113,8 +113,7 @@ domains_sort();
 if ($_POST) {
 	if ($_POST['apply']) {
 		$retval = 0;
-		$retval = services_dnsmasq_configure();
-		$savemsg = get_std_save_message($retval);
+		$retval |= services_dnsmasq_configure();
 
 		// Reload filter (we might need to sync to CARP hosts)
 		filter_configure();
@@ -232,8 +231,8 @@ if ($input_errors) {
 	print_input_errors($input_errors);
 }
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($_POST['apply']) {
+	print_apply_result_box($retval);
 }
 
 if (is_subsystem_dirty('hosts')) {
diff --git a/src/usr/local/www/services_igmpproxy.php b/src/usr/local/www/services_igmpproxy.php
index f3b8775aaf..5de6aa1566 100644
--- a/src/usr/local/www/services_igmpproxy.php
+++ b/src/usr/local/www/services_igmpproxy.php
@@ -42,15 +42,10 @@ $a_igmpproxy = &$config['igmpproxy']['igmpentry'];
 if ($_POST) {
 	$pconfig = $_POST;
 
+	$changes_applied = true;
 	$retval = 0;
 	/* reload all components that use igmpproxy */
-	$retval = services_igmpproxy_configure();
-
-	if (stristr($retval, "error") <> true) {
-		$savemsg = get_std_save_message($retval);
-	} else {
-		$savemsg = $retval;
-	}
+	$retval |= services_igmpproxy_configure();
 
 	clear_subsystem_dirty('igmpproxy');
 }
@@ -68,8 +63,8 @@ if ($_GET['act'] == "del") {
 $pgtitle = array(gettext("Services"), gettext("IGMP Proxy"));
 include("head.inc");
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($changes_applied) {
+	print_apply_result_box($retval);
 }
 
 if (is_subsystem_dirty('igmpproxy')) {
diff --git a/src/usr/local/www/services_ntpd.php b/src/usr/local/www/services_ntpd.php
index 2adcfe07aa..81b1e02ec9 100644
--- a/src/usr/local/www/services_ntpd.php
+++ b/src/usr/local/www/services_ntpd.php
@@ -151,9 +151,9 @@ if ($_POST) {
 
 		write_config("Updated NTP Server Settings");
 
+		$changes_applied = true;
 		$retval = 0;
-		$retval = system_ntp_configure();
-		$savemsg = get_std_save_message($retval);
+		$retval |= system_ntp_configure();
 	}
 }
 
@@ -192,8 +192,9 @@ include("head.inc");
 if ($input_errors) {
 	print_input_errors($input_errors);
 }
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+
+if ($changes_applied) {
+	print_apply_result_box($retval);
 }
 
 $tab_array = array();
diff --git a/src/usr/local/www/services_ntpd_acls.php b/src/usr/local/www/services_ntpd_acls.php
index 19c057d1f4..ea80ea471c 100644
--- a/src/usr/local/www/services_ntpd_acls.php
+++ b/src/usr/local/www/services_ntpd_acls.php
@@ -150,9 +150,9 @@ if ($_POST) {
 
 		write_config("Updated NTP ACL Settings");
 
+		$changes_applied = true;
 		$retval = 0;
-		$retval = system_ntp_configure();
-		$savemsg = get_std_save_message($retval);
+		$retval |= system_ntp_configure();
 	}
 }
 
@@ -165,8 +165,9 @@ include("head.inc");
 if ($input_errors) {
 	print_input_errors($input_errors);
 }
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+
+if ($changes_applied) {
+	print_apply_result_box($retval);
 }
 
 $tab_array = array();
diff --git a/src/usr/local/www/services_ntpd_gps.php b/src/usr/local/www/services_ntpd_gps.php
index 971d57e8fd..f06e03ebd6 100644
--- a/src/usr/local/www/services_ntpd_gps.php
+++ b/src/usr/local/www/services_ntpd_gps.php
@@ -154,8 +154,9 @@ if ($_POST) {
 
 	write_config(gettext("Updated NTP GPS Settings"));
 
-	$retval = system_ntp_configure();
-	$savemsg = get_std_save_message($retval);
+	$changes_applied = true;
+	$retval = 0;
+	$retval |= system_ntp_configure();
 } else {
 	/* set defaults if they do not already exist */
 	if (!is_array($config['ntpd']) || !is_array($config['ntpd']['gps']) || empty($config['ntpd']['gps']['type'])) {
@@ -192,6 +193,10 @@ $pgtitle = array(gettext("Services"), gettext("NTP"), gettext("Serial GPS"));
 $shortcut_section = "ntp";
 include("head.inc");
 
+if ($changes_applied) {
+	print_apply_result_box($retval);
+}
+
 $tab_array = array();
 $tab_array[] = array(gettext("Settings"), false, "services_ntpd.php");
 $tab_array[] = array(gettext("ACLs"), false, "services_ntpd_acls.php");
diff --git a/src/usr/local/www/services_ntpd_pps.php b/src/usr/local/www/services_ntpd_pps.php
index da987f7ec1..c3d70dfdc9 100644
--- a/src/usr/local/www/services_ntpd_pps.php
+++ b/src/usr/local/www/services_ntpd_pps.php
@@ -91,9 +91,9 @@ if ($_POST) {
 
 		write_config("Updated NTP PPS Settings");
 
+		$changes_applied = true;
 		$retval = 0;
-		$retval = system_ntp_configure();
-		$savemsg = get_std_save_message($retval);
+		$retval |= system_ntp_configure();
 	}
 }
 
@@ -107,8 +107,8 @@ if ($input_errors) {
     print_input_errors($input_errors);
 }
 
-if ($savemsg) {
-    print_info_box($savemsg, 'success');
+if ($changes_applied) {
+	print_apply_result_box($retval);
 }
 
 $tab_array = array();
diff --git a/src/usr/local/www/services_pppoe.php b/src/usr/local/www/services_pppoe.php
index a8b0f030e3..85b3531891 100644
--- a/src/usr/local/www/services_pppoe.php
+++ b/src/usr/local/www/services_pppoe.php
@@ -59,7 +59,6 @@ if ($_POST) {
 		}
 		$retval = 0;
 		$retval |= filter_configure();
-		$savemsg = get_std_save_message($retval);
 		clear_subsystem_dirty('vpnpppoe');
 	}
 }
@@ -83,8 +82,8 @@ $pgtitle = array(gettext("Services"), gettext("PPPoE Server"));
 $shortcut_section = "pppoes";
 include("head.inc");
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($_POST['apply']) {
+	print_apply_result_box($retval);
 }
 
 if (is_subsystem_dirty('vpnpppoe')) {
diff --git a/src/usr/local/www/services_router_advertisements.php b/src/usr/local/www/services_router_advertisements.php
index e369d37043..367aedbd53 100644
--- a/src/usr/local/www/services_router_advertisements.php
+++ b/src/usr/local/www/services_router_advertisements.php
@@ -54,7 +54,7 @@ if ($config['installedpackages']['olsrd']) {
 }
 
 if (!$_GET['if']) {
-	$savemsg = gettext("The DHCPv6 Server can only be enabled on interfaces configured with static, non unique local IP addresses.") . "<br />" .
+	$info_msg = gettext("The DHCPv6 Server can only be enabled on interfaces configured with static, non unique local IP addresses.") . "<br />" .
 	    gettext("Only interfaces configured with a static IP will be shown.");
 }
 
@@ -243,8 +243,9 @@ if ($_POST) {
 		}
 
 		write_config();
-		$retval = services_radvd_configure();
-		$savemsg = get_std_save_message($retval);
+		$changes_applied = true;
+		$retval = 0;
+		$retval |= services_radvd_configure();
 	}
 }
 
@@ -261,8 +262,12 @@ if ($input_errors) {
 	print_input_errors($input_errors);
 }
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($changes_applied) {
+	print_apply_result_box($retval);
+}
+
+if ($info_msg) {
+	print_info_box($info_msg, 'success');
 }
 
 /* active tabs */
diff --git a/src/usr/local/www/services_snmp.php b/src/usr/local/www/services_snmp.php
index 66caf4f03e..58bf88e997 100644
--- a/src/usr/local/www/services_snmp.php
+++ b/src/usr/local/www/services_snmp.php
@@ -161,9 +161,9 @@ if ($_POST) {
 
 		write_config();
 
+		$changes_applied = true;
 		$retval = 0;
-		$retval = services_snmpd_configure();
-		$savemsg = get_std_save_message($retval);
+		$retval |= services_snmpd_configure();
 	}
 }
 
@@ -200,8 +200,8 @@ if ($input_errors) {
 	print_input_errors($input_errors);
 }
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($changes_applied) {
+	print_apply_result_box($retval);
 }
 
 $form = new Form();
diff --git a/src/usr/local/www/services_unbound.php b/src/usr/local/www/services_unbound.php
index b79548cf86..10893d1a73 100644
--- a/src/usr/local/www/services_unbound.php
+++ b/src/usr/local/www/services_unbound.php
@@ -88,8 +88,8 @@ if (empty($a_unboundcfg['system_domain_local_zone_type'])) {
 
 if ($_POST) {
 	if ($_POST['apply']) {
-		$retval = services_unbound_configure();
-		$savemsg = get_std_save_message($retval);
+		$retval = 0;
+		$retval |= services_unbound_configure();
 		if ($retval == 0) {
 			clear_subsystem_dirty('unbound');
 		}
@@ -244,8 +244,8 @@ if ($input_errors) {
 	print_input_errors($input_errors);
 }
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($_POST['apply']) {
+	print_apply_result_box($retval);
 }
 
 if (is_subsystem_dirty('unbound')) {
diff --git a/src/usr/local/www/services_unbound_acls.php b/src/usr/local/www/services_unbound_acls.php
index 1174202a5c..31e218035f 100644
--- a/src/usr/local/www/services_unbound_acls.php
+++ b/src/usr/local/www/services_unbound_acls.php
@@ -99,8 +99,8 @@ if ($_POST) {
 	}
 
 	if ($_POST['apply']) {
-		$retval = services_unbound_configure();
-		$savemsg = get_std_save_message($retval);
+		$retval = 0;
+		$retval |= services_unbound_configure();
 		if ($retval == 0) {
 			clear_subsystem_dirty('unbound');
 		}
@@ -185,8 +185,8 @@ if ($input_errors) {
 	print_input_errors($input_errors);
 }
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($_POST['apply']) {
+	print_apply_result_box($retval);
 }
 
 if (is_subsystem_dirty('unbound')) {
diff --git a/src/usr/local/www/services_unbound_advanced.php b/src/usr/local/www/services_unbound_advanced.php
index 14bb37666d..1f869deb8b 100644
--- a/src/usr/local/www/services_unbound_advanced.php
+++ b/src/usr/local/www/services_unbound_advanced.php
@@ -77,8 +77,8 @@ if (isset($config['unbound']['use_caps'])) {
 
 if ($_POST) {
 	if ($_POST['apply']) {
-		$retval = services_unbound_configure();
-		$savemsg = get_std_save_message($retval);
+		$retval = 0;
+		$retval |= services_unbound_configure();
 		if ($retval == 0) {
 			clear_subsystem_dirty('unbound');
 		}
@@ -192,8 +192,8 @@ if ($input_errors) {
 	print_input_errors($input_errors);
 }
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($_POST['apply']) {
+	print_apply_result_box($retval);
 }
 
 if (is_subsystem_dirty('unbound')) {
diff --git a/src/usr/local/www/status_lb_pool.php b/src/usr/local/www/status_lb_pool.php
index 911e891cfd..7d22242287 100644
--- a/src/usr/local/www/status_lb_pool.php
+++ b/src/usr/local/www/status_lb_pool.php
@@ -68,7 +68,6 @@ if ($_POST) {
 		$retval = 0;
 		$retval |= filter_configure();
 		$retval |= relayd_configure();
-		$savemsg = get_std_save_message($retval);
 		clear_subsystem_dirty('loadbalancer');
 	} else {
 		/* Keep a list of servers we find in POST variables */
@@ -110,6 +109,10 @@ if (is_subsystem_dirty('loadbalancer')) {
 	print_apply_box(gettext("The load balancer configuration has been changed.") . "<br />" . gettext("The changes must be applied for them to take effect."));
 }
 
+if ($_POST['apply']) {
+	print_apply_result_box($retval);
+}
+
 /* active tabs */
 $tab_array = array();
 $tab_array[] = array(gettext("Pools"), true, "status_lb_pool.php");
diff --git a/src/usr/local/www/status_logs.php b/src/usr/local/www/status_logs.php
index 7435974bdd..74f94a9f16 100644
--- a/src/usr/local/www/status_logs.php
+++ b/src/usr/local/www/status_logs.php
@@ -99,8 +99,8 @@ if (in_array($logfile, array('system', 'gateways', 'routing', 'resolver', 'wirel
 }
 include("head.inc");
 
-if (!$input_errors && $savemsg) {
-	print_info_box($savemsg, 'success');
+if ($changes_applied) {
+	print_apply_result_box($retval, $extra_save_msg);
 	$manage_log_active = false;
 }
 
diff --git a/src/usr/local/www/status_logs_common.inc b/src/usr/local/www/status_logs_common.inc
index f35b9a2a2d..7a1d9c2533 100644
--- a/src/usr/local/www/status_logs_common.inc
+++ b/src/usr/local/www/status_logs_common.inc
@@ -584,8 +584,10 @@ function manage_log_code() {
 		return;
 	}
 
-	global $logfile, $specific_log, $config, $pconfig, $save_settings, $input_errors, $savemsg;
+	global $logfile, $specific_log, $config, $pconfig, $save_settings, $input_errors, $extra_save_msg, $retval, $changes_applied;
 
+	$changes_applied = false;
+	$extra_save_msg = "";
 	$specific_log = basename($logfile) . '_settings';
 
 	// Common to All Logs
@@ -711,37 +713,35 @@ function manage_log_code() {
 				}
 			}
 
+			$retval = 0;
 
 		// If any of the logging settings were changed then backup and sync (standard write_config).  Otherwise only write config (don't backup, don't sync).
-		if ($logging_changed) {
-			write_config($desc = gettext("Log Display Settings Saved: ") . gettext($allowed_logs[$logfile]["name"]), $backup = true, $write_config_only = false);
-			$retval = 0;
-			$retval = system_syslogd_start();
-			$savemsg = gettext("The changes have been applied successfully.");
-		} else {
-			write_config($desc = gettext("Log Display Settings Saved (no backup, no sync): ") . gettext($allowed_logs[$logfile]["name"]), $backup = false, $write_config_only = true);
-			$savemsg = '';
-		}
+			if ($logging_changed) {
+				write_config($desc = gettext("Log Display Settings Saved: ") . gettext($allowed_logs[$logfile]["name"]), $backup = true, $write_config_only = false);
+				$changes_applied = true;
+				$retval |= system_syslogd_start();
+			} else {
+				write_config($desc = gettext("Log Display Settings Saved (no backup, no sync): ") . gettext($allowed_logs[$logfile]["name"]), $backup = false, $write_config_only = true);
+			}
 
 		// Specific to System General (main) Log
-		if ($logfile == 'system') {
-			if ($nginx_logging_changed) {
-				ob_flush();
-				flush();
-				log_error(gettext("webConfigurator configuration has changed. Restarting webConfigurator."));
-				send_event("service restart webgui");
-				$savemsg .= "<br />" . gettext("WebGUI process is restarting.");
+			if ($logfile == 'system') {
+				if ($nginx_logging_changed) {
+					ob_flush();
+					flush();
+					log_error(gettext("webConfigurator configuration has changed. Restarting webConfigurator."));
+					send_event("service restart webgui");
+					$extra_save_msg = gettext("WebGUI process is restarting.");
+				}
 			}
-		}
 
 		// Specific to Firewall Log
 			if ($logfile == 'filter') {
 				if ($firewall_logging_changed) {
 					require_once("filter.inc");
+					$changes_applied = true;
 					$retval |= filter_configure();
 					filter_pflog_start(true);
-
-					$savemsg = get_std_save_message($retval);
 				}
 			}
 		}
diff --git a/src/usr/local/www/status_logs_filter.php b/src/usr/local/www/status_logs_filter.php
index 4c37c9156a..2f1b86ecf1 100644
--- a/src/usr/local/www/status_logs_filter.php
+++ b/src/usr/local/www/status_logs_filter.php
@@ -102,12 +102,11 @@ status_logs_common_code();
 $pgtitle = array(gettext("Status"), gettext("System Logs"), gettext($allowed_logs[$logfile]["name"]), $view_title);
 include("head.inc");
 
-if (!$input_errors && $savemsg) {
-	print_info_box($savemsg, 'success');
+if ($changes_applied) {
+	print_apply_result_box($retval, $extra_save_msg);
 	$manage_log_active = false;
 }
 
-
 // Tab Array
 tab_array_logs_common();
 
diff --git a/src/usr/local/www/status_logs_filter_dynamic.php b/src/usr/local/www/status_logs_filter_dynamic.php
index 4ea4d4afaa..04d70c2aa8 100644
--- a/src/usr/local/www/status_logs_filter_dynamic.php
+++ b/src/usr/local/www/status_logs_filter_dynamic.php
@@ -82,12 +82,11 @@ status_logs_common_code();
 $pgtitle = array(gettext("Status"), gettext("System Logs"), gettext($allowed_logs[$logfile]["name"]), $view_title);
 include("head.inc");
 
-if (!$input_errors && $savemsg) {
-	print_info_box($savemsg, 'success');
+if ($changes_applied) {
+	print_apply_result_box($retval, $extra_save_msg);
 	$manage_log_active = false;
 }
 
-
 // Tab Array
 tab_array_logs_common();
 
diff --git a/src/usr/local/www/status_logs_filter_summary.php b/src/usr/local/www/status_logs_filter_summary.php
index 124d190263..333c97e751 100644
--- a/src/usr/local/www/status_logs_filter_summary.php
+++ b/src/usr/local/www/status_logs_filter_summary.php
@@ -67,12 +67,11 @@ status_logs_common_code();
 $pgtitle = array(gettext("Status"), gettext("System Logs"), gettext($allowed_logs[$logfile]["name"]), $view_title);
 include("head.inc");
 
-if (!$input_errors && $savemsg) {
-	print_info_box($savemsg, 'success');
+if ($changes_applied) {
+	print_apply_result_box($retval, $extra_save_msg);
 	$manage_log_active = false;
 }
 
-
 // Tab Array
 tab_array_logs_common();
 
diff --git a/src/usr/local/www/status_logs_settings.php b/src/usr/local/www/status_logs_settings.php
index 33881ed3ac..fe7f04ee3c 100644
--- a/src/usr/local/www/status_logs_settings.php
+++ b/src/usr/local/www/status_logs_settings.php
@@ -80,7 +80,7 @@ function is_valid_syslog_server($target) {
 
 if ($_POST['resetlogs'] == gettext("Reset Log Files")) {
 	clear_all_log_files(true);
-	$savemsg .= gettext("The log files have been reset.");
+	$reset_msg = gettext("The log files have been reset.");
 } elseif ($_POST) {
 	unset($input_errors);
 	$pconfig = $_POST;
@@ -162,8 +162,9 @@ if ($_POST['resetlogs'] == gettext("Reset Log Files")) {
 
 		write_config();
 
+		$changes_applied = true;
 		$retval = 0;
-		$retval = system_syslogd_start();
+		$retval |= system_syslogd_start();
 		if (($oldnologdefaultblock !== isset($config['syslog']['nologdefaultblock'])) ||
 		    ($oldnologdefaultpass !== isset($config['syslog']['nologdefaultpass'])) ||
 		    ($oldnologbogons !== isset($config['syslog']['nologbogons'])) ||
@@ -171,14 +172,12 @@ if ($_POST['resetlogs'] == gettext("Reset Log Files")) {
 			$retval |= filter_configure();
 		}
 
-		$savemsg = get_std_save_message($retval);
-
 		if ($oldnolognginx !== isset($config['syslog']['nolognginx'])) {
 			ob_flush();
 			flush();
 			log_error(gettext("webConfigurator configuration has changed. Restarting webConfigurator."));
 			send_event("service restart webgui");
-			$savemsg .= "<br />" . gettext("WebGUI process is restarting.");
+			$extra_save_msg = gettext("WebGUI process is restarting.");
 		}
 
 		filter_pflog_start(true);
@@ -204,8 +203,12 @@ if ($input_errors) {
 	print_input_errors($input_errors);
 }
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($reset_msg) {
+	print_info_box($reset_msg, 'success');
+}
+
+if ($changes_applied) {
+	print_apply_result_box($retval, $extra_save_msg);
 }
 
 $tab_array = array();
diff --git a/src/usr/local/www/system.php b/src/usr/local/www/system.php
index 83ab5e700c..492caa0dcf 100644
--- a/src/usr/local/www/system.php
+++ b/src/usr/local/www/system.php
@@ -314,8 +314,9 @@ if ($_POST) {
 			write_config($changedesc);
 		}
 
+		$changes_applied = true;
 		$retval = 0;
-		$retval = system_hostname_configure();
+		$retval |= system_hostname_configure();
 		$retval |= system_hosts_generate();
 		$retval |= system_resolvconf_generate();
 		if (isset($config['dnsmasq']['enable'])) {
@@ -332,8 +333,6 @@ if ($_POST) {
 
 		// Reload the filter - plugins might need to be run.
 		$retval |= filter_configure();
-
-		$savemsg = get_std_save_message($retval);
 	}
 
 	unset($ignore_posted_dnsgw);
@@ -346,8 +345,8 @@ if ($input_errors) {
 	print_input_errors($input_errors);
 }
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($changes_applied) {
+	print_apply_result_box($retval);
 }
 ?>
 <div id="container">
diff --git a/src/usr/local/www/system_advanced_admin.php b/src/usr/local/www/system_advanced_admin.php
index b7207c4b5f..d0da2a32f6 100644
--- a/src/usr/local/www/system_advanced_admin.php
+++ b/src/usr/local/www/system_advanced_admin.php
@@ -263,11 +263,12 @@ if ($_POST) {
 
 		write_config();
 
-		$retval = filter_configure();
-		$savemsg = get_std_save_message($retval);
+		$changes_applied = true;
+		$retval = 0;
+		$retval |= filter_configure();
 
 		if ($restart_webgui) {
-			$savemsg .= sprintf("<br />" . gettext("One moment...redirecting to %s in 20 seconds."), $url);
+			$extra_save_msg = sprintf("<br />" . gettext("One moment...redirecting to %s in 20 seconds."), $url);
 		}
 
 		setup_serial_port();
@@ -287,8 +288,8 @@ if ($input_errors) {
 	print_input_errors($input_errors);
 }
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($changes_applied) {
+	print_apply_result_box($retval, $extra_save_msg);
 }
 
 $tab_array = array();
diff --git a/src/usr/local/www/system_advanced_firewall.php b/src/usr/local/www/system_advanced_firewall.php
index 1d0e811500..e74d8f5d96 100644
--- a/src/usr/local/www/system_advanced_firewall.php
+++ b/src/usr/local/www/system_advanced_firewall.php
@@ -356,15 +356,9 @@ if ($_POST) {
 			killbypid("{$g['varrun_path']}/filterdns.pid");
 		}
 
+		$changes_applied = true;
 		$retval = 0;
-		$retval = filter_configure();
-		if (stristr($retval, "error") <> true) {
-			$savemsg = get_std_save_message($retval);
-			$class = 'success';
-		} else {
-			$savemsg = $retval;
-			$class = 'warning';
-		}
+		$retval |= filter_configure();
 	}
 }
 
@@ -374,8 +368,9 @@ include("head.inc");
 if ($input_errors) {
 	print_input_errors($input_errors);
 }
-if ($savemsg) {
-	print_info_box($savemsg, $class);
+
+if ($changes_applied) {
+	print_apply_result_box($retval);
 }
 
 $tab_array = array();
diff --git a/src/usr/local/www/system_advanced_misc.php b/src/usr/local/www/system_advanced_misc.php
index 796a32bbf6..d43d5913a8 100644
--- a/src/usr/local/www/system_advanced_misc.php
+++ b/src/usr/local/www/system_advanced_misc.php
@@ -265,14 +265,10 @@ if ($_POST) {
 
 		write_config();
 
+		$changes_applied = true;
 		$retval = 0;
 		system_resolvconf_generate(true);
-		$retval = filter_configure();
-		if (stristr($retval, "error") <> true) {
-			$savemsg = get_std_save_message(gettext($retval));
-		} else {
-			$savemsg = gettext($retval);
-		}
+		$retval |= filter_configure();
 
 		activate_powerd();
 		load_crypto();
@@ -291,8 +287,8 @@ if ($input_errors) {
 	unset($pconfig['doreboot']);
 }
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($changes_applied) {
+	print_apply_result_box($retval);
 }
 
 $tab_array = array();
diff --git a/src/usr/local/www/system_advanced_network.php b/src/usr/local/www/system_advanced_network.php
index b99dad8a57..67c80c5274 100644
--- a/src/usr/local/www/system_advanced_network.php
+++ b/src/usr/local/www/system_advanced_network.php
@@ -129,14 +129,9 @@ if ($_POST) {
 		// Set preferred protocol
 		prefer_ipv4_or_ipv6();
 
-		$retval = filter_configure();
-		if (stristr($retval, "error") <> true) {
-			$savemsg = get_std_save_message(gettext($retval));
-			$class = 'success';
-		} else {
-			$savemsg = gettext($retval);
-			$class = 'warning';
-		}
+		$changes_applied = true;
+		$retval = 0;
+		$retval |= filter_configure();
 	}
 }
 
@@ -146,8 +141,9 @@ include("head.inc");
 if ($input_errors) {
 	print_input_errors($input_errors);
 }
-if ($savemsg) {
-	print_info_box($savemsg, $class);
+
+if ($changes_applied) {
+	print_apply_result_box($retval);
 }
 
 $tab_array = array();
diff --git a/src/usr/local/www/system_advanced_sysctl.php b/src/usr/local/www/system_advanced_sysctl.php
index 3ab51fd60c..a8556b95fe 100644
--- a/src/usr/local/www/system_advanced_sysctl.php
+++ b/src/usr/local/www/system_advanced_sysctl.php
@@ -87,7 +87,6 @@ if ($_POST) {
 	if ($_POST['apply']) {
 		$retval = 0;
 		system_setup_sysctl();
-		$savemsg = get_std_save_message($retval);
 		clear_subsystem_dirty('sysctl');
 	}
 
@@ -129,8 +128,8 @@ if ($input_errors) {
 	print_input_errors($input_errors);
 }
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($_POST['apply']) {
+	print_apply_result_box($retval);
 }
 
 if (is_subsystem_dirty('sysctl') && ($act != "edit" )) {
diff --git a/src/usr/local/www/system_gateway_groups.php b/src/usr/local/www/system_gateway_groups.php
index c8f956d4fc..436faec963 100644
--- a/src/usr/local/www/system_gateway_groups.php
+++ b/src/usr/local/www/system_gateway_groups.php
@@ -49,13 +49,12 @@ if ($_POST) {
 
 		$retval = 0;
 
-		$retval = system_routing_configure();
+		$retval |= system_routing_configure();
 		send_multiple_events(array("service reload dyndnsall", "service reload ipsecdns", "filter reload"));
 
 		/* reconfigure our gateway monitor */
 		setup_gateways_monitor();
 
-		$savemsg = get_std_save_message($retval);
 		if ($retval == 0) {
 			clear_subsystem_dirty('staticroutes');
 		}
@@ -106,8 +105,8 @@ $shortcut_section = "gateway-groups";
 
 include("head.inc");
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($_POST['apply']) {
+	print_apply_result_box($retval);
 }
 
 if (is_subsystem_dirty('staticroutes')) {
diff --git a/src/usr/local/www/system_gateways.php b/src/usr/local/www/system_gateways.php
index 9eb95deee0..2927f0fce4 100644
--- a/src/usr/local/www/system_gateways.php
+++ b/src/usr/local/www/system_gateways.php
@@ -53,7 +53,7 @@ if ($_POST) {
 
 		$retval = 0;
 
-		$retval = system_routing_configure();
+		$retval |= system_routing_configure();
 		$retval |= system_resolvconf_generate();
 		$retval |= filter_configure();
 		/* reconfigure our gateway monitor */
@@ -61,7 +61,6 @@ if ($_POST) {
 		/* Dynamic DNS on gw groups may have changed */
 		send_event("service reload dyndnsall");
 
-		$savemsg = get_std_save_message($retval);
 		if ($retval == 0) {
 			clear_subsystem_dirty('staticroutes');
 		}
@@ -230,8 +229,9 @@ include("head.inc");
 if ($input_errors) {
 	print_input_errors($input_errors);
 }
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+
+if ($_POST['apply']) {
+	print_apply_result_box($retval);
 }
 
 if (is_subsystem_dirty('staticroutes')) {
diff --git a/src/usr/local/www/system_groupmanager_addprivs.php b/src/usr/local/www/system_groupmanager_addprivs.php
index ad07c1c08a..5c25e59ea8 100644
--- a/src/usr/local/www/system_groupmanager_addprivs.php
+++ b/src/usr/local/www/system_groupmanager_addprivs.php
@@ -88,19 +88,13 @@ if ($_POST) {
 			}
 		}
 
-		$retval = write_config();
-		$savemsg = get_std_save_message($retval);
+		write_config();
 
 		pfSenseHeader("system_groupmanager.php?act=edit&groupid={$groupid}");
 		exit;
 	}
 }
 
-/* if ajax is calling, give them an update message */
-if (isAjax()) {
-	print_info_box($savemsg, 'success');
-}
-
 function build_priv_list() {
 	global $spriv_list, $a_group;
 
@@ -123,10 +117,6 @@ if ($input_errors) {
 	print_input_errors($input_errors);
 }
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
-}
-
 $tab_array = array();
 $tab_array[] = array(gettext("Users"), false, "system_usermanager.php");
 $tab_array[] = array(gettext("Groups"), true, "system_groupmanager.php");
diff --git a/src/usr/local/www/system_routes.php b/src/usr/local/www/system_routes.php
index cac6cce15d..48925c1c9f 100644
--- a/src/usr/local/www/system_routes.php
+++ b/src/usr/local/www/system_routes.php
@@ -61,12 +61,11 @@ if ($_POST) {
 			@unlink("{$g['tmp_path']}/.system_routes.apply");
 		}
 
-		$retval = system_routing_configure();
+		$retval |= system_routing_configure();
 		$retval |= filter_configure();
 		/* reconfigure our gateway monitor */
 		setup_gateways_monitor();
 
-		$savemsg = get_std_save_message($retval);
 		if ($retval == 0) {
 			clear_subsystem_dirty('staticroutes');
 		}
@@ -218,8 +217,8 @@ include("head.inc");
 if ($input_errors) {
 	print_input_errors($input_errors);
 }
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($_POST['apply']) {
+	print_apply_result_box($retval);
 }
 if (is_subsystem_dirty('staticroutes')) {
 	print_apply_box(gettext("The static route configuration has been changed.") . "<br />" . gettext("The changes must be applied for them to take effect."));
diff --git a/src/usr/local/www/system_usermanager_addprivs.php b/src/usr/local/www/system_usermanager_addprivs.php
index ee6d416ecb..3b2ec2ee02 100644
--- a/src/usr/local/www/system_usermanager_addprivs.php
+++ b/src/usr/local/www/system_usermanager_addprivs.php
@@ -84,8 +84,7 @@ if ($_POST) {
 
 		$a_user['priv'] = sort_user_privs($a_user['priv']);
 		local_user_set($a_user);
-		$retval = write_config();
-		$savemsg = get_std_save_message($retval);
+		write_config();
 
 		post_redirect("system_usermanager.php", array('act' => 'edit', 'userid' => $userid));
 
@@ -110,21 +109,12 @@ function build_priv_list() {
 	return($list);
 }
 
-/* if ajax is calling, give them an update message */
-if (isAjax()) {
-	print_info_box($savemsg, 'success');
-}
-
 include("head.inc");
 
 if ($input_errors) {
 	print_input_errors($input_errors);
 }
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
-}
-
 $tab_array = array();
 $tab_array[] = array(gettext("Users"), true, "system_usermanager.php");
 $tab_array[] = array(gettext("Groups"), false, "system_groupmanager.php");
diff --git a/src/usr/local/www/vpn_ipsec.php b/src/usr/local/www/vpn_ipsec.php
index 64b628d596..4a69ad4460 100644
--- a/src/usr/local/www/vpn_ipsec.php
+++ b/src/usr/local/www/vpn_ipsec.php
@@ -50,11 +50,11 @@ $a_phase2 = &$config['ipsec']['phase2'];
 
 if ($_POST) {
 	if ($_POST['apply']) {
-		$retval = vpn_ipsec_configure();
+		$ipsec_dynamic_hosts = vpn_ipsec_configure();
 		/* reload the filter in the background */
-		filter_configure();
-		$savemsg = get_std_save_message($retval);
-		if ($retval >= 0) {
+		$retval = 0;
+		$retval |= filter_configure();
+		if ($ipsec_dynamic_hosts >= 0) {
 			if (is_subsystem_dirty('ipsec')) {
 				clear_subsystem_dirty('ipsec');
 			}
@@ -228,13 +228,13 @@ $tab_array[] = array(gettext("Pre-Shared Keys"), false, "vpn_ipsec_keys.php");
 $tab_array[] = array(gettext("Advanced Settings"), false, "vpn_ipsec_settings.php");
 display_top_tabs($tab_array);
 
-	if ($savemsg) {
-		print_info_box($savemsg, 'success');
-	}
+if ($_POST['apply']) {
+	print_apply_result_box($retval);
+}
 
-	if (is_subsystem_dirty('ipsec')) {
-		print_apply_box(gettext("The IPsec tunnel configuration has been changed.") . "<br />" . gettext("The changes must be applied for them to take effect."));
-	}
+if (is_subsystem_dirty('ipsec')) {
+	print_apply_box(gettext("The IPsec tunnel configuration has been changed.") . "<br />" . gettext("The changes must be applied for them to take effect."));
+}
 ?>
 
 <form name="mainform" method="post">
diff --git a/src/usr/local/www/vpn_ipsec_keys.php b/src/usr/local/www/vpn_ipsec_keys.php
index 46b2e7aa8b..25acd38253 100644
--- a/src/usr/local/www/vpn_ipsec_keys.php
+++ b/src/usr/local/www/vpn_ipsec_keys.php
@@ -50,10 +50,10 @@ foreach ($config['system']['user'] as $id => $user) {
 }
 
 if (isset($_POST['apply'])) {
-	$retval = vpn_ipsec_configure();
+	vpn_ipsec_configure();
 	/* reload the filter in the background */
-	filter_configure();
-	$savemsg = get_std_save_message($retval);
+	$retval = 0;
+	$retval |= filter_configure();
 	if (is_subsystem_dirty('ipsec')) {
 		clear_subsystem_dirty('ipsec');
 	}
@@ -74,8 +74,8 @@ $shortcut_section = "ipsec";
 
 include("head.inc");
 
-if ($savemsg) {
-	print_info_box($savemsg);
+if ($_POST['apply']) {
+	print_apply_result_box($retval);
 }
 
 if (is_subsystem_dirty('ipsec')) {
diff --git a/src/usr/local/www/vpn_ipsec_mobile.php b/src/usr/local/www/vpn_ipsec_mobile.php
index 05df61de6e..f9c0dde529 100644
--- a/src/usr/local/www/vpn_ipsec_mobile.php
+++ b/src/usr/local/www/vpn_ipsec_mobile.php
@@ -129,9 +129,8 @@ if ($_POST['create']) {
 if ($_POST['apply']) {
 	$retval = 0;
 	/* NOTE: #4353 Always restart ipsec when mobile clients settings change */
-	$retval = vpn_ipsec_configure(true);
-	$savemsg = get_std_save_message($retval);
-	if ($retval >= 0) {
+	$ipsec_dynamic_hosts = vpn_ipsec_configure(true);
+	if ($ipsec_dynamic_hosts >= 0) {
 		if (is_subsystem_dirty('ipsec')) {
 			clear_subsystem_dirty('ipsec');
 		}
@@ -400,8 +399,8 @@ include("head.inc");
 	</script>
 
 <?php
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($_POST['apply']) {
+	print_apply_result_box($retval);
 }
 if (is_subsystem_dirty('ipsec')) {
 	print_apply_box(gettext("The IPsec tunnel configuration has been changed.") . "<br />" . gettext("The changes must be applied for them to take effect."));
diff --git a/src/usr/local/www/vpn_ipsec_settings.php b/src/usr/local/www/vpn_ipsec_settings.php
index 43608375a9..3bcfa1d8e5 100644
--- a/src/usr/local/www/vpn_ipsec_settings.php
+++ b/src/usr/local/www/vpn_ipsec_settings.php
@@ -172,15 +172,9 @@ if ($_POST) {
 
 		write_config();
 
+		$changes_applied = true;
 		$retval = 0;
-		$retval = filter_configure();
-		if (stristr($retval, "error") <> true) {
-			$savemsg = get_std_save_message(gettext($retval));
-			$class = 'success';
-		} else {
-			$savemsg = gettext($retval);
-			$class = 'warning';
-		}
+		$retval |= filter_configure();
 
 		vpn_ipsec_configure($needsrestart);
 
@@ -220,8 +214,8 @@ function maxmss_checked(obj) {
 </script>
 
 <?php
-if ($savemsg) {
-	print_info_box($savemsg, $class);
+if ($changes_applied) {
+	print_apply_result_box($retval);
 }
 
 if ($input_errors) {
diff --git a/src/usr/local/www/vpn_l2tp.php b/src/usr/local/www/vpn_l2tp.php
index 1adf21b742..29cddc1bca 100644
--- a/src/usr/local/www/vpn_l2tp.php
+++ b/src/usr/local/www/vpn_l2tp.php
@@ -159,14 +159,9 @@ if ($_POST) {
 
 		write_config();
 
+		$changes_applied = true;
 		$retval = 0;
-		$retval = vpn_l2tp_configure();
-		$savemsg = get_std_save_message($retval);
-
-		/* if ajax is calling, give them an update message */
-		if (isAjax()) {
-			print_info_box($savemsg, 'success');
-		}
+		$retval |= vpn_l2tp_configure();
 	}
 }
 
@@ -178,8 +173,8 @@ if ($input_errors) {
 	print_input_errors($input_errors);
 }
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($changes_applied) {
+	print_apply_result_box($retval);
 }
 
 $tab_array = array();
diff --git a/src/usr/local/www/vpn_l2tp_users.php b/src/usr/local/www/vpn_l2tp_users.php
index 3bfaec16fd..4c31eb8269 100644
--- a/src/usr/local/www/vpn_l2tp_users.php
+++ b/src/usr/local/www/vpn_l2tp_users.php
@@ -44,9 +44,8 @@ if ($_POST) {
 	if ($_POST['apply']) {
 		$retval = 0;
 		if (!is_subsystem_dirty('rebootreq')) {
-			$retval = vpn_l2tp_configure();
+			$retval |= vpn_l2tp_configure();
 		}
-		$savemsg = get_std_save_message($retval);
 		if ($retval == 0) {
 			if (is_subsystem_dirty('l2tpusers')) {
 				clear_subsystem_dirty('l2tpusers');
@@ -67,8 +66,8 @@ if ($_GET['act'] == "del") {
 
 include("head.inc");
 
-if ($savemsg) {
-	print_info_box($savemsg, 'success');
+if ($_POST['apply']) {
+	print_apply_result_box($retval);
 }
 
 if (isset($config['l2tp']['radius']['enable'])) {
