Fix getting the user's IP address when proxied

This commit is contained in:
Flavio Copes
2016-01-06 23:15:06 +01:00
parent 3c4dd26c20
commit 566da30513

View File

@@ -454,16 +454,20 @@ abstract class Utils
*/
private static function generateNonceString($action, $plusOneTick = false)
{
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
$username = '';
if (isset(self::getGrav()['user'])) {
$user = self::getGrav()['user'];
$username = $user->username;
if (isset($_SERVER['REMOTE_ADDR'])) {
$username .= $_SERVER['REMOTE_ADDR'];
}
} else {
$username = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
}
$username .= $ip;
$token = session_id();
$i = self::nonceTick();