PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-beta
Jetpack – WP Security, Backup, Speed, & Growth v16.3-beta
16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 All 507 releases
← All changes | jetpack_vendor/automattic/jetpack-waf/src/functions.php +48 -0 13.6.2 → 16.3-beta View file →
@@ -69,4 +69,52 @@
69 69 }
70 70 }
71 71 return $return;
72 72 }
73 +
74 +/**
75 + * Polyfill for getallheaders, which is not available in all PHP environments.
76 + *
77 + * @link https://github.com/ralouphie/getallheaders
78 + */
79 +if ( ! function_exists( 'getallheaders' ) ) {
80 + /**
81 + * Get all HTTP header key/values as an associative array for the current request.
82 + *
83 + * @return array The HTTP header key/value pairs.
84 + */
85 + function getallheaders() {
86 + // phpcs:disable WordPress.Security.ValidatedSanitizedInput
87 + $headers = array();
88 +
89 + $copy_server = array(
90 + 'CONTENT_TYPE' => 'Content-Type',
91 + 'CONTENT_LENGTH' => 'Content-Length',
92 + 'CONTENT_MD5' => 'Content-Md5',
93 + );
94 +
95 + foreach ( $_SERVER as $key => $value ) {
96 + if ( substr( $key, 0, 5 ) === 'HTTP_' ) {
97 + $key = substr( $key, 5 );
98 + if ( ! isset( $copy_server[ $key ] ) || ! isset( $_SERVER[ $key ] ) ) {
99 + $key = str_replace( ' ', '-', ucwords( strtolower( str_replace( '_', ' ', $key ) ) ) );
100 + $headers[ $key ] = $value;
101 + }
102 + } elseif ( isset( $copy_server[ $key ] ) ) {
103 + $headers[ $copy_server[ $key ] ] = $value;
104 + }
105 + }
106 +
107 + if ( ! isset( $headers['Authorization'] ) ) {
108 + if ( isset( $_SERVER['REDIRECT_HTTP_AUTHORIZATION'] ) ) {
109 + $headers['Authorization'] = $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];
110 + } elseif ( isset( $_SERVER['PHP_AUTH_USER'] ) ) {
111 + $basic_pass = $_SERVER['PHP_AUTH_PW'] ?? '';
112 + $headers['Authorization'] = 'Basic ' . base64_encode( $_SERVER['PHP_AUTH_USER'] . ':' . $basic_pass );
113 + } elseif ( isset( $_SERVER['PHP_AUTH_DIGEST'] ) ) {
114 + $headers['Authorization'] = $_SERVER['PHP_AUTH_DIGEST'];
115 + }
116 + }
117 +
118 + return $headers;
119 + }
120 +}