Delete ip-api.php
This commit is contained in:
parent
448225e1c8
commit
f1d8bc1059
1 changed files with 0 additions and 31 deletions
31
ip-api.php
31
ip-api.php
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
function getUserIP() {
|
||||
$ipHeaders = [
|
||||
'HTTP_CLIENT_IP',
|
||||
'HTTP_X_FORWARDED_FOR',
|
||||
'HTTP_X_FORWARDED',
|
||||
'HTTP_X_CLUSTER_CLIENT_IP',
|
||||
'HTTP_FORWARDED_FOR',
|
||||
'HTTP_FORWARDED',
|
||||
'REMOTE_ADDR'
|
||||
];
|
||||
|
||||
foreach ($ipHeaders as $header) {
|
||||
if (!empty($_SERVER[$header])) {
|
||||
$ips = explode(',', $_SERVER[$header]);
|
||||
$ip = trim($ips[0]);
|
||||
if (filter_var($ip, FILTER_VALIDATE_IP)) {
|
||||
return $ip;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$userIP = getUserIP();
|
||||
$response = ['ip' => $userIP];
|
||||
echo json_encode($response);
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue