#! /usr/bin/perl ############################################################################## # Cliff's 404 Finder Version 1.01 # # Copyright 1998 Shaven Ferret Productions # # Created 7/9/98 Last Modified 9/13/98 # # Available at http://www.shavenferret.com/scripts # ############################################################################## # COPYRIGHT NOTICE # # Copyright 1998 Shaven Ferret Productions All Rights Reserved. # # This script can be used\modified free of charge as long as you don't # # change this header thing. By using this script you agree to indemnify # # me from any liability that might arise from its use. In simple English, # # if this script somehow makes your computer run amuck and kill the pope, # # it's not my fault. # # # # Redistributing\selling the code for this program without prior written # # consent is expressly forbidden. # ############################################################################## # if the data file is not in the same directory as this script, enter it's # path. $datafile = "404.txt"; # Enter the URL of the page you would like people to be forwarded to when they # try to view a file that doesn't exist. $go_to = "404.html"; # Enter the password you want to use. $password = "sitex21"; ############################################################################## # Congratulations! You've finished defining the variables. If you want to, # # you can continue screwing with the script, but it isn't necessary. # ############################################################################## open (FILE,"$datafile"); @urls = ; close(FILE); if ($ENV{'QUERY_STRING'}) { if ($ENV{'HTTP_REFERER'}) { $i = 0; for ($i = 0; $i <= $#urls; $i++) { chomp($urls[$i]); ($num,$url) = split(/\|/, $urls[$i]); if ($ENV{'HTTP_REFERER'} eq $url) { $num++; $urls[$i] = "$num|$url"; $found = 1; } } unless ($found) { push(@urls,"1|$ENV{'HTTP_REFERER'}"); } if ($#urls > 1) { for($i = 0; $i < $#urls; $i++) { for($j = 0; $j <= $i; $j++) { ($num1,$x) = split(/\|/,$urls[$j]); ($num2,$x) = split(/\|/,$urls[$j+1]); if ($num1 < $num2) { $temp = $urls[$j]; $urls[$j] = $urls[$j+1]; $urls[$j+1] = $temp; } } } } open(FILE,">$datafile"); foreach $line(@urls) { print FILE "$line\n"; } close(FILE); } print "Location: $go_to\n\n"; } elsif ($ENV{"REQUEST_METHOD"} eq 'POST') { print "Content-type: text/html\n\n"; read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } if ($FORM{'password'} eq $password) { open (FILE,">$datafile"); close(FILE); print "Deleted\n"; print "The data has been deleted\n"; exit; } else { print "Bad Password\n"; print "The password you entered is incorrect.\n"; exit; } } else { print "Content-type: text/html\n\n"; print "404 Report\n"; print "
Rate\n"; print "this Script @ The CGI Resource Index
\n"; print "

404 Report

\n"; print "\n"; foreach $line(@urls) { chomp($line); ($num,$url) = split(/\|/,$line); print "\n"; } print "
HitsReferring URL
$num$url

Delete Data

\n"; print "Password:
\n"; print "
\n"; }