2007-12-31

* php : IP checker (korean IP)

IPCheck.php
=====================================================
<?
$isDebug = $HTTP_GET_VARS['debug'];
$thisIP = $_SERVER['REMOTE_ADDR'];

function isKoreaIP($ip)
{
  if (!empty($ip) && ip2long($ip)!=-1)
  {
    include("IPKorea.php");
    foreach ($korea_ips as $r)
    {
      $min = ip2long($r[0]);
      $max = ip2long($r[1]);
      if ((ip2long($ip) >= $min) && (ip2long($ip) <= $max))
      {
        return 1;
      }
    }

    return 0;
  }
  else
  {
    return 0;
  }
}

echo isKoreaIP($thisIP);
if($isDebug) echo "<hr>MyIP : $thisIP";
exit();
?>
=====================================================

IPKorea.php
=====================================================
<?
$korea_ips = array
(
  array('202.6.95.0','202.6.95.255'),
  array('202.14.103.0','202.14.103.255'),
  array('202.14.165.0','202.14.165.255'),
  array('202.21.0.0','202.21.7.255'),
  array('202.20.82.0','202.20.82.255'),
  array('202.20.83.0','202.20.86.255'),
  array('202.20.128.0','202.20.255.255'),
  array('202.20.99.0','202.20.99.255'),
  array('202.20.119.0','202.20.119.255'),
  array('202.30.0.0','202.31.255.255'),
  array('203.252.0.0','203.255.255.255'),
  array('203.248.0.0','203.251.255.255'),
  array('203.244.0.0','203.247.255.255'),
  array('117.53.192.0','117.53.255.255'),
  array('117.55.128.0','117.55.191.255'),
  array('117.58.128.0','117.58.143.255'),
  array('152.99.0.0','152.99.255.255'),
  array('117.110.0.0','117.111.255.255'),
  array('118.32.0.0','118.63.255.255')
);
?>
=====================================================

korean IP
* http://ipstat.nida.or.kr/korea_ip/korea_ip4_data.jsp (http://ipstat.nida.or.kr/)

Labels: , , , , ,

0 Comments:

Post a Comment

<< Home