#!/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 = 0; # 1 log, 0 no log
$logfile = '/tmp/redir.log';
$delay = 10; # delay in seconds. $delay=0, $output=0 work well together.
$output = 1; # 1 output, 0 no output
#
# END OF DEFAULT VARIABLES
#
# get the parameters from the form or url
$target = $q->param('date');
chomp ($target);
$title = "Previous SPC Convective Outlooks Issued on $target:";
# if $url is blank then set equal to root of current server
if ($target eq "") {
$target = 'http://'.$q->server_name().'/';
}
# print html header
header();
# if output requested, print body
if ($output) { body(); }
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=gmtime(time);
$today = ($year+1900)*10000+($mon+1)*100+$mday;
if ($target < 20030123 || $target > $today ) {
print "