Handle proxy cascades on X-Forwrded-For

This commit is contained in:
Mike Primm 2022-02-22 22:33:33 -06:00
parent a9b4ace851
commit 60147e8d16
3 changed files with 6 additions and 3 deletions

View File

@ -35,7 +35,8 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && $lastchat < time()) {
}
}
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$data->ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
$proxy = array_map('trim', explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']));
$data->ip = $proxy[0];
}
$content = getStandaloneFile('dynmap_webchat.json');
$gotold = false;

View File

@ -35,7 +35,8 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && $lastchat < time()) {
}
}
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$data->ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
$proxy = array_map('trim', explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']));
$data->ip = $proxy[0];
}
$content = getStandaloneFile('dynmap_webchat.json');
$gotold = false;

View File

@ -35,7 +35,8 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && $lastchat < time()) {
}
}
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$data->ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
$proxy = array_map('trim', explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']));
$data->ip = $proxy[0];
}
if (is_readable('dynmap_webchat.json')) {
$old_messages = json_decode(file_get_contents('dynmap_webchat.json'), true);