diff --git a/src/etc/inc/filter.inc b/src/etc/inc/filter.inc
index 559216c7b..5c97155d3 100644
--- a/src/etc/inc/filter.inc
+++ b/src/etc/inc/filter.inc
@@ -106,11 +106,8 @@ function filter_pflog_start()
mwexec('/usr/local/sbin/filterlog -i pflog0 -p /var/run/filterlog.pid');
}
-/* reload filter async */
function filter_configure()
{
- global $g;
-
/*
* NOTE: Check here for bootup status since this should not be triggered during bootup.
* The reason is that rc.bootup calls filter_configure_sync directly which does this too.
@@ -123,7 +120,8 @@ function filter_configure()
}
}
-function filter_delete_states_for_down_gateways() {
+function filter_delete_states_for_down_gateways()
+{
global $config, $GatewaysList;
if (isset($config['system']['kill_states'])) {
@@ -158,7 +156,7 @@ function filter_delete_states_for_down_gateways() {
function filter_configure_sync()
{
- global $config, $g, $after_filter_configure_run;
+ global $config, $after_filter_configure_run;
global $time_based_rules, $filterdns, $aliases;
$FilterIflist = filter_generate_optcfg_array();
@@ -649,8 +647,9 @@ function filter_generate_aliases(&$FilterIflist)
return $result;
}
-function filter_generate_gateways() {
- global $config, $g, $GatewaysList;
+function filter_generate_gateways()
+{
+ global $config, $GatewaysList;
$rules = "# Gateways\n";
@@ -1627,7 +1626,7 @@ function filter_nat_rules_generate_if(&$FilterIflist, $if, $src = "any", $srcpor
function filter_nat_rules_generate(&$FilterIflist)
{
- global $config, $g, $after_filter_configure_run, $GatewaysList, $aliases;
+ global $config, $after_filter_configure_run, $GatewaysList, $aliases;
$natrules = "no nat proto carp\n";
$natrules .= "no rdr proto carp\n";
@@ -2404,7 +2403,7 @@ function filter_generate_address(&$FilterIflist, &$rule, $target = 'source', $is
function filter_generate_user_rule(&$FilterIflist, $rule)
{
- global $config, $g, $GatewaysList;
+ global $config, $GatewaysList;
/* don't include disabled rules */
if(isset($rule['disabled'])) {
@@ -2764,7 +2763,7 @@ function filter_generate_user_rule(&$FilterIflist, $rule)
function filter_rules_generate(&$FilterIflist)
{
- global $config, $g, $time_based_rules, $GatewaysList;
+ global $config, $time_based_rules, $GatewaysList;
$fix_rule_label = 'fix_rule_label';
@@ -3382,8 +3381,10 @@ EOD;
function filter_rules_spoofcheck_generate($ifname, $ifcfg, $log)
{
- global $g, $config;
+ global $config;
+
$ipfrules = "antispoof {$log['block']} for \${$ifcfg['descr']} \n";
+
return $ipfrules;
}
@@ -3396,8 +3397,9 @@ function filter_rules_spoofcheck_generate($ifname, $ifcfg, $log)
* RESULT
* none
******/
-function filter_tdr_install_cron($should_install) {
- global $config, $g;
+function filter_tdr_install_cron($should_install)
+{
+ global $config;
if(file_exists("/var/run/booting")) {
return;
@@ -3509,10 +3511,8 @@ function filter_get_time_based_rule_status($schedule) {
return false;
}
-function filter_tdr_day($schedule) {
- global $g;
-
-
+function filter_tdr_day($schedule)
+{
/*
* Calculate day of month.
* IE: 29th of may
@@ -3526,9 +3526,9 @@ function filter_tdr_day($schedule) {
}
return false;
}
-function filter_tdr_hour($schedule) {
- global $g;
+function filter_tdr_hour($schedule)
+{
/* $schedule should be a string such as 16:00-19:00 */
$tmp = explode("-", $schedule);
$starting_time = strtotime($tmp[0]);
@@ -3540,9 +3540,8 @@ function filter_tdr_hour($schedule) {
return false;
}
-function filter_tdr_position($schedule) {
- global $g;
-
+function filter_tdr_position($schedule)
+{
/*
* Calculate position, ie: day of week.
* Sunday = 7, Monday = 1, Tuesday = 2
@@ -3563,9 +3562,8 @@ function filter_tdr_position($schedule) {
return false;
}
-function filter_tdr_month($schedule) {
- global $g;
-
+function filter_tdr_month($schedule)
+{
/*
* Calculate month
*/
@@ -3594,7 +3592,7 @@ function filter_setup_logging_interfaces(&$FilterIflist)
function filter_process_carp_rules($log)
{
- global $g, $config;
+ global $config;
$lines = '';
/* return if there are no carp configured items */
@@ -3608,7 +3606,7 @@ function filter_process_carp_rules($log)
/* Generate IPsec Filter Items */
function filter_generate_ipsec_rules(&$FilterIflist, $log = array())
{
- global $config, $g;
+ global $config;
if (isset($config['system']['disablevpnrules'])) {
return "\n# VPN Rules not added disabled in System->Advanced.\n";
diff --git a/src/etc/inc/load_balancer_maintable.inc b/src/etc/inc/load_balancer_maintable.inc
index 8e206de65..13bfbb889 100644
--- a/src/etc/inc/load_balancer_maintable.inc
+++ b/src/etc/inc/load_balancer_maintable.inc
@@ -80,8 +80,8 @@ class MainTable {
echo "\n";
}
- private function display_header() {
- global $g;
+ private function display_header()
+ {
echo "
\n";
for ($col = 0; $col < $this->columns - 1; $col++) {
echo " | width[$col]}%\" class=\"listhdrr\">{$this->headers[$col]} | \n";
@@ -93,8 +93,8 @@ class MainTable {
echo "
\n";
}
- private function display_rows() {
- global $g;
+ private function display_rows()
+ {
$cur_row = 0;
foreach ($this->content as $row) {
echo "\n";
@@ -125,12 +125,9 @@ class MainTable {
$cur_row++;
}
}
- private function display_footer() {
- global $g;
-
- }
- private function display_buttons($row) {
-
+ private function display_footer() { }
+ private function display_buttons($row)
+ {
if ($this->buttons['move'])
echo $this->display_button('move', $row);
if ($this->buttons['edit'])
@@ -140,11 +137,9 @@ class MainTable {
echo $this->display_button('del', $row);
if ($this->buttons['dup'])
echo $this->display_button('dup', $row);
-
}
- private function display_button($button, $row) {
- global $g;
-
+ private function display_button($button, $row)
+ {
switch ($button) {
case "move": {
echo "";
diff --git a/src/etc/inc/openvpn-client-export.inc b/src/etc/inc/openvpn-client-export.inc
index 87032e25b..5db91b7ed 100644
--- a/src/etc/inc/openvpn-client-export.inc
+++ b/src/etc/inc/openvpn-client-export.inc
@@ -75,8 +75,9 @@ function openvpn_client_pem_to_pk12($outpath, $outpass, $crtpath, $keypath, $cap
unlink($capath);
}
-function openvpn_client_export_validate_config($srvid, $usrid, $crtid) {
- global $config, $g, $input_errors;
+function openvpn_client_export_validate_config($srvid, $usrid, $crtid)
+{
+ global $config, $input_errors;
$nokeys = false;
// lookup server settings
@@ -138,8 +139,9 @@ function openvpn_client_export_validate_config($srvid, $usrid, $crtid) {
return array($settings, $server_cert, $server_ca, $servercn, $user, $cert, $nokeys);
}
-function openvpn_client_export_config($srvid, $usrid, $crtid, $useaddr, $verifyservercn, $randomlocalport, $usetoken, $nokeys = false, $proxy, $expformat = "baseconf", $outpass = "", $skiptls=false, $doslines=false, $openvpnmanager, $advancedoptions = "") {
- global $config, $input_errors, $g;
+function openvpn_client_export_config($srvid, $usrid, $crtid, $useaddr, $verifyservercn, $randomlocalport, $usetoken, $nokeys = false, $proxy, $expformat = "baseconf", $outpass = "", $skiptls=false, $doslines=false, $openvpnmanager, $advancedoptions = "")
+{
+ global $config, $input_errors;
$nl = ($doslines) ? "\r\n" : "\n";
$conf = "";
@@ -438,8 +440,9 @@ function openvpn_client_export_config($srvid, $usrid, $crtid, $useaddr, $verifys
}
}
-function openvpn_client_export_installer($srvid, $usrid, $crtid, $useaddr, $verifyservercn, $randomlocalport, $usetoken, $outpass, $proxy, $openvpnmanager, $advancedoptions, $openvpn_version = "x86-xp") {
- global $config, $g, $input_errors, $current_openvpn_version, $current_openvpn_version_rev;
+function openvpn_client_export_installer($srvid, $usrid, $crtid, $useaddr, $verifyservercn, $randomlocalport, $usetoken, $outpass, $proxy, $openvpnmanager, $advancedoptions, $openvpn_version = "x86-xp")
+{
+ global $config, $input_errors, $current_openvpn_version, $current_openvpn_version_rev;
$uname_p = trim(exec("uname -p"));
switch ($openvpn_version) {
@@ -559,8 +562,9 @@ RunProgram="openvpn-postinstall.exe"
return $outfile;
}
-function viscosity_openvpn_client_config_exporter($srvid, $usrid, $crtid, $useaddr, $verifyservercn, $randomlocalport, $usetoken, $outpass, $proxy, $openvpnmanager, $advancedoptions) {
- global $config, $g;
+function viscosity_openvpn_client_config_exporter($srvid, $usrid, $crtid, $useaddr, $verifyservercn, $randomlocalport, $usetoken, $outpass, $proxy, $openvpnmanager, $advancedoptions)
+{
+ global $config;
$uname_p = trim(exec("uname -p"));
$ovpndir = "/usr/local/opnsense/contrib/openvpn/";
@@ -674,8 +678,9 @@ EOF;
}
-function openvpn_client_export_sharedkey_config($srvid, $useaddr, $proxy, $zipconf = false) {
- global $config, $input_errors, $g;
+function openvpn_client_export_sharedkey_config($srvid, $useaddr, $proxy, $zipconf = false)
+{
+ global $config, $input_errors;
// lookup server settings
$settings = $config['openvpn']['openvpn-server'][$srvid];
diff --git a/src/etc/inc/openvpn.inc b/src/etc/inc/openvpn.inc
index 64a2a070d..6763dd653 100644
--- a/src/etc/inc/openvpn.inc
+++ b/src/etc/inc/openvpn.inc
@@ -346,7 +346,7 @@ function openvpn_add_keyfile(&$data, &$conf, $mode_id, $directive, $opt = '')
function openvpn_reconfigure($mode, $settings)
{
- global $g, $config;
+ global $config;
if (empty($settings) || isset($settings['disable'])) {
return;
@@ -756,7 +756,7 @@ function openvpn_reconfigure($mode, $settings)
function openvpn_restart($mode, $settings)
{
- global $g, $config;
+ global $config;
$vpnid = $settings['vpnid'];
$mode_id = $mode.$vpnid;
@@ -796,7 +796,7 @@ function openvpn_restart($mode, $settings)
function openvpn_delete($mode, & $settings)
{
- global $g, $config;
+ global $config;
$vpnid = $settings['vpnid'];
$mode_id = $mode.$vpnid;
@@ -829,7 +829,7 @@ function openvpn_delete($mode, & $settings)
function openvpn_resync_csc(&$settings)
{
- global $g, $config;
+ global $config;
$fpath = "/var/etc/openvpn-csc/{$settings['common_name']}";
@@ -895,7 +895,7 @@ function openvpn_resync($mode, $settings)
function openvpn_resync_all($interface = '')
{
- global $g, $config;
+ global $config;
openvpn_create_dirs();
@@ -931,8 +931,9 @@ function openvpn_resync_all($interface = '')
}
-function openvpn_get_active_servers($type="multipoint") {
- global $config, $g;
+function openvpn_get_active_servers($type = 'multipoint')
+{
+ global $config;
$servers = array();
if (isset($config['openvpn']['openvpn-server']) && is_array($config['openvpn']['openvpn-server'])) {
@@ -1033,8 +1034,9 @@ function openvpn_get_server_status($server, $socket) {
return $server;
}
-function openvpn_get_active_clients() {
- global $config, $g;
+function openvpn_get_active_clients()
+{
+ global $config;
$clients = array();
if (isset($config['openvpn']['openvpn-client']) && is_array($config['openvpn']['openvpn-client'])) {
diff --git a/src/etc/inc/services.inc b/src/etc/inc/services.inc
index 55b3886a4..c3e0e3f15 100644
--- a/src/etc/inc/services.inc
+++ b/src/etc/inc/services.inc
@@ -98,7 +98,7 @@ function get_configured_pppoe_server_interfaces()
/* implement ipv6 route advertising deamon */
function services_radvd_configure($blacklist = array())
{
- global $config, $g;
+ global $config;
if (!isset($config['dhcpdv6']) || !is_array($config['dhcpdv6'])) {
$config['dhcpdv6'] = array();
@@ -1361,8 +1361,9 @@ EOD;
return 0;
}
-function services_igmpproxy_configure() {
- global $config, $g;
+function services_igmpproxy_configure()
+{
+ global $config;
/* kill any running igmpproxy */
killbyname("igmpproxy");
@@ -1420,7 +1421,7 @@ EOD;
function services_dhcrelay_configure()
{
- global $config, $g;
+ global $config;
/* kill any running dhcrelay */
killbypid('/var/run/dhcrelay.pid');
@@ -1537,7 +1538,7 @@ function services_dhcrelay_configure()
function services_dhcrelay6_configure()
{
- global $config, $g;
+ global $config;
/* kill any running dhcrelay */
killbypid('/var/run/dhcrelay6.pid');
@@ -1713,7 +1714,7 @@ function services_dyndns_configure_client($conf) {
function services_dyndns_configure($int = '')
{
- global $config, $g;
+ global $config;
if (isset($config['dyndnses']['dyndns'])) {
$dyndnscfg = $config['dyndnses']['dyndns'];
@@ -1772,7 +1773,7 @@ function dyndnsCheckIP($int)
function services_dnsmasq_configure()
{
- global $config, $g;
+ global $config;
$return = 0;
// hard coded args: will be removed to avoid duplication if specified in custom_options
@@ -1922,7 +1923,7 @@ function services_dnsmasq_configure()
function services_unbound_configure()
{
- global $config, $g;
+ global $config;
$return = 0;
// kill any running Unbound instance
@@ -2151,7 +2152,7 @@ EOD;
function services_dnsupdate_process($int = '', $updatehost = '', $forced = false)
{
- global $config, $g;
+ global $config;
/* Dynamic DNS updating active? */
if (isset($config['dnsupdates']['dnsupdate']) && is_array($config['dnsupdates']['dnsupdate'])) {
@@ -2333,8 +2334,10 @@ function configure_cron()
killbypid('/var/run/cron.pid', 'HUP');
}
-function upnp_action ($action) {
- global $g, $config;
+function upnp_action($action)
+{
+ global $config;
+
switch($action) {
case "start":
if (file_exists('/var/etc/miniupnpd.conf')) {
@@ -2369,7 +2372,7 @@ function upnp_start()
function install_cron_job($command, $active=false, $minute="0", $hour="*", $monthday="*", $month="*", $weekday="*", $who="root") {
- global $config, $g;
+ global $config;
$is_installed = false;
@@ -2612,8 +2615,8 @@ function get_service_status($service)
}
-function get_service_status_icon($service, $withtext = true, $smallicon = false) {
- global $g;
+function get_service_status_icon($service, $withtext = true, $smallicon = false)
+{
$output = "";
if(get_service_status($service)) {
$statustext = gettext("Running");
@@ -2625,9 +2628,8 @@ function get_service_status_icon($service, $withtext = true, $smallicon = false)
return $output;
}
-
-function get_service_control_links($service, $addname = false) {
- global $g;
+function get_service_control_links($service, $addname = false)
+{
$output = "";
$stitle = ($addname) ? $service['name'] . " " : "";
if(get_service_status($service)) {
diff --git a/src/etc/inc/upgrade_config.inc b/src/etc/inc/upgrade_config.inc
index 19219c88e..2b9e36720 100644
--- a/src/etc/inc/upgrade_config.inc
+++ b/src/etc/inc/upgrade_config.inc
@@ -592,7 +592,7 @@ function upgrade_029_to_030() {
}
function upgrade_039_to_040() {
- global $config, $g;
+ global $config;
$config['system']['webgui']['auth_method'] = "session";
$config['system']['webgui']['backing_method'] = "htpasswd";
@@ -625,9 +625,6 @@ function upgrade_039_to_040() {
$config['system']['user'][0]['priv'][2]['id'] = "hasshell";
$config['system']['user'][0]['priv'][2]['name'] = "Has shell access";
$config['system']['user'][0]['priv'][2]['descr'] = gettext("Indicates whether this user is able to login for example via SSH.");
- $config['system']['user'][0]['priv'][3]['id'] = "copyfiles";
- $config['system']['user'][0]['priv'][3]['name'] = "Is allowed to copy files";
- $config['system']['user'][0]['priv'][3]['descr'] = sprintf(gettext("Indicates whether this user is allowed to copy files onto the %s appliance via SCP/SFTP. If you are going to use this privilege, you must install scponly on the appliance (Hint: pkg_add -r scponly)."), $g['product_name']);
$config['system']['user'][0]['priv'][4]['id'] = "isroot";
$config['system']['user'][0]['priv'][4]['name'] = "Is root user";
$config['system']['user'][0]['priv'][4]['descr'] = gettext("This user is associated with the UNIX root user (you should associate this privilege only with one single user).");
@@ -2004,9 +2001,9 @@ function upgrade_053_to_054() {
}
-function upgrade_054_to_055() {
+function upgrade_054_to_055()
+{
global $config;
- global $g;
/* RRD files changed for quality, traffic and packets graphs */
//ini_set("max_execution_time", "1800");
@@ -2642,10 +2639,9 @@ function upgrade_079_to_080() {
}
}
-function upgrade_080_to_081() {
+function upgrade_080_to_081()
+{
global $config;
- global $g;
- /* Welcome to the 2.1 migration path */
/* tag all the existing gateways as being IPv4 */
$i = 0;
@@ -2893,8 +2889,9 @@ function upgrade_084_to_085() {
unset($gateways, $oldnames, $gateway_group_arr);
}
-function upgrade_085_to_086() {
- global $config, $g;
+function upgrade_085_to_086()
+{
+ global $config;
/* XXX: Gross hacks in sight */
if (is_array($config['virtualip']['vip'])) {
@@ -3036,15 +3033,18 @@ function upgrade_091_to_092() {
}
}
-function upgrade_092_to_093() {
- global $g;
-
+function upgrade_092_to_093()
+{
$suffixes = array("concurrent", "loggedin");
- foreach ($suffixes as $suffix)
- if (file_exists("/var/db/rrd/captiveportal-{$suffix}.rrd"))
- rename("/var/db/rrd/captiveportal-{$suffix}.rrd",
- "/var/db/rrd/captiveportal-cpZone-{$suffix}.rrd");
+ foreach ($suffixes as $suffix) {
+ if (file_exists("/var/db/rrd/captiveportal-{$suffix}.rrd")) {
+ rename(
+ "/var/db/rrd/captiveportal-{$suffix}.rrd",
+ "/var/db/rrd/captiveportal-cpZone-{$suffix}.rrd"
+ );
+ }
+ }
enable_rrd_graphing();
}
@@ -3071,8 +3071,9 @@ function upgrade_094_to_095() {
$config['interfaces'][$iface]['track6-prefix-id'] = 0;
}
-function upgrade_095_to_096() {
- global $config, $g;
+function upgrade_095_to_096()
+{
+ global $config;
$names = array("inpass", "outpass", "inblock", "outblock",
"inpass6", "outpass6", "inblock6", "outblock6");
@@ -3101,8 +3102,10 @@ function upgrade_095_to_096() {
exec("cd /; LANG=C NO_REMOUNT=1 RRDDBPATH='{$rrddbpath}' CF_CONF_PATH='/conf' /usr/local/etc/rc.backup_rrd");
}
-function upgrade_096_to_097() {
- global $config, $g;
+function upgrade_096_to_097()
+{
+ global $config;
+
/* If the user had disabled default block rule logging before, then bogon/private network logging was already off, so respect their choice. */
if (isset($config['syslog']['nologdefaultblock'])) {
$config['syslog']['nologbogons'] = true;
@@ -3110,8 +3113,10 @@ function upgrade_096_to_097() {
}
}
-function upgrade_097_to_098() {
- global $config, $g;
+function upgrade_097_to_098()
+{
+ global $config;
+
/* Disable kill_states by default */
$config['system']['kill_states'] = true;
}
@@ -3130,12 +3135,14 @@ function upgrade_098_to_099() {
}
}
-function upgrade_099_to_100() {
+function upgrade_099_to_100()
+{
install_cron_job("newsyslog", false);
}
-function upgrade_100_to_101() {
- global $config, $g;
+function upgrade_100_to_101()
+{
+ global $config;
if (!is_array($config['voucher']))
return;
@@ -3150,8 +3157,9 @@ function upgrade_100_to_101() {
}
}
-function upgrade_101_to_102() {
- global $config, $g;
+function upgrade_101_to_102()
+{
+ global $config;
if (is_array($config['captiveportal'])) {
foreach ($config['captiveportal'] as $cpzone => $cp) {
diff --git a/src/etc/inc/vpn.inc b/src/etc/inc/vpn.inc
index 5e6e2a76f..3729d264a 100644
--- a/src/etc/inc/vpn.inc
+++ b/src/etc/inc/vpn.inc
@@ -931,8 +931,9 @@ EOD;
* For all other occasions the normal vpn_ipsec_configure()
* will gracefully reload the settings without restarting
*/
-function vpn_ipsec_force_reload($interface = "") {
- global $g, $config;
+function vpn_ipsec_force_reload($interface = '')
+{
+ global $config;
$ipseccfg = $config['ipsec'];
@@ -960,8 +961,6 @@ function vpn_ipsec_force_reload($interface = "") {
/* master setup for vpn (mpd) */
function vpn_setup()
{
- global $g;
-
/* start pptpd */
vpn_pptpd_configure();
@@ -985,7 +984,7 @@ function vpn_netgraph_support() {
}
function vpn_pptpd_configure() {
- global $config, $g;
+ global $config;
$syscfg = $config['system'];
$pptpdcfg = $config['pptpd'];
@@ -1216,7 +1215,7 @@ function vpn_pppoes_configure() {
}
function vpn_pppoe_configure(&$pppoecfg) {
- global $config, $g;
+ global $config;
$syscfg = $config['system'];
@@ -1426,7 +1425,7 @@ EOD;
function vpn_l2tp_configure()
{
- global $config, $g;
+ global $config;
$syscfg = $config['system'];
if (isset($config['l2tp'])) {
diff --git a/src/etc/inc/vslb.inc b/src/etc/inc/vslb.inc
index dfc74daf6..4246d590a 100644
--- a/src/etc/inc/vslb.inc
+++ b/src/etc/inc/vslb.inc
@@ -126,8 +126,9 @@ class SendMonitor extends Monitor {
}
-function relayd_configure($kill_first=false) {
- global $config, $g;
+function relayd_configure($kill_first = false)
+{
+ global $config;
if (isset($config['load_balancer']['virtual_server'])) {
$vs_a = $config['load_balancer']['virtual_server'];
diff --git a/src/etc/rc.filter_synchronize b/src/etc/rc.filter_synchronize
index e0ce03f60..7d6945a1f 100755
--- a/src/etc/rc.filter_synchronize
+++ b/src/etc/rc.filter_synchronize
@@ -174,8 +174,9 @@ function copy_conf_section(&$cnf_structure_in, &$cnf_structure_out, $reference)
* @param string $method xmlrpc method to call
* @return boolean
*/
-function carp_sync_xml($url, $username, $password, $sections, $method = 'opnsense.restore_config_section') {
- global $config, $g;
+function carp_sync_xml($url, $username, $password, $sections, $method = 'opnsense.restore_config_section')
+{
+ global $config;
update_filter_reload_status("Syncing CARP data to {$url}");
diff --git a/src/etc/rc.initial.setlanip b/src/etc/rc.initial.setlanip
index 2e6db97ce..498944998 100755
--- a/src/etc/rc.initial.setlanip
+++ b/src/etc/rc.initial.setlanip
@@ -193,7 +193,8 @@ $ifaceassigned = "";
function next_unused_gateway_name($interface)
{
- global $g, $config;
+ global $config;
+
$new_name = "GW_" . strtoupper($interface);
if (!isset($config['gateways']['gateway_item'])) {
@@ -218,7 +219,7 @@ function next_unused_gateway_name($interface)
function add_gateway_to_config($interface, $gatewayip, $inet_type)
{
- global $g, $config, $dry_run;
+ global $config, $dry_run;
if (!isset($config['gateways']['gateway_item'])) {
$config['gateways']['gateway_item'] = array();
@@ -393,7 +394,7 @@ $config['interfaces'][$interface]['enable'] = true;
function console_configure_dhcpd($version = 4)
{
- global $g, $config, $restart_dhcpd, $fp, $interface, $dry_run, $intip, $intbits, $intip6, $intbits6;
+ global $config, $restart_dhcpd, $fp, $interface, $dry_run, $intip, $intbits, $intip6, $intbits6;
$label_IPvX = ($version === 6) ? "IPv6" : "IPv4";
$dhcpd = ($version === 6) ? "dhcpdv6" : "dhcpd";
diff --git a/src/etc/rc.openvpn b/src/etc/rc.openvpn
index e19ec0fcc..f84f3c7bb 100755
--- a/src/etc/rc.openvpn
+++ b/src/etc/rc.openvpn
@@ -35,22 +35,25 @@ require_once("interfaces.inc");
require_once("filter.inc");
require_once("openvpn.inc");
-function gateway_is_gwgroup_member($name) {
+function gateway_is_gwgroup_member($name)
+{
global $config;
- if (is_array($config['gateways']['gateway_group']))
- $groups = $config['gateways']['gateway_group'];
- else
+ if (!isset($config['gateways']['gateway_group'])) {
return false;
+ }
+ $groups = $config['gateways']['gateway_group'];
$members = array();
+
foreach($groups as $group) {
- if (is_array($group['item'])) {
+ if (isset($group['item'])) {
foreach($group['item'] as $item) {
$elements = explode("|", $item);
$gwname = $elements[0];
- if ($name == $elements[0])
+ if ($name == $elements[0]) {
$members[] = $group['name'];
+ }
}
}
}
@@ -58,10 +61,9 @@ function gateway_is_gwgroup_member($name) {
return $members;
}
-
-
-function openvpn_resync_if_needed ($mode, $ovpn_settings, $interface) {
- global $g, $config;
+function openvpn_resync_if_needed($mode, $ovpn_settings, $interface)
+{
+ global $config;
$resync_needed = true;
if (isset($ovpn_settings['disable'])) {
diff --git a/src/etc/rc.restore_config_backup b/src/etc/rc.restore_config_backup
index 1befa3bd2..471987c43 100755
--- a/src/etc/rc.restore_config_backup
+++ b/src/etc/rc.restore_config_backup
@@ -60,8 +60,10 @@ function choose_backup() {
}
}
-function restore_history_backup($number) {
- global $g, $fp, $confvers;
+function restore_history_backup($number)
+{
+ global $fp, $confvers;
+
if (is_numeric($number) && ($number > 0) && ($number <= count($confvers))) {
echo "\n" . gettext("Is this the backup you wish to restore?") . "\n";
list_backups($number);
diff --git a/src/www/firewall_schedule_edit.php b/src/www/firewall_schedule_edit.php
index 79b8a7841..493252e5e 100644
--- a/src/www/firewall_schedule_edit.php
+++ b/src/www/firewall_schedule_edit.php
@@ -62,16 +62,18 @@ function is_schedule_inuse($schedule)
return false;
}
-
-function schedulecmp($a, $b) {
+function schedulecmp($a, $b)
+{
return strcmp($a['name'], $b['name']);
}
-function schedule_sort(){
- global $g, $config;
+function schedule_sort()
+{
+ global $config;
- if (!is_array($config['schedules']['schedule']))
+ if (!isset($config['schedules']['schedule'])) {
return;
+ }
usort($config['schedules']['schedule'], "schedulecmp");
}
diff --git a/src/www/services_dhcp_edit.php b/src/www/services_dhcp_edit.php
index e5f66d997..2f5cf7477 100644
--- a/src/www/services_dhcp_edit.php
+++ b/src/www/services_dhcp_edit.php
@@ -35,8 +35,9 @@ function staticmapcmp($a, $b) {
return ipcmp($a['ipaddr'], $b['ipaddr']);
}
-function staticmaps_sort($ifgui) {
- global $g, $config;
+function staticmaps_sort($ifgui)
+{
+ global $config;
usort($config['dhcpd'][$ifgui]['staticmap'], "staticmapcmp");
}
diff --git a/src/www/services_dhcpv6_edit.php b/src/www/services_dhcpv6_edit.php
index f0ed3f6e4..bfe5b699d 100644
--- a/src/www/services_dhcpv6_edit.php
+++ b/src/www/services_dhcpv6_edit.php
@@ -30,17 +30,18 @@
require_once("guiconfig.inc");
require_once("interfaces.inc");
-function staticmapcmp($a, $b) {
+function staticmapcmp($a, $b)
+{
return ipcmp($a['ipaddrv6'], $b['ipaddrv6']);
}
-function staticmaps_sort($ifgui) {
- global $g, $config;
+function staticmaps_sort($ifgui)
+{
+ global $config;
usort($config['dhcpdv6'][$ifgui]['staticmap'], "staticmapcmp");
}
-
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/services_dhcpv6.php');
$if = $_GET['if'];
diff --git a/src/www/services_dnsmasq_edit.php b/src/www/services_dnsmasq_edit.php
index f247c84fa..773fc303b 100644
--- a/src/www/services_dnsmasq_edit.php
+++ b/src/www/services_dnsmasq_edit.php
@@ -31,15 +31,18 @@ require_once("guiconfig.inc");
require_once("services.inc");
require_once("interfaces.inc");
-function hostcmp($a, $b) {
+function hostcmp($a, $b)
+{
return strcasecmp($a['host'], $b['host']);
}
-function hosts_sort() {
- global $g, $config;
+function hosts_sort()
+{
+ global $config;
- if (!is_array($config['dnsmasq']['hosts']))
+ if (!isset($config['dnsmasq']['hosts'])) {
return;
+ }
usort($config['dnsmasq']['hosts'], "hostcmp");
}
diff --git a/src/www/services_unbound_host_edit.php b/src/www/services_unbound_host_edit.php
index 7afcaabdd..ce4c9bb58 100644
--- a/src/www/services_unbound_host_edit.php
+++ b/src/www/services_unbound_host_edit.php
@@ -35,15 +35,18 @@ require_once("interfaces.inc");
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/services_unbound_overrides.php');
-function hostcmp($a, $b) {
+function hostcmp($a, $b)
+{
return strcasecmp($a['host'], $b['host']);
}
-function hosts_sort() {
- global $g, $config;
+function hosts_sort()
+{
+ global $config;
- if (!is_array($config['unbound']['hosts']))
+ if (!isset($config['unbound']['hosts'])) {
return;
+ }
usort($config['unbound']['hosts'], "hostcmp");
}
diff --git a/src/www/status.php b/src/www/status.php
index f04a16b07..67074f056 100644
--- a/src/www/status.php
+++ b/src/www/status.php
@@ -27,8 +27,7 @@
POSSIBILITY OF SUCH DAMAGE.
*/
-/* include all configuration functions */
-require_once("guiconfig.inc");
+require_once('guiconfig.inc');
function doCmdT($title, $command) {
$rubbish = array('|', '-', '/', '.', ' '); /* fixes the tag to be W3C compliant */
@@ -105,8 +104,6 @@ function execCmds() {
}
}
-global $g, $config;
-
/* Set up all of the commands we want to execute. */
defCmdT("System uptime","uptime");
defCmdT("Interfaces","/sbin/ifconfig -a");
diff --git a/src/www/status_openvpn.php b/src/www/status_openvpn.php
index 244a690eb..3935119ae 100644
--- a/src/www/status_openvpn.php
+++ b/src/www/status_openvpn.php
@@ -34,9 +34,8 @@ require_once("openvpn.inc");
require_once("services.inc");
require_once("interfaces.inc");
-function kill_client($port, $remipp) {
- global $g;
-
+function kill_client($port, $remipp)
+{
$tcpsrv = "unix:///var/etc/openvpn/{$port}.sock";
$errval;
$errstr;
diff --git a/src/www/system_crlmanager.php b/src/www/system_crlmanager.php
index 012120251..c49721710 100644
--- a/src/www/system_crlmanager.php
+++ b/src/www/system_crlmanager.php
@@ -27,11 +27,12 @@
POSSIBILITY OF SUCH DAMAGE.
*/
-require_once("guiconfig.inc");
+require_once('guiconfig.inc');
require_once('openvpn.inc');
-function openvpn_refresh_crls() {
- global $g, $config;
+function openvpn_refresh_crls()
+{
+ global $config;
openvpn_create_dirs();
diff --git a/src/www/widgets/widgets/openvpn.widget.php b/src/www/widgets/widgets/openvpn.widget.php
index 9b6e896e6..148139d22 100644
--- a/src/www/widgets/widgets/openvpn.widget.php
+++ b/src/www/widgets/widgets/openvpn.widget.php
@@ -49,8 +49,6 @@ if ($_GET['action']) {
function kill_client($port, $remipp)
{
- global $g;
-
//$tcpsrv = "tcp://127.0.0.1:{$port}";
$tcpsrv = "unix:///var/etc/openvpn/{$port}.sock";
$errval;
diff --git a/src/www/wizard.php b/src/www/wizard.php
index 54d4065ac..90993a613 100644
--- a/src/www/wizard.php
+++ b/src/www/wizard.php
@@ -962,8 +962,9 @@ if($pkg['step'][$stepid]['javascriptafterformdisplay'] <> "") {
* HELPER FUNCTIONS
*/
-function fixup_string($string) {
- global $config, $g, $myurl, $title;
+function fixup_string($string)
+{
+ global $config, $myurl, $title;
$newstring = $string;
// fixup #1: $myurl -> http[s]://ip_address:port/
switch($config['system']['webgui']['protocol']) {