Skip to content

Commit b80065a

Browse files
authored
Update functions.php for Caddy
This change gets the left most IP address from the X-Forward-For header. This is required to get the right IP easily from Caddy. Tested and working.
1 parent 424104b commit b80065a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

functions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function getUserAgent() {
7979
function getIP() {
8080
if (defined("CONST_GET_IP_METHOD")) {
8181
if (CONST_GET_IP_METHOD == "HTTP_X_FORWARDED_FOR") {
82-
$ip = getenv('HTTP_X_FORWARDED_FOR');
82+
$ip = explode(',', getenv('HTTP_X_FORWARDED_FOR'))[0];
8383
} else {
8484
$ip = $_SERVER["HTTP_CF_CONNECTING_IP"] ?? $_SERVER['REMOTE_ADDR'];
8585
}
@@ -1636,4 +1636,4 @@ function display_folder_options($parent_folder_id, $client_id, $indent = 0) {
16361636
// Recursively display subfolders
16371637
display_folder_options($folder_id, $client_id, $indent + 1);
16381638
}
1639-
}
1639+
}

0 commit comments

Comments
 (0)