/home/nondinda/domains/nondindaengcity.go.th/public_html/webboard/test_ip_address.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>

<?php
//whether ip is from share internet
if (!empty($_SERVER['HTTP_CLIENT_IP']))   
  {
    
$ip_address $_SERVER['HTTP_CLIENT_IP'];
  }
//whether ip is from proxy
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))  
  {
    
$ip_address $_SERVER['HTTP_X_FORWARDED_FOR'];
  }
//whether ip is from remote address
else
  {
    
$ip_address $_SERVER['REMOTE_ADDR'];
  }
echo 
$ip_address;
?>
<hr>
<?php
  $ip
=$_SERVER['REMOTE_ADDR'];
  
$url=file_get_contents("http://whatismyipaddress.com/ip/$ip");
  
preg_match_all('/<th>(.*?)<\/th><td>(.*?)<\/td>/s',$url,$output,PREG_SET_ORDER);
  
$isp=$output[1][2];
  
$city=$output[9][2];
  
$state=$output[8][2];
  
$zipcode=$output[12][2];
  
$country=$output[7][2];
?>
<body>
  <table align="center">
    <tr><td>ISP :</td><td><?php echo $isp;?></td></tr>
    <tr><td>City :</td><td><?php echo $city;?></td></tr>
    <tr><td>State :</td><td><?php echo $state;?></td></tr>
    <tr><td>Zipcode :</td><td><?php echo $zipcode;?></td></tr>
    <tr><td>Country :</td><td><?php echo $country;?></td></tr>
  </table>
</body>
</body>
</html>