commit 483e6de8423236fd6af30de585caa72a507758f1
Author: Scott Ullrich <sullrich@pfsense.org>
Date:   Sat Nov 21 16:07:54 2009 -0500

    Rework includes/require.  This saves about 4 megabytes.
    Simplify get_memory(). Tested on mips/i386

diff --git a/etc/inc/authgui.inc b/etc/inc/authgui.inc
index 59845c0b91..533258214e 100644
--- a/etc/inc/authgui.inc
+++ b/etc/inc/authgui.inc
@@ -37,6 +37,7 @@
 		pfSense_MODULE: authgui
 */
 
+include_once("auth.inc");
 include_once("priv.inc");
 
 /* We only support htpasswd backed HTTP Basic auth and session
diff --git a/etc/inc/captiveportal.inc b/etc/inc/captiveportal.inc
index 0c745b3be0..dbed5977d9 100644
--- a/etc/inc/captiveportal.inc
+++ b/etc/inc/captiveportal.inc
@@ -41,8 +41,6 @@
 */
 
 /* include all configuration functions */
-require_once("globals.inc");
-require_once("util.inc");
 require_once("radius_authentication.inc");
 require_once("radius_accounting.inc");
 require_once("radius.inc");
diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc
index 3586e4f4cd..c6fea3e0d6 100644
--- a/etc/inc/filter.inc
+++ b/etc/inc/filter.inc
@@ -40,8 +40,6 @@
 /* DISABLE_PHP_LINT_CHECKING */
 
 /* include all configuration functions */
-require_once("config.inc");
-require_once("shaper.inc");
 
 /* holds the items that will be executed *AFTER* the filter is fully loaded */
 $after_filter_configure_run = array();
diff --git a/etc/inc/functions.inc b/etc/inc/functions.inc
index f2ee6e23bf..e05fa59ecf 100644
--- a/etc/inc/functions.inc
+++ b/etc/inc/functions.inc
@@ -78,14 +78,9 @@ require_once("interfaces.inc");
 require_once("gwlb.inc");
 require_once("services.inc");
 require_once("pfsense-utils.inc");
-require_once("captiveportal.inc");
 require_once("filter.inc");
+require_once("shaper.inc");
 require_once("system.inc");
-require_once("ipsec.inc");
-require_once("vpn.inc");
 require_once("vslb.inc");
-require_once("cmd_chain.inc");
-require_once("rrd.inc");
-require_once("itemid.inc");
 
 ?>
\ No newline at end of file
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc
index 08afbb03c7..175edf90f7 100644
--- a/etc/inc/interfaces.inc
+++ b/etc/inc/interfaces.inc
@@ -43,6 +43,7 @@
 
 /* include all configuration functions */
 require_once("globals.inc");
