PHP Classes

File: index.php

Recommend this page to a friend!
  Classes of William Lang   Call of Duty 4 Server Status   index.php   Download  
File: index.php
Role: Example script
Content type: text/plain
Description: Example
Class: Call of Duty 4 Server Status
Retrieve information from COD4 game server
Author: By
Last change: added mapname
Date: 15 years ago
Size: 1,863 bytes
 

Contents

Class file image Download
<?
   
include('COD4ServerStatus.php');
   
   
$status = new COD4ServerStatus('127.0.0.1', '28960');
   
    if (
$status->getServerStatus()){
       
$status->parseServerData();
       
       
$serverStatus = $status->returnServerData();
       
       
$players = $status->returnPlayers();
       
$pings = $status->returnPings();
       
$scores = $status->returnScores();
       
       
?>
<h1>Server: <? echo $serverStatus['sv_hostname'];?></h1>
            Admin: <? echo $serverStatus['_Admin'];?><br />
            Email: <? echo $serverStatus['_Email'];?><br />
            IRC: <? echo $serverStatus['Irc'];?><br />
            Location: <? echo $serverStatus['_Location']; ?><br />
            Website: <a href="http://<? echo $serverStatus['_Website']; ?>">http://<? echo $serverStatus['_Website']; ?></a><br /><br />

            <table width="50%" cellspacing="1" cellpadding="1" border="1">
                <tr>
                    <td style="border:0px;" colspan="4">
                        <img src="img<? echo $serverStatus['mapname']; ?>.jpg" alt="<? echo $serverStatus['mapname']; ?>" align="left" style="margin-right:10px;" />
                        <h3><? echo $serverStatus['mapname']; ?></h3>
                    </td>
                </tr>
                <tr>
                    <th width="5%">#</th>
                    <th>Player</th>
                    <th width="15%">Score</th>
                    <th width="15%">Ping (ms)</th>
                </tr>
        <?
            $rank
= 1;
            foreach(
$players as $i => $v){
       
?>
<tr>
                    <td><? echo $rank; ?></td>
                    <td><? echo $players[$i]; ?></td>
                    <td><? echo $scores[$i]; ?></td>
                    <td><? echo $pings[$i]; ?></td>
                </tr>
        <?
                $rank
++;
            }
       
?>
</table>
        <?
   
}
?>