Skip to content

Commit

Permalink
new: Add regex type to warninglists
Browse files Browse the repository at this point in the history
  • Loading branch information
iglocska committed Jan 20, 2018
1 parent 5a1abae commit 98e0717
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/Model/Warninglist.php
Expand Up @@ -304,6 +304,8 @@ private function __checkValue($listValues, $value, $type, $listType) {
$result = $this->__evalSubString($listValues, $value[$component]);
} else if ($listType === 'hostname') {
$result = $this->__evalHostname($listValues, $value[$component]);
} else if ($listType === 'regex') {
$result = $this->__evalRegex($listValues, $value[$component]);
}
if (!empty($result)) return ($component + 1);
}
Expand Down Expand Up @@ -422,6 +424,13 @@ private function __evalHostname($listValues, $value) {
return false;
}

private function __evalRegex($listValues, $value) {
foreach ($listValues as $listValue) {
if (preg_match($listValue, $value)) return true;
}
return false;
}

public function fetchTLDLists() {
$tldLists = $this->find('list', array('conditions' => array('Warninglist.name' => $this->__tlds), 'recursive' => -1, 'fields' => array('Warninglist.id', 'Warninglist.name')));
$tlds = array();
Expand Down

0 comments on commit 98e0717

Please sign in to comment.