1
0
mirror of https://github.com/prasathmani/tinyfilemanager.git synced 2025-08-01 14:30:45 +02:00

Client IP behind proxy (#665)

Function added for IP filtering when the filemanager is hosted behind a web proxy.

I've added a function for this to the file, not sure how else to implement it since everything is one file.
This commit is contained in:
jicho
2022-02-12 08:58:26 +01:00
committed by GitHub
parent ad30a3a1f3
commit e474ade92b

View File

@@ -244,8 +244,19 @@ if (isset($_GET['logout'])) {
}
// Validate connection IP
if($ip_ruleset != 'OFF'){
$clientIp = $_SERVER['REMOTE_ADDR'];
if ($ip_ruleset != 'OFF') {
function getClientIP() {
if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) {
return $_SERVER["HTTP_X_FORWARDED_FOR"];
}else if (array_key_exists('REMOTE_ADDR', $_SERVER)) {
return $_SERVER['REMOTE_ADDR'];
}else if (array_key_exists('HTTP_CLIENT_IP', $_SERVER)) {
return $_SERVER['HTTP_CLIENT_IP'];
}
return '';
}
$clientIp = getClientIP();
$proceed = false;