PluginProbe
HTTP Headers / trunk
HTTP Headers vtrunk
1.19.5 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.11.0 1.12.0 1.12.1 1.12.2 1.13.0 1.13.1 1.13.2 1.13.3 1.13.4 1.14.0 1.14.1 1.14.2 1.15.0 All 60 releases
http-headers / views / category.php

category.php in HTTP Headers trunk, at views/category.php

246 lines 10.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) {
3 exit;
4 }
5 include dirname(__FILE__) . '/includes/config.inc.php';
6 include dirname(__FILE__) . '/includes/breadcrumbs.inc.php';
7 ?>
8 <table class="hh-index-table">
9 <thead>
10 <tr>
11 <th><?php esc_html_e('Header', 'http-headers'); ?></th>
12 <th style="width: 45%"><?php esc_html_e('Value', 'http-headers'); ?></th>
13 <th class="hh-status"><?php esc_html_e('Status', 'http-headers'); ?></th>
14 <th></th>
15 </tr>
16 </thead>
17 <tbody>
18 <?php
19 foreach ($http_headers_headers as $http_headers_index => $http_headers_item)
20 {
21 if (!isset($_GET['category']) || $_GET['category'] != $http_headers_item[2])
22 {
23 continue;
24 }
25
26 $http_headers_key = $http_headers_item[1];
27
28 $http_headers_option = get_option($http_headers_key, 0);
29 $http_headers_isOn = (int) $http_headers_option === 1;
30 $http_headers_value = NULL;
31 if ($http_headers_isOn)
32 {
33 $http_headers_value = get_option($http_headers_key .'_value');
34 if (is_string($http_headers_value))
35 {
36 $http_headers_value = esc_html($http_headers_value);
37 }
38 switch ($http_headers_key)
39 {
40 case 'hh_age':
41 $http_headers_value = (int) $http_headers_value;
42 break;
43 case 'hh_p3p':
44 if (!empty($http_headers_value))
45 {
46 $http_headers_value = sprintf('CP="%s"', join(' ', array_keys($http_headers_value)));
47 }
48 break;
49 case 'hh_x_xxs_protection':
50 if ($http_headers_value == '1; report=') {
51 $http_headers_value .= esc_html(get_option('hh_x_xxs_protection_uri'));
52 }
53 break;
54 case 'hh_x_powered_by':
55 if (get_option('hh_x_powered_by_option') == 'unset') {
56 $http_headers_value = '[Unset]';
57 }
58 break;
59 case 'hh_x_frame_options':
60 $http_headers_value = strtoupper($http_headers_value);
61 if ($http_headers_value == 'ALLOW-FROM')
62 {
63 $http_headers_value .= ' ' . esc_html(get_option('hh_x_frame_options_domain'));
64 }
65 break;
66 case 'hh_strict_transport_security':
67 $http_headers_tmp = array();
68 $http_headers_hh_strict_transport_security_max_age = get_option('hh_strict_transport_security_max_age');
69 if ($http_headers_hh_strict_transport_security_max_age !== false)
70 {
71 $http_headers_tmp[] = sprintf('max-age=%u', $http_headers_hh_strict_transport_security_max_age);
72 if (get_option('hh_strict_transport_security_sub_domains'))
73 {
74 $http_headers_tmp[] = 'includeSubDomains';
75 }
76 if (get_option('hh_strict_transport_security_preload'))
77 {
78 $http_headers_tmp[] = 'preload';
79 }
80 } else {
81 $http_headers_tmp = array(get_option('hh_strict_transport_security_value'));
82 }
83 if (!empty($http_headers_tmp))
84 {
85 $http_headers_value = join('; ', $http_headers_tmp);
86 }
87 break;
88 case 'hh_timing_allow_origin':
89 if ($http_headers_value == 'origin')
90 {
91 $http_headers_value = esc_html(get_option('hh_timing_allow_origin_url'));
92 }
93 break;
94 case 'hh_access_control_allow_origin':
95 if ($http_headers_value == 'origin')
96 {
97 $http_headers_value = join('<br>', array_map('esc_html', get_option('hh_access_control_allow_origin_url', array())));
98 }
99 break;
100 case 'hh_access_control_expose_headers':
101 case 'hh_access_control_allow_headers':
102 case 'hh_access_control_allow_methods':
103 $http_headers_value = join(', ', array_keys($http_headers_value));
104 break;
105 case 'hh_content_security_policy':
106 $http_headers_value = http_headers_build_csp_value($http_headers_value, true);
107 if (get_option('hh_content_security_policy_report_only')) {
108 $http_headers_item[0] .= '-Report-Only';
109 }
110 break;
111 case 'hh_content_encoding':
112 $http_headers_value = !$http_headers_value ? null : join(', ', array_keys($http_headers_value));
113
114 $http_headers_ext = get_option('hh_content_encoding_ext');
115 if (!empty($http_headers_ext)) {
116 $http_headers_ext = join(', ', array_keys($http_headers_ext));
117 $http_headers_value .= (!empty($http_headers_value) ? '<br>' : null) . $http_headers_ext;
118 }
119 $http_headers_module = get_option('hh_content_encoding_module');
120 switch ($http_headers_module) {
121 case 'brotli_deflate':
122 $http_headers_enc = 'br, gzip';
123 break;
124 case 'brotli':
125 $http_headers_enc = 'br';
126 break;
127 case 'deflate':
128 default:
129 $http_headers_enc = 'gzip';
130 break;
131 }
132
133 $http_headers_value = !empty($http_headers_value) ? sprintf('%s (%s)', $http_headers_enc, $http_headers_value) : $http_headers_enc;
134 break;
135 case 'hh_vary':
136 $http_headers_value = !$http_headers_value ? null : join(', ', array_keys($http_headers_value));
137 break;
138 case 'hh_www_authenticate':
139 $http_headers_value = esc_html(get_option('hh_www_authenticate_type'));
140 break;
141 case 'hh_cache_control':
142 $http_headers_tmp = array();
143 foreach ($http_headers_value as $http_headers_k => $http_headers_v) {
144 if (in_array($http_headers_k, array('max-age', 's-maxage', 'stale-while-revalidate', 'stale-if-error'))) {
145 if (strlen($http_headers_v) > 0) {
146 $http_headers_tmp[] = sprintf("%s=%u", $http_headers_k, $http_headers_v);
147 }
148 } else {
149 $http_headers_tmp[] = $http_headers_k;
150 }
151 }
152 $http_headers_value = join(', ', $http_headers_tmp);
153 break;
154 case 'hh_expires':
155 $http_headers_tmp = array();
156 $http_headers_types = get_option('hh_expires_type', array());
157 foreach ($http_headers_types as $http_headers_type => $http_headers_whatever) {
158 list($http_headers_base, $http_headers_period, $http_headers_suffix) = explode('_', $http_headers_value[$http_headers_type]);
159 if (in_array($http_headers_base, array('access', 'modification'))) {
160 $http_headers_tmp[] = $http_headers_type != 'default'
161 ? sprintf('%s = "%s plus %u %s"', $http_headers_type, $http_headers_base, $http_headers_period, $http_headers_suffix)
162 : sprintf('default = "%s plus %u %s"', $http_headers_base, $http_headers_period, $http_headers_suffix);
163 } elseif ($http_headers_base == 'invalid') {
164 $http_headers_tmp[] = $http_headers_type != 'default'
165 ? sprintf('%s = A0', $http_headers_type)
166 : sprintf('default = A0');
167 }
168 }
169 $http_headers_value = join('<br>', $http_headers_tmp);
170 break;
171 case 'hh_cookie_security':
172 if (is_array($http_headers_value)) {
173 if (isset($http_headers_value['SameSite']) && !http_headers_is_samesite_supported()) {
174 unset($http_headers_value['SameSite']);
175 }
176 }
177 $http_headers_value = is_array($http_headers_value) && !empty($http_headers_value)
178 ? '&#10004; ' . join(' &#10004; ', array_keys($http_headers_value))
179 : NULL;
180 break;
181 case 'hh_expect_ct':
182 $http_headers_tmp = array();
183 $http_headers_tmp[] = sprintf('max-age=%u', get_option('hh_expect_ct_max_age'));
184 if (get_option('hh_expect_ct_enforce') == 1) {
185 $http_headers_tmp[] = 'enforce';
186 }
187 $http_headers_tmp[] = sprintf('report-uri="%s"', esc_html(get_option('hh_expect_ct_report_uri')));
188 $http_headers_value = join(', ', $http_headers_tmp);
189 break;
190 case 'hh_custom_headers':
191 $http_headers__names = array($http_headers_item[0]);
192 $http_headers__values = array('&nbsp;');
193 foreach ($http_headers_value['name'] as $http_headers_key => $http_headers_name)
194 {
195 if (!empty($http_headers_name) && !empty($http_headers_value['value'][$http_headers_key]))
196 {
197 $http_headers__names[] = '<p class="hh-p">&nbsp;&nbsp;&nbsp;&nbsp;'.esc_html($http_headers_name).'</p>';
198 $http_headers__values[] = '<p class="hh-p">'.esc_html($http_headers_value['value'][$http_headers_key]).'</p>';
199 }
200 }
201 $http_headers_item[0] = join('', $http_headers__names);
202 $http_headers_value = join('', $http_headers__values);
203 break;
204 case 'hh_report_to':
205 $http_headers_value = esc_html(http_headers_get_http_header('report_to'));
206 break;
207 case 'hh_nel':
208 $http_headers_value = esc_html(http_headers_get_http_header('nel'));
209 break;
210 case 'hh_feature_policy':
211 $http_headers_value = esc_html(http_headers_get_http_header('feature_policy'));
212 break;
213 case 'hh_permissions_policy':
214 $http_headers_value = esc_html(http_headers_get_http_header('permissions_policy'));
215 break;
216 case 'hh_x_robots_tag':
217 $http_headers_value = esc_html(http_headers_get_http_header('x_robots_tag'));
218 break;
219 case 'hh_clear_site_data':
220 $http_headers_value = '"' . join('", "', array_keys($http_headers_value)) . '"';
221 break;
222 case 'hh_content_type':
223 $http_headers_tmp = array();
224 foreach ($http_headers_value as $http_headers_key => $http_headers_val) {
225 $http_headers_tmp[] = sprintf(".%s => %s", $http_headers_key, $http_headers_val);
226 }
227 $http_headers_value = join("<br>", $http_headers_tmp);
228 break;
229 default:
230 $http_headers_value = !is_array($http_headers_value) ? $http_headers_value : join(', ', $http_headers_value);
231 }
232 }
233 $http_headers_status = $http_headers_isOn ? __('On', 'http-headers') : __('Off', 'http-headers');
234 ?>
235 <tr<?php echo $http_headers_isOn ? ' class="active"' : NULL; ?>>
236 <td><?php echo $http_headers_item[0]; ?></td>
237 <td><?php echo $http_headers_value; ?></td>
238 <td class="hh-status hh-status-<?php echo $http_headers_isOn ? 'on' : 'off'; ?>"><span><?php echo esc_html($http_headers_status); ?></span></td>
239 <td><a href="<?php echo esc_url(get_admin_url()); ?>options-general.php?page=http-headers&header=<?php
240 echo esc_attr($http_headers_index); ?>"><?php esc_html_e('Edit', 'http-headers'); ?></a></td>
241 </tr>
242 <?php
243 }
244 ?>
245 </tbody>
246 </table>