summaryrefslogtreecommitdiffstats
path: root/etc/inc/util.inc
diff options
context:
space:
mode:
authorRenato Botelho <renato.botelho@bluepex.com>2010-09-16 12:27:37 -0300
committerRenato Botelho <renato.botelho@bluepex.com>2010-09-16 12:27:37 -0300
commitad9db2a956814c4e04188b177e37061e7b310472 (patch)
treeda8a82f3ffcd538dd8b0412997714e69f881ff83 /etc/inc/util.inc
parentf14bd707b017d5c6325048c1ff72f7554f8f60bc (diff)
parent97e6256f4d611b7edbfa12d3c03cf9b6cca9e3c1 (diff)
downloadpfsense-ad9db2a956814c4e04188b177e37061e7b310472.zip
pfsense-ad9db2a956814c4e04188b177e37061e7b310472.tar.gz
Merge remote branch 'mainline/master' into inc
Conflicts: etc/inc/filter.inc
Diffstat (limited to 'etc/inc/util.inc')
-rw-r--r--etc/inc/util.inc65
1 files changed, 16 insertions, 49 deletions
diff --git a/etc/inc/util.inc b/etc/inc/util.inc
index a8e9c01..a1a8762 100644
--- a/etc/inc/util.inc
+++ b/etc/inc/util.inc
@@ -439,7 +439,7 @@ function is_hostname($hostname) {
if (!is_string($hostname))
return false;
- if (preg_match("/^([_a-z0-9\-]+\.?)+$/i", $hostname))
+ if (preg_match('/^(?:(?:[a-z0-9_]|[a-z0-9_][a-z0-9_\-]*[a-z0-9_])\.)*(?:[a-z0-9_]|[a-z0-9_][a-z0-9_\-]*[a-z0-9_])$/i', $hostname))
return true;
else
return false;
@@ -450,7 +450,7 @@ function is_domain($domain) {
if (!is_string($domain))
return false;
- if (preg_match("/^([a-z0-9\-]+\.?)+$/i", $domain))
+ if (preg_match('/^(?:(?:[a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)*(?:[a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])$/i', $domain))
return true;
else
return false;
@@ -567,16 +567,9 @@ function get_configured_interface_list($only_opt = false, $withdisabled = false)
$iflist = array();
- if (!$only_opt) {
- if (isset($config['interfaces']['wan']))
- $iflist['wan'] = "wan";
- if (isset($config['interfaces']['lan']))
- $iflist['lan'] = "lan";
- }
-
/* if list */
- foreach($config['interfaces'] as $if => $ifdetail) {
- if ($if == "wan" || $if == "lan")
+ foreach($config['interfaces'] as $if => $ifdetail) {
+ if ($only_opt && ($if == "wan" || $if == "lan"))
continue;
if (isset($ifdetail['enable']) || $withdisabled == true)
$iflist[$if] = $if;
@@ -587,35 +580,22 @@ function get_configured_interface_list($only_opt = false, $withdisabled = false)
/* return the configured interfaces list. */
function get_configured_interface_list_by_realif($only_opt = false, $withdisabled = false) {
- global $config;
-
- $iflist = array();
+ global $config;
- if (!$only_opt) {
- if (isset($config['interfaces']['wan'])) {
- $tmpif = get_real_interface("wan");
- if (!empty($tmpif))
- $iflist[$tmpif] = "wan";
- }
- if (isset($config['interfaces']['lan'])) {
- $tmpif = get_real_interface("lan");
- if (!empty($tmpif))
- $iflist[$tmpif] = "lan";
- }
- }
+ $iflist = array();
- /* if list */
- foreach($config['interfaces'] as $if => $ifdetail) {
- if ($if == "wan" || $if == "lan")
- continue;
- if (isset($ifdetail['enable']) || $withdisabled == true) {
+ /* if list */
+ foreach($config['interfaces'] as $if => $ifdetail) {
+ if ($only_opt && ($if == "wan" || $if == "lan"))
+ continue;
+ if (isset($ifdetail['enable']) || $withdisabled == true) {
$tmpif = get_real_interface($if);
if (!empty($tmpif))
$iflist[$tmpif] = $if;
}
- }
+ }
- return $iflist;
+ return $iflist;
}
/* return the configured interfaces list with their description. */
@@ -624,25 +604,12 @@ function get_configured_interface_with_descr($only_opt = false, $withdisabled =
$iflist = array();
- if (!$only_opt) {
- if (isset($config['interfaces']['wan'])) {
- if (empty($config['interfaces']['wan']['descr']))
- $iflist['wan'] = "WAN";
- else
- $iflist['wan'] = strtoupper($config['interfaces']['wan']['descr']);
- }
- if (isset($config['interfaces']['lan'])) {
- if (empty($config['interfaces']['lan']['descr']))
- $iflist['lan'] = "LAN";
- else
- $iflist['lan'] = strtoupper($config['interfaces']['lan']['descr']);
- }
- }
-
/* if list */
foreach($config['interfaces'] as $if => $ifdetail) {
+ if ($only_opt && ($if == "wan" || $if == "lan"))
+ continue;
if (isset($ifdetail['enable']) || $withdisabled == true) {
- if($ifdetail['descr'] == "")
+ if(empty($ifdetail['descr']))
$iflist[$if] = strtoupper($if);
else
$iflist[$if] = strtoupper($ifdetail['descr']);
OpenPOWER on IntegriCloud