Besucher mit IPv6 erkennen

Friday, February 12. 2010

Natürlich soll man es auch auf den ersten Blick erkennen können, wenn eine site IPv6-ready ist und per IPv6 abgerufen wird. Etwas wie Googles huepfendes Logo oder die Schildkröte auf kame.net musste her.

Die Erkennung der jeweiligen Verbindung leisten ein paar Zeilen php:

 
<?php

class ip_detector
{

function is_ipv6($ip = "")
{
if ($ip == "")
{
$ip = ip_detector::get_ip();
}
if (substr_count($ip,":") > 0 && substr_count($ip,".") == 0){
return true;
} else {
return false;
}
}

function is_ipv4($ip = "")
{
return !ip_detector::is_ipv6($ip);
}

function get_ip()
{
return getenv ("REMOTE_ADDR");
}

function indicateConnectionBySymbol()
{
if (ip_detector::is_ipv6())
{
echo "<img src='img/ipv6.gif' width='31' height='18' alt='Verbunden per IPv6'
title='Verbunden per IPv6 von ".ip_detector::get_ip()."'>";

}
else
{
echo "<img src='img/ipv4.gif' width='31' height='18' alt='Verbunden per IPv4'
title='Verbunden per IPv4 von ".ip_detector::get_ip()."'>";

}
}
}
?>


                              	

Trackbacks


Trackback specific URI for this entry
    No Trackbacks

Comments


    No comments

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA