#!/usr/local/bin/perl -w use Socket; $query = "$ENV{'QUERY_STRING'}"; $pro = "http"; if ($query eq "y") { $hostname = "www.yahoo.com"; } elsif ($query eq "Skippy") { $hostname = "skippy.wgz.org"; } elsif ($query eq "Winpatch") { $hostname = "winpatch.wgz.org"; } elsif ($query eq "Spectral") { $hostname = "spectral.wgz.org"; } elsif ($query eq "Magic") { $hostname = "magic.hurrah.com"; } elsif ($query eq "Skylab") { $hostname = "www.skylab.org"; } elsif ($query eq "biff") { $hostname = "biff.ch.up.edu"; } else { print "Content-type: text/html\n\n"; print <<"EOF"; Invalid Option

Invalid Option


"$query" is not a valid option.
Back
keys\@babylo n5fan.com EOF $stat = "Invalid"; &end; } $hostaddr = (gethostbyname($hostname))[4] || &fail; $proto = (getprotobyname ('tcp'))[2] || &err ("Protocol Failure"); socket (SOCK, AF_INET, SOCK_STREAM, $proto) || &err ("Socket Failure"); connect (SOCK, pack "SnA4x8", AF_INET, $port || 80, $hostaddr) || &fail; select (SOCK); $| = 1; select (STDOUT); print "Location: $pro://$hostname"; print ":$port" if $port ne ""; print "$ENV{'PATH_INFO'}\n\n"; $stat = "Redirected"; &end; sub fail { print "Content-type: text/html\n\n"; print <<"EOF"; Service Unavailable

$query is unavailable


Service for $pro on $query is currently down. Please try again later.
Back
keys\@babylo n5fan.com EOF $stat = "Unavailable"; &end; } sub err { my ($error) = @_; print "Content-type: text/html\n\n"; print <<"EOF"; Error

Error


An error has occurred. With any luck I should already know about it, though...
Back
keys\@babylon5fan.com EOF $stat = "Error: $error"; &end; } sub end { chmod (0602, "./hidden/server.cgi.log"); open (FILE, ">> ./hidden/server.cgi.log") || open (FILE, "> ./hidden/server.cgi.log"); print FILE scalar localtime; print FILE ",$ENV{'REMOTE_HOST'},$ENV{'HTTP_REFERER'},$query,$stat\n"; close (FILE); exit(0); } #### #!/usr/local/bin/perl -wT use strict; use CGI; use LWP::Simple; my %hosts = ( 'skylab' => 'http://skylab.org/', 'tarball' => 'http://tarball.wgz.org/', 'google' => 'http://www.google.com/', 'secure' => 'http://secure.wgz.com/', ); my $q = new CGI; my $dest = $q->param('dest') || ''; my $dest_url = $hosts{lc($dest)}; my $message = ''; if(defined($dest_url)) { if(head($dest_url)) { print $q->redirect(-location=>$dest_url); exit(0); } else { $message = "$dest is unavailable"; } } else { if($dest) { $message = "$dest is not a recognized destination"; } else { $message = 'No dest specified'; } } print $q->header(); print $q->start_html(-title=>$message); print $q->h1($message); print $q->h2('Please try again'); print $q->end_html();