#!/usr/bin/perl
use CGI qw(:standard);
$update=new CGI;
$webwatchdir="/home/toby/mud2/WEBWATCH";
$page_index="$webwatchdir/targetted_pages.txt";
$page_dir="$webwatchdir/pages";
$lynx="/usr/bin/lynx";
$ls="/bin/ls";
$html_fragments_dir=$webwatchdir;
#Read key index
open(KEYINDEX,"$page_index");
while() {
chomp;
($key,$url,$target_url,$title)=split(",");
if (length($target_url)==0) {
$target_url=$url;
}
$index{$key}=$target_url;
$title{$key}=$title;
}
close(KEYINDEX);
open(DIR,"$ls $page_dir/* |");
while() {
chomp;
$fileage=-M;
s/.*\///;
if (/[0-9]+/) {
# Get age of file.
$age{$fileage}=$_;
}
}
close(DIR);
@sortedkeys=sort by_mostly_numeric keys(%age);
$result_7days="";
$result_14days="";
foreach (@sortedkeys) {
$pagetitle=$title{$age{$_}};
$pageurl=$index{$age{$_}};
$pageage=int($_);
if ($_<7) {
$result_7days.=&Template("pagelink2.htmlf");
} elsif ($_<14) {
$result_14days.=&Template("pagelink2.htmlf");
}
}
print $update->header();
$result="";
$result=&Template("webwatch_header2.htmlf");
if (length($result_7days)!=0) {
$result.=&Template("header7days.htmlf");
$result.=$result_7days;
}
if (length($result_14days)!=0) {
$result.=&Template("header14days.htmlf");
$result.=$result_14days;
}
$result.=&Template("webwatch_footer2.htmlf");
print $result;
exit;
sub by_mostly_numeric {
($a <=> $b) || ($a cmp $b);
}
sub Template
{
local(*FILE);
local($file);
local($HTML);
local($_);
$file = $html_fragments_dir."/".$_[0] || die "Template : No template file specified\n";
open(FILE, "$file") || print " Error: $!";
while () {
$HTML .= $_;
}
close(FILE);
$HTML =~ s/\$(\w+)/${$1}/g;
return $HTML;
}
| [ |  | ] |
|
|
What is it?
I like to keep fairly up to date with the various MUD2 sites hosted around the web. Not too long ago this wasn't much of an onerous task; in fact I can remember when The Unofficial MUD2 Home Page was just about the only MUD2 dedicated site on the web. That can't have been more than about 2 years ago. Now? Well, there are quite a few more. And I'm getting lazy.
WEBWATCH keeps an eye on a bunch of MUD2 related web pages; whenever it discovers one of these pages has been updated it alerts me (and you) by listing it under the "WEBWATCH" heading on the MUD2.COM NOW! main page. The boxed number (eg , , etc.) by each page's title indicates the number of completed days since the page was updated. For example, a page that has just been updated today will show a zero. Once it's more than 2 weeks old the page falls off this list (until it's updated again, of course). The most recently updated pages appear towards the top of the WEBWATCH list.
Which web pages does it watch?
#!/usr/bin/perl
use CGI qw(:standard);
$update=new CGI;
$webwatchdir="/home/toby/mud2/WEBWATCH";
$page_index="$webwatchdir/targetted_pages.txt";
$page_dir="$webwatchdir/pages";
$result="";
#Read key index
open(KEYINDEX,"$page_index");
$result="";
while() {
chomp;
($key,$url,$target_url,$title)=split(",");
if (length($target_url)==0) {
$target_url=$url;
}
$result.="| $title | $target_url | ";
$index{$key}=$url;
$title{$key}=$title;
}
close(KEYINDEX);
$result.=" ";
print $update->header();
print $result;
exit;
Can I ask for a page to be added?
Of course! Simply send me an email telling me its URL.
|