#!/usr/bin/perl $source = $ENV{'REMOTE_HOST'}; $host = $ENV{'HTTP_HOST'}; $page = $ENV{'REDIRECT_URL'}; $page = substr($page,1,(length($page) - 1)); $log = "/home/carpe/logs/forward_log"; $when = `date +%y.%m.%d-%H:%M`; chop $when; $entry = "$when - $host/$page - $source\n"; $url = ""; $info_dir = "/home/spool/forward"; # first, a less than clever way of extracting the actual domain name... $host_tmp = $host; while ($host_tmp ne "") { if (-e "$info_dir/$host_tmp") { $info_file = "$info_dir/$host_tmp"; $host_tmp = ""; } else { $host_tmp = substr($host_tmp,1,(length($host_tmp) - 1)); } } if (-e $info_file) { open(INFO_FILE,$info_file); while () { ($what, $action) = split(/\|/,$_); if ($what eq "x-location") { chop($action); $url = "$action$page"; } elsif ($what eq "x-forwardt") { chop($action); $method = $action; } if ($what eq "x-metadescription") { chop($action); $action =~ s/\\//g; $description= $action; } if ($what eq "x-metakeywords") { chop($action); $action =~ s/\\//g; $keywords= $action; } if ($what eq "x-title") { chop($action); $action =~ s/\\//g; $title= $action; } } close(INFO_FILE); } if ($url eq "") { print "Content-type: text/html\n\n"; print "\n"; exit(0); } if($url =~ /^http:\/\//) { }else { $url = "http://".$url; } if ($method eq "standard") { print "Content-type: text/html\n"; print "Status: 200 OK\n\n"; print "\n"; } else { print "Content-type: text/html\n"; print "Status: 200 OK\n\n"; print "\n"; print "\n"; print "$title\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "<body bgcolor=\"#ffffff\" text=\"#000000\" link=\"#000000\" vlink=\"#000000\" alink=\"#000000\">\n"; print "Your browser does not support frames. Please click "; print "<font face=\"Arial\"><a href=\"$url\">here</a></font>\n"; print "</body>\n"; print "\n"; print "\n"; print "\n"; } # write a log entry open(THE_FILE,">>$log"); flock(THE_FILE,2); print THE_FILE $entry; flock(THE_FILE,8); close(THE_FILE); exit(0);