fixed list filtering

This commit is contained in:
Roland Gruber 2018-11-11 19:56:15 +01:00
parent 29c3f6582c
commit b7396de612
2 changed files with 25 additions and 5 deletions

View File

@ -735,7 +735,7 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I
*/
private function getDefaultLeaseTime() {
$return = null;
if (is_array($this->attributes['dhcpStatements'])) {
if (!empty($this->attributes['dhcpStatements'])) {
for ($i = 0; $i < sizeof($this->attributes['dhcpStatements']); $i++) {
if (substr($this->attributes['dhcpStatements'][$i], 0, 19) == 'default-lease-time ') {
$return = substr($this->attributes['dhcpStatements'][$i],19);
@ -773,7 +773,7 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I
*/
private function getUnknownClients() {
$return = null;
if (is_array($this->attributes['dhcpStatements'])) {
if (!empty($this->attributes['dhcpStatements'])) {
for ($i = 0; $i < sizeof($this->attributes['dhcpStatements']); $i++) {
$val = $this->attributes['dhcpStatements'][$i];
if (strpos($val, 'unknown-clients') === (strlen($val) - strlen('unknown-clients'))) {
@ -791,7 +791,7 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I
* @param String $option allow/deny
*/
private function setUnknownClients($option) {
if (!is_array($this->attributes['dhcpStatements'])) {
if (!isset($this->attributes['dhcpStatements'])) {
$this->attributes['dhcpStatements'] = array();
}
for ($i = 0; $i < sizeof($this->attributes['dhcpStatements']); $i++) {
@ -813,7 +813,7 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I
*/
private function getMaxLeaseTime() {
$return = null;
if (is_array($this->attributes['dhcpStatements'])) {
if (!empty($this->attributes['dhcpStatements'])) {
for ($i = 0; $i < sizeof($this->attributes['dhcpStatements']); $i++) {
if (substr($this->attributes['dhcpStatements'][$i], 0, 15) == 'max-lease-time ') {
$return = substr($this->attributes['dhcpStatements'][$i],15);

View File

@ -182,7 +182,7 @@ class lamDHCPList extends lamList {
* @see lamList::isFilterMatching()
*/
protected function isFilterMatching(&$data, $filterAttribute, $regex) {
if ($filterAttribute == "fixed_ips") {
if ($filterAttribute === "fixed_ips") {
if (empty($regex)) {
return true;
}
@ -211,6 +211,26 @@ class lamDHCPList extends lamList {
}
return false;
}
elseif ($filterAttribute === "dhcprange") {
if (isset($entry['dhcprange'])) {
foreach ($entry['dhcprange'] as $range) {
if (preg_match($regex, $range)) {
return true;
}
}
}
$pooledRanges = searchLDAP($data['dn'], '(objectclass=dhcpPool)', array('dhcprange'));
foreach ($pooledRanges as $pooledRange) {
if (empty($pooledRange['dhcprange'])) {
continue;
}
foreach ($pooledRange['dhcprange'] as $range) {
if (preg_match($regex, $range)) {
return true;
}
}
}
}
return parent::isFilterMatching($data, $filterAttribute, $regex);
}