+require_once("cmd_chain.inc");
 
 function interfaces_bring_up($interface) {
 	if(!$interface) {
diff --git a/etc/inc/priv.inc b/etc/inc/priv.inc
index 03b2e8c64a..9afaa78174 100644
--- a/etc/inc/priv.inc
+++ b/etc/inc/priv.inc
@@ -44,8 +44,6 @@
 	pfSense_MODULE:	auth
 */
 
-require_once("priv.defs.inc");
-require_once("auth.inc");
 
 /*
  * USER PRIVILEGE DEFINITIONS
diff --git a/etc/inc/rrd.inc b/etc/inc/rrd.inc
index a915d53c35..b98180df85 100644
--- a/etc/inc/rrd.inc
+++ b/etc/inc/rrd.inc
@@ -33,7 +33,6 @@
 */
 
 /* include all configuration functions */
-require_once("config.inc");
 
 function dump_rrd_to_xml($rrddatabase, $xmldumpfile) {
 	$rrdtool = "/usr/bin/nice -n20 /usr/local/bin/rrdtool";
diff --git a/etc/inc/services.inc b/etc/inc/services.inc
index decaf03517..0622fe3b6e 100644
--- a/etc/inc/services.inc
+++ b/etc/inc/services.inc
@@ -39,7 +39,6 @@
 */
 
 /* include all configuration functions */
-require_once("functions.inc");
 
 function services_dhcpd_configure() {
 	global $config, $g;
diff --git a/etc/inc/util.inc b/etc/inc/util.inc
index 370627971b..3d8cd43f17 100644
--- a/etc/inc/util.inc
+++ b/etc/inc/util.inc
@@ -885,37 +885,18 @@ function make_dirs($path, $mode = 0755) {
  *     [0]real and [1]available
  */
 function get_memory() {
-        if(file_exists("/var/log/dmesg.boot")) {
-                $mem = `cat /var/log/dmesg.boot | grep memory`;
-                $matches = "";
-                if (preg_match_all("/real memory  = .* \((.*) MB/", $mem, $matches))
-                        $real = $matches[1];
-                if (preg_match_all("/avail memory = .* \((.*) MB/", $mem, $matches))
-                        $avail = $matches[1];
-				if(!$real && !$avail) {
-					$real = trim(`sysctl hw.physmem | cut -d' ' -f2`);
-					$avail = trim(`sysctl hw.realmem | cut -d' ' -f2`);
-					$real_mem = $real / 1024;
-					$avail_mem = $avail / 1024;
-					return array($real_mem,$avail_mem);
-				}
-                return array($real[0],$avail[0]);
-        } else {
-                $mem = `dmesg -a`;
-                $matches = "";
-                if (preg_match_all("/real memory  = .* \((.*) MB/", $mem, $matches))
-                        $real = $matches[1];
-                if (preg_match_all("/avail memory = .* \((.*) MB/", $mem, $matches))
-                        $avail = $matches[1];
-				if(!$real && !$avail) {
-					$real = trim(`sysctl hw.physmem | cut -d' ' -f2`);
-					$avail = trim(`sysctl hw.realmem | cut -d' ' -f2`);
-					$real_mem = $real / 1024;
-					$avail_mem = $avail / 1024;
-					return array($real_mem,$avail_mem);
-				}
-                return array($real[0],$avail[0]);
-        }
+		$matches = "";
+        if(file_exists("/var/log/dmesg.boot"))
+			$mem = `cat /var/log/dmesg.boot | grep memory`;
+		else
+			$mem = `dmesg -a | grep memory`;			
+		if (preg_match_all("/avail memory.* \((.*)MB\)/", $mem, $matches)) 
+			return array($matches[1][0], $matches[1][0]);
+		if(!$real && !$avail) {
+			$real = trim(`sysctl hw.physmem | cut -d' ' -f2`);
+			$avail = trim(`sysctl hw.realmem | cut -d' ' -f2`);
+			return array(($real/1024),($avail/1024));
+		}
 }
 
 function mute_kernel_msgs() {
@@ -1039,4 +1020,4 @@ function msort($array, $id="id", $sort_ascending=true) {
 	}
 }
 
-?>
+?>
\ No newline at end of file
diff --git a/etc/inc/voucher.inc b/etc/inc/voucher.inc
index 700f1978e3..2db6d19229 100644
--- a/etc/inc/voucher.inc
+++ b/etc/inc/voucher.inc
@@ -32,7 +32,6 @@
 */
 
 /* include all configuration functions */
-require_once("config.inc");
 
 /* 
  *Authenticate a voucher and return the remaining time credit in minutes
diff --git a/etc/inc/vpn.inc b/etc/inc/vpn.inc
index 6073e6f8b1..d987a42c2b 100644
--- a/etc/inc/vpn.inc
+++ b/etc/inc/vpn.inc
@@ -42,8 +42,6 @@
 */
 
 /* include all configuration functions */
-require_once ("functions.inc");
-require_once("certs.inc");
 
 function vpn_ipsec_failover_configure() {
 	global $config, $g;
@@ -1687,4 +1685,4 @@ function reload_tunnel_spd_policy($phase1, $phase2, $old_phase1, $old_phase2) {
 	return true;
 }
 
-?>
\ No newline at end of file
+?>
diff --git a/etc/inc/vslb.inc b/etc/inc/vslb.inc
index a5cebcb21c..86616c787c 100644
--- a/etc/inc/vslb.inc
+++ b/etc/inc/vslb.inc
@@ -36,7 +36,6 @@
 /* DISABLE_PHP_LINT_CHECKING */
 
 /* include all configuration functions */
-require_once("config.inc");
 
 class Monitor {
 	private $conf = array();
@@ -271,4 +270,4 @@ function relayd_configure() {
   }
 }
 
-?>
\ No newline at end of file
+?>
diff --git a/etc/rc.bootup b/etc/rc.bootup
index 2b59052b7f..8e2ebca87a 100755
--- a/etc/rc.bootup
+++ b/etc/rc.bootup
@@ -85,12 +85,14 @@ echo " done.\n";
 echo "Initializing...";
 echo ".";
 require_once("/etc/inc/globals.inc");
+echo ".";
 require_once("/etc/inc/led.inc");
 led_normalize();
+echo ".";
 if (led_count() >= 3) {
 	led_kitt();
 }
-echo ".";
+
 /* let the other functions know we're booting */
 $pkg_interface = 'console';
 $g['booting'] = true;
@@ -106,8 +108,16 @@ require_once("/etc/inc/config.inc");
 echo ".";
 require_once("/etc/inc/functions.inc");
 echo ".";
+require_once("/etc/inc/ipsec.inc");
+echo ".";
+require_once("/etc/inc/vpn.inc");
+echo ".";
 require_once("openvpn.inc");
 echo ".";
+require_once("/etc/inc/captiveportal.inc");
+echo ".";
+require_once("/etc/inc/rrd.inc");
+echo ".";
 
 /* get system memory amount */
 $memory = get_memory();
diff --git a/etc/rc.filter_configure b/etc/rc.filter_configure
index 2f34d1543c..852d584a1d 100755
--- a/etc/rc.filter_configure
+++ b/etc/rc.filter_configure
@@ -30,6 +30,7 @@
 */
 
 require_once("config.inc");
+require_once("functions.inc");
 require_once("filter.inc");
 
 /* invalidate interface cache */
diff --git a/etc/rc.filter_configure_sync b/etc/rc.filter_configure_sync
index ec2e83a3c4..8597e62ff5 100755
--- a/etc/rc.filter_configure_sync
+++ b/etc/rc.filter_configure_sync
@@ -30,7 +30,7 @@
 */
 
 require_once("config.inc");
-require_once("filter.inc");
+require_once("functions.inc");
 
 /* invalidate interface cache */
 get_interface_arr(true);
diff --git a/etc/rc.interfaces_carp_configure b/etc/rc.interfaces_carp_configure
index 10153b4da2..6faa589ede 100755
--- a/etc/rc.interfaces_carp_configure
+++ b/etc/rc.interfaces_carp_configure
@@ -30,6 +30,7 @@
 */
 
 require_once("config.inc");
+require_once("functions.inc");
 require_once("filter.inc");
 
 interfaces_carp_configure();
diff --git a/etc/rc.interfaces_lan_configure b/etc/rc.interfaces_lan_configure
index 7eb5a6e99e..d5c16fdbb2 100755
--- a/etc/rc.interfaces_lan_configure
+++ b/etc/rc.interfaces_lan_configure
@@ -30,6 +30,7 @@
 */
 
 require_once("config.inc");
+require_once("functions.inc");
 require_once("filter.inc");
 
 interface_configure("lan");
diff --git a/etc/rc.interfaces_opt_configure b/etc/rc.interfaces_opt_configure
index d3d309b7a7..3ccb8b9981 100755
--- a/etc/rc.interfaces_opt_configure
+++ b/etc/rc.interfaces_opt_configure
@@ -30,6 +30,7 @@
 */
 
 require_once("config.inc");
+require_once("functions.inc");
 require_once("filter.inc");
 
 interfaces_configure();
diff --git a/etc/rc.interfaces_wan_configure b/etc/rc.interfaces_wan_configure
index 505c3ab3b2..350cdfe746 100755
--- a/etc/rc.interfaces_wan_configure
+++ b/etc/rc.interfaces_wan_configure
@@ -30,6 +30,7 @@
 */
 
 require_once("config.inc");
+require_once("functions.inc");
 require_once("filter.inc");
 
 interface_configure("wan");
diff --git a/etc/rc.newipsecdns b/etc/rc.newipsecdns
index 42675e35e1..d6509f958e 100755
--- a/etc/rc.newipsecdns
+++ b/etc/rc.newipsecdns
@@ -32,7 +32,9 @@
 
 	/* parse the configuration and include all functions used below */
 	require_once("functions.inc");
-	
+	require_once("ipsec.inc");
+	require_once("vpn.inc");
+
 	/* make sure to wait until the boot scripts have finished */
 	while (file_exists("{$g['varrun_path']}/booting")) {
 		sleep(1);
diff --git a/etc/rc.newwanip b/etc/rc.newwanip
index a8a77aab36..5918084c08 100755
--- a/etc/rc.newwanip
+++ b/etc/rc.newwanip
@@ -35,7 +35,6 @@
 require_once("globals.inc");
 require_once("config.inc");
 require_once("functions.inc");
-require_once("gwlb.inc");
 
 /* WAN IP address has changed */
 
diff --git a/etc/rc.prunecaptiveportal b/etc/rc.prunecaptiveportal
index 3b130c8d95..bff2667eff 100755
--- a/etc/rc.prunecaptiveportal
+++ b/etc/rc.prunecaptiveportal
@@ -30,10 +30,12 @@
 	POSSIBILITY OF SUCH DAMAGE.
 */
 
-	/* parse the configuration and include all functions used below */
-	/* config.inc retrives the util.inc and globals.inc */
-	require_once("config.inc");
-	require_once("captiveportal.inc");
-	
-	captiveportal_prune_old();
+/* parse the configuration and include all functions used below */
+/* config.inc retrives the util.inc and globals.inc */
+require_once("config.inc");
+require_once("functions.inc");
+require_once("captiveportal.inc");
+
+captiveportal_prune_old();
+
 ?>
diff --git a/etc/rc.restart_webgui b/etc/rc.restart_webgui
index 812dcdf92f..eef95d5bac 100755
--- a/etc/rc.restart_webgui
+++ b/etc/rc.restart_webgui
@@ -4,6 +4,8 @@
 
 require("config.inc");
 require("functions.inc");
+require("captiveportal.inc");
+require("rrd.inc");
 
 mwexec("killall -9 lighttpd");
 
diff --git a/etc/rc.savevoucher b/etc/rc.savevoucher
index 338fd49e5d..4ccc4d444e 100644
--- a/etc/rc.savevoucher
+++ b/etc/rc.savevoucher
@@ -29,6 +29,9 @@
 */
 
 	/* parse the configuration and include all functions used below */
+	require_once("functions.inc");
+	require_once("config.inc");
+	require_once("captiveportal.inc");
 	require_once("voucher.inc");
 	
 	voucher_save_db_to_config();
diff --git a/usr/local/captiveportal/index.php b/usr/local/captiveportal/index.php
index 92eb95db44..0011f0b65d 100755
--- a/usr/local/captiveportal/index.php
+++ b/usr/local/captiveportal/index.php
@@ -35,6 +35,7 @@
 
 require_once("auth.inc");
 require_once("functions.inc");
+require_once("captiveportal.inc");
 
 header("Expires: 0");
 header("Cache-Control: no-store, no-cache, must-revalidate");
diff --git a/usr/local/www/diag_ipsec.php b/usr/local/www/diag_ipsec.php
index 692191264f..87c3c47162 100644
--- a/usr/local/www/diag_ipsec.php
+++ b/usr/local/www/diag_ipsec.php
@@ -49,6 +49,7 @@ $pgtitle = array("Status","IPsec");
 
 require("guiconfig.inc");
 include("head.inc");
+require("ipsec.inc");
 
 if (!is_array($config['ipsec']['phase2']))
     $config['ipsec']['phase2'] = array();
diff --git a/usr/local/www/diag_ipsec_sad.php b/usr/local/www/diag_ipsec_sad.php
index 9d6740f245..75ec78204e 100755
--- a/usr/local/www/diag_ipsec_sad.php
+++ b/usr/local/www/diag_ipsec_sad.php
@@ -44,6 +44,7 @@
 ##|-PRIV
 
 require("guiconfig.inc");
+require("ipsec.inc");
 
 $pgtitle = array("Status","IPsec","SAD");
 include("head.inc");
diff --git a/usr/local/www/diag_ipsec_spd.php b/usr/local/www/diag_ipsec_spd.php
index 2f97df9a09..3d44b6296e 100755
--- a/usr/local/www/diag_ipsec_spd.php
+++ b/usr/local/www/diag_ipsec_spd.php
@@ -44,6 +44,7 @@
 ##|-PRIV
 
 require("guiconfig.inc");
+require("ipsec.inc");
 
 $pgtitle = array("Status","IPsec","SPD");
 include("head.inc");
diff --git a/usr/local/www/diag_logs_ipsec.php b/usr/local/www/diag_logs_ipsec.php
index 1529daa224..aeb8aec257 100755
--- a/usr/local/www/diag_logs_ipsec.php
+++ b/usr/local/www/diag_logs_ipsec.php
@@ -44,6 +44,7 @@
 ##|-PRIV
 
 require("guiconfig.inc");
+require("ipsec.inc");
 
 $ipsec_logfile = "{$g['varlog_path']}/ipsec.log";
 
diff --git a/usr/local/www/diag_logs_openvpn.php b/usr/local/www/diag_logs_openvpn.php
index 692484b5a3..50a609875d 100644
--- a/usr/local/www/diag_logs_openvpn.php
+++ b/usr/local/www/diag_logs_openvpn.php
@@ -42,10 +42,10 @@
 ##|*MATCH=diag_logs_openvpn.php*
 ##|-PRIV
 
-
 $pgtitle = array("Status","System logs","OpenVPN");
 
 require("guiconfig.inc");
+require_once("vpn.inc");
 
 $openvpn_logfile = "{$g['varlog_path']}/openvpn.log";
 
diff --git a/usr/local/www/diag_logs_vpn.php b/usr/local/www/diag_logs_vpn.php
index b9532113c2..9019f894a6 100755
--- a/usr/local/www/diag_logs_vpn.php
+++ b/usr/local/www/diag_logs_vpn.php
@@ -43,6 +43,7 @@
 
 $pgtitle = array("Status","System logs","PPTP VPN");
 require("guiconfig.inc");
+require_once("vpn.inc");
 
 $nentries = $config['syslog']['nentries'];
 if (!$nentries)
diff --git a/usr/local/www/firewall_nat.php b/usr/local/www/firewall_nat.php
index 480661973c..212aaff0ff 100755
--- a/usr/local/www/firewall_nat.php
+++ b/usr/local/www/firewall_nat.php
@@ -42,6 +42,7 @@
 ##|-PRIV
 
 require("guiconfig.inc");
+require_once("itemid.inc");
 
 if (!is_array($config['nat']['rule']))
 	$config['nat']['rule'] = array();
diff --git a/usr/local/www/firewall_nat_edit.php b/usr/local/www/firewall_nat_edit.php
index 5406a04432..c4dd0a9443 100755
--- a/usr/local/www/firewall_nat_edit.php
+++ b/usr/local/www/firewall_nat_edit.php
@@ -40,6 +40,7 @@
 ##|-PRIV
 
 require("guiconfig.inc");
+require_once("itemid.inc");
 
 if (!is_array($config['nat']['rule'])) {
 	$config['nat']['rule'] = array();
diff --git a/usr/local/www/index.php b/usr/local/www/index.php
index 09d5a612a9..f6c6fe5abd 100755
--- a/usr/local/www/index.php
+++ b/usr/local/www/index.php
@@ -158,7 +158,6 @@ while (false !== ($filename = readdir($dirhandle))) {
 		$widgetfiles[] = $filename;   		
 }
 
-
 ##sort widgets alphabetically
 sort($widgetfiles);
 
@@ -206,13 +205,11 @@ if ($config['widgets'] && $config['widgets']['sequence'] != "") {
     }   
 	
 	$widgetlist = $savedwidgetfiles;	
-} 
-##no saved widget sequence found, build default list.
-else{
+} else{
+	// no saved widget sequence found, build default list.
 	$widgetlist = $widgetfiles;
 }
 
-
 ##build list of php include files
 $phpincludefiles = array();
 $directory = "/usr/local/www/widgets/include/";
diff --git a/usr/local/www/services_captiveportal.php b/usr/local/www/services_captiveportal.php
index 472da57955..744cd475b8 100755
--- a/usr/local/www/services_captiveportal.php
+++ b/usr/local/www/services_captiveportal.php
@@ -40,6 +40,7 @@
 
 $pgtitle = array("Services","Captive portal");
 require("guiconfig.inc");
+require_once("captiveportal.inc");
 
 if (!is_array($config['captiveportal'])) {
 	$config['captiveportal'] = array();
diff --git a/usr/local/www/services_captiveportal_filemanager.php b/usr/local/www/services_captiveportal_filemanager.php
index 8bf23eb026..38b0576bd3 100755
--- a/usr/local/www/services_captiveportal_filemanager.php
+++ b/usr/local/www/services_captiveportal_filemanager.php
@@ -52,6 +52,7 @@ function cpelements_sort() {
 $pgtitle = array("Services","Captive portal");
 
 require_once("guiconfig.inc");
+require_once("captiveportal.inc");
 
 if (!is_array($config['captiveportal']['element']))
 	$config['captiveportal']['element'] = array();
diff --git a/usr/local/www/services_captiveportal_ip.php b/usr/local/www/services_captiveportal_ip.php
index da8fe37523..0146439af5 100755
--- a/usr/local/www/services_captiveportal_ip.php
+++ b/usr/local/www/services_captiveportal_ip.php
@@ -41,6 +41,7 @@
 
 $pgtitle = array("Services","Captive portal");
 require("guiconfig.inc");
+require_once("captiveportal.inc");
 
 if (!is_array($config['captiveportal']['allowedip']))
 	$config['captiveportal']['allowedip'] = array();
diff --git a/usr/local/www/services_captiveportal_ip_edit.php b/usr/local/www/services_captiveportal_ip_edit.php
index 60b76b5727..62d39a736d 100755
--- a/usr/local/www/services_captiveportal_ip_edit.php
+++ b/usr/local/www/services_captiveportal_ip_edit.php
@@ -51,6 +51,7 @@ function allowedips_sort() {
 
 $pgtitle = array("Services","Captive portal","Edit allowed IP address");
 require("guiconfig.inc");
+require_once("captiveportal.inc");
 
 if (!is_array($config['captiveportal']['allowedip']))
 	$config['captiveportal']['allowedip'] = array();
diff --git a/usr/local/www/services_captiveportal_mac.php b/usr/local/www/services_captiveportal_mac.php
index 42fabb007d..24cab5ea09 100755
--- a/usr/local/www/services_captiveportal_mac.php
+++ b/usr/local/www/services_captiveportal_mac.php
@@ -40,6 +40,7 @@
 
 $pgtitle = array("Services","Captive portal");
 require("guiconfig.inc");
+require_once("captiveportal.inc");
 
 if (!is_array($config['captiveportal']['passthrumac']))
 	$config['captiveportal']['passthrumac'] = array();
diff --git a/usr/local/www/services_captiveportal_mac_edit.php b/usr/local/www/services_captiveportal_mac_edit.php
index e675779e32..5d8a769f54 100755
--- a/usr/local/www/services_captiveportal_mac_edit.php
+++ b/usr/local/www/services_captiveportal_mac_edit.php
@@ -50,6 +50,7 @@ function passthrumacs_sort() {
 
 $pgtitle = array("Services","Captive portal","Edit pass-through MAC address");
 require("guiconfig.inc");
+require_once("captiveportal.inc");
 
 if (!is_array($config['captiveportal']['passthrumac']))
 	$config['captiveportal']['passthrumac'] = array();
diff --git a/usr/local/www/services_captiveportal_vouchers.php b/usr/local/www/services_captiveportal_vouchers.php
index dd6933d0b8..8bf8f509c8 100644
--- a/usr/local/www/services_captiveportal_vouchers.php
+++ b/usr/local/www/services_captiveportal_vouchers.php
@@ -38,6 +38,7 @@
 
 $pgtitle = array("Services", "Captive portal", "Vouchers");
 require("guiconfig.inc");
+require_once("captiveportal.inc");
 require_once("voucher.inc");
 
 if (!is_array($config['voucher'])) {
diff --git a/usr/local/www/services_captiveportal_vouchers_edit.php b/usr/local/www/services_captiveportal_vouchers_edit.php
index 6afc325225..665b00ceb2 100644
--- a/usr/local/www/services_captiveportal_vouchers_edit.php
+++ b/usr/local/www/services_captiveportal_vouchers_edit.php
@@ -37,6 +37,7 @@
 
 $pgtitle = array("Services", "Captive portal", "Edit Voucher Rolls");
 require("guiconfig.inc");
+require_once("captiveportal.inc");
 require_once("voucher.inc");
 
 if (!is_array($config['voucher'])) {
diff --git a/usr/local/www/status_graph.php b/usr/local/www/status_graph.php
index 7de1c7e567..e130a746ef 100755
--- a/usr/local/www/status_graph.php
+++ b/usr/local/www/status_graph.php
@@ -54,7 +54,6 @@ if ($_POST['height'])
 else
 	$height = "200";
 
-
 if ($_GET['if'])
 	$curif = $_GET['if'];
 else
@@ -142,7 +141,7 @@ function updateBandwidthHosts(data){
         }
     }
     
-    setTimeout('updateBandwidth()', 3000);
+    setTimeout('updateBandwidth()', 10);
 }
 
 
diff --git a/usr/local/www/status_openvpn.php b/usr/local/www/status_openvpn.php
index 52f4f0427f..e9a538fdf7 100644
--- a/usr/local/www/status_openvpn.php
+++ b/usr/local/www/status_openvpn.php
@@ -40,6 +40,7 @@
 
 $pgtitle = array("Status", "OpenVPN");
 require("guiconfig.inc");
+require_once("vpn.inc");
 
 $servers = array();
 
diff --git a/usr/local/www/status_rrd_graph.php b/usr/local/www/status_rrd_graph.php
index 5b76725993..da46b37cce 100755
--- a/usr/local/www/status_rrd_graph.php
+++ b/usr/local/www/status_rrd_graph.php
@@ -40,6 +40,7 @@
 ##|-PRIV
 
 require("guiconfig.inc");
+require_once("rrd.inc");
 
 /* if the rrd graphs are not enabled redirect to settings page */
 if(! isset($config['rrd']['enable'])) {
diff --git a/usr/local/www/status_rrd_graph_img.php b/usr/local/www/status_rrd_graph_img.php
index 7830c22c44..9cf8ee1d5d 100644
--- a/usr/local/www/status_rrd_graph_img.php
+++ b/usr/local/www/status_rrd_graph_img.php
@@ -33,6 +33,7 @@
 */
 
 require("guiconfig.inc");
+require_once("rrd.inc");
 
 $pgtitle = array("System","RRD Graphs","Image viewer");
 
diff --git a/usr/local/www/status_rrd_graph_settings.php b/usr/local/www/status_rrd_graph_settings.php
index f0b5666376..e8d89f0500 100755
--- a/usr/local/www/status_rrd_graph_settings.php
+++ b/usr/local/www/status_rrd_graph_settings.php
@@ -40,6 +40,7 @@
 ##|-PRIV
 
 require("guiconfig.inc");
+require_once("rrd.inc");
 
 $pconfig['enable'] = isset($config['rrd']['enable']);
 $pconfig['category'] = $config['rrd']['category'];
diff --git a/usr/local/www/vpn_ipsec.php b/usr/local/www/vpn_ipsec.php
index 9eb99ed6ac..b8c0aae6f2 100755
--- a/usr/local/www/vpn_ipsec.php
+++ b/usr/local/www/vpn_ipsec.php
@@ -38,6 +38,8 @@
 
 require("functions.inc");
 require("guiconfig.inc");
+require_once("ipsec.inc");
+require_once("vpn.inc");
 
 if (!is_array($config['ipsec']['phase1']))
 	$config['ipsec']['phase1'] = array();
diff --git a/usr/local/www/vpn_ipsec_mobile.php b/usr/local/www/vpn_ipsec_mobile.php
index 7a952e30c2..6f15b6c515 100755
--- a/usr/local/www/vpn_ipsec_mobile.php
+++ b/usr/local/www/vpn_ipsec_mobile.php
@@ -36,6 +36,8 @@
 
 require("functions.inc");
 require("guiconfig.inc");
+require_once("ipsec.inc");
+require_once("vpn.inc");
 
 if (!is_array($config['ipsec']['phase1']))
 	$config['ipsec']['phase1'] = array();
diff --git a/usr/local/www/vpn_ipsec_phase1.php b/usr/local/www/vpn_ipsec_phase1.php
index 6bade97489..5b8fb25854 100644
--- a/usr/local/www/vpn_ipsec_phase1.php
+++ b/usr/local/www/vpn_ipsec_phase1.php
@@ -38,6 +38,8 @@
 
 require("functions.inc");
 require("guiconfig.inc");
+require_once("ipsec.inc");
+require_once("vpn.inc");
 
 if (!is_array($config['ipsec']['phase1']))
 	$config['ipsec']['phase1'] = array();
diff --git a/usr/local/www/vpn_ipsec_phase2.php b/usr/local/www/vpn_ipsec_phase2.php
index 2f63bb014c..9c99ef1b1b 100644
--- a/usr/local/www/vpn_ipsec_phase2.php
+++ b/usr/local/www/vpn_ipsec_phase2.php
@@ -38,6 +38,8 @@
 
 require("functions.inc");
 require("guiconfig.inc");
+require_once("ipsec.inc");
+require_once("vpn.inc");
 
 if (!is_array($config['ipsec']['client']))
 	$config['ipsec']['client'] = array();
diff --git a/usr/local/www/vpn_l2tp.php b/usr/local/www/vpn_l2tp.php
index 0c0336ee19..24bb85c0d5 100644
--- a/usr/local/www/vpn_l2tp.php
+++ b/usr/local/www/vpn_l2tp.php
@@ -38,6 +38,7 @@
 $pgtitle = array(gettext("VPN"), gettext("L2TP"), gettext("L2TP"));
 
 require("guiconfig.inc");
+require_once("vpn.inc");
 
 if (!is_array($config['l2tp']['radius'])) {
 	$config['l2tp']['radius'] = array();
diff --git a/usr/local/www/vpn_l2tp_users.php b/usr/local/www/vpn_l2tp_users.php
index 7aa358d7b0..3cba0a2f48 100644
--- a/usr/local/www/vpn_l2tp_users.php
+++ b/usr/local/www/vpn_l2tp_users.php
@@ -38,6 +38,7 @@
 $pgtitle = array(gettext("VPN"),gettext("L2TP"),gettext("Users"));
 
 require("guiconfig.inc");
+require_once("vpn.inc");
 
 if (!is_array($config['l2tp']['user'])) {
 	$config['l2tp']['user'] = array();
diff --git a/usr/local/www/vpn_l2tp_users_edit.php b/usr/local/www/vpn_l2tp_users_edit.php
index c54a449802..ad1db193ec 100644
--- a/usr/local/www/vpn_l2tp_users_edit.php
+++ b/usr/local/www/vpn_l2tp_users_edit.php
@@ -51,6 +51,7 @@ function  l2tp_users_sort()  {
 }
 
 require("guiconfig.inc");
+require_once("vpn.inc");
 
 if (!is_array($config['l2tp']['user'])) {
 	$config['l2tp']['user'] = array();
diff --git a/usr/local/www/vpn_openvpn_client.php b/usr/local/www/vpn_openvpn_client.php
index 5f1df405f5..060c24e374 100644
--- a/usr/local/www/vpn_openvpn_client.php
+++ b/usr/local/www/vpn_openvpn_client.php
@@ -34,7 +34,6 @@
 ##|*MATCH=vpn_openvpn_client.php*
 ##|-PRIV
 
-
 require("guiconfig.inc");
 require_once("openvpn.inc");
 
diff --git a/usr/local/www/vpn_openvpn_csc.php b/usr/local/www/vpn_openvpn_csc.php
index 2a0670a5df..328d72a6aa 100644
--- a/usr/local/www/vpn_openvpn_csc.php
+++ b/usr/local/www/vpn_openvpn_csc.php
@@ -34,7 +34,6 @@
 ##|*MATCH=vpn_openvpn_csc.php*
 ##|-PRIV
 
-
 require("guiconfig.inc");
 require_once("openvpn.inc");
 
diff --git a/usr/local/www/vpn_openvpn_server.php b/usr/local/www/vpn_openvpn_server.php
index c1da985c6b..45247310f1 100644
--- a/usr/local/www/vpn_openvpn_server.php
+++ b/usr/local/www/vpn_openvpn_server.php
@@ -34,7 +34,6 @@
 ##|*MATCH=vpn_openvpn_server.php*
 ##|-PRIV
 
-
 require("guiconfig.inc");
 require_once("openvpn.inc");
 
diff --git a/usr/local/www/vpn_pppoe.php b/usr/local/www/vpn_pppoe.php
index 581fb24b70..7b0cd4146b 100755
--- a/usr/local/www/vpn_pppoe.php
+++ b/usr/local/www/vpn_pppoe.php
@@ -35,8 +35,8 @@
 ##|*MATCH=vpn_pppoe.php*
 ##|-PRIV
 
-
 require("guiconfig.inc");
+require_once("vpn.inc");
 
 if (!is_array($config['pppoe']['radius'])) {
 	$config['pppoe']['radius'] = array();
diff --git a/usr/local/www/vpn_pppoe_users.php b/usr/local/www/vpn_pppoe_users.php
index b92fcef2ac..a10589a736 100755
--- a/usr/local/www/vpn_pppoe_users.php
+++ b/usr/local/www/vpn_pppoe_users.php
@@ -35,8 +35,8 @@
 ##|*MATCH=vpn_pppoe_users.php*
 ##|-PRIV
 
-
 require("guiconfig.inc");
+require_once("vpn.inc");
 
 if (!is_array($config['pppoe']['user'])) {
 	$config['pppoe']['user'] = array();
diff --git a/usr/local/www/vpn_pppoe_users_edit.php b/usr/local/www/vpn_pppoe_users_edit.php
index de5a314afa..2b884abd25 100755
--- a/usr/local/www/vpn_pppoe_users_edit.php
+++ b/usr/local/www/vpn_pppoe_users_edit.php
@@ -49,6 +49,7 @@ function pppoe_users_sort() {
 }
 
 require("guiconfig.inc");
+require_once("vpn.inc");
 
 if (!is_array($config['pppoe']['user'])) {
 	$config['pppoe']['user'] = array();
diff --git a/usr/local/www/vpn_pptp.php b/usr/local/www/vpn_pptp.php
index c402533d2b..f841d984df 100755
--- a/usr/local/www/vpn_pptp.php
+++ b/usr/local/www/vpn_pptp.php
@@ -35,8 +35,8 @@
 ##|*MATCH=vpn_pptp.php*
 ##|-PRIV
 
-
 require("guiconfig.inc");
+require_once("vpn.inc");
 
 if (!is_array($config['pptpd']['radius'])) {
 	$config['pptpd']['radius'] = array();
diff --git a/usr/local/www/vpn_pptp_users.php b/usr/local/www/vpn_pptp_users.php
index 31aa0ad632..8d74aece92 100755
--- a/usr/local/www/vpn_pptp_users.php
+++ b/usr/local/www/vpn_pptp_users.php
@@ -35,8 +35,8 @@
 ##|*MATCH=vpn_pptp_users.php*
 ##|-PRIV
 
-
 require("guiconfig.inc");
+require_once("vpn.inc");
 
 if (!is_array($config['pptpd']['user'])) {
 	$config['pptpd']['user'] = array();
diff --git a/usr/local/www/vpn_pptp_users_edit.php b/usr/local/www/vpn_pptp_users_edit.php
index b8ad07468c..5d5c9e2eef 100755
--- a/usr/local/www/vpn_pptp_users_edit.php
+++ b/usr/local/www/vpn_pptp_users_edit.php
@@ -49,6 +49,7 @@ function pptpd_users_sort() {
 }
 
 require("guiconfig.inc");
+require_once("vpn.inc");
 
 if (!is_array($config['pptpd']['user'])) {
 	$config['pptpd']['user'] = array();
diff --git a/usr/local/www/widgets/widgets/ipsec.widget.php b/usr/local/www/widgets/widgets/ipsec.widget.php
index 1a63029cb7..4966dd7d70 100644
--- a/usr/local/www/widgets/widgets/ipsec.widget.php
+++ b/usr/local/www/widgets/widgets/ipsec.widget.php
@@ -30,9 +30,10 @@
         ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
         POSSIBILITY OF SUCH DAMAGE.
 */
+
 require_once("guiconfig.inc");
-require_once("pfsense-utils.inc");
 require_once("functions.inc");
+require_once("ipsec.inc");
 
 	if (isset($config['ipsec']['phase1'])){?>
 	<div>&nbsp;</div>
