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

267 lines 8.4 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_timing_allow_origin':
85 if ($value == 'origin')
86 {
87 $value = get_option('hh_timing_allow_origin_url');
88 }
89 break;
90 case 'hh_access_control_allow_origin':
91 if ($value == 'origin')
92 {
93 $value = join('<br>', get_option('hh_access_control_allow_origin_url', array()));
94 }
95 break;
96 case 'hh_access_control_expose_headers':
97 case 'hh_access_control_allow_headers':
98 case 'hh_access_control_allow_methods':
99 $value = join(', ', array_keys($value));
100 break;
101 case 'hh_content_security_policy':
102 $value = build_csp_value($value);
103 if (get_option('hh_content_security_policy_report_only')) {
104 $item[0] .= '-Report-Only';
105 }
106 break;
107 case 'hh_content_encoding':
108 $value = !$value ? null : join(', ', array_keys($value));
109
110 $ext = get_option('hh_content_encoding_ext');
111 if (!empty($ext)) {
112 $ext = join(', ', array_keys($ext));
113 $value .= (!empty($value) ? '<br>' : null) . $ext;
114 }
115 $module = get_option('hh_content_encoding_module');
116 switch ($module) {
117 case 'brotli_deflate':
118 $enc = 'br, gzip';
119 break;
120 case 'brotli':
121 $enc = 'br';
122 break;
123 case 'deflate':
124 default:
125 $enc = 'gzip';
126 break;
127 }
128
129 $value = !empty($value) ? sprintf('%s (%s)', $enc, $value) : $enc;
130 break;
131 case 'hh_vary':
132 $value = !$value ? null : join(', ', array_keys($value));
133 break;
134 case 'hh_www_authenticate':
135 $value = get_option('hh_www_authenticate_type');
136 break;
137 case 'hh_cache_control':
138 $tmp = array();
139 foreach ($value as $k => $v) {
140 if (in_array($k, array('max-age', 's-maxage', 'stale-while-revalidate', 'stale-if-error'))) {
141 if (strlen($v) > 0) {
142 $tmp[] = sprintf("%s=%u", $k, $v);
143 }
144 } else {
145 $tmp[] = $k;
146 }
147 }
148 $value = join(', ', $tmp);
149 break;
150 case 'hh_expires':
151 $tmp = array();
152 $types = get_option('hh_expires_type', array());
153 foreach ($types as $type => $whatever) {
154 list($base, $period, $suffix) = explode('_', $value[$type]);
155 if (in_array($base, array('access', 'modification'))) {
156 $tmp[] = $type != 'default'
157 ? sprintf('%s = "%s plus %u %s"', $type, $base, $period, $suffix)
158 : sprintf('default = "%s plus %u %s"', $base, $period, $suffix);
159 } elseif ($base == 'invalid') {
160 $tmp[] = $type != 'default'
161 ? sprintf('%s = A0', $type)
162 : sprintf('default = A0');
163 }
164 }
165 $value = join('<br>', $tmp);
166 break;
167 case 'hh_cookie_security':
168 if (is_array($value)) {
169 if (isset($value['SameSite']) && !is_samesite_supported()) {
170 unset($value['SameSite']);
171 }
172 }
173 $value = is_array($value) && !empty($value)
174 ? '&#10004; ' . join(' &#10004; ', array_keys($value))
175 : NULL;
176 break;
177 case 'hh_expect_ct':
178 $tmp = array();
179 $tmp[] = sprintf('max-age=%u', get_option('hh_expect_ct_max_age'));
180 if (get_option('hh_expect_ct_enforce') == 1) {
181 $tmp[] = 'enforce';
182 }
183 $tmp[] = sprintf('report-uri="%s"', get_option('hh_expect_ct_report_uri'));
184 $value = join(', ', $tmp);
185 break;
186 case 'hh_custom_headers':
187 $_names = array($item[0]);
188 $_values = array('&nbsp;');
189 foreach ($value['name'] as $key => $name)
190 {
191 if (!empty($name) && !empty($value['value'][$key]))
192 {
193 $_names[] = '<p class="hh-p">&nbsp;&nbsp;&nbsp;&nbsp;'.$name.'</p>';
194 $_values[] = '<p class="hh-p">'.$value['value'][$key].'</p>';
195 }
196 }
197 $item[0] = join('', $_names);
198 $value = join('', $_values);
199 break;
200 case 'hh_report_to':
201 $tmp = array();
202 foreach ($value as $a_item)
203 {
204 $tmp[] = sprintf('{"url": "%s", "group": "%s", "max-age": %u%s}',
205 $a_item['url'], $a_item['group'], $a_item['max-age'], isset($a_item['includeSubDomains']) ? ', includeSubDomains' : NULL);
206 }
207 $value = join(', ', $tmp);
208 break;
209 case 'hh_feature_policy':
210 $fp = array();
211 $features = get_option('hh_feature_policy_feature');
212 if (!$features)
213 {
214 $features = array();
215 }
216 $origins = get_option('hh_feature_policy_origin');
217 foreach ($features as $key => $whatever)
218 {
219 switch ($value[$key])
220 {
221 case '*':
222 case "'none'":
223 $fp[] = sprintf("%s %s", $key, $value[$key]);
224 break;
225 case "'self'":
226 $fp[] = sprintf("%s %s%s", $key, $value[$key], !empty($origins[$key]) ? " " . $origins[$key] : NULL);
227 break;
228 case 'origin(s)':
229 $fp[] = sprintf("%s %s", $key, $origins[$key]);
230 break;
231 }
232 }
233 if (!empty($fp))
234 {
235 $value = join('; ', $fp);
236 } else {
237 $value = "";
238 }
239 break;
240 case 'hh_clear_site_data':
241 $value = '"' . join('", "', array_keys($value)) . '"';
242 break;
243 case 'hh_content_type':
244 $tmp = array();
245 foreach ($value as $key => $val) {
246 $tmp[] = sprintf(".%s => %s", $key, $val);
247 }
248 $value = join("<br>", $tmp);
249 break;
250 default:
251 $value = !is_array($value) ? $value : join(', ', $value);
252 }
253 }
254 $status = $isOn ? __('On', 'http-headers') : __('Off', 'http-headers');
255 ?>
256 <tr<?php echo $isOn ? ' class="active"' : NULL; ?>>
257 <td><?php echo $item[0]; ?></td>
258 <td><?php echo $value; ?></td>
259 <td class="hh-status hh-status-<?php echo $isOn ? 'on' : 'off'; ?>"><span><?php echo $status; ?></span></td>
260 <td><a href="<?php echo get_admin_url(); ?>options-general.php?page=http-headers&header=<?php
261 echo $index; ?>"><?php _e('Edit', 'http-headers'); ?></a></td>
262 </tr>
263 <?php
264 }
265 ?>
266 </tbody>
267 </table>