#!/usr/bin/perl # If required, adjust line above to point to Perl 5. ###################################################################### # fantomas shadowSniper(TM) - Keyword Switch File # # ver. 02.02.01-e # 2000-02-27 # ###################################################################### # (c) Copyright 1999, 2000 by fantomaster.com # # All rights reserved. # # Copying, modification or distribution requires permission # # in writing by copyright holder. # # fantomas shadowSniper(TM) is the protected trade mark of # # fantomaster.com. # # Please contact: # # URL: # ###################################################################### ###################################################################### ########## WHAT TO DO WITH THIS FILE ################## # # # SAVE THIS FILE FOR EVERY KEYWORD UNDER THE PERTINENT # # KEYWORD NAME! # # Example: "keyword1.htm" # # BE SURE TO SAVE UNDER EXTENSION ".htm" (i.e. NOT ".html")! # # File permissions: "chmod 755" [-rwxr-xr-x] # # # # Make sure to store in the directory defined as # # variable "$stats_dir" (see below) a stealth page carrying an # # identical name (this time, however, sporting extension ".html"! # # Example: "keyword1.html" # # The ".html" stealth page will only be read by search bots and can # # hence be optimized accordingly. # ###################################################################### ########## PLEASE READ! PLEASE HEED! ############# # # # Variable "$standard" denotes the path and file you want to # # redirect your "normal" visitors to (i.e. NO machines, searchbots, # # etc.) The default value assumes: # # 1. that this script file sniper-e.cgi resides in your CGI # # directory (e.g. "cgi-bin"); # # 2. that normal visitors shall be diverted to file "index.html" in # # your main directory, which will typically reside one level # # above the CGI directory. # # Should you wish to change this (e.g. for redirection to another # # web site directory) please note that the path must be given in # # URL format - NOT in UNIX path format! # # Example: "http://YourDomain.com/reports/report1.html" # # # # If the pages for normal visitors have the extension ".htm", the # # file in variable "$standard" must also have the extension ".htm"! # # # # Seeing that you can adjust this entry individually in each and # # every Keyword Switch File, it is possible to guide your visitors # # precisely to every one of your site's pages, in full accord with # # chosen key words. # ###################################################################### ###################################################################### ########## PLEASE ADJUST THE FOLLOWING VARIABLES! ################ # # # "$standard" = Please heed advice in commentary box above! # # "$normal_ext" = extension of pages for normal visitors # # "$stats_dir" = stealth pages directory - *MUST* BE BELOW # # DIRECTORY OF FILE "sniper-e.cgi"! # # (Default name is: "stats") # # Directory permissions: "chmod 777" [drwxrwxrwx] (*nix) # # Directory permissions: "write" (NT) # # "$log_file" = log file listing spider robots hits # # (Default name is: "hits.log") # # File permissions: "chmod 666" [-rw-rw-rw-] (*nix) # # File permissions: "write" (NT) # # THIS FILE MUST RESIDE IN THE DIRECTORY SPECIFIED # # UNDER "$stats_dir"! # # "$robot_file" = file containing spider robots list # # (Default name is: "register.txt") # # File permissions: "chmod 666" [-rw-rw-rw-] (*nix) # # File permissions: "write" (NT) # # THIS FILE MUST RESIDE IN THE DIRECTORY SPECIFIED # # UNDER "$stats_dir"! # # "$redirect" = if variable is set to "1", normal visitors will be # # redirected to the normal page; # # if variable is set to "0", the normal page wll be # # read by this script and displayed to the normal # # visitor from there - NO SSI possible on such pages!# ###################################################################### $standard = "/home/wb/www/help/human/index_3.html"; $normal_ext = "html"; $stats_dir = "../cgi-bin/stats"; $phantom_dir = "/home/wb/www/help/spider/"; $log_file = "hits.log"; $robot_file = "spiderspy.txt"; $redirect = 0; ###################################################################### ################ THE FINAL STEPS ################ # # # After editing the variables above, you will want to copy this # # whole Keyword Switch File under various keyword names, # # e.g. "keyword1.htm", "keyword2.htm", etc. # # Please take care to ALWAYS give it the ending "htm" (i.e. # # NOT "html" or anything else for that matter). # # When uploading to your WWW directory, be sure to upload ONLY # # in ASCII mode! # # After upload, you will need to assign file permission "755" # # [-rwxr-xr-x] to your Keyword Switch Files. # # These are the same files whose URLs you will register with the # # search engines, e.g. "http://yourdomain.com/cgi-bin/keyword1.htm". # # While it is strongly advised to store your Keyword Switch Files in # # your main WWW directory (e.g."http://yourdomain.com/keyword1.htm") # # note that you may have to adjust your directory's configuration # # to make this a viable option. Under Unix, this is usually effected # # by employing file ".htaccess". # # Please see the manual for further details, including NT server # # issues. # ###################################################################### ###################################################################### ############# NO EDITING BEYOND THIS LINE! ####################### ###################################################################### $switch_name = $ENV{'SCRIPT_NAME'}; #if ($normal_ext eq "html"){ # $fantom_name = $switch_name."l"; #} #elsif ($normal_ext eq "htm"){ # $fantom_name = substr ($switch_name, 0, -1); #} $fantom_name = $switch_name; $fantom_name =~ s/^\/.*\///; $referer = "$ENV{'HTTP_REFERER'}"; $user_agent = "$ENV{'HTTP_USER_AGENT'}"; $remote_host = "$ENV{'REMOTE_HOST'}"; $remote_addr = "$ENV{'REMOTE_ADDR'}"; ###################################################################### &get_date; &process_register; if ($search_engine){&fantom;} else {&standard;} exit; ###################################################################### sub get_date { ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(); $mon++; $min = sprintf ("%02d", $min); $hour = sprintf ("%02d", $hour); $mday = sprintf ("%02d", $mday); $mon = sprintf ("%02d", $mon); $year = scalar localtime; $year =~ s/.*?(\d{4})/$1/; $date="$year-$mon-$mday, $hour:$min"; } ###################################################################### sub process_register { open (REGISTER, "$stats_dir/$robot_file"); @register=; close (REGISTER); $search_engine = (); foreach $robot (@register) { next if ($robot =~ /^[#-]/); next if ($robot =~ /^\s*$/); chomp $robot; if (($remote_host eq $robot) or ($remote_addr eq $robot)){ $search_engine = 1; last; } } } ###################################################################### sub standard { if ($redirect == 1){ print "Location: $standard\n\n"; } elsif ($redirect == 0){ open (STANDARD, "<$standard"); @HTML = ; close (STANDARD); print "Content-type: text/html\n\n"; print @HTML; } &log_hits ("$date -- $remote_host -- $remote_addr -- $switch_name -- $referer -- $user_agent\n"); } ###################################################################### sub fantom { open (FANTOM, "<$phantom_dir/$fantom_name"); @HTML = ; close (FANTOM); print "Content-type: text/html\n\n"; print @HTML; &log_hits ("!!$date -- $remote_host -- $remote_addr -- $switch_name -- $referer -- $user_agent\n"); } ###################################################################### sub log_hits { open (HITS, ">>$stats_dir/$log_file"); print HITS @_; close (HITS); } ######################################################################