今天,我实施了Content-Security-Policy (CSP)。我还包括了report-uri所以它发送一个POST请求到myserver.com/csp-report.php. 正如 MDN 在他们的网站上解释的那样,POST请求是这样的:
{
"csp-report": {
"document-uri": "http://example.com/signup.html",
"referrer": "http://evil.example.net/haxor.html",
"blocked-uri": "http://evil.example.net/injected.png",
"violated-directive": "img-src *.example.com",
"original-policy": "default-src 'self'; img-src 'self' *.example.com; report-uri /_/csp-reports",
}
}
Run Code Online (Sandbox Code Playgroud)
我想将此信息通过电子邮件发送至reports@myserver.com。目前,我有这个代码,但它只是通过电子邮件发送“Array() Array()”
<?php
$tars = Array("reports@myserver.com", "webm@myserver.com");
$from = "notify@myserver.com";
$subject = "CSP Report";
$text = print_r($_POST, true);
$text = (isSet($_GET["text"]) ? $_GET["text"] : $text);
foreach($tars as $tar){
$e = mail($tar,$subject,$text,"From: $from");
}
if($e){
header("Content-type: text/javascript");
echo 'console.log("Email Sent");';
exit();
}
?>
Run Code Online (Sandbox Code Playgroud) 我有一个数组(从API获取)有近300个值,但我需要调用someAction()10个值的集合.我的意思是,1-10,11-20,21-30 ......等等.我把它限制在10,但其他290个值都丢失了.它是一个多维数组.
var n = 10; // Limit of names
for (var i = 0; i < n; i++) {
namestr += names[i].first + "(" + names[i].nick + ")";
if(i != (n-1)){namestr += ", ";}
}
someAction(namest, function(){...});
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助