A
Annie
A kind volunteer wrote an effective perl script for my website ten or
more years back.
The script was called from header.html, and worked flawlessly for
years...until someone decided to mess with the headers and removed the
call to the cgi script.
This is the script - it delivered custom headers based on the visitor's
domain, and worked perfectly:
#!/usr/bin/env perl
use strict;
sub do_default {
open (HTMLIN, "header-default.html") or die "Error opening default
header";
while (<HTMLIN>) {
print;
}
close HTMLIN;
}
sub do_header {
my $domain;
$domain = shift(@_);
if (open (HTMLIN, "header-$domain.html")) {
while (<HTMLIN>) {
print;
}
close HTMLIN;
} else {
do_default;
}
}
MAIN: {
my($domain, $html, $toplevel);
$domain=$ENV{"REMOTE_HOST"};
$domain =~ /.+\.(.{1,3})$/;
$toplevel = $1;
print "Content-Type: text/html\n\n";
do_header($toplevel);
}
Can some kind soul provide me with a line of code that will call this
script?
more years back.
The script was called from header.html, and worked flawlessly for
years...until someone decided to mess with the headers and removed the
call to the cgi script.
This is the script - it delivered custom headers based on the visitor's
domain, and worked perfectly:
#!/usr/bin/env perl
use strict;
sub do_default {
open (HTMLIN, "header-default.html") or die "Error opening default
header";
while (<HTMLIN>) {
print;
}
close HTMLIN;
}
sub do_header {
my $domain;
$domain = shift(@_);
if (open (HTMLIN, "header-$domain.html")) {
while (<HTMLIN>) {
print;
}
close HTMLIN;
} else {
do_default;
}
}
MAIN: {
my($domain, $html, $toplevel);
$domain=$ENV{"REMOTE_HOST"};
$domain =~ /.+\.(.{1,3})$/;
$toplevel = $1;
print "Content-Type: text/html\n\n";
do_header($toplevel);
}
Can some kind soul provide me with a line of code that will call this
script?