aboutsummaryrefslogtreecommitdiff
path: root/modules/private/websites/tools/tools/landing/report_csp_violation.php
blob: 13a323426d78e7bb282b4c40184503549f1a334c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
$email_address = 'ismael@bouya.org';
$email_subject = 'Content-Security-Policy violation';

$current_domain = $_SERVER['SERVER_NAME'];
$email_subject = $email_subject . ' on ' . $current_domain;

http_response_code(204);

$json_data = file_get_contents('php://input');

if ($json_data = json_decode($json_data)) {
  $json_data = json_encode($json_data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);

  $message = "The following Content-Security-Policy violation occurred on " .
    $current_domain . ":\n\n" .
    $json_data;
  mail($email_address, $email_subject, $message, 'Content-Type: text/plain;charset=utf-8');
}