Commit fa5f6e2d authored by Franco Fichtner's avatar Franco Fichtner

src: remove a whole lotta nop

Lookie how far we've come...

(cherry picked from commit 6ee8eb78)
parent d49d6b0e
...@@ -106,11 +106,8 @@ function filter_pflog_start() ...@@ -106,11 +106,8 @@ function filter_pflog_start()
mwexec('/usr/local/sbin/filterlog -i pflog0 -p /var/run/filterlog.pid'); mwexec('/usr/local/sbin/filterlog -i pflog0 -p /var/run/filterlog.pid');
} }
/* reload filter async */
function filter_configure() function filter_configure()
{ {
global $g;
/* /*
* NOTE: Check here for bootup status since this should not be triggered during bootup. * 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. * The reason is that rc.bootup calls filter_configure_sync directly which does this too.
...@@ -123,7 +120,8 @@ function filter_configure() ...@@ -123,7 +120,8 @@ function filter_configure()
} }
} }
function filter_delete_states_for_down_gateways() { function filter_delete_states_for_down_gateways()
{
global $config, $GatewaysList; global $config, $GatewaysList;
if (isset($config['system']['kill_states'])) { if (isset($config['system']['kill_states'])) {
...@@ -158,7 +156,7 @@ function filter_delete_states_for_down_gateways() { ...@@ -158,7 +156,7 @@ function filter_delete_states_for_down_gateways() {
function filter_configure_sync() function filter_configure_sync()
{ {
global $config, $g, $after_filter_configure_run; global $config, $after_filter_configure_run;
global $time_based_rules, $filterdns, $aliases; global $time_based_rules, $filterdns, $aliases;
$FilterIflist = filter_generate_optcfg_array(); $FilterIflist = filter_generate_optcfg_array();
...@@ -649,8 +647,9 @@ function filter_generate_aliases(&$FilterIflist) ...@@ -649,8 +647,9 @@ function filter_generate_aliases(&$FilterIflist)
return $result; return $result;
} }
function filter_generate_gateways() { function filter_generate_gateways()
global $config, $g, $GatewaysList; {
global $config, $GatewaysList;
$rules = "# Gateways\n"; $rules = "# Gateways\n";
...@@ -1627,7 +1626,7 @@ function filter_nat_rules_generate_if(&$FilterIflist, $if, $src = "any", $srcpor ...@@ -1627,7 +1626,7 @@ function filter_nat_rules_generate_if(&$FilterIflist, $if, $src = "any", $srcpor
function filter_nat_rules_generate(&$FilterIflist) 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 nat proto carp\n";
$natrules .= "no rdr proto carp\n"; $natrules .= "no rdr proto carp\n";
...@@ -2404,7 +2403,7 @@ function filter_generate_address(&$FilterIflist, &$rule, $target = 'source', $is ...@@ -2404,7 +2403,7 @@ function filter_generate_address(&$FilterIflist, &$rule, $target = 'source', $is
function filter_generate_user_rule(&$FilterIflist, $rule) function filter_generate_user_rule(&$FilterIflist, $rule)
{ {
global $config, $g, $GatewaysList; global $config, $GatewaysList;
/* don't include disabled rules */ /* don't include disabled rules */
if(isset($rule['disabled'])) { if(isset($rule['disabled'])) {
...@@ -2764,7 +2763,7 @@ function filter_generate_user_rule(&$FilterIflist, $rule) ...@@ -2764,7 +2763,7 @@ function filter_generate_user_rule(&$FilterIflist, $rule)
function filter_rules_generate(&$FilterIflist) function filter_rules_generate(&$FilterIflist)
{ {
global $config, $g, $time_based_rules, $GatewaysList; global $config, $time_based_rules, $GatewaysList;
$fix_rule_label = 'fix_rule_label'; $fix_rule_label = 'fix_rule_label';
...@@ -3382,8 +3381,10 @@ EOD; ...@@ -3382,8 +3381,10 @@ EOD;
function filter_rules_spoofcheck_generate($ifname, $ifcfg, $log) function filter_rules_spoofcheck_generate($ifname, $ifcfg, $log)
{ {
global $g, $config; global $config;
$ipfrules = "antispoof {$log['block']} for \${$ifcfg['descr']} \n"; $ipfrules = "antispoof {$log['block']} for \${$ifcfg['descr']} \n";
return $ipfrules; return $ipfrules;
} }
...@@ -3396,8 +3397,9 @@ function filter_rules_spoofcheck_generate($ifname, $ifcfg, $log) ...@@ -3396,8 +3397,9 @@ function filter_rules_spoofcheck_generate($ifname, $ifcfg, $log)
* RESULT * RESULT
* none * none
******/ ******/
function filter_tdr_install_cron($should_install) { function filter_tdr_install_cron($should_install)
global $config, $g; {
global $config;
if(file_exists("/var/run/booting")) { if(file_exists("/var/run/booting")) {
return; return;
...@@ -3509,10 +3511,8 @@ function filter_get_time_based_rule_status($schedule) { ...@@ -3509,10 +3511,8 @@ function filter_get_time_based_rule_status($schedule) {
return false; return false;
} }
function filter_tdr_day($schedule) { function filter_tdr_day($schedule)
global $g; {
/* /*
* Calculate day of month. * Calculate day of month.
* IE: 29th of may * IE: 29th of may
...@@ -3526,9 +3526,9 @@ function filter_tdr_day($schedule) { ...@@ -3526,9 +3526,9 @@ function filter_tdr_day($schedule) {
} }
return false; 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 */ /* $schedule should be a string such as 16:00-19:00 */
$tmp = explode("-", $schedule); $tmp = explode("-", $schedule);
$starting_time = strtotime($tmp[0]); $starting_time = strtotime($tmp[0]);
...@@ -3540,9 +3540,8 @@ function filter_tdr_hour($schedule) { ...@@ -3540,9 +3540,8 @@ function filter_tdr_hour($schedule) {
return false; return false;
} }
function filter_tdr_position($schedule) { function filter_tdr_position($schedule)
global $g; {
/* /*
* Calculate position, ie: day of week. * Calculate position, ie: day of week.
* Sunday = 7, Monday = 1, Tuesday = 2 * Sunday = 7, Monday = 1, Tuesday = 2
...@@ -3563,9 +3562,8 @@ function filter_tdr_position($schedule) { ...@@ -3563,9 +3562,8 @@ function filter_tdr_position($schedule) {
return false; return false;
} }
function filter_tdr_month($schedule) { function filter_tdr_month($schedule)
global $g; {
/* /*
* Calculate month * Calculate month
*/ */
...@@ -3594,7 +3592,7 @@ function filter_setup_logging_interfaces(&$FilterIflist) ...@@ -3594,7 +3592,7 @@ function filter_setup_logging_interfaces(&$FilterIflist)
function filter_process_carp_rules($log) function filter_process_carp_rules($log)
{ {
global $g, $config; global $config;
$lines = ''; $lines = '';
/* return if there are no carp configured items */ /* return if there are no carp configured items */
...@@ -3608,7 +3606,7 @@ function filter_process_carp_rules($log) ...@@ -3608,7 +3606,7 @@ function filter_process_carp_rules($log)
/* Generate IPsec Filter Items */ /* Generate IPsec Filter Items */
function filter_generate_ipsec_rules(&$FilterIflist, $log = array()) function filter_generate_ipsec_rules(&$FilterIflist, $log = array())
{ {
global $config, $g; global $config;
if (isset($config['system']['disablevpnrules'])) { if (isset($config['system']['disablevpnrules'])) {
return "\n# VPN Rules not added disabled in System->Advanced.\n"; return "\n# VPN Rules not added disabled in System->Advanced.\n";
......
...@@ -80,8 +80,8 @@ class MainTable { ...@@ -80,8 +80,8 @@ class MainTable {
echo "<!-- end content table -->\n"; echo "<!-- end content table -->\n";
} }
private function display_header() { private function display_header()
global $g; {
echo "<tr>\n"; echo "<tr>\n";
for ($col = 0; $col < $this->columns - 1; $col++) { for ($col = 0; $col < $this->columns - 1; $col++) {
echo " <td width=\"{$this->width[$col]}%\" class=\"listhdrr\">{$this->headers[$col]}</td>\n"; echo " <td width=\"{$this->width[$col]}%\" class=\"listhdrr\">{$this->headers[$col]}</td>\n";
...@@ -93,8 +93,8 @@ class MainTable { ...@@ -93,8 +93,8 @@ class MainTable {
echo "</tr>\n"; echo "</tr>\n";
} }
private function display_rows() { private function display_rows()
global $g; {
$cur_row = 0; $cur_row = 0;
foreach ($this->content as $row) { foreach ($this->content as $row) {
echo "<tr>\n"; echo "<tr>\n";
...@@ -125,12 +125,9 @@ class MainTable { ...@@ -125,12 +125,9 @@ class MainTable {
$cur_row++; $cur_row++;
} }
} }
private function display_footer() { private function display_footer() { }
global $g; private function display_buttons($row)
{
}
private function display_buttons($row) {
if ($this->buttons['move']) if ($this->buttons['move'])
echo $this->display_button('move', $row); echo $this->display_button('move', $row);
if ($this->buttons['edit']) if ($this->buttons['edit'])
...@@ -140,11 +137,9 @@ class MainTable { ...@@ -140,11 +137,9 @@ class MainTable {
echo $this->display_button('del', $row); echo $this->display_button('del', $row);
if ($this->buttons['dup']) if ($this->buttons['dup'])
echo $this->display_button('dup', $row); echo $this->display_button('dup', $row);
} }
private function display_button($button, $row) { private function display_button($button, $row)
global $g; {
switch ($button) { switch ($button) {
case "move": { case "move": {
echo "<button name=\"move_{$row}\" type=\"submit\" title=\"".gettext('Move selected entries before this entry')."\" onmouseover=\"fr_insline({$row}, true)\" onmouseout=\"fr_insline({$row}, false)\" class=\"btn btn-default btn-xs\"><span class=\"glyphicon glyphicon-arrow-left\"></span></button>"; echo "<button name=\"move_{$row}\" type=\"submit\" title=\"".gettext('Move selected entries before this entry')."\" onmouseover=\"fr_insline({$row}, true)\" onmouseout=\"fr_insline({$row}, false)\" class=\"btn btn-default btn-xs\"><span class=\"glyphicon glyphicon-arrow-left\"></span></button>";
......
...@@ -75,8 +75,9 @@ function openvpn_client_pem_to_pk12($outpath, $outpass, $crtpath, $keypath, $cap ...@@ -75,8 +75,9 @@ function openvpn_client_pem_to_pk12($outpath, $outpass, $crtpath, $keypath, $cap
unlink($capath); unlink($capath);
} }
function openvpn_client_export_validate_config($srvid, $usrid, $crtid) { function openvpn_client_export_validate_config($srvid, $usrid, $crtid)
global $config, $g, $input_errors; {
global $config, $input_errors;
$nokeys = false; $nokeys = false;
// lookup server settings // lookup server settings
...@@ -138,8 +139,9 @@ function openvpn_client_export_validate_config($srvid, $usrid, $crtid) { ...@@ -138,8 +139,9 @@ function openvpn_client_export_validate_config($srvid, $usrid, $crtid) {
return array($settings, $server_cert, $server_ca, $servercn, $user, $cert, $nokeys); 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 = "") { 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; {
global $config, $input_errors;
$nl = ($doslines) ? "\r\n" : "\n"; $nl = ($doslines) ? "\r\n" : "\n";
$conf = ""; $conf = "";
...@@ -438,8 +440,9 @@ function openvpn_client_export_config($srvid, $usrid, $crtid, $useaddr, $verifys ...@@ -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") { 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; {
global $config, $input_errors, $current_openvpn_version, $current_openvpn_version_rev;
$uname_p = trim(exec("uname -p")); $uname_p = trim(exec("uname -p"));
switch ($openvpn_version) { switch ($openvpn_version) {
...@@ -559,8 +562,9 @@ RunProgram="openvpn-postinstall.exe" ...@@ -559,8 +562,9 @@ RunProgram="openvpn-postinstall.exe"
return $outfile; return $outfile;
} }
function viscosity_openvpn_client_config_exporter($srvid, $usrid, $crtid, $useaddr, $verifyservercn, $randomlocalport, $usetoken, $outpass, $proxy, $openvpnmanager, $advancedoptions) { function viscosity_openvpn_client_config_exporter($srvid, $usrid, $crtid, $useaddr, $verifyservercn, $randomlocalport, $usetoken, $outpass, $proxy, $openvpnmanager, $advancedoptions)
global $config, $g; {
global $config;
$uname_p = trim(exec("uname -p")); $uname_p = trim(exec("uname -p"));
$ovpndir = "/usr/local/opnsense/contrib/openvpn/"; $ovpndir = "/usr/local/opnsense/contrib/openvpn/";
...@@ -674,8 +678,9 @@ EOF; ...@@ -674,8 +678,9 @@ EOF;
} }
function openvpn_client_export_sharedkey_config($srvid, $useaddr, $proxy, $zipconf = false) { function openvpn_client_export_sharedkey_config($srvid, $useaddr, $proxy, $zipconf = false)
global $config, $input_errors, $g; {
global $config, $input_errors;
// lookup server settings // lookup server settings
$settings = $config['openvpn']['openvpn-server'][$srvid]; $settings = $config['openvpn']['openvpn-server'][$srvid];
......
...@@ -346,7 +346,7 @@ function openvpn_add_keyfile(&$data, &$conf, $mode_id, $directive, $opt = '') ...@@ -346,7 +346,7 @@ function openvpn_add_keyfile(&$data, &$conf, $mode_id, $directive, $opt = '')
function openvpn_reconfigure($mode, $settings) function openvpn_reconfigure($mode, $settings)
{ {
global $g, $config; global $config;
if (empty($settings) || isset($settings['disable'])) { if (empty($settings) || isset($settings['disable'])) {
return; return;
...@@ -756,7 +756,7 @@ function openvpn_reconfigure($mode, $settings) ...@@ -756,7 +756,7 @@ function openvpn_reconfigure($mode, $settings)
function openvpn_restart($mode, $settings) function openvpn_restart($mode, $settings)
{ {
global $g, $config; global $config;
$vpnid = $settings['vpnid']; $vpnid = $settings['vpnid'];
$mode_id = $mode.$vpnid; $mode_id = $mode.$vpnid;
...@@ -796,7 +796,7 @@ function openvpn_restart($mode, $settings) ...@@ -796,7 +796,7 @@ function openvpn_restart($mode, $settings)
function openvpn_delete($mode, & $settings) function openvpn_delete($mode, & $settings)
{ {
global $g, $config; global $config;
$vpnid = $settings['vpnid']; $vpnid = $settings['vpnid'];
$mode_id = $mode.$vpnid; $mode_id = $mode.$vpnid;
...@@ -829,7 +829,7 @@ function openvpn_delete($mode, & $settings) ...@@ -829,7 +829,7 @@ function openvpn_delete($mode, & $settings)
function openvpn_resync_csc(&$settings) function openvpn_resync_csc(&$settings)
{ {
global $g, $config; global $config;
$fpath = "/var/etc/openvpn-csc/{$settings['common_name']}"; $fpath = "/var/etc/openvpn-csc/{$settings['common_name']}";
...@@ -895,7 +895,7 @@ function openvpn_resync($mode, $settings) ...@@ -895,7 +895,7 @@ function openvpn_resync($mode, $settings)
function openvpn_resync_all($interface = '') function openvpn_resync_all($interface = '')
{ {
global $g, $config; global $config;
openvpn_create_dirs(); openvpn_create_dirs();
...@@ -931,8 +931,9 @@ function openvpn_resync_all($interface = '') ...@@ -931,8 +931,9 @@ function openvpn_resync_all($interface = '')
} }
function openvpn_get_active_servers($type="multipoint") { function openvpn_get_active_servers($type = 'multipoint')
global $config, $g; {
global $config;
$servers = array(); $servers = array();
if (isset($config['openvpn']['openvpn-server']) && is_array($config['openvpn']['openvpn-server'])) { if (isset($config['openvpn']['openvpn-server']) && is_array($config['openvpn']['openvpn-server'])) {
...@@ -1033,8 +1034,9 @@ function openvpn_get_server_status($server, $socket) { ...@@ -1033,8 +1034,9 @@ function openvpn_get_server_status($server, $socket) {
return $server; return $server;
} }
function openvpn_get_active_clients() { function openvpn_get_active_clients()
global $config, $g; {
global $config;
$clients = array(); $clients = array();
if (isset($config['openvpn']['openvpn-client']) && is_array($config['openvpn']['openvpn-client'])) { if (isset($config['openvpn']['openvpn-client']) && is_array($config['openvpn']['openvpn-client'])) {
......
...@@ -98,7 +98,7 @@ function get_configured_pppoe_server_interfaces() ...@@ -98,7 +98,7 @@ function get_configured_pppoe_server_interfaces()
/* implement ipv6 route advertising deamon */ /* implement ipv6 route advertising deamon */
function services_radvd_configure($blacklist = array()) function services_radvd_configure($blacklist = array())
{ {
global $config, $g; global $config;
if (!isset($config['dhcpdv6']) || !is_array($config['dhcpdv6'])) { if (!isset($config['dhcpdv6']) || !is_array($config['dhcpdv6'])) {
$config['dhcpdv6'] = array(); $config['dhcpdv6'] = array();
...@@ -1361,8 +1361,9 @@ EOD; ...@@ -1361,8 +1361,9 @@ EOD;
return 0; return 0;
} }
function services_igmpproxy_configure() { function services_igmpproxy_configure()
global $config, $g; {
global $config;
/* kill any running igmpproxy */ /* kill any running igmpproxy */
killbyname("igmpproxy"); killbyname("igmpproxy");
...@@ -1420,7 +1421,7 @@ EOD; ...@@ -1420,7 +1421,7 @@ EOD;
function services_dhcrelay_configure() function services_dhcrelay_configure()
{ {
global $config, $g; global $config;
/* kill any running dhcrelay */ /* kill any running dhcrelay */
killbypid('/var/run/dhcrelay.pid'); killbypid('/var/run/dhcrelay.pid');
...@@ -1537,7 +1538,7 @@ function services_dhcrelay_configure() ...@@ -1537,7 +1538,7 @@ function services_dhcrelay_configure()
function services_dhcrelay6_configure() function services_dhcrelay6_configure()
{ {
global $config, $g; global $config;
/* kill any running dhcrelay */ /* kill any running dhcrelay */
killbypid('/var/run/dhcrelay6.pid'); killbypid('/var/run/dhcrelay6.pid');
...@@ -1713,7 +1714,7 @@ function services_dyndns_configure_client($conf) { ...@@ -1713,7 +1714,7 @@ function services_dyndns_configure_client($conf) {
function services_dyndns_configure($int = '') function services_dyndns_configure($int = '')
{ {
global $config, $g; global $config;
if (isset($config['dyndnses']['dyndns'])) { if (isset($config['dyndnses']['dyndns'])) {
$dyndnscfg = $config['dyndnses']['dyndns']; $dyndnscfg = $config['dyndnses']['dyndns'];
...@@ -1772,7 +1773,7 @@ function dyndnsCheckIP($int) ...@@ -1772,7 +1773,7 @@ function dyndnsCheckIP($int)
function services_dnsmasq_configure() function services_dnsmasq_configure()
{ {
global $config, $g; global $config;
$return = 0; $return = 0;
// hard coded args: will be removed to avoid duplication if specified in custom_options // hard coded args: will be removed to avoid duplication if specified in custom_options
...@@ -1922,7 +1923,7 @@ function services_dnsmasq_configure() ...@@ -1922,7 +1923,7 @@ function services_dnsmasq_configure()
function services_unbound_configure() function services_unbound_configure()
{ {
global $config, $g; global $config;
$return = 0; $return = 0;
// kill any running Unbound instance // kill any running Unbound instance
...@@ -2151,7 +2152,7 @@ EOD; ...@@ -2151,7 +2152,7 @@ EOD;
function services_dnsupdate_process($int = '', $updatehost = '', $forced = false) function services_dnsupdate_process($int = '', $updatehost = '', $forced = false)
{ {
global $config, $g; global $config;
/* Dynamic DNS updating active? */ /* Dynamic DNS updating active? */
if (isset($config['dnsupdates']['dnsupdate']) && is_array($config['dnsupdates']['dnsupdate'])) { if (isset($config['dnsupdates']['dnsupdate']) && is_array($config['dnsupdates']['dnsupdate'])) {
...@@ -2333,8 +2334,10 @@ function configure_cron() ...@@ -2333,8 +2334,10 @@ function configure_cron()
killbypid('/var/run/cron.pid', 'HUP'); killbypid('/var/run/cron.pid', 'HUP');
} }
function upnp_action ($action) { function upnp_action($action)
global $g, $config; {
global $config;
switch($action) { switch($action) {
case "start": case "start":
if (file_exists('/var/etc/miniupnpd.conf')) { if (file_exists('/var/etc/miniupnpd.conf')) {
...@@ -2369,7 +2372,7 @@ function upnp_start() ...@@ -2369,7 +2372,7 @@ function upnp_start()
function install_cron_job($command, $active=false, $minute="0", $hour="*", $monthday="*", $month="*", $weekday="*", $who="root") { function install_cron_job($command, $active=false, $minute="0", $hour="*", $monthday="*", $month="*", $weekday="*", $who="root") {
global $config, $g; global $config;
$is_installed = false; $is_installed = false;
...@@ -2612,8 +2615,8 @@ function get_service_status($service) ...@@ -2612,8 +2615,8 @@ function get_service_status($service)
} }
function get_service_status_icon($service, $withtext = true, $smallicon = false) { function get_service_status_icon($service, $withtext = true, $smallicon = false)
global $g; {
$output = ""; $output = "";
if(get_service_status($service)) { if(get_service_status($service)) {
$statustext = gettext("Running"); $statustext = gettext("Running");
...@@ -2625,9 +2628,8 @@ function get_service_status_icon($service, $withtext = true, $smallicon = false) ...@@ -2625,9 +2628,8 @@ function get_service_status_icon($service, $withtext = true, $smallicon = false)
return $output; return $output;
} }
function get_service_control_links($service, $addname = false)
function get_service_control_links($service, $addname = false) { {
global $g;
$output = ""; $output = "";
$stitle = ($addname) ? $service['name'] . " " : ""; $stitle = ($addname) ? $service['name'] . " " : "";
if(get_service_status($service)) { if(get_service_status($service)) {
......
...@@ -592,7 +592,7 @@ function upgrade_029_to_030() { ...@@ -592,7 +592,7 @@ function upgrade_029_to_030() {
} }
function upgrade_039_to_040() { function upgrade_039_to_040() {
global $config, $g; global $config;
$config['system']['webgui']['auth_method'] = "session"; $config['system']['webgui']['auth_method'] = "session";
$config['system']['webgui']['backing_method'] = "htpasswd"; $config['system']['webgui']['backing_method'] = "htpasswd";
...@@ -625,9 +625,6 @@ function upgrade_039_to_040() { ...@@ -625,9 +625,6 @@ function upgrade_039_to_040() {
$config['system']['user'][0]['priv'][2]['id'] = "hasshell"; $config['system']['user'][0]['priv'][2]['id'] = "hasshell";
$config['system']['user'][0]['priv'][2]['name'] = "Has shell access"; $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'][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]['id'] = "isroot";
$config['system']['user'][0]['priv'][4]['name'] = "Is root user"; $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)."); $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() { ...@@ -2004,9 +2001,9 @@ function upgrade_053_to_054() {
} }
function upgrade_054_to_055() { function upgrade_054_to_055()
{
global $config; global $config;
global $g;
/* RRD files changed for quality, traffic and packets graphs */ /* RRD files changed for quality, traffic and packets graphs */
//ini_set("max_execution_time", "1800"); //ini_set("max_execution_time", "1800");
...@@ -2642,10 +2639,9 @@ function upgrade_079_to_080() { ...@@ -2642,10 +2639,9 @@ function upgrade_079_to_080() {
} }
} }
function upgrade_080_to_081() { function upgrade_080_to_081()
{
global $config; global $config;
global $g;
/* Welcome to the 2.1 migration path */
/* tag all the existing gateways as being IPv4 */ /* tag all the existing gateways as being IPv4 */
$i = 0; $i = 0;
...@@ -2893,8 +2889,9 @@ function upgrade_084_to_085() { ...@@ -2893,8 +2889,9 @@ function upgrade_084_to_085() {
unset($gateways, $oldnames, $gateway_group_arr); unset($gateways, $oldnames, $gateway_group_arr);
} }
function upgrade_085_to_086() { function upgrade_085_to_086()
global $config, $g; {
global $config;
/* XXX: Gross hacks in sight */ /* XXX: Gross hacks in sight */
if (is_array($config['virtualip']['vip'])) { if (is_array($config['virtualip']['vip'])) {
...@@ -3036,15 +3033,18 @@ function upgrade_091_to_092() { ...@@ -3036,15 +3033,18 @@ function upgrade_091_to_092() {
} }
} }
function upgrade_092_to_093() { function upgrade_092_to_093()
global $g; {
$suffixes = array("concurrent", "loggedin"); $suffixes = array("concurrent", "loggedin");
foreach ($suffixes as $suffix) foreach ($suffixes as $suffix) {
if (file_exists("/var/db/rrd/captiveportal-{$suffix}.rrd")) if (file_exists("/var/db/rrd/captiveportal-{$suffix}.rrd")) {
rename("/var/db/rrd/captiveportal-{$suffix}.rrd", rename(
"/var/db/rrd/captiveportal-cpZone-{$suffix}.rrd"); "/var/db/rrd/captiveportal-{$suffix}.rrd",
"/var/db/rrd/captiveportal-cpZone-{$suffix}.rrd"
);
}
}
enable_rrd_graphing(); enable_rrd_graphing();
} }
...@@ -3071,8 +3071,9 @@ function upgrade_094_to_095() { ...@@ -3071,8 +3071,9 @@ function upgrade_094_to_095() {
$config['interfaces'][$iface]['track6-prefix-id'] = 0; $config['interfaces'][$iface]['track6-prefix-id'] = 0;
} }
function upgrade_095_to_096() { function upgrade_095_to_096()
global $config, $g; {
global $config;
$names = array("inpass", "outpass", "inblock", "outblock", $names = array("inpass", "outpass", "inblock", "outblock",
"inpass6", "outpass6", "inblock6", "outblock6"); "inpass6", "outpass6", "inblock6", "outblock6");
...@@ -3101,8 +3102,10 @@ function upgrade_095_to_096() { ...@@ -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"); exec("cd /; LANG=C NO_REMOUNT=1 RRDDBPATH='{$rrddbpath}' CF_CONF_PATH='/conf' /usr/local/etc/rc.backup_rrd");
} }
function upgrade_096_to_097() { function upgrade_096_to_097()
global $config, $g; {
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 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'])) { if (isset($config['syslog']['nologdefaultblock'])) {
$config['syslog']['nologbogons'] = true; $config['syslog']['nologbogons'] = true;
...@@ -3110,8 +3113,10 @@ function upgrade_096_to_097() { ...@@ -3110,8 +3113,10 @@ function upgrade_096_to_097() {
} }
} }
function upgrade_097_to_098() { function upgrade_097_to_098()
global $config, $g; {
global $config;
/* Disable kill_states by default */ /* Disable kill_states by default */
$config['system']['kill_states'] = true; $config['system']['kill_states'] = true;
} }
...@@ -3130,12 +3135,14 @@ function upgrade_098_to_099() { ...@@ -3130,12 +3135,14 @@ function upgrade_098_to_099() {
} }
} }
function upgrade_099_to_100() { function upgrade_099_to_100()
{
install_cron_job("newsyslog", false); install_cron_job("newsyslog", false);
} }
function upgrade_100_to_101() { function upgrade_100_to_101()
global $config, $g; {
global $config;
if (!is_array($config['voucher'])) if (!is_array($config['voucher']))
return; return;
...@@ -3150,8 +3157,9 @@ function upgrade_100_to_101() { ...@@ -3150,8 +3157,9 @@ function upgrade_100_to_101() {
} }
} }
function upgrade_101_to_102() { function upgrade_101_to_102()
global $config, $g; {
global $config;
if (is_array($config['captiveportal'])) { if (is_array($config['captiveportal'])) {
foreach ($config['captiveportal'] as $cpzone => $cp) { foreach ($config['captiveportal'] as $cpzone => $cp) {
......
...@@ -931,8 +931,9 @@ EOD; ...@@ -931,8 +931,9 @@ EOD;
* For all other occasions the normal vpn_ipsec_configure() * For all other occasions the normal vpn_ipsec_configure()
* will gracefully reload the settings without restarting * will gracefully reload the settings without restarting
*/ */
function vpn_ipsec_force_reload($interface = "") { function vpn_ipsec_force_reload($interface = '')
global $g, $config; {
global $config;
$ipseccfg = $config['ipsec']; $ipseccfg = $config['ipsec'];
...@@ -960,8 +961,6 @@ function vpn_ipsec_force_reload($interface = "") { ...@@ -960,8 +961,6 @@ function vpn_ipsec_force_reload($interface = "") {
/* master setup for vpn (mpd) */ /* master setup for vpn (mpd) */
function vpn_setup() function vpn_setup()
{ {
global $g;
/* start pptpd */ /* start pptpd */
vpn_pptpd_configure(); vpn_pptpd_configure();
...@@ -985,7 +984,7 @@ function vpn_netgraph_support() { ...@@ -985,7 +984,7 @@ function vpn_netgraph_support() {
} }
function vpn_pptpd_configure() { function vpn_pptpd_configure() {
global $config, $g; global $config;
$syscfg = $config['system']; $syscfg = $config['system'];
$pptpdcfg = $config['pptpd']; $pptpdcfg = $config['pptpd'];
...@@ -1216,7 +1215,7 @@ function vpn_pppoes_configure() { ...@@ -1216,7 +1215,7 @@ function vpn_pppoes_configure() {
} }
function vpn_pppoe_configure(&$pppoecfg) { function vpn_pppoe_configure(&$pppoecfg) {
global $config, $g; global $config;
$syscfg = $config['system']; $syscfg = $config['system'];
...@@ -1426,7 +1425,7 @@ EOD; ...@@ -1426,7 +1425,7 @@ EOD;
function vpn_l2tp_configure() function vpn_l2tp_configure()
{ {
global $config, $g; global $config;
$syscfg = $config['system']; $syscfg = $config['system'];
if (isset($config['l2tp'])) { if (isset($config['l2tp'])) {
......
...@@ -126,8 +126,9 @@ class SendMonitor extends Monitor { ...@@ -126,8 +126,9 @@ class SendMonitor extends Monitor {
} }
function relayd_configure($kill_first=false) { function relayd_configure($kill_first = false)
global $config, $g; {
global $config;
if (isset($config['load_balancer']['virtual_server'])) { if (isset($config['load_balancer']['virtual_server'])) {
$vs_a = $config['load_balancer']['virtual_server']; $vs_a = $config['load_balancer']['virtual_server'];
......
...@@ -174,8 +174,9 @@ function copy_conf_section(&$cnf_structure_in, &$cnf_structure_out, $reference) ...@@ -174,8 +174,9 @@ function copy_conf_section(&$cnf_structure_in, &$cnf_structure_out, $reference)
* @param string $method xmlrpc method to call * @param string $method xmlrpc method to call
* @return boolean * @return boolean
*/ */
function carp_sync_xml($url, $username, $password, $sections, $method = 'opnsense.restore_config_section') { function carp_sync_xml($url, $username, $password, $sections, $method = 'opnsense.restore_config_section')
global $config, $g; {
global $config;
update_filter_reload_status("Syncing CARP data to {$url}"); update_filter_reload_status("Syncing CARP data to {$url}");
......
...@@ -193,7 +193,8 @@ $ifaceassigned = ""; ...@@ -193,7 +193,8 @@ $ifaceassigned = "";
function next_unused_gateway_name($interface) function next_unused_gateway_name($interface)
{ {
global $g, $config; global $config;
$new_name = "GW_" . strtoupper($interface); $new_name = "GW_" . strtoupper($interface);
if (!isset($config['gateways']['gateway_item'])) { if (!isset($config['gateways']['gateway_item'])) {
...@@ -218,7 +219,7 @@ function next_unused_gateway_name($interface) ...@@ -218,7 +219,7 @@ function next_unused_gateway_name($interface)
function add_gateway_to_config($interface, $gatewayip, $inet_type) function add_gateway_to_config($interface, $gatewayip, $inet_type)
{ {
global $g, $config, $dry_run; global $config, $dry_run;
if (!isset($config['gateways']['gateway_item'])) { if (!isset($config['gateways']['gateway_item'])) {
$config['gateways']['gateway_item'] = array(); $config['gateways']['gateway_item'] = array();
...@@ -393,7 +394,7 @@ $config['interfaces'][$interface]['enable'] = true; ...@@ -393,7 +394,7 @@ $config['interfaces'][$interface]['enable'] = true;
function console_configure_dhcpd($version = 4) 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"; $label_IPvX = ($version === 6) ? "IPv6" : "IPv4";
$dhcpd = ($version === 6) ? "dhcpdv6" : "dhcpd"; $dhcpd = ($version === 6) ? "dhcpdv6" : "dhcpd";
......
...@@ -35,33 +35,35 @@ require_once("interfaces.inc"); ...@@ -35,33 +35,35 @@ require_once("interfaces.inc");
require_once("filter.inc"); require_once("filter.inc");
require_once("openvpn.inc"); require_once("openvpn.inc");
function gateway_is_gwgroup_member($name) { function gateway_is_gwgroup_member($name)
{
global $config; global $config;
if (is_array($config['gateways']['gateway_group'])) if (!isset($config['gateways']['gateway_group'])) {
$groups = $config['gateways']['gateway_group'];
else
return false; return false;
}
$groups = $config['gateways']['gateway_group'];
$members = array(); $members = array();
foreach($groups as $group) { foreach($groups as $group) {
if (is_array($group['item'])) { if (isset($group['item'])) {
foreach($group['item'] as $item) { foreach($group['item'] as $item) {
$elements = explode("|", $item); $elements = explode("|", $item);
$gwname = $elements[0]; $gwname = $elements[0];
if ($name == $elements[0]) if ($name == $elements[0]) {
$members[] = $group['name']; $members[] = $group['name'];
} }
} }
} }
}
return $members; return $members;
} }
function openvpn_resync_if_needed($mode, $ovpn_settings, $interface)
{
function openvpn_resync_if_needed ($mode, $ovpn_settings, $interface) { global $config;
global $g, $config;
$resync_needed = true; $resync_needed = true;
if (isset($ovpn_settings['disable'])) { if (isset($ovpn_settings['disable'])) {
......
...@@ -60,8 +60,10 @@ function choose_backup() { ...@@ -60,8 +60,10 @@ function choose_backup() {
} }
} }
function restore_history_backup($number) { function restore_history_backup($number)
global $g, $fp, $confvers; {
global $fp, $confvers;
if (is_numeric($number) && ($number > 0) && ($number <= count($confvers))) { if (is_numeric($number) && ($number > 0) && ($number <= count($confvers))) {
echo "\n" . gettext("Is this the backup you wish to restore?") . "\n"; echo "\n" . gettext("Is this the backup you wish to restore?") . "\n";
list_backups($number); list_backups($number);
......
...@@ -62,16 +62,18 @@ function is_schedule_inuse($schedule) ...@@ -62,16 +62,18 @@ function is_schedule_inuse($schedule)
return false; return false;
} }
function schedulecmp($a, $b)
function schedulecmp($a, $b) { {
return strcmp($a['name'], $b['name']); return strcmp($a['name'], $b['name']);
} }
function schedule_sort(){ function schedule_sort()
global $g, $config; {
global $config;
if (!is_array($config['schedules']['schedule'])) if (!isset($config['schedules']['schedule'])) {
return; return;
}
usort($config['schedules']['schedule'], "schedulecmp"); usort($config['schedules']['schedule'], "schedulecmp");
} }
......
...@@ -35,8 +35,9 @@ function staticmapcmp($a, $b) { ...@@ -35,8 +35,9 @@ function staticmapcmp($a, $b) {
return ipcmp($a['ipaddr'], $b['ipaddr']); return ipcmp($a['ipaddr'], $b['ipaddr']);
} }
function staticmaps_sort($ifgui) { function staticmaps_sort($ifgui)
global $g, $config; {
global $config;
usort($config['dhcpd'][$ifgui]['staticmap'], "staticmapcmp"); usort($config['dhcpd'][$ifgui]['staticmap'], "staticmapcmp");
} }
......
...@@ -30,17 +30,18 @@ ...@@ -30,17 +30,18 @@
require_once("guiconfig.inc"); require_once("guiconfig.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
function staticmapcmp($a, $b) { function staticmapcmp($a, $b)
{
return ipcmp($a['ipaddrv6'], $b['ipaddrv6']); return ipcmp($a['ipaddrv6'], $b['ipaddrv6']);
} }
function staticmaps_sort($ifgui) { function staticmaps_sort($ifgui)
global $g, $config; {
global $config;
usort($config['dhcpdv6'][$ifgui]['staticmap'], "staticmapcmp"); usort($config['dhcpdv6'][$ifgui]['staticmap'], "staticmapcmp");
} }
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/services_dhcpv6.php'); $referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/services_dhcpv6.php');
$if = $_GET['if']; $if = $_GET['if'];
......
...@@ -31,15 +31,18 @@ require_once("guiconfig.inc"); ...@@ -31,15 +31,18 @@ require_once("guiconfig.inc");
require_once("services.inc"); require_once("services.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
function hostcmp($a, $b) { function hostcmp($a, $b)
{
return strcasecmp($a['host'], $b['host']); return strcasecmp($a['host'], $b['host']);
} }
function hosts_sort() { function hosts_sort()
global $g, $config; {
global $config;
if (!is_array($config['dnsmasq']['hosts'])) if (!isset($config['dnsmasq']['hosts'])) {
return; return;
}
usort($config['dnsmasq']['hosts'], "hostcmp"); usort($config['dnsmasq']['hosts'], "hostcmp");
} }
......
...@@ -35,15 +35,18 @@ require_once("interfaces.inc"); ...@@ -35,15 +35,18 @@ require_once("interfaces.inc");
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/services_unbound_overrides.php'); $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']); return strcasecmp($a['host'], $b['host']);
} }
function hosts_sort() { function hosts_sort()
global $g, $config; {
global $config;
if (!is_array($config['unbound']['hosts'])) if (!isset($config['unbound']['hosts'])) {
return; return;
}
usort($config['unbound']['hosts'], "hostcmp"); usort($config['unbound']['hosts'], "hostcmp");
} }
......
...@@ -27,8 +27,7 @@ ...@@ -27,8 +27,7 @@
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
*/ */
/* include all configuration functions */ require_once('guiconfig.inc');
require_once("guiconfig.inc");
function doCmdT($title, $command) { function doCmdT($title, $command) {
$rubbish = array('|', '-', '/', '.', ' '); /* fixes the <a> tag to be W3C compliant */ $rubbish = array('|', '-', '/', '.', ' '); /* fixes the <a> tag to be W3C compliant */
...@@ -105,8 +104,6 @@ function execCmds() { ...@@ -105,8 +104,6 @@ function execCmds() {
} }
} }
global $g, $config;
/* Set up all of the commands we want to execute. */ /* Set up all of the commands we want to execute. */
defCmdT("System uptime","uptime"); defCmdT("System uptime","uptime");
defCmdT("Interfaces","/sbin/ifconfig -a"); defCmdT("Interfaces","/sbin/ifconfig -a");
......
...@@ -34,9 +34,8 @@ require_once("openvpn.inc"); ...@@ -34,9 +34,8 @@ require_once("openvpn.inc");
require_once("services.inc"); require_once("services.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
function kill_client($port, $remipp) { function kill_client($port, $remipp)
global $g; {
$tcpsrv = "unix:///var/etc/openvpn/{$port}.sock"; $tcpsrv = "unix:///var/etc/openvpn/{$port}.sock";
$errval; $errval;
$errstr; $errstr;
......
...@@ -27,11 +27,12 @@ ...@@ -27,11 +27,12 @@
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
*/ */
require_once("guiconfig.inc"); require_once('guiconfig.inc');
require_once('openvpn.inc'); require_once('openvpn.inc');
function openvpn_refresh_crls() { function openvpn_refresh_crls()
global $g, $config; {
global $config;
openvpn_create_dirs(); openvpn_create_dirs();
......
...@@ -49,8 +49,6 @@ if ($_GET['action']) { ...@@ -49,8 +49,6 @@ if ($_GET['action']) {
function kill_client($port, $remipp) function kill_client($port, $remipp)
{ {
global $g;
//$tcpsrv = "tcp://127.0.0.1:{$port}"; //$tcpsrv = "tcp://127.0.0.1:{$port}";
$tcpsrv = "unix:///var/etc/openvpn/{$port}.sock"; $tcpsrv = "unix:///var/etc/openvpn/{$port}.sock";
$errval; $errval;
......
...@@ -962,8 +962,9 @@ if($pkg['step'][$stepid]['javascriptafterformdisplay'] <> "") { ...@@ -962,8 +962,9 @@ if($pkg['step'][$stepid]['javascriptafterformdisplay'] <> "") {
* HELPER FUNCTIONS * HELPER FUNCTIONS
*/ */
function fixup_string($string) { function fixup_string($string)
global $config, $g, $myurl, $title; {
global $config, $myurl, $title;
$newstring = $string; $newstring = $string;
// fixup #1: $myurl -> http[s]://ip_address:port/ // fixup #1: $myurl -> http[s]://ip_address:port/
switch($config['system']['webgui']['protocol']) { switch($config['system']['webgui']['protocol']) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment