#!/usr/bin/perl -w # # Copyright (c) 2002 Nathan Lutchansky # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. use strict; use CGI; # # IPv6 web bug # # This little script is designed to run on a dual-stack (IPv4 and IPv6) # web server. It will redirect users to one of two different pages # depending on the protocol used to request the page. Users connecting # with IPv4 are redirected to the page passed in the "v4dest" field, and # users connecting with IPv6 are redirected to the page passed in the # "v6dest" field. Optionally, the string "__IP__" (sans quotes) may be # included in the v6dest field and will be replaced by the user's IPv6 # address upon redirection. # # For more information, see . # # If you copy this script to your own site, you may want to change # the two variables below. They appear when the script is run without # input. # my $version = "IPv6 web bug v0.2"; my $descr = "http://www.litech.org/webbug/"; #### my $q = new CGI; my $ip = $ENV{"REMOTE_ADDR"}; if($q->param() && $q->param('v4dest') && $q->param('v6dest')) { if( $ip =~ /\./ ) { print $q->redirect('http://'.$q->param('v4dest')); } else { my $dest = $q->param('v6dest'); $dest =~ s/__IP__/$ip/e; print $q->redirect('http://'.$dest); } } else { print $q->header, $q->start_html($version), $q->p("Client IP: $ip"), $q->p("See",$q->a({-href=>$descr},$descr), "for more information about this script."), $q->end_html; }