#!/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.=""; #} #$result.="
$_$kills{$_}
"; 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.=""; $total=$kills{protector}+$kills{seer}+$kills{seeress}; $score=$total*$level{protector}; $sum+=$score; $kills+=$total; $table.=""; $total=$kills{yeoman}+$kills{yeowoman}+$kills{soothsayer}; $score=$total*$level{yeoman}; $sum+=$score; $kills+=$total; $table.=""; $total=$kills{warrior}+$kills{cabalist}; $score=$total*$level{warrior}; $sum+=$score; $kills+=$total; $table.=""; $total=$kills{swordsman}+$kills{swordswoman}+$kills{magician}+$kills{magicienne}; $score=$total*$level{swordsman}; $sum+=$score; $kills+=$total; $table.=""; $total=$kills{hero}+$kills{heroine}+$kills{enchanter}+$kills{echantress}; $score=$total*$level{hero}; $sum+=$score; $kills+=$total; $table.=""; $total=$kills{superhero}+$kills{superheroine}+$kills{spellbinder}+$kills{spellbindress}; $score=$total*$level{superhero}; $sum+=$score; $kills+=$total; $table.=""; $total=$kills{champion}+$kills{championne}+$kills{sorcerer}+$kills{sorceress}; $score=$total*$level{champion}; $sum+=$score; $kills+=$total; $table.=""; $total=$kills{guardian}+$kills{guardienne}+$kills{necromancer}+$kills{necromancess}; $score=$total*$level{guardian}; $sum+=$score; $kills+=$total; $table.=""; $total=$kills{legend}+$kills{warlock}; $score=$total*$level{legend}; $sum+=$score; $kills+=$total; $table.=""; $total=$kills{Sir}+$kills{Lady}+$kills{mage}; $score=$total*$level{Sir}; $sum+=$score; $kills+=$total; $table.=""; $table.=""; $total=$kills{pathfinder}+$kills{neophyte}; $score=$total*$level{pathfinder}; $sum+=$score; $kills+=$total; $table.=""; $total=$kills{voyager}+$kills{pilgrim}; $score=$total*$level{voyager}; $sum+=$score; $kills+=$total; $table.=""; $total=$kills{wayfarer}+$kills{acolyte}; $score=$total*$level{wayfarer}; $sum+=$score; $kills+=$total; $table.=""; $total=$kills{scout}+$kills{friar}; $score=$total*$level{scout}; $sum+=$score; $kills+=$total; $table.=""; $total=$kills{rover}+$kills{cleric}; $score=$total*$level{rover}; $sum+=$score; $kills+=$total; $table.=""; $total=$kills{pioneer}+$kills{Brother}+$kills{Sister}; $score=$total*$level{pioneer}; $sum+=$score; $kills+=$total; $table.=""; $total=$kills{explorer}+$kills{priest}+$kills{priestess}; $score=$total*$level{explorer}; $sum+=$score; $kills+=$total; $table.=""; $total=$kills{ranger}+$kills{prelate}; $score=$total*$level{ranger}; $sum+=$score; $kills+=$total; $table.=""; $total=$kills{minstrel}+$kills{patriarch}+$kills{matriarch}; $score=$total*$level{minstrel}; $sum+=$score; $kills+=$total; $table.=""; $table.=""; $table.="
UNPROTECTED PERSONAEKILLSSCORE
protector$kills{protector}seer/seeress $kills{seer}/$kills{seeress}$total$score
yeoman/yeowoman$kills{yeoman}/$kills{yeowoman}soothsayer$kills{soothsayer}$total$score
warrior$kills{warrior}cabalist$kills{cabalist}$total$score
swordsman/swordswoman$kills{swordsman}/$kills{swordswoman}magician/magicienne$kills{magician}/$kills{magicienne}$total$score
hero/heroine$kills{hero}/$kills{heroine}enchanter/enchantress$kills{enchanter}/$kills{enchantress}$total$score
superhero/superheroine$kills{superhero}/$kills{superheroine}spellbinder/spellbindress$kills{spellbinder}/$kills{spellbindress}$total$score
champion/championne$kills{champion}/$kills{championne}sorcerer/sorceress$kills{sorcerer}/$kills{sorceress}$total$score
guardian/guardienne$kills{guardian}/$kills{guardienne}necromancer/necromancess$kills{necromancer}/$kills{necromancess}$total$score
legend$kills{legend}warlock$kills{warlock}$total$score
Sir/Lady$kills{Sir}/$kills{Lady}mage$kills{mage}$total$score
PROTECTED PERSONAEKILLSSCORE
pathfinder$kills{pathfinder}neophyte$kills{neophyte}$total$score
voyager$kills{voyager}pilgrim$kills{pilgrim}$total$score
wayfarer$kills{wayfarer}acolyte$kills{acolyte}$total$score
scout$kills{scout}friar$kills{friar}$total$score
rover$kills{rover}cleric$kills{cleric}$total$score
pioneer$kills{pioneer}Brother/Sister$kills{Brother}/$kills{Sister}$total$score
explorer$kills{explorer}priest/priestess$kills{priest}/$kills{priestess}$total$score
ranger$kills{ranger}prelate$kills{prelate}$total$score
minstrel$kills{minstrel}patriarch/matriarch$kills{patriarch}/$kills{matriarch}$total$score
GRAND TOTAL$kills$sum
"; $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); }