#!/usr/bin/perl # Created and copyright 1997 by Urb LeJeune, lejeune@usats.com # Initially created on 7/20/97. # Last modified July 20, 1997. # This is program url-mine.pl $mailprog = "/usr/sbin/sendmail"; $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 text $NEW_URL = $URL_MINDER . $in{'QUERY'}; #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"; #exit; &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); } sub Parse { 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'}); } # add invalid request. @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 $in{$key} .= "\0" if (defined($in{$key})); # \0 is the multiple separator $in{$key} .= $val; } $in{'QUERY'} = $QUERY; return scalar(@in); }