initial Greylist: TODO: System-settings

This commit is contained in:
2016-11-09 17:52:38 +01:00
parent f5dc8aa1c9
commit 2e0ee3d683
6 changed files with 55 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
<?php
<?php
/**
* This file is part of the Froxlor project.
@@ -43,7 +43,7 @@ if ($page == 'overview') {
'm.destination' => $lng['emails']['forwarders']
);
$paging = new paging($userinfo, TABLE_MAIL_VIRTUAL, $fields);
$result_stmt = Database::prepare('SELECT `m`.`id`, `m`.`domainid`, `m`.`email`, `m`.`email_full`, `m`.`iscatchall`, `u`.`quota`, `m`.`destination`, `m`.`popaccountid`, `d`.`domain`, `u`.`mboxsize` FROM `' . TABLE_MAIL_VIRTUAL . '` `m`
$result_stmt = Database::prepare('SELECT `m`.`id`, `m`.`domainid`, `m`.`email`, `m`.`email_full`, `m`.`iscatchall`, `u`.`quota`, `m`.`destination`, `m`.`popaccountid`,`m`.`disablegreylist`, `d`.`domain`, `u`.`mboxsize` FROM `' . TABLE_MAIL_VIRTUAL . '` `m`
LEFT JOIN `' . TABLE_PANEL_DOMAINS . '` `d` ON (`m`.`domainid` = `d`.`id`)
LEFT JOIN `' . TABLE_MAIL_USERS . '` `u` ON (`m`.`popaccountid` = `u`.`id`)
WHERE `m`.`customerid`= :customerid ' . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit()
@@ -227,7 +227,7 @@ if ($page == 'overview') {
standard_error('emailiswrong', $email_full);
}
$stmt = Database::prepare("SELECT `id`, `email`, `email_full`, `iscatchall`, `destination`, `customerid` FROM `" . TABLE_MAIL_VIRTUAL . "`
$stmt = Database::prepare("SELECT `id`, `email`, `email_full`, `iscatchall`, `destination`, `customerid`, `disablegreylist` FROM `" . TABLE_MAIL_VIRTUAL . "`
WHERE (`email` = :email
OR `email_full` = :emailfull )
AND `customerid`= :cid"
@@ -251,15 +251,16 @@ if ($page == 'overview') {
standard_error('youhavealreadyacatchallforthisdomain');
} else {
$stmt = Database::prepare("INSERT INTO `" . TABLE_MAIL_VIRTUAL . "`
(`customerid`, `email`, `email_full`, `iscatchall`, `domainid`)
VALUES (:cid, :email, :email_full, :iscatchall, :domainid)"
(`customerid`, `email`, `email_full`, `iscatchall`, `domainid`, `disablegreylist`)
VALUES (:cid, :email, :email_full, :iscatchall, :domainid, :disablegreylist)"
);
$params = array(
"cid" => $userinfo['customerid'],
"email" => $email,
"email_full" => $email_full,
"iscatchall" => $iscatchall,
"domainid" => $domain_check['id']
"domainid" => $domain_check['id'],
"disablegreylist" => $disablegreylist,
);
Database::pexecute($stmt, $params);
@@ -305,7 +306,7 @@ if ($page == 'overview') {
standard_error('allresourcesused');
}
} elseif ($action == 'edit' && $id != 0) {
$stmt = Database::prepare("SELECT `v`.`id`, `v`.`email`, `v`.`email_full`, `v`.`iscatchall`, `v`.`destination`, `v`.`customerid`, `v`.`popaccountid`, `u`.`quota`
$stmt = Database::prepare("SELECT `v`.`id`, `v`.`email`, `v`.`email_full`, `v`.`iscatchall`, `v`.`destination`, `v`.`customerid`, `v`.`popaccountid`, `v`.`disablegreylist`, u`.`quota`
FROM `" . TABLE_MAIL_VIRTUAL . "` `v`
LEFT JOIN `" . TABLE_MAIL_USERS . "` `u`
ON(`v`.`popaccountid` = `u`.`id`)
@@ -402,6 +403,32 @@ if ($page == 'overview') {
} else {
standard_error(array('operationnotpermitted', 'featureisdisabled'), 'Catchall');
}
} elseif ($action == 'togglegreylist' && $id != 0) {
//if (Settings::Get('catchall.catchall_enabled') == '1') {
$stmt = Database::prepare("SELECT `id`, `email`, `email_full`, `destination`, `customerid`, `popaccountid`, `disablegreylist` FROM `" . TABLE_MAIL_VIRTUAL . "`
WHERE `customerid`= :cid
AND `id`= :id"
);
$result = Database::pexecute_first($stmt, array("cid" => $userinfo['customerid'], "id" => $id));
$gr_val = $result['disablegreylist'] == 0 ? 1 : 0;
if (isset($result['email']) && $result['email'] != '') {
$stmt = Database::prepare("UPDATE `" . TABLE_MAIL_VIRTUAL . "`
SET `email` = :email, `disablegreylist` = :gr_val
WHERE `customerid`= :cid
AND `id`= :id"
);
$params = array(
"email" => $result['email_full'],
"cid" => $userinfo['customerid'],
"id" => $id,
"gr_val" => $gr_val,
);
Database::pexecute($stmt, $params);
redirectTo($filename, array('page' => $page, 'action' => 'edit', 'id' => $id, 's' => $s));
}
// } else {
// standard_error(array('operationnotpermitted', 'featureisdisabled'), 'Greylisting');
// }
}
} elseif ($page == 'accounts') {
if ($action == 'add' && $id != 0) {

View File

@@ -3415,3 +3415,9 @@ if (isFroxlorVersion('0.9.37-rc1')) {
showUpdateStep("Updating from 0.9.37-rc1 to 0.9.37 final", false);
updateToVersion('0.9.37');
}
if(isFroxlorVersion('0.9.37')) {
Database::query("ALTER TABLE `".TABLE_MAIL_VIRTUAL."` ADD disablegreylist TINYINT(1)");
showUpdateStep("Updating from 0.9.37 to 0.9.37 greylist", false);
updateToVersion('0.9.37-greylist');
}

View File

@@ -43,6 +43,14 @@ return array(
array ('label' => $lng['panel']['yes'], 'value' => '1')
),
'value' => array()
),
'disablegreylist' => array(
'label' => $lng['emails']['greylist'],
'type' => 'checkbox',
'values' => array(
array ('label' => $lng['panel']['yes'], 'value' => '1')
),
'value' => array()
)
)
)

View File

@@ -53,6 +53,11 @@ return array(
'type' => 'label',
'value' => ($result['iscatchall'] == 0 ? $lng['panel']['no'] : $lng['panel']['yes']).' [<a href="'.$filename.'?page='.$page.'&amp;action=togglecatchall&amp;id='.$result['id'].'&amp;s='.$s.'">'.$lng['panel']['toggle'].'</a>]'
),
'mail_greylist' => array(
'label' => $lng['emails']['greylist'],
'type' => 'label',
'value' => ($result['disablegreylist'] == 0 ? $lng['panel']['no'] : $lng['panel']['yes']).' [<a href="'.$filename.'?page='.$page.'&amp;action=togglegreylist&amp;id='.$result['id'].'&amp;s='.$s.'">'.$lng['panel']['toggle'].'</a>]'
),
'mail_fwds' => array(
'label' => $lng['emails']['forwarders'].' ('.$forwarders_count.')',
'type' => 'label',

View File

@@ -141,6 +141,7 @@ $lng['emails']['from'] = 'Source';
$lng['emails']['to'] = 'Destination';
$lng['emails']['forwarders'] = 'Forwarders';
$lng['emails']['forwarder_add'] = 'Create forwarder';
$lng['emails']['greylist'] = 'Disable greylisting';
/**
* FTP

View File

@@ -140,6 +140,7 @@ $lng['emails']['from'] = 'Von';
$lng['emails']['to'] = 'Nach';
$lng['emails']['forwarders'] = 'Weiterleitungen';
$lng['emails']['forwarder_add'] = 'Weiterleitung hinzufügen';
$lng['emails']['greylist'] = 'Greylisting ausschalten';
/**
* FTP