Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion inc/cleantalk-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ function apbct_settings__set_fields()
. __(' - connection status to ' . $apbct->data["wl_brandname_short"] . ' cloud during Anti-Spam request', 'cleantalk-spam-protect')
. $send_connection_reports__sfw_text
. '<br>'
. sprintf(esc_html__('The reports are to be sent to %s'), $apbct->data['wl_support_email'])
. sprintf(esc_html__('The reports are to be sent to %s'), 'pluginreports@cleantalk.org')
),
'misc__async_js' => array(
'type' => 'checkbox',
Expand Down
31 changes: 4 additions & 27 deletions lib/Cleantalk/ApbctWP/ConnectionReports.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private function loadReportsDataFromDb()
return;
}

$sql = "SELECT * FROM " . $this->cr_table_name . " ORDER BY date;";
$sql = "SELECT *, FROM_UNIXTIME(date) AS date, FROM_UNIXTIME(sent_on) AS sent_on FROM " . $this->cr_table_name . " ORDER BY date;";
$this->reports_data = TT::toArray($this->db->fetchAll($sql));
$this->reports_data_dirty = false;
$this->unsent_reports_cache = null; // Invalidate cache
Expand Down Expand Up @@ -357,7 +357,7 @@ private function prepareReportRow($key, $report)

return '<tr style="color:' . $color . '">'
. '<td>' . Escape::escHtml((int)$key + 1) . '.</td>'
. '<td>' . Escape::escHtml(date('m-d-y H:i:s', $report_date)) . '</td>'
. '<td>' . Escape::escHtml($report_date) . '</td>'
. '<td>' . Escape::escUrl($report_page_url) . '</td>'
. '<td>' . Escape::escHtml($report_lib_report) . '</td>'
. '<td>' . Escape::escHtml($report_failed_work_urls) . '</td>'
Expand Down Expand Up @@ -430,7 +430,7 @@ private function sendEmail(array $unsent_reports_ids, $is_cron_task = false)
return false;
}

$to = $apbct->data['wl_support_email'];
$to = 'pluginreports@cleantalk.org';
$subject = "Connection report for " . TT::toString(Server::get('HTTP_HOST'));

$message = $this->prepareEmailContent($selection, $is_cron_task);
Expand All @@ -451,8 +451,6 @@ private function sendEmail(array $unsent_reports_ids, $is_cron_task = false)
*/
private function prepareEmailContent(array $selection, $is_cron_task = false)
{
global $apbct;

$stat_since = isset($this->reports_count['stat_since']) ? $this->reports_count['stat_since'] : '';
$total = isset($this->reports_count['total']) ? $this->reports_count['total'] : '';
$positive = isset($this->reports_count['positive']) ? $this->reports_count['positive'] : '';
Expand Down Expand Up @@ -481,7 +479,7 @@ private function prepareEmailContent(array $selection, $is_cron_task = false)
foreach ($selection as $report) {
$message .= '<tr>'
. '<td>' . (++$counter) . '.</td>'
. '<td>' . TT::toString(date('m-d-y H:i:s', $report['date'])) . '</td>'
. '<td>' . TT::toString($report['date']) . '</td>'
. '<td>' . Escape::escUrl($report['page_url']) . '</td>'
. '<td>' . Escape::escHtml($report['lib_report']) . '</td>'
. '<td>' . Escape::escHtml($report['failed_work_urls']) . '</td>'
Expand All @@ -490,33 +488,12 @@ private function prepareEmailContent(array $selection, $is_cron_task = false)
}

$message .= '</table><br>';
$message .= $this->prepareRemoteCallLink($apbct);
$message .= '<br>' . ($is_cron_task ? 'This is a cron task.' : 'This is a manual task.') . '<br>';
$message .= '</body></html>';

return $message;
}

/**
* Prepare remote call link for email
* @param mixed $apbct
* @return string
*/
private function prepareRemoteCallLink($apbct)
{
$show_connection_reports_link =
(substr(get_option('home'), -1) === '/' ? get_option('home') : get_option('home') . '/')
. '?'
. http_build_query([
'plugin_name' => 'apbct',
'spbc_remote_call_token' => md5($apbct->api_key),
'spbc_remote_call_action' => 'debug',
'show_only' => 'connection_reports',
]);

return '<a href="' . $show_connection_reports_link . '" target="_blank">Show connection reports with remote call</a>';
}

/**
* Init reports sending
* @param bool $is_cron_task Set if this is a cron task
Expand Down
13 changes: 1 addition & 12 deletions lib/Cleantalk/ApbctWP/Firewall/SFWUpdateSentinel.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private function sendSentinelEmail()
return false;
}

$to = $apbct->data['wl_support_email'];
$to = 'pluginreports@cleantalk.org';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's better to initialize mail in one place and then use it in 4 places? Then the edit will be needed in one place, not in 4. For example, in a global variable

$subject = "SFW failed updates report for " . TT::toString(Server::get('HTTP_HOST'));
$message = '
<html lang="en">
Expand Down Expand Up @@ -151,19 +151,8 @@ private function sendSentinelEmail()

$last_fw_stats_html .= '</table>';


$show_connection_reports_link =
substr(get_option('home'), -1) === '/' ? get_option('home') : get_option('home') . '/'
. '?'
. http_build_query([
'plugin_name' => 'apbct',
'spbc_remote_call_token' => md5($apbct->api_key),
'spbc_remote_call_action' => 'debug',
'show_only' => 'connection_reports',
]);
$message .= '<p>Last FW stats:</p>';
$message .= '<p>' . $last_fw_stats_html . '</p>';
$message .= '<a href="' . $show_connection_reports_link . '" target="_blank">Show connection reports with remote call</a>';
$message .= '<br>';

$message .= '<p>This report is sent by cron task on: ' . current_time('m-d-y H:i:s') . '</p>';
Expand Down
2 changes: 1 addition & 1 deletion lib/Cleantalk/ApbctWP/JsErrorsReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function sendEmail($is_cron_task = false)
return false;
}

$to = "support@cleantalk.org";
$to = "pluginreports@cleantalk.org";
$subject = "JS errors report for " . TT::toString(Server::get('HTTP_HOST'));
$message = '
<html lang="en">
Expand Down