mirror of
https://git.terrot.net/terrot.net/checkip.git
synced 2023-08-25 13:53:09 +02:00
62 lines
1.8 KiB
PHP
62 lines
1.8 KiB
PHP
<?php ?>
|
|
<html>
|
|
<head>
|
|
<Title>Current IP Check</title>
|
|
</head>
|
|
<?php
|
|
|
|
// Function to get the client ip address
|
|
function get_client_ip_env() {
|
|
$ipaddress = '';
|
|
if (getenv('HTTP_CLIENT_IP'))
|
|
$ipaddress = getenv('HTTP_CLIENT_IP');
|
|
else if(getenv('HTTP_X_FORWARDED_FOR'))
|
|
$ipaddress = getenv('HTTP_X_FORWARDED_FOR');
|
|
else if(getenv('HTTP_X_FORWARDED'))
|
|
$ipaddress = getenv('HTTP_X_FORWARDED');
|
|
else if(getenv('HTTP_FORWARDED_FOR'))
|
|
$ipaddress = getenv('HTTP_FORWARDED_FOR');
|
|
else if(getenv('HTTP_FORWARDED'))
|
|
$ipaddress = getenv('HTTP_FORWARDED');
|
|
else if(getenv('REMOTE_ADDR'))
|
|
$ipaddress = getenv('REMOTE_ADDR');
|
|
else
|
|
$ipaddress = 'UNKNOWN';
|
|
|
|
return $ipaddress;
|
|
}
|
|
|
|
|
|
// Function to get the client ip address
|
|
function get_client_ip_server() {
|
|
$ipaddress = '';
|
|
if ($_SERVER['HTTP_CLIENT_IP'])
|
|
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
|
|
else if($_SERVER['HTTP_X_FORWARDED_FOR'])
|
|
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
|
else if($_SERVER['HTTP_X_FORWARDED'])
|
|
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
|
|
else if($_SERVER['HTTP_FORWARDED_FOR'])
|
|
$ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
|
|
else if($_SERVER['HTTP_FORWARDED'])
|
|
$ipaddress = $_SERVER['HTTP_FORWARDED'];
|
|
else if($_SERVER['REMOTE_ADDR'])
|
|
$ipaddress = $_SERVER['REMOTE_ADDR'];
|
|
else
|
|
$ipaddress = 'UNKNOWN';
|
|
|
|
return $ipaddress;
|
|
}
|
|
|
|
// Get the client ip address
|
|
$ipaddress = $_SERVER['REMOTE_ADDR'];
|
|
?>
|
|
<body>
|
|
<?php
|
|
//echo 'Your IP address (using $_SERVER[\'REMOTE_ADDR\']) is ' . $ipaddress . '<br />';
|
|
//echo 'Your IP address (using get_client_ip_env function) is ' . get_client_ip_env() . '<br />';
|
|
echo 'Current IP Address: ' . get_client_ip_server();
|
|
?>
|
|
</body>
|
|
</html>
|