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 / report-to.php

report-to.php in HTTP Headers trunk, at views/report-to.php

177 lines 10.1 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 ?>
6 <tr valign="top">
7 <th scope="row">Report-To
8 <p class="description"><?php esc_html_e('The Report-To HTTP response header field instructs the user agent to store reporting endpoints for an origin.', 'http-headers'); ?></p>
9 </th>
10 <td>
11 <fieldset>
12 <legend class="screen-reader-text">Report-To</legend>
13 <?php
14 $http_headers_report_to = get_option('hh_report_to', 0);
15 foreach ($http_headers_bools as $http_headers_k => $http_headers_v)
16 {
17 ?><p><label><input type="radio" class="http-header" name="hh_report_to" value="<?php echo esc_attr($http_headers_k); ?>"<?php checked($http_headers_report_to, $http_headers_k, true); ?> /> <?php echo esc_html($http_headers_v); ?></label></p><?php
18 }
19 ?>
20 </fieldset>
21 <?php settings_fields( 'http-headers-rt' ); ?>
22 <?php do_settings_sections( 'http-headers-rt' ); ?>
23 </td>
24 </tr>
25 <?php
26 $http_headers_default_value = array(
27 array(
28 'endpoints' => array(),
29 'group' => '',
30 'max_age' => '',
31 )
32 );
33 $http_headers_report_to_value = get_option('hh_report_to_value');
34 if (!is_array($http_headers_report_to_value) || empty($http_headers_report_to_value))
35 {
36 $http_headers_report_to_value = $http_headers_default_value;
37 }
38 ?>
39 <tr>
40 <td colspan="2">
41 <div style="max-width: 1024px; overflow-x: auto">
42 <table class="hh-bordered hh-p-sm">
43 <tr>
44 <th rowspan="2" class="hh-center hh-middle">group</th>
45 <th rowspan="2" class="hh-center hh-middle">max_age</th>
46 <th rowspan="2" class="hh-center hh-middle">include_subdomains</th>
47 <th colspan="3" class="hh-center">endpoints</th>
48 <th>&nbsp;</th>
49 <th>&nbsp;</th>
50 </tr>
51 <tr>
52 <th class="hh-center">url</th>
53 <th class="hh-center">priority</th>
54 <th class="hh-center">weight</th>
55 <th>&nbsp;</th>
56 <th>&nbsp;</th>
57 </tr>
58 <?php
59 $http_headers_items = array('0' => '0 (Delete entire reporting cache)', '3600' => '1 hour', '86400' => '1 day', '604800' => '7 days', '2592000' => '30 days', '5184000' => '60 days', '7776000' => '90 days', '31536000' => '1 year', '63072000' => '2 years');
60 $http_headers_i = 0;
61 foreach ($http_headers_report_to_value as $http_headers_item)
62 {
63 if (isset($http_headers_item['endpoints']) && !empty($http_headers_item['endpoints']))
64 {
65 $http_headers_cnt = count($http_headers_item['endpoints']);
66 $http_headers_c = 0;
67 foreach ($http_headers_item['endpoints'] as $http_headers_k => $http_headers_v)
68 {
69 $http_headers_classes = array();
70 if ($http_headers_c == 0)
71 {
72 if ($http_headers_i == 0)
73 {
74 $http_headers_classes[] = 'hh-tr-first';
75 }
76 $http_headers_classes[] = 'hh-tr-group-start';
77 }
78
79 if ($http_headers_c == $http_headers_cnt - 1)
80 {
81 $http_headers_classes[] = 'hh-tr-group-end';
82 }
83 ?>
84 <tr class="<?php echo esc_attr(join(' ', $http_headers_classes)); ?>">
85 <?php
86 if ($http_headers_c == 0)
87 {
88 ?>
89 <td rowspan="<?php echo esc_attr($http_headers_cnt); ?>" class="hh-middle"><input type="text" class="http-header-value" name="hh_report_to_value[<?php echo esc_attr($http_headers_i); ?>][group]" value="<?php echo esc_attr($http_headers_item['group']); ?>" placeholder="csp-endpoint"<?php echo $http_headers_report_to == 1 ? NULL : ' readonly'; ?>></td>
90 <td rowspan="<?php echo esc_attr($http_headers_cnt); ?>" class="hh-middle"><select class="http-header-value" name="hh_report_to_value[<?php echo esc_attr($http_headers_i); ?>][max_age]"<?php echo $http_headers_report_to == 1 ? NULL : ' readonly'; ?>>
91 <?php
92 foreach ($http_headers_items as $http_headers_key => $http_headers_val) {
93 ?><option value="<?php echo esc_attr($http_headers_key); ?>"<?php selected($http_headers_item['max_age'], $http_headers_key); ?>><?php echo esc_html($http_headers_val); ?></option><?php
94 }
95 ?>
96 </select></td>
97 <td rowspan="<?php echo esc_attr($http_headers_cnt); ?>" class="hh-middle hh-center"><input type="checkbox" class="http-header-value" name="hh_report_to_value[<?php echo esc_attr($http_headers_i); ?>][include_subdomains]" value="1"<?php array_key_exists('include_subdomains', $http_headers_item) ? checked($http_headers_item['include_subdomains'], 1, true) : NULL; ?><?php echo $http_headers_report_to == 1 ? NULL : ' readonly'; ?> /></td>
98 <?php
99 }
100 ?>
101
102 <td><input type="text" class="http-header-value" name="hh_report_to_value[<?php echo esc_attr($http_headers_i); ?>][endpoints][<?php echo esc_attr($http_headers_k); ?>][url]" value="<?php echo esc_attr($http_headers_v['url']); ?>" placeholder="https://example.com/report/csp"<?php echo $http_headers_report_to == 1 ? NULL : ' readonly'; ?> size="40"></td>
103 <td><input type="number" class="http-header-value" name="hh_report_to_value[<?php echo esc_attr($http_headers_i); ?>][endpoints][<?php echo esc_attr($http_headers_k); ?>][priority]" value="<?php echo esc_attr($http_headers_v['priority']); ?>" min="0" step="1"></td>
104 <td><input type="number" class="http-header-value" name="hh_report_to_value[<?php echo esc_attr($http_headers_i); ?>][endpoints][<?php echo esc_attr($http_headers_k); ?>][weight]" value="<?php echo esc_attr($http_headers_v['weight']); ?>" min="0" step="1"></td>
105
106 <td><?php
107 if ($http_headers_c == 0)
108 {
109 ?>
110 <button type="button" class="button hh-btn-add-endpoint"><?php esc_html_e('Add endpoint', 'http-headers'); ?></button>
111 <?php
112 } else {
113 ?>
114 <button type="button" class="button hh-btn-delete-endpoint"><?php esc_html_e('Remove endpoint', 'http-headers'); ?></button>
115 <?php
116 }
117 ?></td>
118 <?php
119 if ($http_headers_c == 0)
120 {
121 ?>
122 <td rowspan="<?php echo esc_attr($http_headers_cnt); ?>" class="hh-middle hh-center"><?php
123 if ($http_headers_i > 0)
124 {
125 ?>
126 <button type="button" class="button hh-btn-delete-endpoint-group" title="<?php esc_attr_e('Delete', 'http-headers'); ?>"><?php esc_html_e('Remove group', 'http-headers'); ?></button>
127 <?php
128 }
129 ?></td>
130 <?php
131 }
132 ?>
133 </tr>
134 <?php
135 $http_headers_c += 1;
136 }
137 } else {
138 ?>
139 <tr class="hh-tr-first hh-tr-group-start hh-tr-group-end">
140 <td><input type="text" class="http-header-value" name="hh_report_to_value[<?php echo esc_attr($http_headers_i); ?>][group]" value="<?php echo esc_attr($http_headers_item['group']); ?>" placeholder="csp-endpoint"<?php echo $http_headers_report_to == 1 ? NULL : ' readonly'; ?>></td>
141 <td><select class="http-header-value" name="hh_report_to_value[<?php echo esc_attr($http_headers_i); ?>][max_age]"<?php echo $http_headers_report_to == 1 ? NULL : ' readonly'; ?>>
142 <?php
143 foreach ($http_headers_items as $http_headers_key => $http_headers_val) {
144 ?><option value="<?php echo esc_attr($http_headers_key); ?>"<?php selected($http_headers_item['max_age'], $http_headers_key); ?>><?php echo esc_html($http_headers_val); ?></option><?php
145 }
146 ?>
147 </select></td>
148 <td class="hh-center"><input type="checkbox" class="http-header-value" name="hh_report_to_value[<?php echo esc_attr($http_headers_i); ?>][include_subdomains]" value="1"<?php array_key_exists('include_subdomains', $http_headers_item) ? checked($http_headers_item['include_subdomains'], 1, true) : NULL; ?><?php echo $http_headers_report_to == 1 ? NULL : ' readonly'; ?> /></td>
149
150 <td><input type="text" class="http-header-value" name="hh_report_to_value[<?php echo esc_attr($http_headers_i); ?>][endpoints][0][url]" placeholder="https://example.com/report/csp"<?php echo $http_headers_report_to == 1 ? NULL : ' readonly'; ?> size="40"></td>
151 <td><input type="number" class="http-header-value" name="hh_report_to_value[<?php echo esc_attr($http_headers_i); ?>][endpoints][0][priority]" min="0" step="1"></td>
152 <td><input type="number" class="http-header-value" name="hh_report_to_value[<?php echo esc_attr($http_headers_i); ?>][endpoints][0][weight]" min="0" step="1"></td>
153
154 <td>
155 <button type="button" class="button hh-btn-add-endpoint"><?php esc_html_e('Add endpoint', 'http-headers'); ?></button>
156 </td>
157 <td rowspan="1"><?php
158 if ($http_headers_i > 0)
159 {
160 ?><button type="button" class="button hh-btn-delete-endpoint-group" title="<?php esc_attr_e('Delete', 'http-headers'); ?>"><?php esc_html_e('Remove group', 'http-headers'); ?></button><?php
161 }
162 ?></td>
163 </tr>
164 <?php
165 }
166 $http_headers_i += 1;
167 }
168 ?>
169 <tr>
170 <td colspan="8">
171 <button type="button" class="button" id="hh-btn-add-endpoint-group">+ <?php esc_html_e('Add endpoint group', 'http-headers'); ?></button>
172 </td>
173 </tr>
174 </table>
175 </div>
176 </td>
177 </tr>