if (!empty($_SERVER["HTTP_CLIENT_IP"])) {
$ip = $_SERVER["HTTP_CLIENT_IP"];
} elseif (!empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
} else {
$ip = $_SERVER["REMOTE_ADDR"];
}
"37.112.42.197, 45.84.226.210"
await this.$axios
.get('api/v1/geo')
.then((result) => {
commit('SET_DATA', result.data.data)
})
.catch((error) => {
commit('SET_ERRORS', error)
})
К тому же, все топовые ответы по теме на SO
Note: REMOTE_ADDR might not contain the real IP of the TCP connection. This entirely depends on your SAPI. Ensure that your SAPI is properly configured such that $_SERVER['REMOTE_ADDR'] actually returns the IP of the TCP connection. Failing that might give rise to some serious vulnerabilities, for example, StackExchange used to grant admin access by checking REMOTE_ADDR to see if it matches "localhost", unfortunately the SAPI's config had a vulnerability (it takes HTTP_X_FORWARDED_FOR as input) which allows non-admins to gain admin access by altering the HTTP_X_FORWARDED_FOR header. Also see blog.ircmaxell.com/2012/11/anatomy-of-attack-how-i-hacked.html
split(", ", $_SERVER["HTTP_X_FORWARDED_FOR"])[0]