From eff501a2089540ec37edd3700483a291c8ffe8ea Mon Sep 17 00:00:00 2001 From: "maenz.torsten" Date: Sat, 28 Aug 2021 12:56:09 +0200 Subject: [PATCH] * fix bug in image URL --- system/includes/functions.php | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/system/includes/functions.php b/system/includes/functions.php index fd623bb..dc56c95 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -2044,16 +2044,23 @@ function matomo($title) if($matomoTracking == 'javascript') { - $url = $matomoURL; + $jsURL = $matomoURL; + $imageURL = $matomoURL; // remove http | https if (startsWith($matomoURL, 'https')) { - $url = replace_first_str('https', '', $matomoURL); + $jsURL = replace_first_str('https', '', $matomoURL); } else if (startsWith($matomoURL, 'http')) { - $url = replace_first_str('http', '', $matomoURL); + $jsURL = replace_first_str('http', '', $matomoURL); + } + + if(!endsWith($matomoURL, '/')) + { + $jsURL = $jsURL . '/'; + $imageURL = $imageURL . "/"; } $script = << - + EOF; return $script; @@ -2083,8 +2090,8 @@ EOF; return; } - $url = 'system/plugins/matomo/MatomoTracker.php'; - require_once ($url); + $jsURL = 'system/plugins/matomo/MatomoTracker.php'; + require_once ($jsURL); MatomoTracker::$URL = $matomoURL; @@ -2102,10 +2109,25 @@ EOF; } } -function startsWith($haystack, $needle) + +function startsWith($haystack, $needle, $case = true) { - $length = strlen( $needle ); - return substr( $haystack, 0, $length ) === $needle; + if ($case) + { + return (strcmp(substr($haystack, 0, strlen($needle)), $needle) === 0); + } + + return (strcasecmp(substr($haystack, 0, strlen($needle)), $needle) === 0); +} + +function endsWith($haystack, $needle, $case = true) +{ + if ($case) + { + return (strcmp(substr($haystack, strlen($haystack) - strlen($needle)), $needle) === 0); + } + + return (strcasecmp(substr($haystack, strlen($haystack) - strlen($needle)), $needle) === 0); } function replace_first_str($search_str, $replacement_str, $src_str)