#!/usr/bin/perl ####################################################### # Send Them! # © 2000 Veinotte.com International Inc. # Basic redirection script. # # This script has only been tested on UNIX, but should be fine # on NT or any Win32 platform. # # A simple redirection script to allow redirect forms on # your website without having to use JavaScript. This script # also makes it easy to use one form throught your site if # you have SSI enabled on your website. Just place a form # like the one below in a text file somewhere and call it # with an ssi call in all the pages you want to use it in: # # # # Just make the call above make sense on your system. It should be # a direct system path to the text file. # # This allow you to edit one text file when adding a new URL # instead of editing each HTML file. # # Here is an example of the form use in your pages or in a text # file with SSI # #
# # #
# # One more note: If you wanted the page to open in a new window, or another # frame just add a target to the first line like so: # #
####################################################### $| = 1; use CGI qw(:standard); # # @okay_domains are just that: Domains that can use this script from your server. # If someone tries to use it that is not listed here, they are sent to the $home_url # below. # Each domain must be seperated by a space. @okay_domains = qw(graphxpress.com); $homeurl = 'http://www.graphxpress.com/'; # # No more configuration is necessary, but hack away. # $page = param("page"); $IIS = ($ENV{'SERVER_SOFTWARE'} && ($ENV{'SERVER_SOFTWARE'} =~ /iis/i)) ? 1:0; chdir($1) if (($IIS) && ($0 =~ /(.*)(\\|\/)/)); if ($page eq "") { print "HTTP/1.0 302 Temporary Redirection\r\n" if ($IIS); print "Content-type: text/html\r\n"; print "Location: $homeurl\r\n\r\n"; exit; } else { chomp $page; if ($page !~ m!^http://!) { $page = "http://" . "$page"; } my $allow = verify($page); if ($allow == 1) { print "HTTP/1.0 302 Temporary Redirection\r\n" if ($IIS); print "Content-type: text/html\r\n"; print "Location: $page\r\n\r\n"; exit; } else { print "HTTP/1.0 302 Temporary Redirection\r\n" if ($IIS); print "Content-type: text/html\r\n"; print "Location: $homeurl\r\n\r\n"; exit; } } sub verify { my $check = $_[0]; my $allowed = 0; foreach my $domain(@okay_domains) { if ($check =~ m!^http://(.*)$domain(.*)!) { $allowed++; last; } } return $allowed; } # That's it! Told you it was a simple script !