#!/usr/bin/perl -w #!/usr/local/bin/perl -w #!/opt/perl/bin/perl -w # # Copyright (C) 1999 Mark Baysinger (mbaysing@ucsd.edu) # Copyright (C) 1999,2000,2001 Ross Combs (rocombs@cs.nmsu.edu) # Copyright (C) 2001 Roland Haeder (webmaster@ai-project-now.de) # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Version of this script $version = "v1.05"; # modify to use correct locations $infile = "./bnetdlist.txt"; #$infile = "/var/tmp/bnetdlist.txt"; $outfile = "./bnetdlist.html"; #$outfile = "/home/httpd/html/bnetdlist.html"; $tmpfile = $outfile . ".temp"; # document look $page_bg_color = "#202020"; $link_color = "#5070FF"; $alink_color = "#FF3030"; $vlink_color = "#8090FF"; $tbl_border_color = "#404040"; $tbl_border_ramp = "0"; $tbl_border_width = "2"; $tbl_padding = "1"; $tbl_head_bg_color = "$tbl_border_color"; $tbl_bg_color = "#000000"; $tbl_text_color = "#80A0FF"; $title_bg_color = "$page_bg_color"; $title_text_color = "#FFFFFF"; $sum_bg_color = "$page_bg_color"; $sum_text_color = "$title_text_color"; # header strings $title = "BNETD Server Status"; $header = "
$title
"; open(INFILE, "<$infile") || die("Can't open \"$infile\" for reading: $!\n"); $/ = "\#\#\#\n"; @servers = ; chomp @servers; close INFILE; open(OUTFILE, ">$tmpfile") || die("Can't open \"$tmpfile\" for writing: $!\n"); print OUTFILE "\n"; print OUTFILE "\n"; print OUTFILE " \n"; print OUTFILE " $title\n"; print OUTFILE "\n"; print OUTFILE "\n"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE "
$header
\n"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE "
\n"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE " \n"; $allservers = 0; $allusers = 0; $allgames = 0; foreach $server (@servers) { print OUTFILE " \n"; $/ = "\#\#\n"; # Fix-up for special characters $server =~ s/&/&/g; $server =~ s//>/g; @serverinfo = split /^\#\#\n/m, $server; chomp @serverinfo; chop @serverinfo; # put fields into descriptive variable names $addr = $serverinfo[0]; $loc = $serverinfo[2]; if (length($loc)<1) { $loc = " "; } $desc = $serverinfo[8]; if (length($desc)<1) { $desc = " "; } $soft = $serverinfo[3] . " " . $serverinfo[4]; $osys = $serverinfo[9]; if (length($osys)<1) { $osys = "unknown"; } $url = $serverinfo[10]; $contact = $serverinfo[11]; if (length($contact)<1) { $contact = " "; } $email = $serverinfo[12]; $currusers = $serverinfo[5]; $totusers = $serverinfo[15]; $currchans = $serverinfo[6]; $currgames = $serverinfo[7]; $totgames = $serverinfo[14]; $uptime = sprintf("%02d:%02d:%02d",int $serverinfo[13]/3600, int ($serverinfo[13]%3600)/60, int $serverinfo[13]%60); # print it out print OUTFILE " \n"; # IP print OUTFILE " \n"; print OUTFILE " \n"; if (length($url)<1) { print OUTFILE " \n"; } else { print OUTFILE " \n"; } print OUTFILE " \n"; if (length($email)<1) { print OUTFILE " \n"; } else { print OUTFILE " \n"; } print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE " \n"; $allservers++; $allusers+=${currusers}; $allgames+=${currgames}; } print OUTFILE "
AddressLocationDescriptionURLUptimeContactSoftwareUCG
$addr$loc$desc $url$uptime$contact$contact ($email)$soft
$osys
${currusers}c
${totusers}t
${currchans}${currgames}c
${totgames}t
\n"; print OUTFILE "
\n"; print OUTFILE "

\n"; print OUTFILE "
\n"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE " \n"; print OUTFILE "
\n"; print OUTFILE " \n"; print OUTFILE " servers: " . $allservers . "
\n"; print OUTFILE " users: " . $allusers . "
\n"; print OUTFILE " games: " . $allgames . "
\n"; print OUTFILE "
\n"; print OUTFILE " Last updated " . gmtime(time) . " GMT
\n"; print OUTFILE "

\n"; print OUTFILE "
\n"; print OUTFILE "
\n"; print OUTFILE "\n"; close(OUTFILE); unlink($outfile); rename($tmpfile, $outfile); exit(0);