-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSpamChecker.php
More file actions
44 lines (25 loc) · 868 Bytes
/
SpamChecker.php
File metadata and controls
44 lines (25 loc) · 868 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace dastanaron\spamchecker;
class SpamChecker {
private $blacklist = [];
public function __construct($path_to_list, $limit = 0) {
$this->blacklist = file($path_to_list, FILE_SKIP_EMPTY_LINES | FILE_IGNORE_NEW_LINES);
if ($limit > 0) {
$this->blacklist = array_slice($this->blacklist, 0, $limit);
}
}
public function check($host) {
$result = [
"host" => $host,
"blacklists" => [],
];
$host_revert = join(".", array_reverse(explode(".", $host)));
foreach ($this->blacklist as $dns) {
$response = @dns_get_record($host_revert . '.' . $dns, DNS_TXT);
if (!empty($response)) {
$result["blacklists"][$dns] = $response;
}
}
return $result;
}
}