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

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