PluginProbe
Media Cloud Sync / 1.0.3
Media Cloud Sync v1.0.3
1.4.2 1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 All 36 releases
media-cloud-sync / includes / sdk / google / ralouphie / getallheaders / src / getallheaders.php

getallheaders.php in Media Cloud Sync 1.0.3, at includes/sdk/google/ralouphie/getallheaders/src/getallheaders.php

39 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Dudlewebs\WPMCS;
4
5 if (!\function_exists('getallheaders') && !\function_exists('Dudlewebs\WPMCS\getallheaders')) {
6 /**
7 * Get all HTTP header key/values as an associative array for the current request.
8 *
9 * @return string[string] The HTTP header key/value pairs.
10 */
11 function getallheaders()
12 {
13 $headers = array();
14 $copy_server = array('CONTENT_TYPE' => 'Content-Type', 'CONTENT_LENGTH' => 'Content-Length', 'CONTENT_MD5' => 'Content-Md5');
15 foreach ($_SERVER as $key => $value) {
16 if (\substr($key, 0, 5) === 'HTTP_') {
17 $key = \substr($key, 5);
18 if (!isset($copy_server[$key]) || !isset($_SERVER[$key])) {
19 $key = \str_replace(' ', '-', \ucwords(\strtolower(\str_replace('_', ' ', $key))));
20 $headers[$key] = $value;
21 }
22 } elseif (isset($copy_server[$key])) {
23 $headers[$copy_server[$key]] = $value;
24 }
25 }
26 if (!isset($headers['Authorization'])) {
27 if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) {
28 $headers['Authorization'] = $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];
29 } elseif (isset($_SERVER['PHP_AUTH_USER'])) {
30 $basic_pass = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : '';
31 $headers['Authorization'] = 'Basic ' . \base64_encode($_SERVER['PHP_AUTH_USER'] . ':' . $basic_pass);
32 } elseif (isset($_SERVER['PHP_AUTH_DIGEST'])) {
33 $headers['Authorization'] = $_SERVER['PHP_AUTH_DIGEST'];
34 }
35 }
36 return $headers;
37 }
38 }
39