| 1 |
#!/usr/bin/perl -w
|
| 2 |
#!/usr/local/bin/perl -w
|
| 3 |
#!/opt/perl/bin/perl -w
|
| 4 |
#
|
| 5 |
# Copyright (C) 1999 Mark Baysinger (mbaysing@ucsd.edu)
|
| 6 |
# Copyright (C) 1999,2000,2001 Ross Combs (rocombs@cs.nmsu.edu)
|
| 7 |
# Copyright (C) 2001 Roland Haeder (webmaster@ai-project-now.de)
|
| 8 |
#
|
| 9 |
# This program is free software; you can redistribute it and/or
|
| 10 |
# modify it under the terms of the GNU General Public License
|
| 11 |
# as published by the Free Software Foundation; either version 2
|
| 12 |
# of the License, or (at your option) any later version.
|
| 13 |
#
|
| 14 |
# This program is distributed in the hope that it will be useful,
|
| 15 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 17 |
# GNU General Public License for more details.
|
| 18 |
#
|
| 19 |
# You should have received a copy of the GNU General Public License
|
| 20 |
# along with this program; if not, write to the Free Software
|
| 21 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
| 22 |
|
| 23 |
# Version of this script
|
| 24 |
$version = "v1.05";
|
| 25 |
|
| 26 |
# modify to use correct locations
|
| 27 |
$infile = "./bnetdlist.txt";
|
| 28 |
#$infile = "/var/tmp/bnetdlist.txt";
|
| 29 |
$outfile = "./bnetdlist.html";
|
| 30 |
#$outfile = "/home/httpd/html/bnetdlist.html";
|
| 31 |
$tmpfile = $outfile . ".temp";
|
| 32 |
|
| 33 |
# document look
|
| 34 |
$page_bg_color = "#202020";
|
| 35 |
$link_color = "#5070FF";
|
| 36 |
$alink_color = "#FF3030";
|
| 37 |
$vlink_color = "#8090FF";
|
| 38 |
$tbl_border_color = "#404040";
|
| 39 |
$tbl_border_ramp = "0";
|
| 40 |
$tbl_border_width = "2";
|
| 41 |
$tbl_padding = "1";
|
| 42 |
$tbl_head_bg_color = "$tbl_border_color";
|
| 43 |
$tbl_bg_color = "#000000";
|
| 44 |
$tbl_text_color = "#80A0FF";
|
| 45 |
$title_bg_color = "$page_bg_color";
|
| 46 |
$title_text_color = "#FFFFFF";
|
| 47 |
$sum_bg_color = "$page_bg_color";
|
| 48 |
$sum_text_color = "$title_text_color";
|
| 49 |
|
| 50 |
# header strings
|
| 51 |
$title = "BNETD Server Status";
|
| 52 |
$header = "<br>$title<br>";
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
open(INFILE, "<$infile") || die("Can't open \"$infile\" for reading: $!\n");
|
| 57 |
$/ = "\#\#\#\n";
|
| 58 |
@servers = <INFILE>;
|
| 59 |
chomp @servers;
|
| 60 |
close INFILE;
|
| 61 |
|
| 62 |
|
| 63 |
open(OUTFILE, ">$tmpfile") || die("Can't open \"$tmpfile\" for writing: $!\n");
|
| 64 |
|
| 65 |
print OUTFILE "<html>\n";
|
| 66 |
print OUTFILE "<head>\n";
|
| 67 |
print OUTFILE " <meta name=\"GENERATOR\" content=\"process.pl $version\">\n";
|
| 68 |
print OUTFILE " <title>$title</title>\n";
|
| 69 |
print OUTFILE "</head>\n";
|
| 70 |
print OUTFILE "<body bgcolor=\"$page_bg_color\" text=\"$tbl_text_color\" link=\"$link_color\" vlink=\"$vlink_color\" alink=\"$alink_color\">\n";
|
| 71 |
print OUTFILE " <font face=\"Verdana,Helvetica,Arial\">\n";
|
| 72 |
|
| 73 |
print OUTFILE " <table border=\"0\" width=\"100%\">\n";
|
| 74 |
print OUTFILE " <tr>\n";
|
| 75 |
print OUTFILE " <td align=middle bgcolor=\"$title_bg_color\"><font color=\"$title_text_color\">$header</font><br></td>\n";
|
| 76 |
print OUTFILE " </tr>\n";
|
| 77 |
print OUTFILE " <tr>\n";
|
| 78 |
print OUTFILE " <td align=middle>\n";
|
| 79 |
print OUTFILE " <table border=\"0\" cellspacing=\"0\" bgcolor=\"$tbl_border_color\">\n";
|
| 80 |
print OUTFILE " <tr>\n";
|
| 81 |
print OUTFILE " <td>\n";
|
| 82 |
print OUTFILE " <table border=\"$tbl_border_ramp\" cellspacing=\"$tbl_border_width\" cellpadding=\"$tbl_padding\" bgcolor=\"$tbl_bg_color\">\n";
|
| 83 |
print OUTFILE " <tr>\n";
|
| 84 |
print OUTFILE " <th bgcolor=\"$tbl_head_bg_color\"><font size=2>Address</font></th>\n";
|
| 85 |
print OUTFILE " <th bgcolor=\"$tbl_head_bg_color\"><font size=2>Location</font></th>\n";
|
| 86 |
print OUTFILE " <th bgcolor=\"$tbl_head_bg_color\"><font size=2>Description</font></th>\n";
|
| 87 |
print OUTFILE " <th bgcolor=\"$tbl_head_bg_color\"><font size=2>URL</font></th>\n";
|
| 88 |
print OUTFILE " <th bgcolor=\"$tbl_head_bg_color\"><font size=2>Uptime</font></th>\n";
|
| 89 |
print OUTFILE " <th bgcolor=\"$tbl_head_bg_color\"><font size=2>Contact</font></th>\n";
|
| 90 |
print OUTFILE " <th bgcolor=\"$tbl_head_bg_color\"><font size=2>Software</font></th>\n";
|
| 91 |
print OUTFILE " <th bgcolor=\"$tbl_head_bg_color\"><font size=2>U</font></th>\n";
|
| 92 |
print OUTFILE " <th bgcolor=\"$tbl_head_bg_color\"><font size=2>C</font></th>\n";
|
| 93 |
print OUTFILE " <th bgcolor=\"$tbl_head_bg_color\"><font size=2>G</font></th>\n";
|
| 94 |
print OUTFILE " </tr>\n";
|
| 95 |
|
| 96 |
$allservers = 0;
|
| 97 |
$allusers = 0;
|
| 98 |
$allgames = 0;
|
| 99 |
|
| 100 |
foreach $server (@servers) {
|
| 101 |
print OUTFILE " <tr>\n";
|
| 102 |
$/ = "\#\#\n";
|
| 103 |
|
| 104 |
# Fix-up for special characters
|
| 105 |
$server =~ s/&/&/g;
|
| 106 |
$server =~ s/</</g;
|
| 107 |
$server =~ s/>/>/g;
|
| 108 |
|
| 109 |
@serverinfo = split /^\#\#\n/m, $server;
|
| 110 |
chomp @serverinfo;
|
| 111 |
chop @serverinfo;
|
| 112 |
|
| 113 |
# put fields into descriptive variable names
|
| 114 |
$addr = $serverinfo[0];
|
| 115 |
|
| 116 |
$loc = $serverinfo[2];
|
| 117 |
if (length($loc)<1) {
|
| 118 |
$loc = " ";
|
| 119 |
}
|
| 120 |
$desc = $serverinfo[8];
|
| 121 |
if (length($desc)<1) {
|
| 122 |
$desc = " ";
|
| 123 |
}
|
| 124 |
|
| 125 |
$soft = $serverinfo[3] . " " . $serverinfo[4];
|
| 126 |
$osys = $serverinfo[9];
|
| 127 |
if (length($osys)<1) {
|
| 128 |
$osys = "unknown";
|
| 129 |
}
|
| 130 |
|
| 131 |
$url = $serverinfo[10];
|
| 132 |
|
| 133 |
$contact = $serverinfo[11];
|
| 134 |
if (length($contact)<1) {
|
| 135 |
$contact = " ";
|
| 136 |
}
|
| 137 |
$email = $serverinfo[12];
|
| 138 |
|
| 139 |
$currusers = $serverinfo[5];
|
| 140 |
$totusers = $serverinfo[15];
|
| 141 |
|
| 142 |
$currchans = $serverinfo[6];
|
| 143 |
|
| 144 |
$currgames = $serverinfo[7];
|
| 145 |
$totgames = $serverinfo[14];
|
| 146 |
|
| 147 |
$uptime = sprintf("%02d:%02d:%02d",int $serverinfo[13]/3600, int ($serverinfo[13]%3600)/60, int $serverinfo[13]%60);
|
| 148 |
|
| 149 |
# print it out
|
| 150 |
print OUTFILE " <td><font size=1><a href=\"bnetd://$addr/\">$addr</a></font></td>\n"; # IP
|
| 151 |
print OUTFILE " <td><font size=1>$loc</font></td>\n";
|
| 152 |
print OUTFILE " <td><font size=1>$desc</font></td>\n";
|
| 153 |
if (length($url)<1) {
|
| 154 |
print OUTFILE " <td><font size=1> </font></td>\n";
|
| 155 |
} else {
|
| 156 |
print OUTFILE " <td><a href=\"$url\"><font size=1>$url</font></a></td>\n";
|
| 157 |
}
|
| 158 |
print OUTFILE " <td align=right><font size=1>$uptime</font></td>\n";
|
| 159 |
if (length($email)<1) {
|
| 160 |
print OUTFILE " <td><font size=1>$contact</font></td>\n";
|
| 161 |
} else {
|
| 162 |
print OUTFILE " <td><font size=1>$contact <a href=\"mailto:$email\">($email)</a></font></td>\n";
|
| 163 |
}
|
| 164 |
print OUTFILE " <td><font size=1>$soft<br>$osys</font></td>\n";
|
| 165 |
print OUTFILE " <td align=right><font size=1>${currusers}c<br>${totusers}t</font></td>\n";
|
| 166 |
print OUTFILE " <td align=right><font size=1>${currchans}</font></td>\n";
|
| 167 |
print OUTFILE " <td align=right><font size=1>${currgames}c<br>${totgames}t</font></td>\n";
|
| 168 |
print OUTFILE " </tr>\n";
|
| 169 |
|
| 170 |
$allservers++;
|
| 171 |
$allusers+=${currusers};
|
| 172 |
$allgames+=${currgames};
|
| 173 |
}
|
| 174 |
|
| 175 |
print OUTFILE " </table>\n";
|
| 176 |
print OUTFILE " </td>\n";
|
| 177 |
print OUTFILE " </tr>\n";
|
| 178 |
print OUTFILE " </table>\n";
|
| 179 |
print OUTFILE " <br><br>\n";
|
| 180 |
print OUTFILE " </td>\n";
|
| 181 |
print OUTFILE " </tr>\n";
|
| 182 |
|
| 183 |
print OUTFILE " <tr>\n";
|
| 184 |
print OUTFILE " <td align=middle><table border=\"0\">\n";
|
| 185 |
print OUTFILE " <tr>\n";
|
| 186 |
print OUTFILE " <td align=middle bgcolor=\"$sum_bg_color\">\n";
|
| 187 |
print OUTFILE " <font size=2 color=\"$sum_text_color\">\n";
|
| 188 |
print OUTFILE " servers: " . $allservers . "<br>\n";
|
| 189 |
print OUTFILE " users: " . $allusers . "<br>\n";
|
| 190 |
print OUTFILE " games: " . $allgames . "<br>\n";
|
| 191 |
print OUTFILE " <br>\n";
|
| 192 |
print OUTFILE " Last updated " . gmtime(time) . " GMT<br>\n";
|
| 193 |
print OUTFILE " </font><br>\n";
|
| 194 |
print OUTFILE " </td>\n";
|
| 195 |
print OUTFILE " </tr>\n";
|
| 196 |
print OUTFILE " </table></td>\n";
|
| 197 |
print OUTFILE " </tr>\n";
|
| 198 |
|
| 199 |
print OUTFILE " </table>\n";
|
| 200 |
print OUTFILE " </font>\n";
|
| 201 |
print OUTFILE "</body></html>\n";
|
| 202 |
|
| 203 |
close(OUTFILE);
|
| 204 |
|
| 205 |
unlink($outfile);
|
| 206 |
rename($tmpfile, $outfile);
|
| 207 |
|
| 208 |
exit(0);
|
| 209 |
|