Skip to content

Commit

Permalink
Adding Matomo URL to email report
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkeschiren committed Dec 17, 2024
1 parent 99ec0e5 commit 203af86
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion BanIpNotificationEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,15 @@ public function send($ipRange, $ip, $email, $maxActionsAllowed, $locationData, $
$mail->setFrom($mail->getFrom(), 'Web Analytics Reports');
}


$mailBody = 'This is for your information. The following IP was banned because visit tried to track more than ' . Common::sanitizeInputValue($maxActionsAllowed) . ' actions:';
$mailBody .= PHP_EOL . PHP_EOL . '"' . Common::sanitizeInputValue($ipRange) . '"' . PHP_EOL;
$instanceId = SettingsPiwik::getPiwikInstanceId();

$matomoUrl = SettingsPiwik::getPiwikUrl();
if (!empty($matomoUrl)) {
$url = parse_url($matomoUrl);
$matomoHost = $url['host'];
}

if (!empty($_GET)) {
$get = $_GET;
Expand All @@ -62,6 +67,9 @@ public function send($ipRange, $ip, $email, $maxActionsAllowed, $locationData, $
if (!empty($instanceId)) {
$mailBody .= PHP_EOL . 'Instance ID: ' . Common::sanitizeInputValue($instanceId);
}
if (!empty($matomoHost)) {
$mailBody .= PHP_EOL . 'URL: ' . Common::sanitizeInputValue($matomoHost);
}
$mailBody .= PHP_EOL . 'Current date (UTC): ' . Common::sanitizeInputValue($nowDateTime) . '
IP as detected in header: ' . Common::sanitizeInputValue($ip) . '
GET request info: ' . json_encode($get) . '
Expand Down
1 change: 1 addition & 0 deletions tests/Integration/NotificationEmailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function test_send_ValidEmail()
"10.10.10.10/12"
URL: localhost
Current date (UTC): 2020-12-14 01:42:27
IP as detected in header: 127.0.0.1
GET request info: []
Expand Down

0 comments on commit 203af86

Please sign in to comment.