mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-15 09:04:39 +00:00
mvc: new style checker has new style checks ;)
This commit is contained in:
parent
9821d6fb7a
commit
6ca40bc406
@ -314,7 +314,7 @@ class FilterRule
|
||||
// set prio
|
||||
if (isset($tmp['set-prio']) && $tmp['set-prio'] !== ""
|
||||
&& 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;
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
/**
|
||||
* Copyright (C) 2017 Deciso B.V.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -37,75 +36,75 @@ use \OPNsense\Core\Config;
|
||||
*/
|
||||
class Util
|
||||
{
|
||||
/**
|
||||
* is provided address an ip address.
|
||||
* @param string $network address
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isIpAddress($address)
|
||||
{
|
||||
return !empty(filter_var($address, FILTER_VALIDATE_IP));
|
||||
}
|
||||
/**
|
||||
* is provided address an ip address.
|
||||
* @param string $network address
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isIpAddress($address)
|
||||
{
|
||||
return !empty(filter_var($address, FILTER_VALIDATE_IP));
|
||||
}
|
||||
|
||||
/**
|
||||
* is provided network valid
|
||||
* @param string $network network
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isSubnet($network)
|
||||
{
|
||||
$tmp = explode('/', $network);
|
||||
if (count($tmp) == 2) {
|
||||
if (self::isIpAddress($tmp[0]) && abs($tmp[1]) == $tmp[1]) {
|
||||
if (strpos($tmp[0], ':') !== false && $tmp[1] <= 128) {
|
||||
// subnet v6
|
||||
return true;
|
||||
} elseif ($tmp[1] <= 32) {
|
||||
// subnet v4
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* is provided network valid
|
||||
* @param string $network network
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isSubnet($network)
|
||||
{
|
||||
$tmp = explode('/', $network);
|
||||
if (count($tmp) == 2) {
|
||||
if (self::isIpAddress($tmp[0]) && abs($tmp[1]) == $tmp[1]) {
|
||||
if (strpos($tmp[0], ':') !== false && $tmp[1] <= 128) {
|
||||
// subnet v6
|
||||
return true;
|
||||
} elseif ($tmp[1] <= 32) {
|
||||
// subnet v4
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if name exists in alias config section
|
||||
* @param string $name name
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isAlias($name)
|
||||
{
|
||||
if (!empty(Config::getInstance()->object()->aliases)) {
|
||||
foreach (Config::getInstance()->object()->aliases->children() as $node) {
|
||||
if ($node->name == $name) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* check if name exists in alias config section
|
||||
* @param string $name name
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isAlias($name)
|
||||
{
|
||||
if (!empty(Config::getInstance()->object()->aliases)) {
|
||||
foreach (Config::getInstance()->object()->aliases->children() as $node) {
|
||||
if ($node->name == $name) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if name exists in alias config section
|
||||
* @param string $number port number or range
|
||||
* @param boolean $allow_range ranges allowed
|
||||
* @return boolean
|
||||
*/
|
||||
public function isPort($number, $allow_range=true)
|
||||
{
|
||||
$tmp = explode(':', $number);
|
||||
foreach ($tmp as $port) {
|
||||
if (!getservbyname($port, "tcp") && !getservbyname($port, "udp")
|
||||
&& filter_var($port, FILTER_VALIDATE_INT, array(
|
||||
"options" => array("min_range"=>1, "max_range"=>65535))) === false
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (($allow_range && count($tmp) <=2) || count($tmp) == 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* check if name exists in alias config section
|
||||
* @param string $number port number or range
|
||||
* @param boolean $allow_range ranges allowed
|
||||
* @return boolean
|
||||
*/
|
||||
public function isPort($number, $allow_range = true)
|
||||
{
|
||||
$tmp = explode(':', $number);
|
||||
foreach ($tmp as $port) {
|
||||
if (!getservbyname($port, "tcp") && !getservbyname($port, "udp")
|
||||
&& filter_var($port, FILTER_VALIDATE_INT, array(
|
||||
"options" => array("min_range"=>1, "max_range"=>65535))) === false
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (($allow_range && count($tmp) <=2) || count($tmp) == 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,7 +33,6 @@ use Phalcon\Validation\Validator\InclusionIn;
|
||||
use OPNsense\Base\Validators\CsvListValidator;
|
||||
use OPNsense\Core\Config;
|
||||
|
||||
|
||||
class AuthGroupField extends BaseField
|
||||
{
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user