IPv6 Specific Content in Apache
From SixXS Wiki
In PHP you can take different actions based on whether the client is connecting from IPv4 or IPv6. This is an example from Linux Blog:
<?php $from=$_SERVER["REMOTE_ADDR"]; $ipv6="off"; $message="Our website is available on IPv6. Get connected!"; if (ereg("^[23]...[:]", $from)) { $ipv6="on"; $message="Our connectivity is powered by SixXS!"; } ?> <A HREF="http://www.sixxs.net" target="_blank"> <IMG SRC="http://blogimages.project76.tv/ipv6_<?php echo $ipv6; ?>.png" WIDTH="96" HEIGHT="32" ALT="<?php echo $message; ?>"></A>
This file is then included in the blog template with
<!--#include virtual="/ipv6_detect.php" -->
The remote client address is checked; because all valid IPv6 space is currently in 2000::/3 the first 16-bit segment will always have 4 digits in its representation, will start with a 2 or a 3, and will have a colon in position 5. The regular expression exploits this fact.