Commit cd08f1e0 authored by Franco Fichtner's avatar Franco Fichtner

src: whitespaces; style; isset() foo

parent 687097ab
...@@ -1463,8 +1463,7 @@ $priv_list['user-pppoe-dialin'] = array(); ...@@ -1463,8 +1463,7 @@ $priv_list['user-pppoe-dialin'] = array();
$priv_list['user-pppoe-dialin']['name'] = "User - VPN - PPPOE Dialin"; $priv_list['user-pppoe-dialin']['name'] = "User - VPN - PPPOE Dialin";
$priv_list['user-pppoe-dialin']['descr'] = "Indicates whether the user is allowed to dial in via PPPOE"; $priv_list['user-pppoe-dialin']['descr'] = "Indicates whether the user is allowed to dial in via PPPOE";
// sort by name ( case insensitive ) // sort by name ( case insensitive )
uasort($priv_list,function($a,$b) { uasort($priv_list,function($a,$b) {
return strcasecmp($a["name"], $b["name"]) ; return strcasecmp($a["name"], $b["name"]) ;
}); });
...@@ -432,20 +432,21 @@ function is_hostnamewithport($hostport) { ...@@ -432,20 +432,21 @@ function is_hostnamewithport($hostport) {
} }
/* returns true if $ipaddr is a valid dotted IPv4 address or an alias thereof */ /* returns true if $ipaddr is a valid dotted IPv4 address or an alias thereof */
function is_ipaddroralias($ipaddr) { function is_ipaddroralias($ipaddr)
{
global $config; global $config;
if (is_alias($ipaddr)) { if (is_alias($ipaddr)) {
if (is_array($config['aliases']['alias'])) { if (isset($config['aliases']['alias'])) {
foreach ($config['aliases']['alias'] as $alias) { foreach ($config['aliases']['alias'] as $alias) {
if ($alias['name'] == $ipaddr && !preg_match("/port/i", $alias['type'])) if ($alias['name'] == $ipaddr && !preg_match("/port/i", $alias['type']))
return true; return true;
} }
} }
return false; return false;
} else }
return is_ipaddr($ipaddr);
return is_ipaddr($ipaddr);
} }
/* returns true if $subnet is a valid IPv4 or IPv6 subnet in CIDR format /* returns true if $subnet is a valid IPv4 or IPv6 subnet in CIDR format
...@@ -537,19 +538,21 @@ function is_portrange($portrange) { ...@@ -537,19 +538,21 @@ function is_portrange($portrange) {
} }
/* returns true if $port is a valid port number or an alias thereof */ /* returns true if $port is a valid port number or an alias thereof */
function is_portoralias($port) { function is_portoralias($port)
{
global $config; global $config;
if (is_alias($port)) { if (is_alias($port)) {
if (is_array($config['aliases']['alias'])) { if (isset($config['aliases']['alias'])) {
foreach ($config['aliases']['alias'] as $alias) { foreach ($config['aliases']['alias'] as $alias) {
if ($alias['name'] == $port && preg_match("/port/i", $alias['type'])) if ($alias['name'] == $port && preg_match("/port/i", $alias['type']))
return true; return true;
} }
} }
return false; return false;
} else }
return is_port($port);
return is_port($port);
} }
/* create ranges of sequential port numbers (200:215) and remove duplicates */ /* create ranges of sequential port numbers (200:215) and remove duplicates */
...@@ -627,12 +630,13 @@ function is_inrange($test, $start, $end) { ...@@ -627,12 +630,13 @@ function is_inrange($test, $start, $end) {
} }
/* XXX: return the configured carp interface list */ /* XXX: return the configured carp interface list */
function get_configured_carp_interface_list($carpinterface = "", $family = "inet") { function get_configured_carp_interface_list($carpinterface = '', $family = 'inet')
{
global $config; global $config;
$iflist = array(); $iflist = array();
if(isset($config['virtualip']['vip']) && is_array($config['virtualip']['vip'])) { if (isset($config['virtualip']['vip'])) {
$viparr = &$config['virtualip']['vip']; $viparr = &$config['virtualip']['vip'];
foreach ($viparr as $vip) { foreach ($viparr as $vip) {
switch ($vip['mode']) { switch ($vip['mode']) {
...@@ -656,12 +660,13 @@ function get_configured_carp_interface_list($carpinterface = "", $family = "inet ...@@ -656,12 +660,13 @@ function get_configured_carp_interface_list($carpinterface = "", $family = "inet
} }
/* return the configured IP aliases list */ /* return the configured IP aliases list */
function get_configured_ip_aliases_list($returnfullentry = false) { function get_configured_ip_aliases_list($returnfullentry = false)
{
global $config; global $config;
$alias_list=array(); $alias_list = array();
if(isset($config['virtualip']['vip']) && is_array($config['virtualip']['vip'])) { if (isset($config['virtualip']['vip'])) {
$viparr = &$config['virtualip']['vip']; $viparr = &$config['virtualip']['vip'];
foreach ($viparr as $vip) { foreach ($viparr as $vip) {
if ($vip['mode']=="ipalias") { if ($vip['mode']=="ipalias") {
...@@ -677,12 +682,13 @@ function get_configured_ip_aliases_list($returnfullentry = false) { ...@@ -677,12 +682,13 @@ function get_configured_ip_aliases_list($returnfullentry = false) {
} }
/* return all configured aliases list (IP, carp, proxyarp and other) */ /* return all configured aliases list (IP, carp, proxyarp and other) */
function get_configured_vips_list() { function get_configured_vips_list()
{
global $config; global $config;
$alias_list=array(); $alias_list=array();
if(is_array($config['virtualip']['vip'])) { if (isset($config['virtualip']['vip'])) {
$viparr = &$config['virtualip']['vip']; $viparr = &$config['virtualip']['vip'];
foreach ($viparr as $vip) { foreach ($viparr as $vip) {
if ($vip['mode'] == "carp") if ($vip['mode'] == "carp")
...@@ -788,12 +794,14 @@ function get_configured_ip_addresses() { ...@@ -788,12 +794,14 @@ function get_configured_ip_addresses() {
} }
} }
$interfaces = get_configured_carp_interface_list(); $interfaces = get_configured_carp_interface_list();
if (is_array($interfaces)) if (is_array($interfaces)) {
foreach($interfaces as $int => $ipaddr) foreach($interfaces as $int => $ipaddr) {
$ip_array[$int] = $ipaddr; $ip_array[$int] = $ipaddr;
}
}
/* pppoe server */ /* pppoe server */
if (is_array($config['pppoes']) && is_array($config['pppoes']['pppoe'])) { if (isset($config['pppoes']['pppoe'])) {
foreach($config['pppoes']['pppoe'] as $pppoe) { foreach($config['pppoes']['pppoe'] as $pppoe) {
if ($pppoe['mode'] == "server") { if ($pppoe['mode'] == "server") {
if(is_ipaddr($pppoe['localip'])) { if(is_ipaddr($pppoe['localip'])) {
...@@ -812,7 +820,8 @@ function get_configured_ip_addresses() { ...@@ -812,7 +820,8 @@ function get_configured_ip_addresses() {
* interfaces IPv6 Addresses * interfaces IPv6 Addresses
* *
*/ */
function get_configured_ipv6_addresses() { function get_configured_ipv6_addresses()
{
require_once("interfaces.inc"); require_once("interfaces.inc");
$ipv6_array = array(); $ipv6_array = array();
$interfaces = get_configured_interface_list(); $interfaces = get_configured_interface_list();
...@@ -1407,7 +1416,7 @@ function is_interface_vlan_mismatch() ...@@ -1407,7 +1416,7 @@ function is_interface_vlan_mismatch()
{ {
global $config; global $config;
if (is_array($config['vlans']['vlan'])) { if (isset($config['vlans']['vlan'])) {
foreach ($config['vlans']['vlan'] as $vlan) { foreach ($config['vlans']['vlan'] as $vlan) {
if (does_interface_exist($vlan['if']) == false) if (does_interface_exist($vlan['if']) == false)
return true; return true;
...@@ -1545,15 +1554,19 @@ function is_URL($url) { ...@@ -1545,15 +1554,19 @@ function is_URL($url) {
/* /*
* Replace a value on a deep associative array using regex * Replace a value on a deep associative array using regex
*/ */
function array_replace_values_recursive($data, $match, $replace) { function array_replace_values_recursive($data, $match, $replace)
if (empty($data)) {
if (empty($data)) {
return $data; return $data;
}
if (is_string($data)) if (is_string($data)) {
$data = preg_replace("/{$match}/", $replace, $data); $data = preg_replace("/{$match}/", $replace, $data);
else if (is_array($data)) } elseif (is_array($data)) {
foreach ($data as $k => $v) foreach ($data as $k => $v) {
$data[$k] = array_replace_values_recursive($v, $match, $replace); $data[$k] = array_replace_values_recursive($v, $match, $replace);
}
}
return $data; return $data;
} }
...@@ -1678,30 +1691,34 @@ function get_staticroutes($returnsubnetsonly = false, $returnhostnames = false) ...@@ -1678,30 +1691,34 @@ function get_staticroutes($returnsubnetsonly = false, $returnhostnames = false)
* If $type is a string, all aliases of the type specified in $type are returned. * If $type is a string, all aliases of the type specified in $type are returned.
* If $type is an array, all aliases of any type specified in any element of $type are returned. * If $type is an array, all aliases of any type specified in any element of $type are returned.
*/ */
function get_alias_list($type = null) { function get_alias_list($type = null)
{
global $config; global $config;
$result = array(); $result = array();
if ($config['aliases']['alias'] <> "" && is_array($config['aliases']['alias'])) {
if (isset($config['aliases']['alias'])) {
foreach ($config['aliases']['alias'] as $alias) { foreach ($config['aliases']['alias'] as $alias) {
if ($type === null) { if ($type === null) {
$result[] = $alias['name']; $result[] = $alias['name'];
} } elseif (is_array($type)) {
else if (is_array($type)) {
if (in_array($alias['type'], $type)) { if (in_array($alias['type'], $type)) {
$result[] = $alias['name']; $result[] = $alias['name'];
} }
} } elseif ($type === $alias['type']) {
else if ($type === $alias['type']) {
$result[] = $alias['name']; $result[] = $alias['name'];
} }
} }
} }
return $result; return $result;
} }
/* returns an array consisting of every element of $haystack that is not equal to $needle. */ /* returns an array consisting of every element of $haystack that is not equal to $needle. */
function array_exclude($needle, $haystack) { function array_exclude($needle, $haystack)
{
$result = array(); $result = array();
if (is_array($haystack)) { if (is_array($haystack)) {
foreach ($haystack as $thing) { foreach ($haystack as $thing) {
if ($needle !== $thing) { if ($needle !== $thing) {
...@@ -1709,6 +1726,7 @@ function array_exclude($needle, $haystack) { ...@@ -1709,6 +1726,7 @@ function array_exclude($needle, $haystack) {
} }
} }
} }
return $result; return $result;
} }
......
...@@ -119,7 +119,7 @@ $status = ipsec_smp_dump_status(); ...@@ -119,7 +119,7 @@ $status = ipsec_smp_dump_status();
?> ?>
<tr> <tr>
<td class="listr"><?php echo htmlspecialchars(ipsec_get_descr($con_id));?></td> <td class="listr"><?php echo htmlspecialchars(ipsec_get_descr($con_id));?></td>
<td class="listr"> <td class="listr">
<?php if (!is_array($ikesa['local'])) { <?php if (!is_array($ikesa['local'])) {
echo "Unknown"; echo "Unknown";
} else { } else {
......
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