Client IP behind proxy

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 2021-11-16 15:11:40 +01:00 committed by GitHub
parent 2046bbde72
commit 0494726ca6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -236,8 +236,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;