-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdater.php
58 lines (45 loc) · 2.68 KB
/
updater.php
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
ini_set('memory_limit', '1G');
use AndreasMaximilianGerum\DisposableMailDetection\Helper;
const TYPE_PHP = 'PHP';
const TYPE_JSON = 'JSON';
const TYPE_TEXT = 'TEXT';
$sources = [
'https://raw.githubusercontent.com/StephaneBour/disposable-email-domains/master/config/domains.php' => TYPE_PHP,
'https://raw.githubusercontent.com/ivolo/disposable-email-domains/master/index.json' => TYPE_JSON,
'https://raw.githubusercontent.com/FGRibreau/mailchecker/master/list.txt' => TYPE_TEXT,
'https://raw.githubusercontent.com/nojacko/email-data-disposable/master/data/disposable.txt' => TYPE_TEXT,
'https://raw.githubusercontent.com/MattKetmo/EmailChecker/master/res/throwaway_domains.txt' => TYPE_TEXT,
'https://raw.githubusercontent.com/disposable/disposable-email-domains/master/domains.txt' => TYPE_TEXT,
'https://gist.githubusercontent.com/adamloving/4401361/raw/temporary-email-address-domains' => TYPE_TEXT,
'https://raw.githubusercontent.com/vboctor/disposable_email_checker/master/data/domains.txt' => TYPE_TEXT,
'https://gist.githubusercontent.com/tbrianjones/5992856/raw/free_email_provider_domains.txt' => TYPE_TEXT,
'https://raw.githubusercontent.com/Propaganistas/Laravel-Disposable-Email/master/domains.json' => TYPE_JSON,
'https://gist.githubusercontent.com/michenriksen/8710649/raw/disposable-email-provider-domains' => TYPE_TEXT,
];
$disposableMailAddresses = include __DIR__ . '/disposable-mails-blacklist.inc.php';
require_once __DIR__ . '/Helper.php';
$helper = new Helper();
foreach ($sources as $source => $sourceType) {
if ($sourceType === TYPE_PHP) {
// We could just do an eval on the returned php file/array but this would be risky - Dont want to trust the source so use regex
preg_match_all('/\'(.*)\',/', $helper->fetchContent($source), $matches, PREG_SET_ORDER, 0);
$disposableMailAddresses = array_merge($disposableMailAddresses, array_column($matches, 1));
continue;
}
if ($sourceType === TYPE_JSON) {
$disposableMailAddresses = array_merge($disposableMailAddresses, json_decode($helper->fetchContent($source)));
continue;
}
if ($sourceType === TYPE_TEXT) {
$separator = '---#|#---';
$disposableMailAddresses = array_merge($disposableMailAddresses, explode($separator, str_replace([
"\r\n",
"\r",
"\n"
], $separator, $helper->fetchContent($source))));
continue;
}
throw new \RuntimeException('Unknown source type: "' . $sourceType . '" for source: "' . $source . '"');
}
$helper->writeLookup($disposableMailAddresses);