#!/usr/bin/perl
use CGI qw(:standard);
use Time::Local;
$html_fragments_dir="/home/toby/webs/www.qtq.org/htdocs/mud2/NOW";
$mobile_records_dir="/home/toby/mud2/telnet/RESET_LOGS/mobile_records";
$your_host=remote_addr();
%level=("protector",1,"seer",1,
"yeoman",2,"soothsayer",2,
"warrior",3,"cabalist",3,
"swordsman",4,"magician",4,
"hero",5,"enchanter",5,
"superhero",6,"spellbinder",6,
"champion",7,"sorcerer",7,
"guardian",8,"necromancer",8,
"legend",9,"warlock",9,
"Sir",10,"mage",10,
"protector",1,"seeress",1,
"yeowoman",2,"soothsayer",2,
"warrior",3,"cabalist",3,
"swordswoman",4,"magicienne",4,
"heroine",5,"enchantress",5,
"superheroine",6,"spellbindress",6,
"championne",7,"sorceress",7,
"guardienne",8,"necromancess",8,
"legend",9,"warlock",9,
"Lady",10,"mage",10,
"pathfinder",1,"neophyte",1,
"voyager",2,"pilgrim",2,
"wayfarer",3,"acolyte",3,
"scout",4,"friar",4,
"rover",5,"cleric",5,
"pioneer",6,"Brother",6,
"explorer",7,"priest",7,
"ranger",8,"prelate",8,
"minstrel",9,"patriarch",9,
"pathfinder",1,"neophyte",1,
"voyager",2,"pilgrim",2,
"wayfarer",3,"acolyte",3,
"scout",4,"friar",4,
"rover",5,"cleric",5,
"pioneer",6,"Sister",6,
"explorer",7,"priestess",7,
"ranger",8,"prelate",8,
"minstrel",9,"matriarch",9);
foreach (keys %level) {
#print "
$_=$level{$_}
";
$kills{$_}=0;
}
$mobile=param('keywords');
if ((length($mobile)==0)||(length($mobile)>20)) {
print "Status: 204 No Response\n\n";
SystemLog("mobile_victims.pl: 204 (mobile name invalid)");
exit;
}
$_=$mobile;
s/[0-9]//g;
tr/A-Z/a-z/;
$bad_chars=tr/a-z//c;
if ($bad_chars!=0) {
SystemLog("mobile_victims.pl: 204 (contained invalid characters: [$_])");
print "Status: 204 No Response\n\n";
exit;
}
$match_found=0;
open(FILE,"/home/toby/webs/www.qtq.org/htdocs/mud2/NOW/top5mobiles.html");
while () {
s/.+\//;
s/\.\ | \ | .*//;
s/ //g;
if (m/$mobile/) {
$match_found=1;
last;
}
}
close(FILE);
if (! $match_found) {
SystemLog("mobile_victims.pl: 204 ($mobile not in top5mobiles.html");
print "Status: 204 No Response\n\n";
exit;
}
foreach $filename (<$mobile_records_dir/The_*>) {
$_=$filename;
s#.*\/##g;
s#_##g;
s#The##g;
if (m#$mobile#) {
open(FILE,$filename);
$mobile_name=;
chomp($mobile_name);
while ($line=) {
chomp($line);
$_=$line;
($victim)=/\[.*\]\=\>\[(.*)\]/;
$victim=~s/\(//;
$victim=~s/\)//;
$victim=" $victim ";
#$result.="($mobile_name,$victim)
";
foreach (keys %level) {
if ($victim=~m# $_ #) {
#$result.="$_
";
$kills{$_}++;
last;
}
}
}
close(FILE);
last;
}
}
#$result.="";
#foreach (keys %level) {
# $result.="| $_ | $kills{$_} |
";
#}
#$result.="
";
if (! defined($mobile_name)) {
SystemLog("mobile_victims.pl: couldn't find a file for [$mobile]");
print "Status: 204 No Response\n\n";
exit;
}
SystemLog("mobile_victims.pl: [$mobile] OK");
#print "Fatalities caused by $mobile_name.
\n";
open(FILE,"/home/toby/mud2/telnet/RESET_LOGS/LAST_RESET_MOBILE_KILLS_COUNTED");
$LAST_RESET=;
close(FILE);
chomp($LAST_RESET);
$mobile_name=lc($mobile_name);
$sum=0;
$kills=0;
$table="";
$table.="| UNPROTECTED PERSONAE | KILLS | SCORE |
";
$total=$kills{protector}+$kills{seer}+$kills{seeress};
$score=$total*$level{protector};
$sum+=$score;
$kills+=$total;
$table.="| protector | $kills{protector} | seer/seeress | $kills{seer}/$kills{seeress} | $total | $score |
";
$total=$kills{yeoman}+$kills{yeowoman}+$kills{soothsayer};
$score=$total*$level{yeoman};
$sum+=$score;
$kills+=$total;
$table.="| yeoman/yeowoman | $kills{yeoman}/$kills{yeowoman} | soothsayer | $kills{soothsayer} | $total | $score |
";
$total=$kills{warrior}+$kills{cabalist};
$score=$total*$level{warrior};
$sum+=$score;
$kills+=$total;
$table.="| warrior | $kills{warrior} | cabalist | $kills{cabalist} | $total | $score |
";
$total=$kills{swordsman}+$kills{swordswoman}+$kills{magician}+$kills{magicienne};
$score=$total*$level{swordsman};
$sum+=$score;
$kills+=$total;
$table.="| swordsman/swordswoman | $kills{swordsman}/$kills{swordswoman} | magician/magicienne | $kills{magician}/$kills{magicienne} | $total | $score |
";
$total=$kills{hero}+$kills{heroine}+$kills{enchanter}+$kills{echantress};
$score=$total*$level{hero};
$sum+=$score;
$kills+=$total;
$table.="| hero/heroine | $kills{hero}/$kills{heroine} | enchanter/enchantress | $kills{enchanter}/$kills{enchantress} | $total | $score |
";
$total=$kills{superhero}+$kills{superheroine}+$kills{spellbinder}+$kills{spellbindress};
$score=$total*$level{superhero};
$sum+=$score;
$kills+=$total;
$table.="| superhero/superheroine | $kills{superhero}/$kills{superheroine} | spellbinder/spellbindress | $kills{spellbinder}/$kills{spellbindress} | $total | $score |
";
$total=$kills{champion}+$kills{championne}+$kills{sorcerer}+$kills{sorceress};
$score=$total*$level{champion};
$sum+=$score;
$kills+=$total;
$table.="| champion/championne | $kills{champion}/$kills{championne} | sorcerer/sorceress | $kills{sorcerer}/$kills{sorceress} | $total | $score |
";
$total=$kills{guardian}+$kills{guardienne}+$kills{necromancer}+$kills{necromancess};
$score=$total*$level{guardian};
$sum+=$score;
$kills+=$total;
$table.="| guardian/guardienne | $kills{guardian}/$kills{guardienne} | necromancer/necromancess | $kills{necromancer}/$kills{necromancess} | $total | $score |
";
$total=$kills{legend}+$kills{warlock};
$score=$total*$level{legend};
$sum+=$score;
$kills+=$total;
$table.="| legend | $kills{legend} | warlock | $kills{warlock} | $total | $score |
";
$total=$kills{Sir}+$kills{Lady}+$kills{mage};
$score=$total*$level{Sir};
$sum+=$score;
$kills+=$total;
$table.="| Sir/Lady | $kills{Sir}/$kills{Lady} | mage | $kills{mage} | $total | $score |
";
$table.="| PROTECTED PERSONAE | KILLS | SCORE |
";
$total=$kills{pathfinder}+$kills{neophyte};
$score=$total*$level{pathfinder};
$sum+=$score;
$kills+=$total;
$table.="| pathfinder | $kills{pathfinder} | neophyte | $kills{neophyte} | $total | $score |
";
$total=$kills{voyager}+$kills{pilgrim};
$score=$total*$level{voyager};
$sum+=$score;
$kills+=$total;
$table.="| voyager | $kills{voyager} | pilgrim | $kills{pilgrim} | $total | $score |
";
$total=$kills{wayfarer}+$kills{acolyte};
$score=$total*$level{wayfarer};
$sum+=$score;
$kills+=$total;
$table.="| wayfarer | $kills{wayfarer} | acolyte | $kills{acolyte} | $total | $score |
";
$total=$kills{scout}+$kills{friar};
$score=$total*$level{scout};
$sum+=$score;
$kills+=$total;
$table.="| scout | $kills{scout} | friar | $kills{friar} | $total | $score |
";
$total=$kills{rover}+$kills{cleric};
$score=$total*$level{rover};
$sum+=$score;
$kills+=$total;
$table.="| rover | $kills{rover} | cleric | $kills{cleric} | $total | $score |
";
$total=$kills{pioneer}+$kills{Brother}+$kills{Sister};
$score=$total*$level{pioneer};
$sum+=$score;
$kills+=$total;
$table.="| pioneer | $kills{pioneer} | Brother/Sister | $kills{Brother}/$kills{Sister} | $total | $score |
";
$total=$kills{explorer}+$kills{priest}+$kills{priestess};
$score=$total*$level{explorer};
$sum+=$score;
$kills+=$total;
$table.="| explorer | $kills{explorer} | priest/priestess | $kills{priest}/$kills{priestess} | $total | $score |
";
$total=$kills{ranger}+$kills{prelate};
$score=$total*$level{ranger};
$sum+=$score;
$kills+=$total;
$table.="| ranger | $kills{ranger} | prelate | $kills{prelate} | $total | $score |
";
$total=$kills{minstrel}+$kills{patriarch}+$kills{matriarch};
$score=$total*$level{minstrel};
$sum+=$score;
$kills+=$total;
$table.="| minstrel | $kills{minstrel} | patriarch/matriarch | $kills{patriarch}/$kills{matriarch} | $total | $score |
";
$table.="| GRAND TOTAL | $kills | $sum |
";
$table.="
";
$result=&Template("mobile_victims.htmlf");
print header();
print $result;
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;
}
sub SystemLog {
local (*LOG_FILE);
local ($log_filename);
local ($log_string);
local ($log_time);
$log_filename="/home/toby/mud2/mud2comNOW_system_log.txt";
$log_string=$_[0];
$currenttime=`/bin/date +'@ %d %B %y, %X %Z'`;
$log_time=$currenttime;
chomp($log_time);
open(LOG_FILE,">>$log_filename");
print LOG_FILE "$log_time:$log_string/$your_host\n";
close(LOG_FILE);
}