Просмотр файла vavok-1.5.3/adminpanel/ip-informations.php

Размер файла: 1.41Kb
  1. <?php
  2. // (c) vavok.net
  3.  
  4. require_once"../include/startup.php";
  5.  
  6. if (!$users->is_reg() || (!$users->is_moderator() && !$users->is_administrator())) {
  7. redirect_to("../pages/input.php?action=exit");
  8. }
  9.  
  10. $ip = check($_GET['ip']);
  11.  
  12. if (empty($ip)) { exit('please set ip address'); }
  13.  
  14. // Get an array with geoip-infodata
  15. function geo_check_ip($ip) {
  16.  
  17. // check, if the provided ip is valid
  18. if (!filter_var($ip, FILTER_VALIDATE_IP)) {
  19. throw new InvalidArgumentException("IP is not valid");
  20. }
  21.  
  22. // contact ip-server
  23. $response = @file_get_contents('http://ip-api.com/json/' . $ip);
  24.  
  25. if (empty($response)) {
  26. throw new InvalidArgumentException("Error contacting Geo-IP-Server");
  27. }
  28.  
  29. // Return result as array
  30. return json_decode($response, true);
  31.  
  32. }
  33.  
  34. $ipData = geo_check_ip($ip);
  35.  
  36. $my_title = 'IP Informations';
  37. require_once BASEDIR . "themes/" . MY_THEME . "/index.php";
  38.  
  39. ?>
  40.  
  41. <h1>Informations about IP</h1>
  42.  
  43. <div class="b">
  44.  
  45. <?php
  46.  
  47. echo 'IP Address: ' . $ip . '<br />';
  48. echo 'Country: ' . $ipData['country'] . '<br />';
  49. echo 'State/Region: ' . $ipData['regionName'] . '<br />';
  50. echo 'City/Town: ' . $ipData['city'] . '<br />';
  51. echo '</div>';
  52.  
  53. echo '<p><a href="./" class="btn btn-outline-primary sitelink">' . $lang_home['admpanel'] . '</a><br>';
  54. echo '<a href="../" class="btn btn-primary homepage">' . $lang_home['home'] . '</a></p>';
  55.  
  56. require_once BASEDIR . "themes/" . MY_THEME . "/foot.php";
  57.  
  58. ?>