Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit 4ac0f0b

Browse files
author
mattpass
committed
Changing REQUEST to POST and GET
1 parent d72121f commit 4ac0f0b

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

lib/headers.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,17 @@
1818
$_SESSION["csrf"] = md5(uniqid(mt_rand(), true));
1919
}
2020

21-
if (($_GET || $_POST) && (!isset($_REQUEST["csrf"]) || $_REQUEST["csrf"] !== $_SESSION["csrf"])) {
22-
$req = isset($_REQUEST["csrf"]) ? xssClean($_REQUEST["csrf"], "html") : "";
23-
die($t['Bad CSRF token...'] . "<br><br>
24-
CSRF issue:<br>
25-
REQUEST: " . $req . "<br>
26-
SESSION: " . xssClean($_SESSION["csrf"], "html") . "<br>
27-
FILE: " . xssClean($_SERVER["SCRIPT_NAME"], "html") . "<br>
28-
GET: " . xssClean(var_export($_GET, true), "html") . "<br>
29-
POST: " . xssClean(var_export($_POST, true), "html"));
21+
if (($_POST || $_GET) && !$_POST["csrf"] && !$_GET["csrf"]) {
22+
$req = xssClean($_POST["csrf"] ?? $_GET['csrf'] ?? "", "html");
23+
if ($req !== $_SESSION["csrf"]) {
24+
die($t['Bad CSRF token...'] . "<br><br>
25+
CSRF issue:<br>
26+
REQUEST: " . $req . "<br>
27+
SESSION: " . xssClean($_SESSION["csrf"], "html") . "<br>
28+
FILE: " . xssClean($_SERVER["SCRIPT_NAME"], "html") . "<br>
29+
GET: " . xssClean(var_export($_GET, true), "html") . "<br>
30+
POST: " . xssClean(var_export($_POST, true), "html"));
31+
}
3032
}
3133

3234
if (!headers_sent()) {

0 commit comments

Comments
 (0)