Commit 6ca40bc4 authored by Franco Fichtner's avatar Franco Fichtner

mvc: new style checker has new style checks ;)

parent 9821d6fb
...@@ -314,7 +314,7 @@ class FilterRule ...@@ -314,7 +314,7 @@ class FilterRule
// set prio // set prio
if (isset($tmp['set-prio']) && $tmp['set-prio'] !== "" if (isset($tmp['set-prio']) && $tmp['set-prio'] !== ""
&& isset($tmp['set-prio-low']) && $tmp['set-prio-low'] !== "" ) { && isset($tmp['set-prio-low']) && $tmp['set-prio-low'] !== "" ) {
$tmp['set-prio'] = "({$tmp['set-prio']}, {$tmp['set-prio-low']})" ; $tmp['set-prio'] = "({$tmp['set-prio']}, {$tmp['set-prio-low']})";
} }
$result[] = $tmp; $result[] = $tmp;
} }
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
/** /**
* Copyright (C) 2017 Deciso B.V. * Copyright (C) 2017 Deciso B.V.
*
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
...@@ -37,75 +36,75 @@ use \OPNsense\Core\Config; ...@@ -37,75 +36,75 @@ use \OPNsense\Core\Config;
*/ */
class Util class Util
{ {
/** /**
* is provided address an ip address. * is provided address an ip address.
* @param string $network address * @param string $network address
* @return boolean * @return boolean
*/ */
public static function isIpAddress($address) public static function isIpAddress($address)
{ {
return !empty(filter_var($address, FILTER_VALIDATE_IP)); return !empty(filter_var($address, FILTER_VALIDATE_IP));
} }
/** /**
* is provided network valid * is provided network valid
* @param string $network network * @param string $network network
* @return boolean * @return boolean
*/ */
public static function isSubnet($network) public static function isSubnet($network)
{ {
$tmp = explode('/', $network); $tmp = explode('/', $network);
if (count($tmp) == 2) { if (count($tmp) == 2) {
if (self::isIpAddress($tmp[0]) && abs($tmp[1]) == $tmp[1]) { if (self::isIpAddress($tmp[0]) && abs($tmp[1]) == $tmp[1]) {
if (strpos($tmp[0], ':') !== false && $tmp[1] <= 128) { if (strpos($tmp[0], ':') !== false && $tmp[1] <= 128) {
// subnet v6 // subnet v6
return true; return true;
} elseif ($tmp[1] <= 32) { } elseif ($tmp[1] <= 32) {
// subnet v4 // subnet v4
return true; return true;
} }
} }
} }
return false; return false;
} }
/** /**
* check if name exists in alias config section * check if name exists in alias config section
* @param string $name name * @param string $name name
* @return boolean * @return boolean
*/ */
public static function isAlias($name) public static function isAlias($name)
{ {
if (!empty(Config::getInstance()->object()->aliases)) { if (!empty(Config::getInstance()->object()->aliases)) {
foreach (Config::getInstance()->object()->aliases->children() as $node) { foreach (Config::getInstance()->object()->aliases->children() as $node) {
if ($node->name == $name) { if ($node->name == $name) {
return true; return true;
} }
} }
} }
return false; return false;
} }
/** /**
* check if name exists in alias config section * check if name exists in alias config section
* @param string $number port number or range * @param string $number port number or range
* @param boolean $allow_range ranges allowed * @param boolean $allow_range ranges allowed
* @return boolean * @return boolean
*/ */
public function isPort($number, $allow_range=true) public function isPort($number, $allow_range = true)
{ {
$tmp = explode(':', $number); $tmp = explode(':', $number);
foreach ($tmp as $port) { foreach ($tmp as $port) {
if (!getservbyname($port, "tcp") && !getservbyname($port, "udp") if (!getservbyname($port, "tcp") && !getservbyname($port, "udp")
&& filter_var($port, FILTER_VALIDATE_INT, array( && filter_var($port, FILTER_VALIDATE_INT, array(
"options" => array("min_range"=>1, "max_range"=>65535))) === false "options" => array("min_range"=>1, "max_range"=>65535))) === false
) { ) {
return false; return false;
} }
} }
if (($allow_range && count($tmp) <=2) || count($tmp) == 1) { if (($allow_range && count($tmp) <=2) || count($tmp) == 1) {
return true; return true;
} }
return false; return false;
} }
} }
...@@ -33,7 +33,6 @@ use Phalcon\Validation\Validator\InclusionIn; ...@@ -33,7 +33,6 @@ use Phalcon\Validation\Validator\InclusionIn;
use OPNsense\Base\Validators\CsvListValidator; use OPNsense\Base\Validators\CsvListValidator;
use OPNsense\Core\Config; use OPNsense\Core\Config;
class AuthGroupField extends BaseField class AuthGroupField extends BaseField
{ {
/** /**
......
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