Mendapatkan IP pengunjung()

Ingin mengetahui IP dari network yang digunakan pengunjung?
caranya mudah kok.
function GetIP()
{
  if ($_SERVER["HTTP_X_FORWARDED_FOR"])
    $ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
  else if ($_SERVER["HTTP_CLIENT_IP"])
    $ip = $_SERVER["HTTP_CLIENT_IP"];
  else if ($_SERVER["REMOTE_ADDR"])
    $ip = $_SERVER["REMOTE_ADDR"];
  else if (getenv("HTTP_X_FORWARDED_FOR"))
    $ip = getenv("HTTP_X_FORWARDED_FOR");
  else if (getenv("HTTP_CLIENT_IP"))
    $ip = getenv("HTTP_CLIENT_IP");
  else if (getenv("REMOTE_ADDR"))
    $ip = getenv("REMOTE_ADDR");
  else
    $ip = "tidak diketahui";
  return $ip;
}

contoh:
http://php-id.org/tools/getip/

catatan:
ip yang ditampilkan tidak mencerminkan ip dari pc yang digunakan pengunjung.

SemangaT!
dikutip dari osphp.com.cn

}

About aperta
Nothing or Less.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: