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 / includes / csp-src.inc.php

csp-src.inc.php in HTTP Headers trunk, at views/includes/csp-src.inc.php

90 lines 3.3 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 $http_headers_origins = array(
6 'wildcard' => '*',
7 'self' => "'self'",
8 'none' => "'none'",
9 'unsafe-inline' => "'unsafe-inline'",
10 'unsafe-eval' => "'unsafe-eval'",
11 'strict-dynamic' => "'strict-dynamic'",
12 'report-sample' => "'report-sample'",
13 'http' => 'http:',
14 'https' => 'https:',
15 'data' => 'data:',
16 'mediastream' => 'mediastream:',
17 'blob' => 'blob:',
18 'filesystem' => 'filesystem:',
19 );
20
21 foreach ($http_headers_origins as $http_headers_k => $http_headers_origin)
22 {
23 ?>
24 <p<?php echo $http_headers_origin == '*' || !isset($http_headers_csp_value[$http_headers_item]['*']) ? NULL : ' style="display: none"'; ?>>
25 <input type="checkbox"
26 name="hh_content_security_policy_value[<?php echo esc_attr($http_headers_item); ?>][<?php echo esc_attr($http_headers_origin); ?>]"
27 id="csp-<?php echo esc_attr($http_headers_item); ?>-<?php echo esc_attr($http_headers_k); ?>"
28 value="1"<?php echo isset($http_headers_csp_value[$http_headers_item][$http_headers_origin]) ? ' checked' : NULL; ?>
29 class="http-header-value"<?php echo $http_headers_content_security_policy == 1 ? NULL : ' readonly'; ?>>
30 <label for="csp-<?php echo esc_attr($http_headers_item); ?>-<?php echo esc_attr($http_headers_k); ?>"><?php echo esc_html($http_headers_origin); ?></label>
31 </p>
32 <?php
33 }
34
35 switch ($http_headers_item) {
36 case 'script-src':
37 case 'script-src-elem':
38 $http_headers_host_sources = array(
39 'js.example.com',
40 'http://js.example.com',
41 'https://js.example.com',
42 );
43 break;
44 case 'style-src':
45 case 'style-src-elem':
46 $http_headers_host_sources = array(
47 'css.example.com',
48 'http://css.example.com',
49 'https://css.example.com',
50 );
51 break;
52 case 'img-src':
53 $http_headers_host_sources = array(
54 'img.example.com',
55 'http://img.example.com',
56 'https://img.example.com',
57 );
58 break;
59 case 'font-src':
60 $http_headers_host_sources = array(
61 'font.example.com',
62 'http://font.example.com',
63 'https://font.example.com',
64 );
65 break;
66 case 'default-src':
67 $http_headers_host_sources = array(
68 'http://*.example.com',
69 'mail.example.com:443',
70 'https://assets.example.com',
71 'cdn.example.com',
72 );
73 break;
74 default:
75 $http_headers_host_sources = array(
76 'https://store.example.com',
77 'store.example.com',
78 '*.example.com',
79 );
80 }
81 shuffle($http_headers_host_sources);
82 ?>
83 <p<?php echo !isset($http_headers_csp_value[$http_headers_item]['*']) ? NULL : ' style="display: none"'; ?>>
84 <input type="text"
85 name="hh_content_security_policy_value[<?php echo esc_attr($http_headers_item); ?>][source]"
86 class="http-header-value"
87 size="40"
88 placeholder="<?php echo esc_attr($http_headers_host_sources[0]); ?>"
89 value="<?php echo isset($http_headers_csp_value[$http_headers_item]['source']) ? esc_attr($http_headers_csp_value[$http_headers_item]['source']) : NULL; ?>"<?php echo $http_headers_content_security_policy == 1 ? NULL : ' readonly'; ?>>
90 </p>