aboutsummaryrefslogtreecommitdiff
path: root/modules/private/websites/tools/tools/landing/report_csp_violation.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules/private/websites/tools/tools/landing/report_csp_violation.php')
-rw-r--r--modules/private/websites/tools/tools/landing/report_csp_violation.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/modules/private/websites/tools/tools/landing/report_csp_violation.php b/modules/private/websites/tools/tools/landing/report_csp_violation.php
new file mode 100644
index 0000000..13a3234
--- /dev/null
+++ b/modules/private/websites/tools/tools/landing/report_csp_violation.php
@@ -0,0 +1,19 @@
1<?php
2$email_address = 'ismael@bouya.org';
3$email_subject = 'Content-Security-Policy violation';
4
5$current_domain = $_SERVER['SERVER_NAME'];
6$email_subject = $email_subject . ' on ' . $current_domain;
7
8http_response_code(204);
9
10$json_data = file_get_contents('php://input');
11
12if ($json_data = json_decode($json_data)) {
13 $json_data = json_encode($json_data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
14
15 $message = "The following Content-Security-Policy violation occurred on " .
16 $current_domain . ":\n\n" .
17 $json_data;
18 mail($email_address, $email_subject, $message, 'Content-Type: text/plain;charset=utf-8');
19}