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

270 lines 8.9 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 $value = !empty($value) ? sprintf('gzip (%s)', $value) : 'gzip';
140 break;
141 case 'hh_vary':
142 $value = !$value ? null : join(', ', array_keys($value));
143 break;
144 case 'hh_www_authenticate':
145 $value = get_option('hh_www_authenticate_type');
146 break;
147 case 'hh_cache_control':
148 $tmp = array();
149 foreach ($value as $k => $v) {
150 if (in_array($k, array('max-age', 's-maxage'))) {
151 if (strlen($v) > 0) {
152 $tmp[] = sprintf("%s=%u", $k, $v);
153 }
154 } else {
155 $tmp[] = $k;
156 }
157 }
158 $value = join(', ', $tmp);
159 break;
160 case 'hh_expires':
161 $tmp = array();
162 $types = get_option('hh_expires_type', array());
163 foreach ($types as $type => $whatever) {
164 list($base, $period, $suffix) = explode('_', $value[$type]);
165 if (in_array($base, array('access', 'modification'))) {
166 $tmp[] = $type != 'default'
167 ? sprintf('%s = "%s plus %u %s"', $type, $base, $period, $suffix)
168 : sprintf('default = "%s plus %u %s"', $base, $period, $suffix);
169 } elseif ($base == 'invalid') {
170 $tmp[] = $type != 'default'
171 ? sprintf('%s = A0', $type)
172 : sprintf('default = A0');
173 }
174 }
175 $value = join('<br>', $tmp);
176 break;
177 case 'hh_cookie_security':
178 if (is_array($value)) {
179 if (isset($value['SameSite']) && !is_samesite_supported()) {
180 unset($value['SameSite']);
181 }
182 }
183 $value = is_array($value) && !empty($value)
184 ? '&#10004; ' . join(' &#10004; ', array_keys($value))
185 : NULL;
186 break;
187 case 'hh_expect_ct':
188 $tmp = array();
189 $tmp[] = sprintf('max-age=%u', get_option('hh_expect_ct_max_age'));
190 if (get_option('hh_expect_ct_enforce') == 1) {
191 $tmp[] = 'enforce';
192 }
193 $tmp[] = sprintf('report-uri="%s"', get_option('hh_expect_ct_report_uri'));
194 $value = join(', ', $tmp);
195 break;
196 case 'hh_custom_headers':
197 $_names = array($item[0]);
198 $_values = array('&nbsp;');
199 foreach ($value['name'] as $key => $name)
200 {
201 if (!empty($name) && !empty($value['value'][$key]))
202 {
203 $_names[] = '<p class="hh-p">&nbsp;&nbsp;&nbsp;&nbsp;'.$name.'</p>';
204 $_values[] = '<p class="hh-p">'.$value['value'][$key].'</p>';
205 }
206 }
207 $item[0] = join('', $_names);
208 $value = join('', $_values);
209 break;
210 case 'hh_report_to':
211 $tmp = array();
212 foreach ($value as $a_item)
213 {
214 $tmp[] = sprintf('{"url": "%s", "group": "%s", "max-age": %u%s}',
215 $a_item['url'], $a_item['group'], $a_item['max-age'], isset($a_item['includeSubDomains']) ? ', includeSubDomains' : NULL);
216 }
217 $value = join(', ', $tmp);
218 break;
219 case 'hh_feature_policy':
220 $fp = array();
221 $features = get_option('hh_feature_policy_feature');
222 if (!$features)
223 {
224 $features = array();
225 }
226 $origins = get_option('hh_feature_policy_origin');
227 foreach ($features as $key => $whatever)
228 {
229 switch ($value[$key])
230 {
231 case '*':
232 case "'none'":
233 $fp[] = sprintf("%s %s", $key, $value[$key]);
234 break;
235 case "'self'":
236 $fp[] = sprintf("%s %s%s", $key, $value[$key], !empty($origins[$key]) ? " " . $origins[$key] : NULL);
237 break;
238 case 'origin(s)':
239 $fp[] = sprintf("%s %s", $key, $origins[$key]);
240 break;
241 }
242 }
243 if (!empty($fp))
244 {
245 $value = join('; ', $fp);
246 } else {
247 $value = "";
248 }
249 break;
250 case 'hh_clear_site_data':
251 $value = '"' . join('", "', array_keys($value)) . '"';
252 break;
253 default:
254 $value = !is_array($value) ? $value : join(', ', $value);
255 }
256 }
257 $status = $isOn ? __('On', 'http-headers') : __('Off', 'http-headers');
258 ?>
259 <tr<?php echo $isOn ? ' class="active"' : NULL; ?>>
260 <td><?php echo $item[0]; ?></td>
261 <td><?php echo $value; ?></td>
262 <td class="hh-status hh-status-<?php echo $isOn ? 'on' : 'off'; ?>"><span><?php echo $status; ?></span></td>
263 <td><a href="<?php echo get_admin_url(); ?>options-general.php?page=http-headers&header=<?php
264 echo $index; ?>"><?php _e('Edit', 'http-headers'); ?></a></td>
265 </tr>
266 <?php
267 }
268 ?>
269 </tbody>
270 </table>