Optionally enable spam filter for forwarding hosts
This commit is contained in:
@@ -5094,7 +5094,7 @@ function get_u2f_registrations($username) {
|
||||
}
|
||||
function get_forwarding_hosts() {
|
||||
global $pdo;
|
||||
$sel = $pdo->prepare("SELECT host, source FROM `forwarding_hosts`");
|
||||
$sel = $pdo->prepare("SELECT * FROM `forwarding_hosts`");
|
||||
$sel->execute();
|
||||
return $sel->fetchAll(PDO::FETCH_OBJ);
|
||||
}
|
||||
@@ -5111,6 +5111,7 @@ function add_forwarding_host($postarray) {
|
||||
}
|
||||
$source = $postarray['hostname'];
|
||||
$host = $postarray['hostname'];
|
||||
$filter_spam = !empty($postarray['filter_spam']);
|
||||
$hosts = array();
|
||||
if (preg_match('/^[0-9a-fA-F:\/]+$/', $host)) { // IPv6 address
|
||||
$hosts = array($host);
|
||||
@@ -5133,10 +5134,15 @@ function add_forwarding_host($postarray) {
|
||||
if ($source == $host)
|
||||
$source = '';
|
||||
try {
|
||||
$stmt = $pdo->prepare("INSERT IGNORE INTO `forwarding_hosts` (`host`, `source`) VALUES (:host, :source)");
|
||||
if ($filter_spam) { // if the host already exists, REPLACE it with the spam filter turned on
|
||||
$stmt = $pdo->prepare("REPLACE INTO `forwarding_hosts` (`host`, `source`, `filter_spam`) VALUES (:host, :source, :filter_spam)");
|
||||
} else { // if the host already exists, IGNORE it no matter whether the spam filter is already turned on
|
||||
$stmt = $pdo->prepare("INSERT IGNORE INTO `forwarding_hosts` (`host`, `source`, `filter_spam`) VALUES (:host, :source, :filter_spam)");
|
||||
}
|
||||
$stmt->execute(array(
|
||||
':host' => $host,
|
||||
':source' => $source,
|
||||
':filter_spam' => $filter_spam ? 1 : 0,
|
||||
));
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
|
Reference in New Issue
Block a user