#!/usr/local/bin/perl -- -*-fundamental-*- ## Redirect.pl ## Written by Greg Mullane ## Please see http://www.turnstep.com/Spambot/ ## ## This program redirects a user to another page ## When used as a POST request, it helps avoid spambots ## Is this properly posted from a web page? $ENV{"REQUEST_METHOD"} || exit(1); ## Is it a POST? if ($ENV{"REQUEST_METHOD"} eq "POST" && $ENV{"CONTENT_TYPE"} && $ENV{"CONTENT_TYPE"} eq "application/x-www-form-urlencoded" && $ENV{"CONTENT_LENGTH"}) { $clength = int($ENV{"CONTENT_LENGTH"}); if ($clength>200) { $clength=200; } read(STDIN, $line, $clength); if ($line =~ /(.*)=(.*)/) { $url=$2; $url =~ s/\+/ /g ; $url =~ s/%(..)/pack('c',hex($1))/eg; } else { exit(1); } ## Oops! } ## No POST? then exit. We do not want GET requests! else { exit(1); } ## Tell the browser where to go: $|++; print "Location: http://$url\n\n"; print "Please see http://$url\n"; close(STDOUT); exit;