From 203af86f6ec763feb482086ea86cf02f47d7024b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikke=20Schir=C3=A9n?= Date: Tue, 17 Dec 2024 13:47:19 +0100 Subject: [PATCH] Adding Matomo URL to email report --- BanIpNotificationEmail.php | 10 +++++++++- tests/Integration/NotificationEmailTest.php | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/BanIpNotificationEmail.php b/BanIpNotificationEmail.php index 56c9b96..a2fee8f 100644 --- a/BanIpNotificationEmail.php +++ b/BanIpNotificationEmail.php @@ -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; @@ -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) . ' diff --git a/tests/Integration/NotificationEmailTest.php b/tests/Integration/NotificationEmailTest.php index 274d7ac..548e428 100644 --- a/tests/Integration/NotificationEmailTest.php +++ b/tests/Integration/NotificationEmailTest.php @@ -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: []