mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-11-30 20:27:07 +09:00
Use a better disposable domain email database (#1893)
* Switched the disposable email list * Correctly remove comments * Mention what DB is used and their license
This commit is contained in:
1 parent
4120abb0d4
commit
a106ecaac6
2 files changed
+10
-6
No files matched your search
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright 2022-2023 FOSSBilling
|
||||
* Copyright 2011-2021 BoxBilling, Inc.
|
||||
@@ -194,33 +195,35 @@ class Service implements InjectionAwareInterface
|
||||
|
||||
/**
|
||||
* Fetches the most recent list of disposable email addresses, parses them to remove blanks or invalid domains, and then returns it as an array.
|
||||
* The database is from here: https://github.com/disposable-email-domains/disposable-email-domains
|
||||
* Results are cached for 1 week.
|
||||
* The database is from here: https://github.com/7c/fakefilter
|
||||
* Results are cached for 1 week unless there's an error at which point the list will be retried in a half hour.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getTempMailDomainDB(): array
|
||||
{
|
||||
return $this->di['cache']->get('CentralAlerts.getAlerts', function (ItemInterface $item) {
|
||||
$item->expiresAfter(604800); // Retain the DB cache for one week and then fetch the list again
|
||||
$item->expiresAfter(86400); // The list is updated once every 24 hours, so we will cache it for that long
|
||||
|
||||
$client = HttpClient::create();
|
||||
$response = $client->request('GET', 'https://raw.githubusercontent.com/disposable-email-domains/disposable-email-domains/master/disposable_email_blocklist.conf');
|
||||
$response = $client->request('GET', 'https://raw.githubusercontent.com/7c/fakefilter/main/txt/data.txt');
|
||||
$dbPath = PATH_CACHE . DIRECTORY_SEPARATOR . 'tempEmailDB.txt';
|
||||
|
||||
if ($response->getStatusCode() === 200) {
|
||||
file_put_contents($dbPath, $response->getContent());
|
||||
@file_put_contents($dbPath, $response->getContent());
|
||||
} else {
|
||||
$item->expiresAfter(3600);
|
||||
return [];
|
||||
}
|
||||
|
||||
@$database = file($dbPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
@unlink($dbPath);
|
||||
if (!$database) {
|
||||
$item->expiresAfter(3600);
|
||||
return [];
|
||||
}
|
||||
|
||||
return array_filter($database, fn($domain) => filter_var($domain, FILTER_VALIDATE_DOMAIN));
|
||||
return array_filter($database, fn ($domain) => !str_starts_with($domain, '#') && filter_var($domain, FILTER_VALIDATE_DOMAIN));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -114,6 +114,7 @@
|
||||
<div class="card-body">
|
||||
<h3 class="card-title">{{ 'Temporary / disposable email protection'|trans }}</h3>
|
||||
<p class="card-subtitle">{{ 'If enabled, email addresses will be checked against a database of disposable email domains.'|trans }}</p>
|
||||
<p class="card-subtitle">{{ 'This database is updated daily and provided free of charge by the FakeFilter project under the BSD 3-Clause License.'|trans }}</p>
|
||||
<div class="mb-3 row">
|
||||
<label class="col-md-3 col-form-label" for="check_temp_emails">{{ 'Check for temporary / disposable email addresses.'|trans }}</label>
|
||||
<div class="col-md-6 pt-2 ps-0">
|
||||
|
||||
Reference in new issue
Block a user