#!/usr/bin/perl # # REDIR.PL 1.0 April 9, 1997 # Copyright (C) 1997 John Watson # e-mail: john@watson-net.com # # -----About----- # REDIR.PL is a simple little CGI script that will redirect browsers to # a new URL. It can display a page telling the user they are about to be # redirected as well as log the redirect. This can be useful for tracking # clicks through a web site or just a nice way to say adios to folks # leaving your site. # # The latest copy of this script and documentation can be obtained from # http://www.watson-net.com/ # # Parameters # url: # fully qualified URL to redirect the user to. the url must be # fully qualified (http://...) in order to redirect to another server. # this also allows you to redirect using different protocols (e.g. # ftp://..., gopher://..., etc.). # title: # title of the new URL for display purposes. # # url and title can be passed via POST or GET. # # both arguments are optional. if url is blank, the user will # be redirected to the root of the current server. if title is blank, # it is set equal to url. # # Output # Creates a web page with the REFRESH meta tag. # Redirects the user to the new page after n seconds. # Optionally displays a redirection message to the user. # Optionally logs all redirects. # # Examples # FORM: #
# # ANCHOR: # URL Title # # -----Distribution----- # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. require 'ctime.pl'; use CGI; $q = new CGI; # # DEFAULT VARIABLES SECTION # $log = 1; # 1 log, 0 no log $logfile = 'rocketry.log'; $delay = 0; # delay in seconds. $delay=0, $output=0 work well together. $output = 0; # 1 output, 0 no output # # END OF DEFAULT VARIABLES # # get the parameters from the form or url $url = $q->param('url'); $title = $q->param('title'); # if $url is blank then set equal to root of current server if ($url eq "") { $url = 'http://'.$q->server_name().'/'; } # if $title is blank then set equal to $url if ($title eq "") { $title = $url; } # print html header header(); # if output requested, print body if ($output) { body(); } # print html footer footer(); # if logging requested, add a log entry if ($log) { addlog(); } exit(0); # the http-equiv line in the header actually does the redirect sub header { print $q->header; print <Thanks for using the Rocket Guide to New Caledonia
Please return to www.rocket-guide-newcaledonia.com to order more copies of the CD-ROM.
EOT } sub footer { print <