Skip to content

Commit 8ac736a

Browse files
authored
Merge pull request #137 from Digitalist-Open-Cloud/URL_email_report
Adding Matomo URL to email report
2 parents 99ec0e5 + 203af86 commit 8ac736a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

BanIpNotificationEmail.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,15 @@ public function send($ipRange, $ip, $email, $maxActionsAllowed, $locationData, $
3636
$mail->setFrom($mail->getFrom(), 'Web Analytics Reports');
3737
}
3838

39+
3940
$mailBody = 'This is for your information. The following IP was banned because visit tried to track more than ' . Common::sanitizeInputValue($maxActionsAllowed) . ' actions:';
4041
$mailBody .= PHP_EOL . PHP_EOL . '"' . Common::sanitizeInputValue($ipRange) . '"' . PHP_EOL;
4142
$instanceId = SettingsPiwik::getPiwikInstanceId();
42-
43+
$matomoUrl = SettingsPiwik::getPiwikUrl();
44+
if (!empty($matomoUrl)) {
45+
$url = parse_url($matomoUrl);
46+
$matomoHost = $url['host'];
47+
}
4348

4449
if (!empty($_GET)) {
4550
$get = $_GET;
@@ -62,6 +67,9 @@ public function send($ipRange, $ip, $email, $maxActionsAllowed, $locationData, $
6267
if (!empty($instanceId)) {
6368
$mailBody .= PHP_EOL . 'Instance ID: ' . Common::sanitizeInputValue($instanceId);
6469
}
70+
if (!empty($matomoHost)) {
71+
$mailBody .= PHP_EOL . 'URL: ' . Common::sanitizeInputValue($matomoHost);
72+
}
6573
$mailBody .= PHP_EOL . 'Current date (UTC): ' . Common::sanitizeInputValue($nowDateTime) . '
6674
IP as detected in header: ' . Common::sanitizeInputValue($ip) . '
6775
GET request info: ' . json_encode($get) . '

tests/Integration/NotificationEmailTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public function test_send_ValidEmail()
4343
4444
"10.10.10.10/12"
4545
46+
URL: localhost
4647
Current date (UTC): 2020-12-14 01:42:27
4748
IP as detected in header: 127.0.0.1
4849
GET request info: []

0 commit comments

Comments
 (0)