#!/usr/bin/perl # This is program url-mind.pl Version 0.9. # Created and copyright 1997 by Urb LeJeune, lejeune@usats.com # Initially created on 7/20/97. May only be used with permission. # Last modified July 20, 1997. # The following is the path -- relative to your cgi directory -- # of the file to store the information. $DataFile = "data/url-mind.dat"; $URL_MINDER = "http://www.netmind.com/cgi-bin/uncgi/url-mind?"; $DATE = `date +"%B %d, %Y"`; chop($DATE); &Parse; # Read in and parse supplied variables $NEW_URL = $URL_MINDER . $in{'QUERY'}; &SaveInformation($QUERY_STRING); # Write user info to file or whatever print "Location: $NEW_URL\n\n"; # Send URL off to orginal location. exit; sub SaveInformation{ $EMAIL= $in{'required-email'}; $URL = $in{'url'}; open (URL, ">>$DataFile"); print URL "$URL $EMAIL $DATE $ENV{'REMOTE_HOST'} " . "$ENV{'HTTP_REFERER'} $ENV{'HTTP_USER_AGENT'}\n"; close (URL); } # End of subroutine SaveInformation sub Parse { # Slightly modified version of ReadParse from cgi-lib.pl # Need to save original query string. local (*in) = @_ if @_; local ($i, $key, $val); # Read in text if ($ENV{'REQUEST_METHOD'} eq "GET") { $QUERY = $ENV{'QUERY_STRING'}; } elsif ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN,$QUERY,$ENV{'CONTENT_LENGTH'}); } @in = split(/[&;]/,$QUERY); foreach $i (0 .. $#in) { # Convert plus's to spaces $in[$i] =~ s/\+/ /g; # Split into key and value. ($key, $val) = split(/=/,$in[$i],2); # splits on the first =. # Convert %XX from hex numbers to alphanumeric $key =~ s/%(..)/pack("c",hex($1))/ge; $val =~ s/%(..)/pack("c",hex($1))/ge; # Associate key and value, \0 is the multiple separator $in{$key} .= "\0" if (defined($in{$key})); $in{$key} .= $val; } $in{'QUERY'} = $QUERY; #Save original query string in @in array return scalar(@in); } # End of subroutine Parse #print "Content-type: text/html\n\n"; #print "
query=\"$in{'QUERY'}\"\n"; #print "
url=\"$in{'url'}\"\n"; #print "
email=\"$in{'required-email'}\"\n"; #print "
new=\"$NEW_URL\"\n";