#!/usr/local/bin/perl # You may have to change the line above to refer to where perl # is located on your system. At the Unix prompt, type whereis perl # and a list of locations of perl on your server will be shown. # Change the line above to match one of those locations. ###################################################################### # # (C) Copyright 2000 Volatile Graphix, Inc. All rights reserved. # This script may not be copied or modified in any way without # permission in writing from Volatile Graphix, Inc. # # Limitation of Liability: KloakIt is to be used at your own risk # Volatile Graphix, Inc. d.b.a. KloakIt expressly disclaims any and # all liability from any and all consequences arising from the use # of this and all scripts that Volatile Graphix, Inc. d.b.a. KloakIt # have written. By using this script in whole or in part, the user # hereby agrees to abide by this statement. # ###################################################################### ###################################################################### # # Make $redir equal to the URL (web page address) of the page you want # normal people to see. $redir = "http://www.usseal.com/oringpage.htm"; # OPTIONAL # If you change the name of the data directory, make $writedir equal # to the new name and path of the directory. $writedir = "robots"; # OPTIONAL # Set timeModifier to equal the difference between your server time # and your local time. $timeModifier = "0"; # OPTIONAL # The $listLinks variable decides whether or not to display a list # of links to your cloaked pages at the bottom of each entrance page. # I recommend you leave it set to 1. If you want to turn the list off, # set it to 0. $listLinks = "1"; ###################################################################### ############# NO EDITING NECESSARY BELOW HERE ######################## ############# NO EDITING NECESSARY BELOW HERE ######################## ############# NO EDITING NECESSARY BELOW HERE ######################## ###################################################################### $loc = "http://" . $ENV{'SERVER_NAME'}; $myname = $ENV{'SCRIPT_NAME'}; $myname =~ s/^\/.*\///; $myname =~ s/^\///; $gethost = "$ENV{'REMOTE_HOST'}"; $getaddr = "$ENV{'REMOTE_ADDR'}"; $ref = "$ENV{'HTTP_REFERER'}"; $localdirectory = $ENV{'SCRIPT_NAME'}; $localdirectory =~ s/^(.+)\/.+\.htm$/$1/; open (K, "$writedir/gr.daq"); flock (K, 2); $c = ; flock (K, 8); close (K); unless ($c =~ /$ENV{'SERVER_NAME'}/) { open (A, "$writedir/gra.daq"); flock (A, 2); @gra = ; flock (A, 8); close (A); } if ($localdirectory =~ /\.htm$/) { $localdirectory =~ s/.+.htm$//; } $base =~ s/\/\/(.+)\/.+\.htm.*$/\/\/$1\//; @exclude = ("204.123.9.65", # @exclude is for certain applications "204.123.9.66", # sponsored by search engines such "204.123.9.67", # as Babelfish that translate pages into "204.123.9.68", # other languages and display them. You "204.123.9.106", # don't want humans seeing this, so I "204.123.9.107", # made an exclude list. "204.152.191.27", "204.152.191.28", "204.152.191.29", "204.152.190.27", "204.152.190.28", "204.152.190.29", "204.152.190.37", "204.152.190.154", "204.162.96.104", "204.162.96.154", "204.162.96.176", "209.247.194.100",); if ($gethost eq "") { $gethost = $getaddr; } for ($count=1; $count<=10; $count++){ open (ENGINELIST, "$writedir\/$count" . ".list"); flock(ENGINELIST, 2); @enginelist1= if $count eq 1; @enginelist2= if $count eq 2; @enginelist3= if $count eq 3; @enginelist4= if $count eq 4; @enginelist5= if $count eq 5; @enginelist6= if $count eq 6; @enginelist7= if $count eq 7; @enginelist8= if $count eq 8; @enginelist9= if $count eq 9; @enginelist10= if $count eq 10; flock(ENGINELIST, 8); close (ENGINELIST); } ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time+ (3600*$timeModifier)); # set time if (length ($min) eq 1) {$min= '0'.$min;} $mon++; $year =~ s/.+(..)$/$1/; $date="$mon/$mday/$year, $hour:$min"; # Get a list of URLs from the main directory opendir (LIST, "."); @urls = readdir(LIST); closedir (LIST); splice (@urls, 0, 2); $ix = 0; foreach (@urls) { splice (@urls, $ix, 1) unless $urls[$ix] =~ /\.htm$/; splice (@urls, $ix, 1) if $urls[$ix] =~ /\/page.htm$/; } # MAIN PROGRAM ###################################################################### ###################################################################### # Do not cloak if cloaking is turned off. open (IFCL, "<$writedir/ifcl.daq"); flock (IFCL, 2); $ifcl = ; flock (IFCL, 8); close (IFCL); if (!$ifcl) { &detect; &robot; exit; } # Detect if requestor is a robot or a normal person &detect; # Display normal page to normal person or entrance page to robot if ($isRobot ne "0") { &robot; } else { &normal; } exit; ###################################################################### # DETECT IF REQUESTOR IS ROBOT OR NORMAL ###################################################################### ###################################################################### sub detect{ $isRobot = 0; for ($count=1;$count<=11;$count++){ @list = @enginelist1 if $count eq 1; # Infoseek $SE = "Infoseek" if $count eq 1; @list = @enginelist2 if $count eq 2; # Alta Vista $SE = "Alta Vista" if $count eq 2; @list = @enginelist3 if $count eq 3; # Lycos $SE = "Lycos" if $count eq 3; @list = @enginelist4 if $count eq 4; # Inktomi $SE = "Inktomi" if $count eq 4; @list = @enginelist5 if $count eq 5; # Excite $SE = "Excite" if $count eq 5; @list = @enginelist6 if $count eq 6; # Google $SE = "Google" if $count eq 6; @list = @enginelist7 if $count eq 7; # Northern Light $SE = "Northern Light" if $count eq 7; @list = @enginelist8 if $count eq 8; # Misc $SE = "Misc" if $count eq 8; @list = @enginelist9 if $count eq 9; # Custom 1 $SE = "Custom 1" if $count eq 9; @list = @enginelist10 if $count eq 10; # Custom 2 $SE = "Custom 2" if $count eq 10; $SE = "" if $count eq 11; foreach $line (@list) { chomp $line; next if $line eq ""; next if $line =~ /^\#/; $line =~ s/ //g; if (($gethost =~ /$line/i) or ($getaddr =~ /$line/i)) { $isRobot = $count; if ($gethost =~ /babelfish/i) { $isRobot = 0; } foreach $ip (@exclude) { if ($getaddr =~ /$ip/i) { $isRobot = 0; $translator = " -- Translator"; } } } last if $isRobot eq $count; } last if $isRobot eq $count; } } ###################################################################### # SERVE NORMAL PAGE TO NORMAL REQUESTOR ###################################################################### ###################################################################### sub normal{ # Log the access open (ACCESSLOG, "<$writedir/access.log"); flock(ACCESSLOG, 2); @accesslog = ; flock(ACCESSLOG, 8); close (ACCESSLOG); open (ACCESSLOG, ">$writedir/access.log"); flock(ACCESSLOG, 2); print ACCESSLOG " $date -- $gethost -- $myname -- $ref$translator\n"; $count=1; foreach $occurance (@accesslog){ print ACCESSLOG $occurance; last if $count eq 10000; $count++; } flock(ACCESSLOG, 8); close (ACCESSLOG); if ($redir ne "") { use LWP::Simple; $redirectedpage = get "$redir"; print STDOUT "Content-type: text/html\n\n"; print STDOUT @gra unless $gra[0] eq ""; if ($redir =~ /\.htm.*$/i){ $redir =~ s/^(.+\/).+\.htm.*$/$1/i; } if ($redir !~ /\/$/) { $redir = $redir . "/";} print STDOUT "\n"; print STDOUT $redirectedpage; exit; } } ###################################################################### # SERVE ROBOT PAGE TO ROBOT REQUESTOR ###################################################################### ###################################################################### sub robot{ # determine primary keyword $keyword = $myname; $keyword =~ s/\.htm//; $keyword =~ s/\-/ /g; $keyword =~ s/^\///; if ($keyword eq "index") { open (KEY, "<$writedir/indexkeywords.daq"); flock (KEY, 2); $keyword = ; flock (KEY, 8); close (KEY); } srand(length($keyword)); $SEsymbol = "# "; if (!$ifcl) { if ($SE eq "") { $SE = "web surfer"; $SEsymbol = " "; } $SE = $SE . " (cloaking disabled)"; $count = 9; } # access secondary keyword list open (SECONDARYKEYWORDS, "$writedir/keywords.txt"); flock(SECONDARYKEYWORDS, 2); @secondarykeywords = ; flock(SECONDARYKEYWORDS, 8); # open template open (TEMPLATE, "$writedir/template" . $count . ".txt"); flock(TEMPLATE, 2); @template =