INFiltration:WebTools:php_readme.txt
Written by Kai Dietrich   
Wednesday, 03 January 2007
I) What are these PHP scripts for?
----------------------------------
Well, at first they are a tutorial, example and documentation about the how's and why's
of the WebStat package. The scripts can be divided in two parts: the frontend and the 
backend.
    
I.1.)The backend
I.1.a)General notes
The backend is a PHP master server where WebStat can enlist itself and has a mechanism to 
share the serverlist with other masterservers.
    
I.1.b)The registration process
Each time a gameserver reloads a map, it will pass a HTTP GET request with some parameters 
over to the register_server.php script. The script then contacts the gameserver via UT's
UDP querying and via the WebStat HTTP querying. If the responses seem to be valid the 
server will be put into a MySQL database with all it's available info.

I.1.c)Maintenance
From time to time you may want to verify that the servers you have in your DB are still 
valid. The cleanup.php does this and removes invalid server. Just call it either from you 
webbrowser or create a cronjob somewhere.

I.1.d)Sharing and syncing
Since v1.1.14 the masterservers can talk to each other and share their lists in order to 
create some kind of a lose network.
The sharing of the lists needs two things:
- sharedlist.php = a script that prints all the listed server in a simple way
-  synclists.php = a script that collects these lists from other servers and syncs
them with it's own list
sharelist.php is public and can be received by everyone. synclists.php contains a list of 
URLs to other masterservers sharedlists.php scripts. If you want to add a server you have 
to do that manually.
If synclists.php is called it receives the sharedlists from all listed servers and merges 
the listed gameservers with it's own database.

I.2.)The frontend
The frontend only reads from the database (IIRC ;)).
list.php lists all servers
info.php shows the details about a specific server
live.php queries a WebStat enabled server without using a DB and shows the results
You don't need all scripts to just display some info of a specific server on you homepage.
For this purpose you should read the live.php and query_http.inc.php.

We tried to document this as good as possible. There are (hopefully) usefull comments and
annotations inside the files themselfes.


II) What's new (aka changelog)
------------------------------
v1.1.13 -> v1.1.14
masterserver:
- It's now possible that the servers can share their serverlists between each other. To 
 make that more efficient (MySQL-wise) _we had to change the database structure_ 
 (ws_servers has additional fields). Make sure you change your's too, otherwise the 
 behaviour of the scripts is undefined.
- changed the structure of the scripts and includes a bit
- improved registration process (once again)
- improved cleanup script
- fixed 2 possible SQL injections

III) How to set up a PHP/MySQL masterserver:
-------------------------------------------
1. DB Setup (MySQL)
2. db_login.inc.php setup

III.1.) DB Setup (MySQL):
------------------------
You have to set up two tables in the following way:

ws_servers

ID (int, 10)
IP (varchar, 20)
GamePort (int, 8)
WebPort (int, 8)
WebPath (varchar, 255)

ws_data

ID (int, 10)
property (varchar, 255)
value (text)

use these orders in your phpMyAdmin console

CREATE TABLE ws_servers (
   ID int(10) NOT NULL auto_increment,
   IP varchar(20) NOT NULL default '0',
   GamePort int(8) NOT NULL default '0',
   WebPort int(8) NOT NULL default '0',
   WebPath varchar(255) NOT NULL,
   PRIMARY KEY  (ID),
   UNIQUE KEY ID (ID),
   KEY ID_2 (ID)
) TYPE=MyISAM;

CREATE TABLE ws_data (
   ID int(10) NOT NULL default '0',
   property varchar(255) NOT NULL default '',
   value text NOT NULL
) TYPE=MyISAM;

III.2.) db_login.inc.php setup
-----------------------------
location: WebStat/lib/db_login.inc.php

you have to enter the following values to give the script access to your db

$dbhost  : the server's address
$dblogin : the username
$dbpass  : the password
$dbname  : the database you want to read from and write to
Last Updated ( Wednesday, 03 January 2007 )