#!d:\\webspace\\seeminternet\\clantm\\clantm.co.uk\\www\\cgi-bin

# If your text editor font is set to anything other than "fixedsys"
# I suggest you change it back if you wish to understand this file. :)

#######################################################################
#                                                                     #
#                    Server Status Indicator v 1.0                    #
#                  This file pings MG's MW4 servers                   #
#                                                                     #
#              File by Graeme "Llyd ap Dicter" Blackwood              #
#                                                                     #
#                                                                     #
#        Server Status Indicator is copyright Graeme Blackwood        #
#                      llydapdicter@yahoo.co.uk                       #
#                                                                     #
#                                                                     #
#     This file takes the server IP's from a Hash called %servers     #
#           and pings them to see if they are online or not           #
#                                                                     #
#       The servers name and status is then printed out as HTML       #
#                                                                     #
#                                                                     #
#                                                                     #
# Designed specifically for the use of Mëtälü§ Grävï§: www.clanmg.net #
#                                                                     #
#                                                                     #
#######################################################################

print "Content-type: text/html\n\n";

print "<HTML>\n\n";
print "<HEAD>\n";
print "<TITLE>Checking Server Status</TITLE>\n";

print "<!---*-------- Stylesheet --------*--->\n";
print "<link REL=StyleSheet TYPE=text/css HREF=../style/style.css>\n";
print "<!---*-------- /Stylesheet--------*--->\n\n";

print "<body bgproperties=fixed bgcolor=#000000 background=../images/win_bg2.gif text=#d5d1d7 link=#d5d1d7 alink=#88A1B7 vlink=#d5d1d7>\n\n";
print "<table width=100%>\n";
print "<tr>\n";
print "<td align=center>\n";
print "<font SIZE=2 COLOR=#00ff00 FACE=Federation, Verdana, Arial>&nbsp;&nbsp;&nbsp;&nbsp;<b> M W 4 &nbsp; S E R V E R &nbsp; S T A T S</b> <img src=../images/blink_end.gif WIDTH=6 HEIGHT=2>\n";
print "</td>\n";
print "</tr>\n";
print "</table>\n<br><br>\n";
print "<img src=images/mw4_logo.gif width=315 height=100><br><br>\n";


# Server Hash
# Add additional Server IP's and their respective Names after the last set in the hash

%servers = ("bfc://63.90.243.109","BattleCom");


use Net::Ping;  # Uses Net::Ping Module.  Your server must have this installed for this program to work.

    $p = Net::Ping->new("udp");  # Change "udp" to whatever fits your needs. The options are "icmp" or "tcp"
    foreach $host (keys (%servers))
    {
        print "<font face=Verdana size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $servers{$host} is: </font>";  # Prints the Server name, eg "MG U.S. MW4 Server"
           if ($p->ping($host, 2))
           {
              print "<font face=Verdana size=2 color=#00ff00><b>Online</b></font>\n";
           }
           else
           {
              print "<font face=Verdana size=2 color=red><b>Offline</b></font>\n";
           }
        print "<br>";
        sleep(1);
    }
    $p->close();
print end_html();

# , "63.90.243.109", "BattleCom", "24.113.126.160", "MG Killing Fields", "63.90.243.108", "MG Killing Fields #2"