mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 08:09:41 +00:00
Change foreach loops that don't use values to use array_keys()
This commit is contained in:
parent
6c46b786b8
commit
d27cc83642
@ -278,7 +278,7 @@ function interfaces_create_wireless_clones($verbose = false)
|
||||
flush();
|
||||
}
|
||||
|
||||
foreach (get_configured_interface_with_descr() as $if => $unused) {
|
||||
foreach (array_keys(get_configured_interface_with_descr()) as $if) {
|
||||
$realif = $config['interfaces'][$if]['if'];
|
||||
if (is_interface_wireless($realif)) {
|
||||
interface_wireless_clone(interface_get_wireless_clone($realif), $config['interfaces'][$if]);
|
||||
@ -858,7 +858,7 @@ function interface_gif_configure(&$gif, $gifkey = "")
|
||||
|
||||
interfaces_bring_up($gifif);
|
||||
|
||||
foreach (get_configured_interface_with_descr() as $ifname => $unused) {
|
||||
foreach (array_keys(get_configured_interface_with_descr()) as $ifname) {
|
||||
if ($config['interfaces'][$ifname]['if'] == $gifif) {
|
||||
if (get_interface_gateway($ifname) || get_interface_gateway_v6($ifname)) {
|
||||
system_routing_configure(false, $ifname);
|
||||
@ -1104,11 +1104,11 @@ function interface_bring_down($interface = "wan", $ifacecfg = false)
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($arpflush as $dev => $unused) {
|
||||
foreach (array_keys($arpflush) as $dev) {
|
||||
mwexecf('/usr/sbin/arp -d -i %s -a', $dev);
|
||||
}
|
||||
|
||||
foreach ($pfctlflush as $dev => $unused) {
|
||||
foreach (array_keys($pfctlflush) as $dev) {
|
||||
log_error("Clearing states for stale {$interface} route on {$dev}");
|
||||
mwexecf('/sbin/pfctl -i %s -Fs', $dev);
|
||||
}
|
||||
@ -1787,7 +1787,7 @@ function interface_sync_wireless_clones(&$ifcfg, $sync_changes = false)
|
||||
|
||||
$baseif = interface_get_wireless_base($ifcfg['if']);
|
||||
|
||||
foreach (legacy_config_get_interfaces(array('virtual' => false)) as $if => $unused) {
|
||||
foreach (array_keys(legacy_config_get_interfaces(['virtual' => false])) as $if) {
|
||||
if ($baseif == interface_get_wireless_base($config['interfaces'][$if]['if']) && $ifcfg['if'] != $config['interfaces'][$if]['if']) {
|
||||
if (isset($config['interfaces'][$if]['wireless']['standard']) || $sync_changes) {
|
||||
foreach ($shared_settings as $setting) {
|
||||
@ -3759,7 +3759,7 @@ function get_interface_number_track6($wanif, $targetif)
|
||||
$list = link_interface_to_track6($wanif);
|
||||
$number = 0;
|
||||
|
||||
foreach ($list as $lanif => $unused) {
|
||||
foreach (array_keys($list) as $lanif) {
|
||||
if ($lanif == $targetif) {
|
||||
return $number;
|
||||
}
|
||||
|
||||
@ -810,7 +810,7 @@ function ipsec_configure_do($verbose = false, $interface = '')
|
||||
$srcip = null;
|
||||
$local_subnet = ipsec_idinfo_to_cidr($ph2ent['localid'], true, $ph2ent['mode']);
|
||||
if (is_ipaddrv6($ph2ent['pinghost'])) {
|
||||
foreach ($iflist as $ifent => $unused) {
|
||||
foreach (array_keys($iflist) as $ifent) {
|
||||
$interface_ip = get_interface_ipv6($ifent);
|
||||
if (!is_ipaddrv6($interface_ip)) {
|
||||
continue;
|
||||
@ -821,7 +821,7 @@ function ipsec_configure_do($verbose = false, $interface = '')
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ($iflist as $ifent => $unused) {
|
||||
foreach (array_keys($iflist) as $ifent) {
|
||||
$interface_ip = get_interface_ip($ifent);
|
||||
if (!is_ipaddrv4($interface_ip)) {
|
||||
continue;
|
||||
@ -888,7 +888,7 @@ function ipsec_configure_do($verbose = false, $interface = '')
|
||||
// Debugging configuration
|
||||
// lkey is the log key, which is a three-letter abbreviation of the subsystem to log, e.g. `ike`.
|
||||
// The value will be a number between -1 (silent) and 4 (highest verbosity).
|
||||
foreach (IPSEC_LOG_SUBSYSTEMS as $lkey => $unused) {
|
||||
foreach (array_keys(IPSEC_LOG_SUBSYSTEMS) as $lkey) {
|
||||
if (isset($config['ipsec']["ipsec_{$lkey}"]) && is_numeric($config['ipsec']["ipsec_{$lkey}"]) &&
|
||||
array_key_exists(intval($config['ipsec']["ipsec_{$lkey}"]), IPSEC_LOG_LEVELS)) {
|
||||
$strongswanTree['charon']['syslog']['daemon'][$lkey] = $config['ipsec']["ipsec_{$lkey}"];
|
||||
|
||||
@ -825,7 +825,7 @@ function openvpn_reconfigure($mode, $settings, $device_only = false)
|
||||
// The remote server
|
||||
$server_addr_a = explode(',', $settings['server_addr']);
|
||||
$server_port_a = explode(',', $settings['server_port']);
|
||||
foreach ($server_addr_a as $i => $unused) {
|
||||
foreach (array_keys($server_addr_a) as $i) {
|
||||
$conf .= "remote {$server_addr_a[$i]} {$server_port_a[$i]}\n";
|
||||
}
|
||||
|
||||
|
||||
@ -702,7 +702,7 @@ function unbound_acls_subnets()
|
||||
/* add our networks for active interfaces including localhost */
|
||||
$subnets = array('127.0.0.1/8', '::1/64');
|
||||
|
||||
foreach ($active_interfaces as $ubif => $unused) {
|
||||
foreach (array_keys($active_interfaces) as $ubif) {
|
||||
foreach (legacy_getall_interface_addresses(get_real_interface($ubif)) as $subnet) {
|
||||
$subnets[] = $subnet;
|
||||
}
|
||||
|
||||
@ -291,7 +291,7 @@ function services_radvd_configure($verbose = false, $blacklist = array())
|
||||
}
|
||||
|
||||
/* handle DHCP-PD prefixes and 6RD dynamic interfaces */
|
||||
foreach (get_configured_interface_with_descr() as $if => $unused) {
|
||||
foreach (array_keys(get_configured_interface_with_descr()) as $if) {
|
||||
if (!isset($config['interfaces'][$if]['track6-interface'])) {
|
||||
continue;
|
||||
} elseif (empty($config['interfaces'][$config['interfaces'][$if]['track6-interface']])) {
|
||||
@ -1122,7 +1122,7 @@ function services_dhcpdv6_configure($verbose = false, $blacklist = array())
|
||||
}
|
||||
|
||||
/* we add a fake entry for interfaces that are set to track6 another WAN */
|
||||
foreach ($iflist as $ifname => $unused) {
|
||||
foreach (array_keys($iflist) as $ifname) {
|
||||
/* Do not put in the config an interface which is down */
|
||||
if (isset($blacklist[$ifname])) {
|
||||
continue;
|
||||
@ -1506,7 +1506,7 @@ function services_dhcrelay_configure($verbose = false)
|
||||
unset($destif);
|
||||
|
||||
/* XXX runs multiple times because of server address loop :( */
|
||||
foreach ($iflist as $ifname => $unused) {
|
||||
foreach (array_keys($iflist) as $ifname) {
|
||||
$realif = get_real_interface($ifname);
|
||||
$subnet = find_interface_network($realif);
|
||||
if (!is_subnetv4($subnet)) {
|
||||
@ -1628,7 +1628,7 @@ function services_dhcrelay6_configure($verbose = false)
|
||||
unset($destif);
|
||||
|
||||
/* XXX runs multiple times because of server address loop :( */
|
||||
foreach ($iflist as $ifname => $unused) {
|
||||
foreach (array_keys($iflist) as $ifname) {
|
||||
$realif = get_real_interface($ifname, 'inet6');
|
||||
$subnet = find_interface_networkv6($realif);
|
||||
if (!is_subnetv6($subnet)) {
|
||||
|
||||
@ -338,7 +338,7 @@ function system_hosts_generate($verbose = false)
|
||||
$hosts .= "{$cfgip}\t{$syscfg['hostname']}.{$syscfg['domain']} {$syscfg['hostname']}\n";
|
||||
}
|
||||
} else {
|
||||
foreach (get_configured_interface_with_descr() as $sysif => $unused) {
|
||||
foreach (array_keys(get_configured_interface_with_descr()) as $sysif) {
|
||||
if (!interface_has_gateway($sysif)) {
|
||||
$cfgip = get_interface_ip($sysif);
|
||||
if (is_ipaddr($cfgip)) {
|
||||
|
||||
@ -163,7 +163,7 @@ if ($intnum > $count) {
|
||||
}
|
||||
|
||||
$index = 1;
|
||||
foreach ($ifdescrs as $ifname => $unused) {
|
||||
foreach (array_keys($ifdescrs) as $ifname) {
|
||||
if ($intnum == $index) {
|
||||
$interface = $ifname;
|
||||
break;
|
||||
|
||||
@ -760,7 +760,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
if (!is_numeric($pconfig['prefix-6rd-v4plen'])) {
|
||||
$input_errors[] = gettext('6RD IPv4 prefix length must be a number.');
|
||||
}
|
||||
foreach ($ifdescrs as $ifent => $unused) {
|
||||
foreach (array_keys($ifdescrs) as $ifent) {
|
||||
if ($if != $ifent && ($config['interfaces'][$ifent]['ipaddrv6'] == $pconfig['type6'])) {
|
||||
if ($config['interfaces'][$ifent]['prefix-6rd'] == $pconfig['prefix-6rd']) {
|
||||
$input_errors[] = gettext("You can only have one interface configured in 6rd with same prefix.");
|
||||
@ -770,7 +770,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
}
|
||||
break;
|
||||
case "6to4":
|
||||
foreach ($ifdescrs as $ifent => $unused) {
|
||||
foreach (array_keys($ifdescrs) as $ifent) {
|
||||
if ($if != $ifent && ($config['interfaces'][$ifent]['ipaddrv6'] == $pconfig['type6'])) {
|
||||
$input_errors[] = sprintf(gettext("You can only have one interface configured as 6to4."), $pconfig['type6']);
|
||||
break;
|
||||
|
||||
@ -33,7 +33,7 @@ function lagg_inuse($lagg_intf)
|
||||
{
|
||||
global $config;
|
||||
|
||||
foreach (legacy_config_get_interfaces(array('virtual' => false)) as $if => $unused) {
|
||||
foreach (array_keys(legacy_config_get_interfaces(['virtual' => false])) as $if) {
|
||||
if ($config['interfaces'][$if]['if'] == $lagg_intf) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ function available_interfaces($selected_id=null)
|
||||
global $config;
|
||||
// configured interfaces
|
||||
$configured_interfaces = array();
|
||||
foreach (legacy_config_get_interfaces(array('virtual' => false)) as $intf => $unused) {
|
||||
foreach (array_keys(legacy_config_get_interfaces(['virtual' => false])) as $intf) {
|
||||
$configured_interfaces[] = get_real_interface($intf);
|
||||
}
|
||||
// lagg members from other lagg interfaces
|
||||
|
||||
@ -33,7 +33,7 @@ function clone_inuse($cloneif)
|
||||
{
|
||||
global $config;
|
||||
|
||||
foreach (legacy_config_get_interfaces(array('virtual' => false)) as $if => $unused) {
|
||||
foreach (array_keys(legacy_config_get_interfaces(['virtual' => false])) as $if) {
|
||||
if ($config['interfaces'][$if]['if'] == $cloneif) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ function clone_inuse($cloneif)
|
||||
{
|
||||
global $config;
|
||||
|
||||
foreach (get_configured_interface_with_descr() as $if => $unused) {
|
||||
foreach (array_keys(get_configured_interface_with_descr()) as $if) {
|
||||
if ($config['interfaces'][$if]['if'] == $cloneif) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
} else {
|
||||
$pconfig['passthrough_networks'] = array();
|
||||
}
|
||||
foreach (IPSEC_LOG_SUBSYSTEMS as $lkey => $unused) {
|
||||
foreach (array_keys(IPSEC_LOG_SUBSYSTEMS) as $lkey) {
|
||||
if (!empty($config['ipsec']["ipsec_{$lkey}"])) {
|
||||
$pconfig["ipsec_{$lkey}"] = $config['ipsec']["ipsec_{$lkey}"];
|
||||
} else {
|
||||
@ -80,7 +80,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
unset($config['ipsec']['preferoldsa']);
|
||||
}
|
||||
if (isset($config['ipsec']) && is_array($config['ipsec'])) {
|
||||
foreach (IPSEC_LOG_SUBSYSTEMS as $lkey => $unused) {
|
||||
foreach (array_keys(IPSEC_LOG_SUBSYSTEMS) as $lkey) {
|
||||
if (empty($pconfig["ipsec_{$lkey}"])) {
|
||||
if (isset($config['ipsec']["ipsec_{$lkey}"])) {
|
||||
unset($config['ipsec']["ipsec_{$lkey}"]);
|
||||
|
||||
@ -213,7 +213,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
$server_addr_a = array();
|
||||
$server_port_a = array();
|
||||
|
||||
foreach ($pconfig['server_addr'] as $i => $unused) {
|
||||
foreach (array_keys($pconfig['server_addr']) as $i) {
|
||||
if (empty($pconfig['server_addr'][$i]) && empty($pconfig['server_port'][$i])) {
|
||||
continue;
|
||||
}
|
||||
@ -1190,7 +1190,7 @@ $( document ).ready(function() {
|
||||
$server_addr_a = explode(',', $client['server_addr']);
|
||||
$server_port_a = explode(',', $client['server_port']);
|
||||
$server = array();
|
||||
foreach ($server_addr_a as $j => $unused) {
|
||||
foreach (array_keys($server_addr_a) as $j) {
|
||||
$server[] = "{$server_addr_a[$j]}:{$server_port_a[$j]}";
|
||||
} ?>
|
||||
<tr>
|
||||
|
||||
@ -105,7 +105,7 @@ $gateways = return_gateways_array();
|
||||
<option value="yes" <?= !empty($pconfig['gatewaysinvert']) ? 'selected="selected"' : '' ?>><?= gettext('Show') ?></option>
|
||||
</select>
|
||||
<select id="gatewaysfilter" name="gatewaysfilter[]" multiple="multiple" class="selectpicker_widget">
|
||||
<?php foreach ($gateways as $gwname => $unused): ?>
|
||||
<?php foreach (array_keys($gateways) as $gwname): ?>
|
||||
<option value="<?= html_safe($gwname) ?>" <?= in_array($gwname, $pconfig['gatewaysfilter']) ? 'selected="selected"' : '' ?>><?= html_safe($gwname) ?></option>
|
||||
<?php endforeach;?>
|
||||
</select>
|
||||
@ -125,7 +125,7 @@ $gateways = return_gateways_array();
|
||||
<th><?=gettext('Loss')?></th>
|
||||
<th><?=gettext('Status')?></th>
|
||||
</tr>
|
||||
<?php foreach ($gateways as $gwname => $unused):
|
||||
<?php foreach (array_keys($gateways) as $gwname):
|
||||
$listed = in_array($gwname, $pconfig['gatewaysfilter']);
|
||||
$listed = !empty($pconfig['gatewaysinvert']) ? $listed : !$listed;
|
||||
if (!$listed) {
|
||||
|
||||
@ -45,7 +45,7 @@ function find_ip_interface($ip, $bits = null)
|
||||
|
||||
$isv6ip = is_ipaddrv6($ip);
|
||||
|
||||
foreach (get_configured_interface_with_descr() as $ifname => $unused) {
|
||||
foreach (array_keys(get_configured_interface_with_descr()) as $ifname) {
|
||||
$ifip = ($isv6ip) ? get_interface_ipv6($ifname) : get_interface_ip($ifname);
|
||||
if (is_null($ifip))
|
||||
continue;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user