#!/usr/bin/perl
#Name of the configuration File
$indexdat = \"config.m\";
# Deny Page to be displayed on deny
$denied = \"
http://www.dk.dk/deny.html\";# File to write the denied host name and ip
$write_page = \"denied.txt\";
# IP and host name to be rejected.
$adress_deny = \"121.212.23.23\";
$host_deny=\"ir.irla.dk\";
# Set $antiopt = \"yes\" to protect your files
# From being linked to other people\'s sites.
$antiopt = \"no\";
# Name of the file that contains the names of the
# pages to allw to link to the scipt
$anticfg = \"allow.m\";
####################################
$address = $ENV{\'remote_addr\'};
$host= $ENV{\'remote_host\'};
If($host=~ /$host_deny/)
{
$write_entry;
}
open(LFILE,\"$anticfg\");
@LData = <LFILE>;
close(LFILE);
foreach $LLine (@LData) {
($hname, $mime, $locat) = split(/\\|/,$LLine);
if ($ENV{\'HTTP_REFERER\'} eq \"$hname\") {
&indexfile;
exit;
}
}
if ($antiopt eq \"yes\") {
&Leech;
exit;
}
else {
&indexfile;
}
sub indexfile {
open(FILE,\"$indexdat\");
@Data = <FILE>;
close(FILE);
foreach $Line (@Data) {
($name, $mime, $locat) = split(/\\|/,$Line);
if ($ENV{\'QUERY_STRING\'} eq \"$name\") {
print \"Location: $locat\\n\\n\";
exit;
}
}
if ($ENV{\'QUERY_STRING\'} eq \"\") {
print \"Content-type: text/html\\n\\n\";
print \"<title>Error</title>\\n\";
print \"<center><font face=Arial,Helvetica><h1>Error</h1></center></font><p>\\n\";
print \"<center><font face=Arial,Helvetica>You must enter the name of the file</font></center>\\n\";
exit;
}
else {
print \"Content-type: text/html\\n\\n\";
print \"<title>Error</title>\\n\";
print \"<center><font face=Arial,Helvetica><h1>Error</h1></center></font><p>\\n\";
print \"<center><font face=Arial,Helvetica>The name \'$ENV{\'QUERY_STRING\'}\' was not found in the data file.</center></font><p>\\n\";
exit;
}
}
Sub Write_Entry {
Open(File, \">>$write_page\");
Print File \"$address\\n\";
Print File \"$host\\n\";
close(File);
Print \"Location: $denied\\n\\n\";
}
sub Leech {
print \"Content-type: text/html\\n\\n\";
print \"<title>Sorry</title>\\n\";
print \"<center><font face=Arial,Helvetica><h1>Sorry</h1></center></font><p>\\n\";
print \"<center><font face=Arial,Helvetica>You may not link to my media files</font></center>\\n\";
}
Jeg har da alle filer på serveren, denied.txt, config.m, osv..