Skip to content

Commit 185999a

Browse files
committed
Merge pull request #26 from mschwager/master
REQUEST_SCHEME issues on non-apache webservers
2 parents 1ab010e + c441e3d commit 185999a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

libs/csrf/csrfprotector.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,19 @@ private static function logCSRFattack()
422422
*/
423423
private static function getCurrentUrl()
424424
{
425-
return $_SERVER['REQUEST_SCHEME'] .'://'
426-
.$_SERVER['HTTP_HOST'] .$_SERVER['PHP_SELF'];
425+
$request_scheme = 'https';
426+
427+
if (isset($_SERVER['REQUEST_SCHEME'])) {
428+
$request_scheme = $_SERVER['REQUEST_SCHEME'];
429+
} else {
430+
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') {
431+
$request_scheme = 'https';
432+
} else {
433+
$request_scheme = 'http';
434+
}
435+
}
436+
437+
return $request_scheme . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
427438
}
428439

429440
/*

0 commit comments

Comments
 (0)