#!/usr/bin/perl use Socket; use CGI qw(:standard); my($remote,$port,$iaddr,$paddr,$proto,$q3aquery); my($result); my($gamename,$mapname,$gametype,%p_frags,%p_ping,$p_name,@p_names,$fra +gs,$ping); my($sv_hostname,@f_result,$line); $remote = "204.112.131.22"; $port = "27960"; $q3aquery = "\377\377\377\377getstatus\n"; $iaddr = inet_aton($remote) || die "no host: $remote"; $paddr = sockaddr_in($port, $iaddr); $proto = getprotobyname("udp"); socket(SOCK, PF_INET, SOCK_DGRAM, $proto) || die "socket: $!"; connect(SOCK, $paddr) || die "connect: $!"; send(SOCK, $q3aquery, 0) || die "send: $!"; recv(SOCK, $result, 2048, 0); ($gamename) = $result =~ m/gamename\\(.*?)\\/i; ($mapname) = $result =~ m/mapname\\(.*?)\\/i; ($gametype) = $result =~ m/g_gametype\\(\d)\\/i; ($sv_hostname) = $result =~ m/sv_hostname\\(.*?)\\/i; @f_result = split /\n/, $result; foreach $line (@f_result) { if (($frags, ,$ping, $p_name) = $line =~ m/^(\d+|-\d+)\s(\d+)\s"(. +*?)"/i) { $p_name =~ s/\^\d//g; $p_frags{$p_name} = $frags; $p_ping{$p_name} = $ping; push @p_names, $p_name; } } print "Content=type:text/html\n\n"; print qq!<html><head><title>Quake3Arena</title><META HTTP-EQUIV=Refres +h CONTENT=10; URL=http://www.gibfest.org/cgi/q3astatus.cgi></head> <body bgcolor="#000000" leftmargin="0" topmargin="0" bottombargin="0" +marginwidth="0" marginheight="0" link="#fffffe" vlink="#fffffe" alin +k="#fffffe" text="#fffffe"> !; print "<img src=http://www.gibfest.org/q3a_logo_small.gif border=0 ali +gn=right valign=top>"; print "<table border=0 cellpadding=0 cellspacing=0 width=250><tr><td bgcolor=#000000><font size=1 face=arial>Host: $sv_hostname Status</fon +t></td></tr></table>"; print "<table border=0 cellpadding=0 cellspacing=1 width=220 bgcolor=#000000><tr>"; print "<td width=80 align=right bgcolor=#2F545B><font face=arial size= +1>.: Game :. &nbsp;</font></td>"; print "<td width=130 align=left bgcolor=#23343E><font face=arial size= +1> &nbsp; $gamename</font></td>"; print "</tr><tr>"; print "<td width=80 align=right bgcolor=#2F545B><font face=arial size= +1>.: Map :. &nbsp;</font></td>"; print "<td width=130 align=left bgcolor=#23343E><font face=arial size= +1> &nbsp; $mapname</font></td>"; print "</tr><tr>"; print "<td width=80 align=right bgcolor=#2F545B><font face=arial size= +1>.: Type :. &nbsp;</font></td>"; print "<td width=130 align=left bgcolor=#23343E><font face=arial size= +1> &nbsp; $gametype</font></td>"; print "</tr><tr>"; print "<td width=80 align=right bgcolor=#2F545B><font face=arial size= +1>.: Address :. &nbsp;</font></td>"; print "<td width=130 align=left bgcolor=#23343E><font face=arial size= +1> &nbsp; 204.112.131.22</font></td>"; print "</tr></table>"; print "<br><table border=0 cellpadding=0 cellspacing=1 width=400 bgcolor=#000000>"; print "<th width=225 align=middle bgcolor=#23343E><font face=arial si +ze=1> .: Player Name :.</font></th> <th width=75 align=middle bgcolor=#2F545B><font face=arial size=1> +.: Frags :.</font></th> <th width=100 align=middle bgcolor=#23343E><font face=arial size=1 +>.: Ping :.</font></th>"; if ($#p_names <= -1) { print "<br><font size=1 face=arial>No players currently playing on + $sv_hostname.</font>"; } else { foreach $player (@p_names) { print "<tr> <td bgcolor=#2F545B width=225 align=middle><font size=1face=arial>$pla +yer</font></td> <td bgcolor=#23343E width=75 align=middle><font size=1 face=arial>$p_f +rags{$player}</font></td> <td bgcolor=#2F545B width=100 align=middle><font size=1 face=arial>$p_ +ping{$player}</font></td> </tr>"; } } print "</table></body></html>";

In reply to Quake3 Monitor by djw

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.