PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.2.0
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.2.0
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 / vendor / prefixed / symfony / http-foundation / ServerBag.php
matomo / app / vendor / prefixed / symfony / http-foundation Last commit date
Exception 2 years ago File 1 year ago RateLimiter 2 years ago Session 1 year ago Test 1 year ago AcceptHeader.php 1 year ago AcceptHeaderItem.php 2 years ago BinaryFileResponse.php 1 year ago Cookie.php 1 year ago ExpressionRequestMatcher.php 2 years ago FileBag.php 1 year ago HeaderBag.php 1 year ago HeaderUtils.php 1 year ago InputBag.php 2 years ago IpUtils.php 1 year ago JsonResponse.php 1 year ago LICENSE 2 years ago ParameterBag.php 1 year ago README.md 2 years ago RedirectResponse.php 2 years ago Request.php 1 year ago RequestMatcher.php 1 year ago RequestMatcherInterface.php 2 years ago RequestStack.php 2 years ago Response.php 1 year ago ResponseHeaderBag.php 1 year ago ServerBag.php 1 year ago StreamedResponse.php 1 year ago UrlHelper.php 2 years ago
ServerBag.php
93 lines
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11 namespace Matomo\Dependencies\Symfony\Component\HttpFoundation;
12
13 /**
14 * ServerBag is a container for HTTP headers from the $_SERVER variable.
15 *
16 * @author Fabien Potencier <fabien@symfony.com>
17 * @author Bulat Shakirzyanov <mallluhuct@gmail.com>
18 * @author Robert Kiss <kepten@gmail.com>
19 */
20 class ServerBag extends ParameterBag
21 {
22 /**
23 * Gets the HTTP headers.
24 *
25 * @return array
26 */
27 public function getHeaders()
28 {
29 $headers = [];
30 foreach ($this->parameters as $key => $value) {
31 if (str_starts_with($key, 'HTTP_')) {
32 $headers[substr($key, 5)] = $value;
33 } elseif (\in_array($key, ['CONTENT_TYPE', 'CONTENT_LENGTH', 'CONTENT_MD5'], \true) && '' !== $value) {
34 $headers[$key] = $value;
35 }
36 }
37 if (isset($this->parameters['PHP_AUTH_USER'])) {
38 $headers['PHP_AUTH_USER'] = $this->parameters['PHP_AUTH_USER'];
39 $headers['PHP_AUTH_PW'] = $this->parameters['PHP_AUTH_PW'] ?? '';
40 } else {
41 /*
42 * php-cgi under Apache does not pass HTTP Basic user/pass to PHP by default
43 * For this workaround to work, add these lines to your .htaccess file:
44 * RewriteCond %{HTTP:Authorization} .+
45 * RewriteRule ^ - [E=HTTP_AUTHORIZATION:%0]
46 *
47 * A sample .htaccess file:
48 * RewriteEngine On
49 * RewriteCond %{HTTP:Authorization} .+
50 * RewriteRule ^ - [E=HTTP_AUTHORIZATION:%0]
51 * RewriteCond %{REQUEST_FILENAME} !-f
52 * RewriteRule ^(.*)$ index.php [QSA,L]
53 */
54 $authorizationHeader = null;
55 if (isset($this->parameters['HTTP_AUTHORIZATION'])) {
56 $authorizationHeader = $this->parameters['HTTP_AUTHORIZATION'];
57 } elseif (isset($this->parameters['REDIRECT_HTTP_AUTHORIZATION'])) {
58 $authorizationHeader = $this->parameters['REDIRECT_HTTP_AUTHORIZATION'];
59 }
60 if (null !== $authorizationHeader) {
61 if (0 === stripos($authorizationHeader, 'basic ')) {
62 // Decode AUTHORIZATION header into PHP_AUTH_USER and PHP_AUTH_PW when authorization header is basic
63 $exploded = explode(':', base64_decode(substr($authorizationHeader, 6)), 2);
64 if (2 == \count($exploded)) {
65 [$headers['PHP_AUTH_USER'], $headers['PHP_AUTH_PW']] = $exploded;
66 }
67 } elseif (empty($this->parameters['PHP_AUTH_DIGEST']) && 0 === stripos($authorizationHeader, 'digest ')) {
68 // In some circumstances PHP_AUTH_DIGEST needs to be set
69 $headers['PHP_AUTH_DIGEST'] = $authorizationHeader;
70 $this->parameters['PHP_AUTH_DIGEST'] = $authorizationHeader;
71 } elseif (0 === stripos($authorizationHeader, 'bearer ')) {
72 /*
73 * XXX: Since there is no PHP_AUTH_BEARER in PHP predefined variables,
74 * I'll just set $headers['AUTHORIZATION'] here.
75 * https://php.net/reserved.variables.server
76 */
77 $headers['AUTHORIZATION'] = $authorizationHeader;
78 }
79 }
80 }
81 if (isset($headers['AUTHORIZATION'])) {
82 return $headers;
83 }
84 // PHP_AUTH_USER/PHP_AUTH_PW
85 if (isset($headers['PHP_AUTH_USER'])) {
86 $headers['AUTHORIZATION'] = 'Basic ' . base64_encode($headers['PHP_AUTH_USER'] . ':' . ($headers['PHP_AUTH_PW'] ?? ''));
87 } elseif (isset($headers['PHP_AUTH_DIGEST'])) {
88 $headers['AUTHORIZATION'] = $headers['PHP_AUTH_DIGEST'];
89 }
90 return $headers;
91 }
92 }
93