PluginProbe
HTTP Headers / 1.14.1
HTTP Headers v1.14.1
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 1.14.1, at views/category.php

291 lines 9.6 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 _e('Header', 'http-headers'); ?></th>
12 <th style="width: 45%"><?php _e('Value', 'http-headers'); ?></th>
13 <th class="hh-status"><?php _e('Status', 'http-headers'); ?></th>
14 <th></th>
15 </tr>
16 </thead>
17 <tbody>
18 <?php
19 foreach ($headers as $index => $item)
20 {
21 if (@$_GET['category'] != $item[2])
22 {
23 continue;
24 }
25
26 $key = $item[1];
27
28 $option = get_option($key, 0);
29 $isOn = (int) $option === 1;
30 $value = NULL;
31 if ($isOn)
32 {
33 $value = get_option($key .'_value');
34 switch ($key)
35 {
36 case 'hh_age':
37 $value = (int) $value;
38 break;
39 case 'hh_p3p':
40 if (!empty($value))
41 {
42 $value = sprintf('CP="%s"', join(' ', array_keys($value)));
43 }
44 break;
45 case 'hh_x_xxs_protection':
46 if ($value == '1; report=') {
47 $value .= get_option('hh_x_xxs_protection_uri');
48 }
49 break;
50 case 'hh_x_powered_by':
51 if (get_option('hh_x_powered_by_option') == 'unset') {
52 $value = '[Unset]';
53 }
54 break;
55 case 'hh_x_frame_options':
56 $value = strtoupper($value);
57 if ($value == 'ALLOW-FROM')
58 {
59 $value .= ' ' . get_option('hh_x_frame_options_domain');
60 }
61 break;
62 case 'hh_strict_transport_security':
63 $tmp = array();
64 $hh_strict_transport_security_max_age = get_option('hh_strict_transport_security_max_age');
65 if ($hh_strict_transport_security_max_age !== false)
66 {
67 $tmp[] = sprintf('max-age=%u', $hh_strict_transport_security_max_age);
68 if (get_option('hh_strict_transport_security_sub_domains'))
69 {
70 $tmp[] = 'includeSubDomains';
71 }
72 if (get_option('hh_strict_transport_security_preload'))
73 {
74 $tmp[] = 'preload';
75 }
76 } else {
77 $tmp = array(get_option('hh_strict_transport_security_value'));
78 }
79 if (!empty($tmp))
80 {
81 $value = join('; ', $tmp);
82 }
83 break;
84 case 'hh_public_key_pins':
85 $public_key_pins_sha256_1 = get_option('hh_public_key_pins_sha256_1');
86 $public_key_pins_sha256_2 = get_option('hh_public_key_pins_sha256_2');
87 $public_key_pins_max_age = get_option('hh_public_key_pins_max_age');
88 $public_key_pins_sub_domains = get_option('hh_public_key_pins_sub_domains');
89 $public_key_pins_report_uri = get_option('hh_public_key_pins_report_uri');
90 if (!empty($public_key_pins_sha256_1) && !empty($public_key_pins_sha256_2) && !empty($public_key_pins_max_age)) {
91
92 $public_key_pins = array();
93 $public_key_pins[] = sprintf('pin-sha256="%s"', $public_key_pins_sha256_1);
94 $public_key_pins[] = sprintf('pin-sha256="%s"', $public_key_pins_sha256_2);
95 $public_key_pins[] = sprintf("max-age=%u", $public_key_pins_max_age);
96 if ($public_key_pins_sub_domains) {
97 $public_key_pins[] = "includeSubDomains";
98 }
99 if (!empty($public_key_pins_report_uri)) {
100 $public_key_pins[] = sprintf('report-uri="%s"', $public_key_pins_report_uri);
101 }
102 $value = join('; ', $public_key_pins);
103 if (get_option('hh_public_key_pins_report_only')) {
104 $item[0] .= '-Report-Only';
105 }
106 }
107 break;
108 case 'hh_timing_allow_origin':
109 if ($value == 'origin')
110 {
111 $value = get_option('hh_timing_allow_origin_url');
112 }
113 break;
114 case 'hh_access_control_allow_origin':
115 if ($value == 'origin')
116 {
117 $value = join('<br>', get_option('hh_access_control_allow_origin_url', array()));
118 }
119 break;
120 case 'hh_access_control_expose_headers':
121 case 'hh_access_control_allow_headers':
122 case 'hh_access_control_allow_methods':
123 $value = join(', ', array_keys($value));
124 break;
125 case 'hh_content_security_policy':
126 $value = build_csp_value($value);
127 if (get_option('hh_content_security_policy_report_only')) {
128 $item[0] .= '-Report-Only';
129 }
130 break;
131 case 'hh_content_encoding':
132 $value = !$value ? null : join(', ', array_keys($value));
133
134 $ext = get_option('hh_content_encoding_ext');
135 if (!empty($ext)) {
136 $ext = join(', ', array_keys($ext));
137 $value .= (!empty($value) ? '<br>' : null) . $ext;
138 }
139 $module = get_option('hh_content_encoding_module');
140 switch ($module) {
141 case 'brotli_deflate':
142 $enc = 'br, gzip';
143 break;
144 case 'brotli':
145 $enc = 'br';
146 break;
147 case 'deflate':
148 default:
149 $enc = 'gzip';
150 break;
151 }
152
153 $value = !empty($value) ? sprintf('%s (%s)', $enc, $value) : $enc;
154 break;
155 case 'hh_vary':
156 $value = !$value ? null : join(', ', array_keys($value));
157 break;
158 case 'hh_www_authenticate':
159 $value = get_option('hh_www_authenticate_type');
160 break;
161 case 'hh_cache_control':
162 $tmp = array();
163 foreach ($value as $k => $v) {
164 if (in_array($k, array('max-age', 's-maxage', 'stale-while-revalidate', 'stale-if-error'))) {
165 if (strlen($v) > 0) {
166 $tmp[] = sprintf("%s=%u", $k, $v);
167 }
168 } else {
169 $tmp[] = $k;
170 }
171 }
172 $value = join(', ', $tmp);
173 break;
174 case 'hh_expires':
175 $tmp = array();
176 $types = get_option('hh_expires_type', array());
177 foreach ($types as $type => $whatever) {
178 list($base, $period, $suffix) = explode('_', $value[$type]);
179 if (in_array($base, array('access', 'modification'))) {
180 $tmp[] = $type != 'default'
181 ? sprintf('%s = "%s plus %u %s"', $type, $base, $period, $suffix)
182 : sprintf('default = "%s plus %u %s"', $base, $period, $suffix);
183 } elseif ($base == 'invalid') {
184 $tmp[] = $type != 'default'
185 ? sprintf('%s = A0', $type)
186 : sprintf('default = A0');
187 }
188 }
189 $value = join('<br>', $tmp);
190 break;
191 case 'hh_cookie_security':
192 if (is_array($value)) {
193 if (isset($value['SameSite']) && !is_samesite_supported()) {
194 unset($value['SameSite']);
195 }
196 }
197 $value = is_array($value) && !empty($value)
198 ? '&#10004; ' . join(' &#10004; ', array_keys($value))
199 : NULL;
200 break;
201 case 'hh_expect_ct':
202 $tmp = array();
203 $tmp[] = sprintf('max-age=%u', get_option('hh_expect_ct_max_age'));
204 if (get_option('hh_expect_ct_enforce') == 1) {
205 $tmp[] = 'enforce';
206 }
207 $tmp[] = sprintf('report-uri="%s"', get_option('hh_expect_ct_report_uri'));
208 $value = join(', ', $tmp);
209 break;
210 case 'hh_custom_headers':
211 $_names = array($item[0]);
212 $_values = array('&nbsp;');
213 foreach ($value['name'] as $key => $name)
214 {
215 if (!empty($name) && !empty($value['value'][$key]))
216 {
217 $_names[] = '<p class="hh-p">&nbsp;&nbsp;&nbsp;&nbsp;'.$name.'</p>';
218 $_values[] = '<p class="hh-p">'.$value['value'][$key].'</p>';
219 }
220 }
221 $item[0] = join('', $_names);
222 $value = join('', $_values);
223 break;
224 case 'hh_report_to':
225 $tmp = array();
226 foreach ($value as $a_item)
227 {
228 $tmp[] = sprintf('{"url": "%s", "group": "%s", "max-age": %u%s}',
229 $a_item['url'], $a_item['group'], $a_item['max-age'], isset($a_item['includeSubDomains']) ? ', includeSubDomains' : NULL);
230 }
231 $value = join(', ', $tmp);
232 break;
233 case 'hh_feature_policy':
234 $fp = array();
235 $features = get_option('hh_feature_policy_feature');
236 if (!$features)
237 {
238 $features = array();
239 }
240 $origins = get_option('hh_feature_policy_origin');
241 foreach ($features as $key => $whatever)
242 {
243 switch ($value[$key])
244 {
245 case '*':
246 case "'none'":
247 $fp[] = sprintf("%s %s", $key, $value[$key]);
248 break;
249 case "'self'":
250 $fp[] = sprintf("%s %s%s", $key, $value[$key], !empty($origins[$key]) ? " " . $origins[$key] : NULL);
251 break;
252 case 'origin(s)':
253 $fp[] = sprintf("%s %s", $key, $origins[$key]);
254 break;
255 }
256 }
257 if (!empty($fp))
258 {
259 $value = join('; ', $fp);
260 } else {
261 $value = "";
262 }
263 break;
264 case 'hh_clear_site_data':
265 $value = '"' . join('", "', array_keys($value)) . '"';
266 break;
267 case 'hh_content_type':
268 $tmp = array();
269 foreach ($value as $key => $val) {
270 $tmp[] = sprintf(".%s => %s", $key, $val);
271 }
272 $value = join("<br>", $tmp);
273 break;
274 default:
275 $value = !is_array($value) ? $value : join(', ', $value);
276 }
277 }
278 $status = $isOn ? __('On', 'http-headers') : __('Off', 'http-headers');
279 ?>
280 <tr<?php echo $isOn ? ' class="active"' : NULL; ?>>
281 <td><?php echo $item[0]; ?></td>
282 <td><?php echo $value; ?></td>
283 <td class="hh-status hh-status-<?php echo $isOn ? 'on' : 'off'; ?>"><span><?php echo $status; ?></span></td>
284 <td><a href="<?php echo get_admin_url(); ?>options-general.php?page=http-headers&header=<?php
285 echo $index; ?>"><?php _e('Edit', 'http-headers'); ?></a></td>
286 </tr>
287 <?php
288 }
289 ?>
290 </tbody>
291 </table>