Si4 Readme

Si4 Readme. 1

Features. 1

Requirements. 1

Installation. 1

Changes. 2

Additions. 2

Modifying. 2

How the script works. 2

Modifying the script 4

License. 4

Contact 5

 

Features

  • Queries any Half-Life or Half-Life 2 based game server using the Valve Steam Protocol, to retrieve information on status, players and server rules. Supported games include:
    • Counter-strike 1.6
    • Counter-Strike Source
    • Day of Defeat
    • Day of Defeat Source
    • Half-Life 2: Death match
    • Dystopia
    • And many more..

 

  • Ability to store server information in a MySQL database, to reduce server load on multiple page requests

 

  • Displays server information in one of three formats:
    • HTML (small, medium and large display mode)
    • PNG image (small and large display mode)
    • XML

 

  • Ability to cache output to files, to reduce server load on multiple page requests

Requirements

  • Web host with PHP support
  • UDP socket connections allowed for PHP
  • MySQL database [optional]
  • PHP allowed to write files [optional]

Installation

See installation manual supplied with this script.

Changes

Full rewrite of the old code, to remove unnecessary complicated code and to reduce coupling between different parts of the script. As a result the code is now better maintainable, more robust and can easily be made to work with other games.

Additions

  • PNG Image as new output format
  • XML as new output format
  • Output caching to reduce server load
  • Server rules added to the large HTML output format

Modifying

How the script works

Anyone interested in modifying the source code to Si4 beyond normal install and restyling, a small outline of how the script works:

Querying servers:

The directory “data/query/” contains the file “query.php”with in it the function getquerydata( $host, $protocol );

The first argument is the IP address and port of the game server you’re trying to connect to, for instance: “194.171.252.93:27015”.

The second argument is the protocol this server uses, which should correspond to a folder of the same name, for instance: “steam”

The protocol folder should contain the file “adapter.php”, which implements the function get[protocolname]data($host). This method should return the server information in the format described in “data/query/query.php”, or false upon failure.

This method is called by “data/data.php”, which in turn is called by every presentation format to get the server information.

MySQL storage:

Storage of the server information is automatically called from “data/data.php”, if MySQL is enabled in the configuration file. Any MySQL related sourcecodes can be found in the “data/mysql/” directory.

This server information is stored so the game server will not be queried for the server information every time the script is executed. When the information stored in the database was stored before a certain threshold this information will be used again. If not then the  server will be queried for new information, which will in turn be stored.

HTML presentation:

The file “html/html.php” implements the function html ($host, $type);

The first argument is the IP address and port of the game server you want to display, for instance: “194.171.252.93:27015”.

The second argument is the display mode, which by default can be set to either “small”, “medium” or “large”, representing increasingly large output tables.

Any changes to the html output can be made in this file or the files this file includes.

PNG presentation:

The file “gdlib/gdlib.php” implements the function gdlib ($host, $type);

The first argument is the IP address and port of the game server you want to display, for instance: “194.171.252.93:27015”.

The second argument is the display mode, which by default can be set to either “small” or “large”, representing increasingly large output images.

Any changes to the png output can be made in this file or the files this file includes.

XML presentation:

The file “xml/xml.php” implements the function xml($host);

The argument is the IP address and port of the game server you want to display, for instance: “194.171.252.93:27015”.

The second argument is the display mode, which by default can be set to either “small”, “medium” or “large”, representing increasingly large output tables.

Any changes to the xml output can be made in this file.

Output caching:

The file “cache/cache.php” implements the function putcache($host, $data, $ext);

The first argument is the IP address and port of the game server you want to display, for instance: “194.171.252.93:27015”.

The second argument is the output which needs to be stored.

The third argument is the extension the cache file will be given.

The file “cache/cache.php” also implements the function getcache($host, $ext);

The first argument is the IP address and port of the game server you want to display, for instance: “194.171.252.93:27015”.

The second argument is the extension of the cache file.

This function is called from every output generating function, if caching is enabled.

Caching is done to reduce the load on a web host, by returning the cached information is this information is not older then a set threshold. If it is older then new server information will be retrieved and converted to output, which in turn will be stored.

This method prevents the web host from having to recreate the same output every time the script is called.

 

 

Modifying the script

Now that you know how the script works, here’s a very brief description of how to handle a few of the basic modifications:

  • Add new map images:
    New map images for a certain game can be added by opening the corresponding “images/[game name]” folder and placing the images in there. The following formats are supported: BMP, JPG, GIF, PNG.
  • Add new game:
    A new game for a already installed protocol can be added by placing a 16 by 16 pixel PNG image icon for the game in the “images/icons/” folder. Map pictures for a new game should be places in the folder “images/maps/[gamename]” in which the gamename is the name returned by the protocol, in which the following characters have been removed:
    |, :, ., ?, *, <, >, /, \, ", ', \n, \t
  • Add a new protocol:
    In order to add a new protocol, add a folder “[protocolname]” inside the folder “data/query/”. This folder should contain the file “adapter.php”, which implements the function get[protocolname]data($host). This method should return the server information in the format described in “data/query/query.php”, or false upon failure.
    To query a server using the new protocol, call the function getdata( $host, $protocol ); with the second argument being the new protocols name.
    Should you successfully add a protocol to this script, then I would certainly appreciate you sharing the source code with me, as these could then be added to the script for future users.

License

This script is released under the GNU General Public License.

 

Si4 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or

(at your option) any later version.

 

Si4 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

 

You should have received a copy of the GNU General Public License

along with Si4; if not, write to the
Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor,
Boston, MA  02110-1301  USA

 

Copyright 2006 Tim te Beek

Contact

If you feel the need to contact me you can do so by sending an email to: timtebeek@gmail.com