public
nobgit
read
NobMail
Based on mailcow: dockerized
Languages
Repository composition by tracked source files.
PHP
49%
JavaScript
35%
HTML
9%
CSS
4%
Shell
2%
Python
1%
Lua
0%
Perl
0%
Ruby
0%
SCSS
0%
Create file
Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git
Commit
[Web] Fix order of fuzzy del and fuzzy add when learning from quarantine, fixes #3844
b7956d8a
data/web/inc/functions.quarantine.inc.php | 136 ++++++++++++------------------
1 file changed, 55 insertions(+), 81 deletions(-)
Diff
diff --git a/data/web/inc/functions.quarantine.inc.php b/data/web/inc/functions.quarantine.inc.php
index b240587f..f4f49de4 100644
--- a/data/web/inc/functions.quarantine.inc.php
+++ b/data/web/inc/functions.quarantine.inc.php
@@ -527,7 +527,7 @@ function quarantine($_action, $_data = null) {
if (stripos($response['error'], 'already learned') === false) {
$_SESSION['return'][] = array(
'type' => 'danger',
- 'log' => array(__FUNCTION__),
+ 'log' => array(__FUNCTION__, $_action, $_data_log),
'msg' => array('ham_learn_error', $response['error'])
);
continue;
@@ -539,47 +539,39 @@ function quarantine($_action, $_data = null) {
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
- curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: text/plain', 'Flag: 13'));
- curl_setopt($curl, CURLOPT_URL,"http://rspamd/fuzzyadd");
+ curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: text/plain', 'Flag: 11'));
+ curl_setopt($curl, CURLOPT_URL,"http://rspamd/fuzzydel");
curl_setopt($curl, CURLOPT_POSTFIELDS, $row['msg']);
- $response = curl_exec($curl);
+ // It is most likely not a spam hash, so we ignore any error/warning response
+ // $response = curl_exec($curl);
if (!curl_errno($curl)) {
- $response = json_decode($response, true);
- if (isset($response['error'])) {
- if (stripos($response['error'], 'No content to generate fuzzy') === false) {
- $_SESSION['return'][] = array(
- 'type' => 'warning',
- 'log' => array(__FUNCTION__),
- 'msg' => array('fuzzy_learn_error', $response['error'])
- );
- }
- }
curl_close($curl);
$curl = curl_init();
curl_setopt($curl, CURLOPT_UNIX_SOCKET_PATH, '/var/lib/rspamd/rspamd.sock');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
- curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: text/plain', 'Flag: 11'));
- curl_setopt($curl, CURLOPT_URL,"http://rspamd/fuzzydel");
+ curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: text/plain', 'Flag: 13'));
+ curl_setopt($curl, CURLOPT_URL,"http://rspamd/fuzzyadd");
curl_setopt($curl, CURLOPT_POSTFIELDS, $row['msg']);
- // It is most likely not a spam hash, so we ignore any error/warning response
- // $response = curl_exec($curl);
+ $response = curl_exec($curl);
curl_exec($curl);
- // if (!curl_errno($curl)) {
- // $response = json_decode($response, true);
- // if (isset($response['error'])) {
- // $_SESSION['return'][] = array(
- // 'type' => 'warning',
- // 'log' => array(__FUNCTION__),
- // 'msg' => array('fuzzy_learn_error', $response['error'])
- // );
- // }
- // }
+ if (!curl_errno($curl)) {
+ $response = json_decode($response, true);
+ if (isset($response['error'])) {
+ if (stripos($response['error'], 'No content to generate fuzzy') === false) {
+ $_SESSION['return'][] = array(
+ 'type' => 'warning',
+ 'log' => array(__FUNCTION__, $_action, $_data_log),
+ 'msg' => array('fuzzy_learn_error', $response['error'])
+ );
+ }
+ }
+ }
curl_close($curl);
$_SESSION['return'][] = array(
'type' => 'success',
- 'log' => array(__FUNCTION__),
+ 'log' => array(__FUNCTION__, $_action, $_data_log),
'msg' => array('learned_ham', $id)
);
continue;
@@ -588,7 +580,7 @@ function quarantine($_action, $_data = null) {
curl_close($curl);
$_SESSION['return'][] = array(
'type' => 'danger',
- 'log' => array(__FUNCTION__),
+ 'log' => array(__FUNCTION__, $_action, $_data_log),
'msg' => array('ham_learn_error', 'Curl: ' . curl_strerror(curl_errno($curl)))
);
continue;
@@ -596,7 +588,7 @@ function quarantine($_action, $_data = null) {
curl_close($curl);
$_SESSION['return'][] = array(
'type' => 'danger',
- 'log' => array(__FUNCTION__),
+ 'log' => array(__FUNCTION__, $_action, $_data_log),
'msg' => array('ham_learn_error', 'unknown')
);
continue;
@@ -604,7 +596,7 @@ function quarantine($_action, $_data = null) {
else {
$_SESSION['return'][] = array(
'type' => 'danger',
- 'log' => array(__FUNCTION__),
+ 'log' => array(__FUNCTION__, $_action, $_data_log),
'msg' => array('ham_learn_error', 'Curl: ' . curl_strerror(curl_errno($curl)))
);
curl_close($curl);
@@ -613,7 +605,7 @@ function quarantine($_action, $_data = null) {
curl_close($curl);
$_SESSION['return'][] = array(
'type' => 'danger',
- 'log' => array(__FUNCTION__),
+ 'log' => array(__FUNCTION__, $_action, $_data_log),
'msg' => array('ham_learn_error', 'unknown')
);
continue;
@@ -647,6 +639,10 @@ function quarantine($_action, $_data = null) {
);
continue;
}
+ $stmt = $pdo->prepare("DELETE FROM `quarantine` WHERE `id` = :id");
+ $stmt->execute(array(
+ ':id' => $id
+ ));
$curl = curl_init();
curl_setopt($curl, CURLOPT_UNIX_SOCKET_PATH, '/var/lib/rspamd/rspamd.sock');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
@@ -674,61 +670,39 @@ function quarantine($_action, $_data = null) {
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
- curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: text/plain', 'Flag: 11'));
- curl_setopt($curl, CURLOPT_URL,"http://rspamd/fuzzyadd");
+ curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: text/plain', 'Flag: 13'));
+ curl_setopt($curl, CURLOPT_URL,"http://rspamd/fuzzydel");
curl_setopt($curl, CURLOPT_POSTFIELDS, $row['msg']);
- $response = curl_exec($curl);
+ // It is most likely not a spam hash, so we ignore any error/warning response
+ // $response = curl_exec($curl);
if (!curl_errno($curl)) {
- $response = json_decode($response, true);
- if (isset($response['error'])) {
- if (stripos($response['error'], 'No content to generate fuzzy') === false) {
- $_SESSION['return'][] = array(
- 'type' => 'warning',
- 'log' => array(__FUNCTION__),
- 'msg' => array('fuzzy_learn_error', $response['error'])
- );
- }
- }
curl_close($curl);
$curl = curl_init();
curl_setopt($curl, CURLOPT_UNIX_SOCKET_PATH, '/var/lib/rspamd/rspamd.sock');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
- curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: text/plain', 'Flag: 13'));
- curl_setopt($curl, CURLOPT_URL,"http://rspamd/fuzzydel");
+ curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: text/plain', 'Flag: 11'));
+ curl_setopt($curl, CURLOPT_URL,"http://rspamd/fuzzyadd");
curl_setopt($curl, CURLOPT_POSTFIELDS, $row['msg']);
- // It is most likely not a ham hash, so we ignore any error/warning response
- // $response = curl_exec($curl);
+ $response = curl_exec($curl);
curl_exec($curl);
- // if (!curl_errno($curl)) {
- // $response = json_decode($response, true);
- // if (isset($response['error'])) {
- // $_SESSION['return'][] = array(
- // 'type' => 'warning',
- // 'log' => array(__FUNCTION__),
- // 'msg' => array('fuzzy_learn_error', $response['error'])
- // );
- // }
- // }
- curl_close($curl);
- try {
- $stmt = $pdo->prepare("DELETE FROM `quarantine` WHERE `id` = :id");
- $stmt->execute(array(
- ':id' => $id
- ));
- }
- catch (PDOException $e) {
- $_SESSION['return'][] = array(
- 'type' => 'danger',
- 'log' => array(__FUNCTION__, $_action, $_data_log),
- 'msg' => array('mysql_error', $e)
- );
- continue;
+ if (!curl_errno($curl)) {
+ $response = json_decode($response, true);
+ if (isset($response['error'])) {
+ if (stripos($response['error'], 'No content to generate fuzzy') === false) {
+ $_SESSION['return'][] = array(
+ 'type' => 'warning',
+ 'log' => array(__FUNCTION__, $_action, $_data_log),
+ 'msg' => array('fuzzy_learn_error', $response['error'])
+ );
+ }
+ }
}
+ curl_close($curl);
$_SESSION['return'][] = array(
'type' => 'success',
- 'log' => array(__FUNCTION__),
+ 'log' => array(__FUNCTION__, $_action, $_data_log),
'msg' => array('qlearn_spam', $id)
);
continue;
@@ -737,7 +711,7 @@ function quarantine($_action, $_data = null) {
curl_close($curl);
$_SESSION['return'][] = array(
'type' => 'danger',
- 'log' => array(__FUNCTION__),
+ 'log' => array(__FUNCTION__, $_action, $_data_log),
'msg' => array('spam_learn_error', 'Curl: ' . curl_strerror(curl_errno($curl)))
);
continue;
@@ -745,15 +719,15 @@ function quarantine($_action, $_data = null) {
curl_close($curl);
$_SESSION['return'][] = array(
'type' => 'danger',
- 'log' => array(__FUNCTION__),
- 'msg' => array('learn_spam_error', 'unknown')
+ 'log' => array(__FUNCTION__, $_action, $_data_log),
+ 'msg' => array('spam_learn_error', 'unknown')
);
continue;
}
else {
$_SESSION['return'][] = array(
'type' => 'danger',
- 'log' => array(__FUNCTION__),
+ 'log' => array(__FUNCTION__, $_action, $_data_log),
'msg' => array('spam_learn_error', 'Curl: ' . curl_strerror(curl_errno($curl)))
);
curl_close($curl);
@@ -762,8 +736,8 @@ function quarantine($_action, $_data = null) {
curl_close($curl);
$_SESSION['return'][] = array(
'type' => 'danger',
- 'log' => array(__FUNCTION__),
- 'msg' => array('learn_spam_error', 'unknown')
+ 'log' => array(__FUNCTION__, $_action, $_data_log),
+ 'msg' => array('spam_learn_error', 'unknown')
);
continue;
}