blob: 2528e550aa10c92be3fdfd70de391602e7d85800 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\Overlay;
use Piwik\Url;
use Piwik\UrlHelper;
class Overlay extends \Piwik\Plugin
{
/**
* @see \Piwik\Plugin::registerEvents
*/
function registerEvents()
{
return array(
'AssetManager.getJavaScriptFiles' => 'getJsFiles',
'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys'
);
}
/**
* Returns required Js Files
* @param $jsFiles
*/
public function getJsFiles(&$jsFiles)
{
$jsFiles[] = 'plugins/Overlay/javascripts/rowaction.js';
$jsFiles[] = 'plugins/Overlay/javascripts/Overlay_Helper.js';
}
public function getClientSideTranslationKeys(&$translationKeys)
{
$translationKeys[] = 'General_OverlayRowActionTooltipTitle';
$translationKeys[] = 'General_OverlayRowActionTooltip';
}
/**
* Returns if a request belongs to the Overlay page
*
* Whenever we change the Overlay, or any feature that is available on that page, this list needs to be adjusted
* Otherwise it can happen, that the session cookie is sent with samesite=lax, which might break the session in Overlay
* See https://github.com/matomo-org/matomo/pull/18648
*/
public static function isOverlayRequest($module, $action, $method, $referer)
{
$isOverlay = $module == 'Overlay';
$referrerUrlQuery = parse_url($referer ?? '', PHP_URL_QUERY);
$referrerUrlQueryParams = UrlHelper::getArrayFromQueryString($referrerUrlQuery);
$referrerUrlHost = parse_url($referer ?? '', PHP_URL_HOST);
$comingFromOverlay = Url::isValidHost($referrerUrlHost) && !empty($referrerUrlQueryParams['module']) && $referrerUrlQueryParams['module'] === 'Overlay';
$isPossibleOverlayRequest = (
$module === 'Proxy' // JS & CSS requests
|| ($module === 'API' && 0 === strpos($method, 'Overlay.')) // Overlay API data
|| ($module === 'CoreHome' && $action === 'getRowEvolutionPopover') // Row evolution
|| ($module === 'CoreHome' && $action === 'getRowEvolutionGraph') // Row evolution (graph)
|| ($module === 'CoreHome' && $action === 'saveViewDataTableParameters') // store chart changes (within row evolution & transitions)
|| $module === 'Annotations' // required to interact with annotations in evolution charts (within row evolution)
|| ($module === 'Transitions' && $action === 'renderPopover') // Transitions
|| ($module === 'API' && 0 === strpos($method, 'Transitions.')) // Transitions API data
|| ($module === 'Live' && $action === 'indexVisitorLog') // Visits Log
|| ($module === 'Live' && $action === 'getLastVisitsDetails') // Visits Log (pagination)
|| ($module === 'Live' && $action === 'getVisitorProfilePopup') // Visitor Profile
|| ($module === 'Live' && $action === 'getVisitList') // Visitor Profile (load more visits)
|| ($module === 'UserCountryMap' && $action === 'realtimeMap') // Visitor Profile (map)
);
return $isOverlay || ($comingFromOverlay && $isPossibleOverlayRequest);
}
}
|