Skip to content

Commit 85ef9d5

Browse files
smibasmiba
authored andcommitted
Expend CSRF token expiry time
Change it to 15 minutes, 2 minutes is not enough.
1 parent 1c53b2e commit 85ef9d5

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

include/classes/csrftoken.class.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,22 @@ public function getBasic($user, $type) {
1616
}
1717

1818
/**
19-
* Returns +1 min and +1 hour rollovers hashes
19+
* Returns +1 min up to +15 min rollovers hashes
2020
* @param string $user user or IP/host address
2121
* @param string $type page name or other unique per-page identifier
22-
* @return array 1min and 1hour hashes
22+
* @return array 1 minute ago up to 15 minute ago hashes
2323
*/
24+
2425
public function checkAdditional($user, $type) {
2526
$date = date('m/d/y/H/i');
2627
$d = explode('/', $date);
27-
// minute may have rolled over
28-
$seed1 = $this->buildSeed($user.$type, $d[0], $d[1], $d[2], $d[3], ($d[4]-1));
29-
// hour may have rolled over
30-
$seed2 = $this->buildSeed($user.$type, $d[0], $d[1], $d[2], ($d[3]-1), 59);
31-
return array($this->getHash($seed1), $this->getHash($seed2));
28+
$hashes = array();
29+
for ($x = 1; $x < 16; $x++){
30+
for ($y = 4;$d[$y]-- == 0;$y--);
31+
if ($d[4] < 0) { $d[4] = 59; }
32+
$hashes[$x-1] = $this->getHash($this->buildSeed($user.$type, $d[0], $d[1], $d[2], $d[3], $d[4]));
33+
}
34+
return $hashes;
3235
}
3336

3437
/**

0 commit comments

Comments
 (0)