| OLD | NEW |
| 1 <?php | 1 <?php |
| 2 function undoMagicQuotes($value) { | 2 function undoMagicQuotes($value) { |
| 3 if (get_magic_quotes_gpc()) | 3 if (get_magic_quotes_gpc()) |
| 4 return stripslashes($value); | 4 return stripslashes($value); |
| 5 return $value; | 5 return $value; |
| 6 } | 6 } |
| 7 | 7 |
| 8 $reportFile = fopen("csp-report.txt.tmp", 'w'); | 8 $reportFile = fopen("csp-report." . $_GET["test"] . ".tmp", 'w'); |
| 9 $httpHeaders = $_SERVER; | 9 $httpHeaders = $_SERVER; |
| 10 ksort($httpHeaders, SORT_STRING); | 10 ksort($httpHeaders, SORT_STRING); |
| 11 foreach ($httpHeaders as $name => $value) { | 11 foreach ($httpHeaders as $name => $value) { |
| 12 if ($name === "CONTENT_TYPE" || $name === "HTTP_REFERER" || $name === "REQUE
ST_METHOD") { | 12 if ($name === "CONTENT_TYPE" || $name === "HTTP_REFERER" || $name === "REQUE
ST_METHOD") { |
| 13 $value = undoMagicQuotes($value); | 13 $value = undoMagicQuotes($value); |
| 14 fwrite($reportFile, "$name: $value\n"); | 14 fwrite($reportFile, "$name: $value\n"); |
| 15 } | 15 } |
| 16 if ($name === "HTTP_COOKIE" && $_COOKIE["cspViolationReportCookie"]) { | 16 if ($name === "HTTP_COOKIE" && $_COOKIE["cspViolationReportCookie"]) { |
| 17 fwrite($reportFile, "Cookie: cspViolationReportCookie=" . $_COOKIE["cspV
iolationReportCookie"] . "\n"); | 17 fwrite($reportFile, "Cookie: cspViolationReportCookie=" . $_COOKIE["cspV
iolationReportCookie"] . "\n"); |
| 18 } | 18 } |
| 19 } | 19 } |
| 20 | 20 |
| 21 foreach ($_COOKIE as $name => $value) | 21 foreach ($_COOKIE as $name => $value) |
| 22 setcookie($name, "deleted", time() - 60, "/"); | 22 setcookie($name, "deleted", time() - 60, "/"); |
| 23 | 23 |
| 24 fwrite($reportFile, "=== POST DATA ===\n"); | 24 fwrite($reportFile, "=== POST DATA ===\n"); |
| 25 fwrite($reportFile, file_get_contents("php://input")); | 25 fwrite($reportFile, file_get_contents("php://input")); |
| 26 fclose($reportFile); | 26 fclose($reportFile); |
| 27 rename("csp-report.txt.tmp", "csp-report.txt"); | 27 rename("csp-report." . $_GET["test"] . ".tmp", "csp-report." . $_GET["test"] . "
.txt"); |
| 28 ?> | 28 ?> |
| OLD | NEW |