Add local spammer database and spam submission API
This commit is contained in:
parent
7e7f61cffb
commit
feab0c3a87
@ -65,6 +65,13 @@ $APIS = [
|
||||
"domain (optional)" => ""
|
||||
]
|
||||
],
|
||||
"net/contactspam/submit" => [
|
||||
"load" => "net.contactspam.submit.php",
|
||||
"vars" => [
|
||||
"email (optional)" => "",
|
||||
"ipaddr (optional)" => ""
|
||||
]
|
||||
],
|
||||
"net/geoip" => [
|
||||
"load" => "net.geoip.php",
|
||||
"vars" => [
|
||||
|
BIN
database.mwb
Normal file
BIN
database.mwb
Normal file
Binary file not shown.
BIN
database.mwb.bak
Normal file
BIN
database.mwb.bak
Normal file
Binary file not shown.
@ -132,6 +132,20 @@ try {
|
||||
|
||||
}
|
||||
|
||||
// Check local spammer database
|
||||
if (env("require_database")) {
|
||||
if (!empty($clientip)) {
|
||||
if ($database->has("net.contactspam_spammers", ["ip" => $clientip])) {
|
||||
exitWithJson(["status" => "OK", "clean" => false, "filter" => "netsyms_ip_blacklist", "hit" => $clientip, "message" => "A computer at your IP address has sent spam in the past. Your message has been blocked."]);
|
||||
}
|
||||
}
|
||||
if (!empty($clientip)) {
|
||||
if ($database->has("net.contactspam_spammers", ["email" => $email_lower])) {
|
||||
exitWithJson(["status" => "OK", "clean" => false, "filter" => "netsyms_email_blacklist", "hit" => $clientip, "message" => "Someone put your email as the from address on a spam message. Your message has been blocked."]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Well if we got here then the message tested negative for spam
|
||||
//
|
||||
|
40
endpoints/net.contactspam.submit.php
Normal file
40
endpoints/net.contactspam.submit.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
$fromemail = $VARS["email"] ?? "";
|
||||
$clientip = $VARS["ipaddr"] ?? "";
|
||||
|
||||
if (!empty($fromemail) && filter_var($fromemail, FILTER_VALIDATE_EMAIL)) {
|
||||
$fromemail = strtolower($fromemail);
|
||||
if ($database->has("net.contactspam_spammers", ["email" => $fromemail])) {
|
||||
$database->update("net.contactspam_spammers", [
|
||||
"entrylastreported" => date("Y-m-d H:i:s"),
|
||||
"reportcount[+]" => 1
|
||||
], ["email" => $fromemail]);
|
||||
} else {
|
||||
$database->insert("net.contactspam_spammers", [
|
||||
"entrylastreported" => date("Y-m-d H:i:s"),
|
||||
"reportcount" => 1,
|
||||
"email" => $fromemail
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($clientip) && filter_var($clientip, FILTER_VALIDATE_IP)) {
|
||||
if ($database->has("net.contactspam_spammers", ["ip" => $clientip])) {
|
||||
$database->update("net.contactspam_spammers", [
|
||||
"entrylastreported" => date("Y-m-d H:i:s"),
|
||||
"reportcount[+]" => 1
|
||||
], ["ip" => $clientip]);
|
||||
} else {
|
||||
$database->insert("net.contactspam_spammers", [
|
||||
"entrylastreported" => date("Y-m-d H:i:s"),
|
||||
"reportcount" => 1,
|
||||
"ip" => $clientip
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Well if we got here then the message tested negative for spam
|
||||
//
|
||||
exitWithJson(["status" => "OK"]);
|
Loading…
x
Reference in New Issue
Block a user