armatech 8 Posted April 17, 2007 Download class Usage: 1. Rename ArMaServer.phps to ArMaServer.php 2. Upload the script to your php web server and run this command replacing the ip and port to the one of the server you would like to view details of. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">http://armatechsquad.com/DFF/ArMaServer.php?p=192.168.2.2&port=2302 The query code is from sickboys the gui and data handling is by myself armatec Enjoy it and feel free to use this code just dont steel it and clam its your own work. (Give credits where due) ArMaTeC's work <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> <style type="text/css"> <!-- body,td,th { color: #00FF00; } body { background-color: #000000; } .style1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; font-size: 10px; } --> </style> <?php $addr=$_GET["p"]; $port=$_GET["port"]; if($_GET["p"] == '') { echo "In Ip/Port = NO info"; exit; }; $sock = fsockopen(("udp://" . $addr),$port,$errno,$errdesc,$maxwait); $query = pack("c*",0xFE,0xFD,0x00,0x04,0x05,0x06,0x07,0xFF,0xFF,0xFF); fwrite($sock,$query); @socket_set_timeout($sock, 2); $reply = ""; if (!$sock) { $reply = ""; } else { fwrite($sock,$query); @socket_set_timeout($sock, 2); $reply = @fread($sock, 2048); fclose($sock); if (strlen($reply) > 100) { } else { echo "An Error has poped up please check your setting"; exit; } } $Name = ""; $Ver = ""; $Status = ""; $Numteams = ""; $Numplayers = ""; $Maxplayers = ""; $Gametype = ""; $Mission = ""; $ServerOS = ""; $ServerDed = ""; $ModCheck = ""; $ServerMods = ""; $Passworded = ""; $Difficulty = ""; $GameState = ""; $IslandName = ""; $TimeLimmit = ""; $querysuccess = false; if($reply != '') { $Infoarray = explode(chr(0), $reply); $querysuccess = true; $Ver = $Infoarray[2]; $Name = $Infoarray[4]; $IslandName = $Infoarray[6]; $Gametype = $Infoarray[8]; $Numplayers = $Infoarray[10]; $Numteams = $Infoarray[12]; $Maxplayers = $Infoarray[14]; $Status = $Infoarray[16]; $TimeLimmit = $Infoarray[18]; $Passworded = $Infoarray[20]; $missionparam1 = $Infoarray[22]; $missionparam2 = $Infoarray[24]; $currentversion = $Infoarray[26]; $requiredVersion = $Infoarray[28]; $Serverlang = $Infoarray[40]; $ServerMods = $Infoarray[30]; $ModCheck = $Infoarray[31]; $GameState = $Infoarray[34]; $ServerDed = $Infoarray[36]; $ServerOS = $Infoarray[38]; $Difficulty = $Infoarray[42]; $Mission = $Infoarray[44]; switch ($GameState ){ case -1: $GameState = "NO ANSWER"; break; case 1: $GameState = "Server Empty / Mission Screen"; break; case 3: $GameState = "Lobby Waiting"; break; case 5: $GameState = "Loading Mission"; break; case 6: $GameState = "Briefing Screen"; break; case 7: $GameState = "In Progress"; break; case 9: $GameState = "Debriefing Screen"; break; case 6: case 12: $GameState = "setting up"; break; case 13: $GameState = "briefing"; break; case 14: $GameState = "playing"; break; default: $GameState = "unknown"; break; }; switch ($Difficulty ){ case 0: $Difficulty = "Cadet"; break; default: $Difficulty = "Veteran"; break; }; switch ($Passworded){ case 0: $Passworded= "Yes"; break; default: $Passworded= "No"; break; }; switch ($ModCheck ){ case 0: $ModCheck = "No"; break; default: $ModCheck = "No"; break; }; switch ($Status){ case -1: $Status = "NO ANSWER"; break; case openwaiting: $Status = "Waiting"; break; case openplaying: $Status = "Playing"; break; case 9: $Status = "debriefing"; break; case 6: case 12: $Status = "setting up"; break; case 13: $Status = "briefing"; break; default: $Status = "unknown"; break; }; echo $Infoarray[45]; echo "<p>"; echo $Infoarray[46]; }; ?><title><? echo "Server Submitted is" . $_GET["p"]; ?></title> <script language="JavaScript" type="text/JavaScript"> function showit(box) { document.getElementById(box).style.display="block"; } function closeit(box) { document.getElementById(box).style.display="none"; } closeit('div1') closeit('div2') </script> <div align="center"> <table width="60%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td colspan="2"><div align="center"><span class="style1">This is the information for<strong> <?php echo $Name ?></strong><br /> <br /> </span></div></td> </tr> <tr> <td width="100%"><br> <strong>Server Info</strong></Br> <Br> </p> <div class="style1" id="div1"><table width="459" cellpadding="0" cellspacing="0"> <tr> <td width="175" height="50%" valign="top"><strong>Server Name: </strong></td> <td width="221" height="50%"><strong><?php echo $Name ?></strong></td> </tr> <tr> <td height="50%" valign="top"><strong>Server IP: </strong></td> <td height="50%"><strong><?php echo $addr,':',$port ?></strong></td> </tr> <tr> <td height="50%" valign="top"><strong>Server Status:</strong></td> <td height="50%"><strong><?php echo $Status ?></strong></td> </tr> <tr> <td height="50%" valign="top"><strong>Version:</strong></td> <td height="50%"><strong><?php echo $Ver ?></strong></td> </tr> <tr> <td><strong>Server OS</strong></td> <td><strong><? echo $ServerOS;?></strong></td> </tr> <tr> <td><strong>Is Server Dedicated </strong></td> <td><strong><? echo $ServerDed;?></strong></td> </tr> <tr> <td><strong>Mod Check</strong></td> <td><strong><? echo $ModCheck;?></strong></td> </tr> <tr> <td><strong>Server Mods </strong></td> <td><strong><? echo $ServerMods;?></strong></td> </tr> <tr> <td><strong>Passworded</strong></td> <td><strong><? echo $Passworded;?></strong></td> </tr> </table> </div> <strong><a href="#" onclick="closeit('div1');">Hide</a> <a href="#" onclick="showit('div1');">Show</a></strong><strong><br /> </strong></br> <table width="460" cellpadding="0" cellspacing="0"> <tr> <td width="458" height="50%" valign="top"><p><strong><br> Game Info</br> </br> </strong></p> <div class="style1" id="div2"><table width="458" cellpadding="0" cellspacing="0"> <tr> <td width="203" height="50%" valign="top"><p><strong>Game Type:</strong></p> </td> <td width="253" height="50%"><strong><?php echo $Gametype ?></strong></td> </tr> <tr> <td height="50%" valign="top"><strong>Mission/Map:</strong></td> <td height="50%"><strong><?php echo $Mission ?></strong></td> </tr> <tr> <td height="50%" valign="top"><strong>Number Players:</strong></td> <td height="50%"><strong><?php echo $Numplayers ?></strong></td> </tr> <tr> <td height="50%" valign="top"><strong>Max. Players:</strong></td> <td height="50%"><strong><?php echo $Maxplayers -1 ?></strong></td> </tr> <tr> <td><strong>Difficulty</strong></td> <td><strong><? echo $Difficulty;?></strong></td> </tr> <tr> <td><strong>Game State</strong></td> <td><strong><? echo $GameState;?></strong></td> </tr> <tr> <td><strong>Island Name </strong></td> <td><strong><? echo $IslandName;?></strong></td> </tr> <tr> <td><strong>Time Limmit </strong></td> <td><strong><? echo $TimeLimmit;?></strong></td> </tr> <tr> <td><strong>Number of Teams </strong></td> <td><p><strong><? echo $Numteams;?></strong></p> </td> </tr> </table> </div> </td> </tr> </table> <strong><a href="#" onclick="closeit('div2');">Hide</a> <a href="#" onclick="showit('div2');">Show</a></strong> </p> <p><strong>Player Stats <br /> </strong></p> <div id="div3"><strong> <? $num =$Numplayers; $i5 = 1; $i1 = 52; echo "<table><tr><th>Total Users $num</th></tr>\n"; echo "<table background=\"#D1BB7D\" width=\"400\" height=\"20\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\">"; echo "<td height=\"20\" border=\"0\" width=\"63\">Unit</td>"; echo "<td height=\"20\" border=\"0\" width=\"119\">Username</td>"; echo "<td height=\"20\" border=\"0\" width=\"100\"><div align=\"center\">Squad</div></td>"; echo "<td height=\"20\" border=\"0\" width=\"41\"><div align=\"center\">Kills</div></td>"; echo "<td height=\"20\" border=\"0\" width=\"43\"><div align=\"center\">Deaths</div></td>"; for ($i=0;$i<$num;$i++) { echo "<table background=\"\" width=\"400\" height=\"20\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\">"; echo "<td height=\"20\" border=\"0\" width=\"63\">Player $i5</td>"; echo "<td height=\"20\" border=\"0\" width=\"119\">$Infoarray[$i1]</td>"; $i1 = $i1 +1; echo "<td height=\"20\" border=\"0\" width=\"100\"><div align=\"center\">$Infoarray[$i1]</div></td>"; $i1 = $i1 +1; echo "<td height=\"20\" border=\"0\" width=\"41\"><div align=\"center\">$Infoarray[$i1]</div></td>"; $i1 = $i1 +1; echo "<td height=\"20\" border=\"0\" width=\"43\"><div align=\"center\">$Infoarray[$i1]</div></td>"; $i1 = $i1 +1; $i5 = $i5 +1; echo "</table>"; }; ?> </strong></div> <strong><a href="#" onclick="closeit('div3');">Hide</a> <a href="#" onclick="showit('div3');">Show</a></strong></td> <td width="0%"> </td> </tr> </table> </div> <div align="center"></div> Share this post Link to post Share on other sites
Tommo 0 Posted April 22, 2007 Just noticed some very small errors, you forgot to define php after the <? for quite a few bits of php code so it isn't actually showing the stats for some items, other than that nice work Share this post Link to post Share on other sites
zyklone 1 Posted April 23, 2007 Why are you calling this a class? It's a script, there is not a single class in your code. Share this post Link to post Share on other sites