Revision 8b348d2b
Added by Steve Beaver almost 5 years ago
src/etc/inc/gwlb.inc | ||
---|---|---|
2166 | 2166 |
// These two replacement functions avoid the need to call return_gateways_array() multiple times and |
2167 | 2167 |
// allow system_gateways.php to get everything it needs in a single function call |
2168 | 2168 |
function gateway_getgwtiername($gways, $idx) { |
2169 |
global $config; |
|
2170 |
|
|
2171 |
$gwname = $gways[$idx]['name']; |
|
2172 |
$gw = get_gateway_or_group_by_name($gwname, $gways); |
|
2173 |
if ($config['gateways']['defaultgw4'] == $gwname || $config['gateways']['defaultgw6'] == $gwname) { |
|
2174 |
$result = "Default"; |
|
2175 |
} else { |
|
2176 |
if ($gw['ipprotocol'] == 'inet') { |
|
2177 |
$defgw = get_gateway_or_group_by_name($config['gateways']['defaultgw4'], $gways); |
|
2178 |
} else { |
|
2179 |
$defgw = get_gateway_or_group_by_name($config['gateways']['defaultgw6'], $gways); |
|
2180 |
} |
|
2181 |
if ($defgw['type'] == "gatewaygroup") { |
|
2182 |
$detail = gateway_is_gwgroup_member($gwname, true); |
|
2183 |
foreach($detail as $gwitem) { |
|
2184 |
if ($gwitem['name'] == $defgw['name']) { |
|
2185 |
if (isset($gwitem['tier'])) { |
|
2186 |
$result = "Tier " . $gwitem['tier']; |
|
2187 |
break; |
|
2188 |
} |
|
2189 |
} |
|
2190 |
} |
|
2191 |
} |
|
2192 |
} |
|
2193 |
if (!empty($result)) { |
|
2194 |
if ($gw['ipprotocol'] == "inet") { |
|
2195 |
$result .= " (IPv4)"; |
|
2196 |
} elseif ($gw['ipprotocol'] == "inet6") { |
|
2197 |
$result .= " (IPv6)"; |
|
2198 |
} |
|
2199 |
} |
|
2200 |
return $result; |
|
2169 |
global $config; |
|
2170 |
|
|
2171 |
$result = ""; |
|
2172 |
$gwname = $gways[$idx]['name']; |
|
2173 |
|
|
2174 |
$gw = get_gateway_or_group_by_name($gwname, $gways); |
|
2175 |
if ($config['gateways']['defaultgw4'] == $gwname || $config['gateways']['defaultgw6'] == $gwname) { |
|
2176 |
$result = "Default"; |
|
2177 |
} else { |
|
2178 |
if ($gw['ipprotocol'] == 'inet') { |
|
2179 |
$defgw = get_gateway_or_group_by_name($config['gateways']['defaultgw4'], $gways); |
|
2180 |
} else { |
|
2181 |
$defgw = get_gateway_or_group_by_name($config['gateways']['defaultgw6'], $gways); |
|
2182 |
} |
|
2183 |
|
|
2184 |
if ($defgw['type'] == "gatewaygroup") { |
|
2185 |
$detail = gateway_is_gwgroup_member($gwname, true); |
|
2186 |
foreach($detail as $gwitem) { |
|
2187 |
if ($gwitem['name'] == $defgw['name']) { |
|
2188 |
if (isset($gwitem['tier'])) { |
|
2189 |
$result = "Tier " . $gwitem['tier']; |
|
2190 |
break; |
|
2191 |
} |
|
2192 |
} |
|
2193 |
} |
|
2194 |
} |
|
2195 |
} |
|
2196 |
|
|
2197 |
if (!empty($result)) { |
|
2198 |
if ($gw['ipprotocol'] == "inet") { |
|
2199 |
$result .= " (IPv4)"; |
|
2200 |
} elseif ($gw['ipprotocol'] == "inet6") { |
|
2201 |
$result .= " (IPv6)"; |
|
2202 |
} |
|
2203 |
} |
|
2204 |
|
|
2205 |
return $result; |
|
2201 | 2206 |
} |
2202 | 2207 |
|
2203 | 2208 |
function get_gateway_or_group_by_name($gwname, $gateways_arr) { |
2204 |
global $config;
|
|
2205 |
|
|
2206 |
foreach ($gateways_arr as $gw) {
|
|
2207 |
if ($gw['name'] == $gwname) {
|
|
2208 |
$gw['type'] = 'gateway';
|
|
2209 |
return $gw;
|
|
2210 |
}
|
|
2211 |
}
|
|
2212 |
|
|
2213 |
if (is_array($config['gateways']['gateway_group'])) {
|
|
2214 |
foreach ($config['gateways']['gateway_group'] as $gwg) {
|
|
2215 |
if ($gwg['name'] == $gwname) {
|
|
2216 |
$gwg['type'] = 'gatewaygroup';
|
|
2217 |
return $gwg;
|
|
2218 |
}
|
|
2219 |
}
|
|
2220 |
}
|
|
2221 |
|
|
2222 |
return false;
|
|
2209 |
global $config;
|
|
2210 |
|
|
2211 |
foreach ($gateways_arr as $gw) {
|
|
2212 |
if ($gw['name'] == $gwname) {
|
|
2213 |
$gw['type'] = 'gateway';
|
|
2214 |
return $gw;
|
|
2215 |
}
|
|
2216 |
}
|
|
2217 |
|
|
2218 |
if (is_array($config['gateways']['gateway_group'])) {
|
|
2219 |
foreach ($config['gateways']['gateway_group'] as $gwg) {
|
|
2220 |
if ($gwg['name'] == $gwname) {
|
|
2221 |
$gwg['type'] = 'gatewaygroup';
|
|
2222 |
return $gwg;
|
|
2223 |
}
|
|
2224 |
}
|
|
2225 |
}
|
|
2226 |
|
|
2227 |
return false;
|
|
2223 | 2228 |
} |
2224 | 2229 |
|
2225 | 2230 |
?> |
Also available in: Unified diff
Fix indenting