Merge pull request #256 from mkuron/forwardinghosts
Optionally enable spam filter for forwarding hosts
This commit is contained in:
@@ -5101,7 +5101,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);
|
||||
}
|
||||
@@ -5118,6 +5118,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);
|
||||
@@ -5140,10 +5141,11 @@ function add_forwarding_host($postarray) {
|
||||
if ($source == $host)
|
||||
$source = '';
|
||||
try {
|
||||
$stmt = $pdo->prepare("INSERT IGNORE INTO `forwarding_hosts` (`host`, `source`) VALUES (:host, :source)");
|
||||
$stmt = $pdo->prepare("REPLACE 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) {
|
||||
|
@@ -3,7 +3,7 @@ function init_db_schema() {
|
||||
try {
|
||||
global $pdo;
|
||||
|
||||
$db_version = "01052017_1702";
|
||||
$db_version = "07052017_0824";
|
||||
|
||||
$stmt = $pdo->query("SHOW TABLES LIKE 'versions'");
|
||||
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
|
||||
@@ -268,7 +268,8 @@ function init_db_schema() {
|
||||
"forwarding_hosts" => array(
|
||||
"cols" => array(
|
||||
"host" => "VARCHAR(255) NOT NULL",
|
||||
"source" => "VARCHAR(255) NOT NULL"
|
||||
"source" => "VARCHAR(255) NOT NULL",
|
||||
"filter_spam" => "TINYINT(1) NOT NULL DEFAULT '0'"
|
||||
),
|
||||
"keys" => array(
|
||||
"primary" => array(
|
||||
|
Reference in New Issue
Block a user