Ver Fonte

Handle X-Forwarded-For with multiple hosts (#169)

Matthew Hunt há 7 anos atrás
pai
commit
ec0fa10700
1 ficheiros alterados com 1 adições e 0 exclusões
  1. 1 0
      getIP.php

+ 1 - 0
getIP.php

@@ -13,6 +13,7 @@ if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
     $ip = $_SERVER['X-Real-IP'];
 } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
     $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
+    $ip = preg_replace("/,.*/", "", $ip); # hosts are comma-separated, client is first
 } else {
     $ip = $_SERVER['REMOTE_ADDR'];
 }