PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 1.3.1
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v1.3.1
5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / app / core / Context.php
matomo / app / core Last commit date
API 6 years ago Access 6 years ago Application 6 years ago Archive 6 years ago ArchiveProcessor 6 years ago Archiver 6 years ago AssetManager 6 years ago Auth 6 years ago Category 6 years ago CliMulti 6 years ago Columns 6 years ago Composer 6 years ago Concurrency 6 years ago Config 6 years ago Container 6 years ago CronArchive 6 years ago DataAccess 5 years ago DataFiles 6 years ago DataTable 6 years ago Db 6 years ago DeviceDetector 5 years ago Email 6 years ago Exception 6 years ago Http 6 years ago Intl 6 years ago Mail 6 years ago Measurable 6 years ago Menu 6 years ago Metrics 6 years ago Notification 6 years ago Period 6 years ago Plugin 6 years ago ProfessionalServices 6 years ago Report 6 years ago ReportRenderer 6 years ago Scheduler 6 years ago Segment 6 years ago Session 6 years ago Settings 6 years ago Tracker 5 years ago Translation 6 years ago UpdateCheck 6 years ago Updater 6 years ago Updates 6 years ago Validators 6 years ago View 6 years ago ViewDataTable 6 years ago Visualization 6 years ago Widget 6 years ago .htaccess 6 years ago Access.php 6 years ago Archive.php 6 years ago ArchiveProcessor.php 6 years ago AssetManager.php 6 years ago Auth.php 6 years ago BaseFactory.php 6 years ago Cache.php 6 years ago CacheId.php 6 years ago CliMulti.php 6 years ago Common.php 6 years ago Config.php 6 years ago Console.php 6 years ago Context.php 6 years ago Cookie.php 5 years ago CronArchive.php 5 years ago DataArray.php 6 years ago DataTable.php 6 years ago Date.php 6 years ago Db.php 6 years ago DbHelper.php 6 years ago Development.php 6 years ago DeviceDetectorFactory.php 6 years ago ErrorHandler.php 6 years ago EventDispatcher.php 6 years ago ExceptionHandler.php 6 years ago FileIntegrity.php 6 years ago Filechecks.php 6 years ago Filesystem.php 6 years ago FrontController.php 6 years ago Http.php 6 years ago IP.php 6 years ago Log.php 6 years ago LogDeleter.php 6 years ago Mail.php 6 years ago Metrics.php 6 years ago MetricsFormatter.php 6 years ago Nonce.php 5 years ago Notification.php 6 years ago NumberFormatter.php 6 years ago Option.php 5 years ago Period.php 6 years ago Piwik.php 6 years ago Plugin.php 6 years ago Profiler.php 6 years ago ProxyHeaders.php 6 years ago ProxyHttp.php 6 years ago QuickForm2.php 6 years ago RankingQuery.php 6 years ago Registry.php 6 years ago ReportRenderer.php 6 years ago ScheduledTask.php 6 years ago Segment.php 6 years ago Sequence.php 6 years ago Session.php 6 years ago SettingsPiwik.php 6 years ago SettingsServer.php 6 years ago Singleton.php 6 years ago Site.php 6 years ago TCPDF.php 6 years ago TaskScheduler.php 6 years ago Theme.php 6 years ago Timer.php 6 years ago Tracker.php 6 years ago Translate.php 6 years ago Twig.php 6 years ago Unzip.php 6 years ago UpdateCheck.php 6 years ago Updater.php 6 years ago Updates.php 6 years ago Url.php 6 years ago UrlHelper.php 6 years ago Version.php 5 years ago View.php 6 years ago bootstrap.php 6 years ago dispatch.php 6 years ago testMinimumPhpVersion.php 6 years ago
Context.php
94 lines
1 <?php
2 /**
3 * Piwik - free/libre analytics platform
4 *
5 * @link https://matomo.org
6 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
7 */
8
9 namespace Piwik;
10
11 /**
12 * Methods related to changing the context Matomo code is running in.
13 */
14 class Context
15 {
16 public static function executeWithQueryParameters(array $parametersRequest, callable $callback)
17 {
18 // Temporarily sets the Request array to this API call context
19 $saveGET = $_GET;
20 $savePOST = $_POST;
21 $saveQUERY_STRING = @$_SERVER['QUERY_STRING'];
22 foreach ($parametersRequest as $param => $value) {
23 $_GET[$param] = $value;
24 $_POST[$param] = $value;
25 }
26
27 try {
28 return $callback();
29 } finally {
30 $_GET = $saveGET;
31 $_POST = $savePOST;
32 $_SERVER['QUERY_STRING'] = $saveQUERY_STRING;
33 }
34 }
35
36 /**
37 * Temporarily overwrites the idSite parameter so all code executed by `$callback()`
38 * will use that idSite.
39 *
40 * Useful when you need to change the idSite context for a chunk of code. For example,
41 * if we are archiving for more than one site in sequence, we don't want to use
42 * the same caches for both archiving executions.
43 *
44 * @param string|int $idSite
45 * @param callable $callback
46 * @return mixed returns result of $callback
47 */
48 public static function changeIdSite($idSite, $callback)
49 {
50 // temporarily set the idSite query parameter so archiving will end up using
51 // the correct site aware caches
52 $originalGetIdSite = isset($_GET['idSite']) ? $_GET['idSite'] : null;
53 $originalPostIdSite = isset($_POST['idSite']) ? $_POST['idSite'] : null;
54
55 $originalGetIdSites = isset($_GET['idSites']) ? $_GET['idSites'] : null;
56 $originalPostIdSites = isset($_POST['idSites']) ? $_POST['idSites'] : null;
57
58 $originalTrackerGetIdSite = isset($_GET['idsite']) ? $_GET['idsite'] : null;
59 $originalTrackerPostIdSite = isset($_POST['idsite']) ? $_POST['idsite'] : null;
60
61 try {
62 $_GET['idSite'] = $_POST['idSite'] = $idSite;
63
64 if (Tracker::$initTrackerMode) {
65 $_GET['idsite'] = $_POST['idsite'] = $idSite;
66 }
67
68 // idSites is a deprecated query param that is still in use. since it is deprecated and new
69 // supported code shouldn't rely on it, we can (more) safely unset it here, since we are just
70 // calling downstream matomo code. we unset it because we don't want it interfering w/
71 // code in $callback().
72 unset($_GET['idSites']);
73 unset($_POST['idSites']);
74
75 return $callback();
76 } finally {
77 self::resetIdSiteParam($_GET, 'idSite', $originalGetIdSite);
78 self::resetIdSiteParam($_POST, 'idSite', $originalPostIdSite);
79 self::resetIdSiteParam($_GET, 'idSites', $originalGetIdSites);
80 self::resetIdSiteParam($_POST, 'idSites', $originalPostIdSites);
81 self::resetIdSiteParam($_GET, 'idsite', $originalTrackerGetIdSite);
82 self::resetIdSiteParam($_POST, 'idsite', $originalTrackerPostIdSite);
83 }
84 }
85
86 private static function resetIdSiteParam(&$superGlobal, $paramName, $originalValue)
87 {
88 if ($originalValue !== null) {
89 $superGlobal[$paramName] = $originalValue;
90 } else {
91 unset($superGlobal[$paramName]);
92 }
93 }
94 }