Advertisement
virbo

IP Geolocation

Jan 8th, 2017
564
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.68 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.   <meta charset="utf-8">
  5.  
  6.   <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
  7.        Remove this if you use the .htaccess -->
  8.   <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  9.  
  10.   <title>IP Geolocation</title>
  11.   <meta name="description" content="">
  12.  
  13.   <meta name="viewport" content="width=device-width; initial-scale=1.0">
  14.  
  15.   <!-- Replace favicon.ico & apple-touch-icon.png in the root of your domain and delete these references -->
  16.   <link rel="shortcut icon" href="/favicon.ico">
  17.   <link rel="apple-touch-icon" href="/apple-touch-icon.png">
  18.   <link rel="stylesheet" href="css/flags.css" />
  19. </head>
  20.  
  21. <body>
  22.   <div>
  23.     <header>
  24.       <h1>IP Geolocation</h1>
  25.     </header>
  26.    
  27.     <div>
  28.       <?php
  29.             $temp_ip = '173.252.120.6,202.146.4.100,173.194.38.132,27.111.43.209,98.139.183.24,203.190.241.43,72.52.91.14';
  30.             $temp_pecah = explode(',', $temp_ip);
  31.            
  32.             //var_dump($temp_pecah);
  33.             foreach ($temp_pecah as $key) {
  34.                 $dump = json_decode(file_get_contents("http://ipinfo.io/{$key}"));
  35.                 //var_dump($details);
  36.                 echo "IP Address: ".$dump->ip."<br />";
  37.                 echo "Hostname: ".$dump->hostname."<br />";
  38.                 echo "City: ".$dump->city."<br />";
  39.                 echo "Region: ".$dump->region."<br />";
  40.                 echo "Country: <img src=\"img/blank.gif\" class=\"flag flag-".strtolower($dump->country)."\"><br />";
  41.                 echo "Location: ".$dump->loc."<br />";
  42.                 echo "Network: ".$dump->org."<br />";
  43.                 if (empty($dump->postal)) {
  44.                     echo "Postal Code: -<br /><hr />";
  45.                 } else {
  46.                     echo "Postal Code: ".$dump->postal."<br /><hr />";
  47.                 }
  48.             }
  49.            
  50.         ?>
  51.     </div>
  52.   </div>
  53. </body>
  54. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement