Difference between revisions of "Design Document PHP Coding Details"
(→makeTables.php: initial contents) |
(→emailPlayerAdd.php: Initial contents) |
||
Line 36: | Line 36: | ||
===emailPlayerAdd.php=== | ===emailPlayerAdd.php=== | ||
emailPlayerAdd.php is the server side code for the | |||
AJAX emailPlayerAdd call. It adds a player to a game. | |||
If the add is successful it then calls sendEmail.php | |||
and exits. This leaves it to sendEmail to return the | |||
final 'success" status. | |||
Input consists the following parameters: | |||
login | |||
game | |||
Output, if any, is the echo return status "fail". | |||
===emailPlayerRem.php=== | ===emailPlayerRem.php=== | ||
===emailPlayerID.php=== | ===emailPlayerID.php=== |
Revision as of 10:23, 16 December 2013
Design Document edit | |
This page has details of all of the PHP files that are described in the Server Side Overview. The origional description for each file has been taken from the comments at the top of the file in question. While creating this page I will also be bringing these comments in line with these Standards.
AJAX Called Programs
An oveview discussion of these programs is available here.
changePlayers.php
changePlayers.php is the server side code for the AJAX changePlayers call. This program adds and/or removes players from existing game sessions.
Inputs:
mode - A string with a value of '1', '2' or '3'. 1 - Remove player with login ID in prem. 2 - Add player with login ID in padd. 3 - Take both of the above actions. game - game_id of current game. prem - Login ID of the player to be removed from the game. padd - Login ID of the player to be added to the game.
Output is an echo return status of either "success", "fail" or "dupadd".
createGame.php
This is the server side code for the AJAX createGame call. It creates a new row in the game table and adds a row in the game_player table for each player in the game. Input is the following JSON string.
{ "gname": "name", "boxid": "boxid", "players": [ "pname0", . . . . . "pnamen", ] }
Output is the echo return status "success", "fail", "nobox" or "noplayer #".
emailPlayerAdd.php
emailPlayerAdd.php is the server side code for the AJAX emailPlayerAdd call. It adds a player to a game. If the add is successful it then calls sendEmail.php and exits. This leaves it to sendEmail to return the final 'success" status.
Input consists the following parameters:
login game
Output, if any, is the echo return status "fail".
emailPlayerRem.php
emailPlayerID.php
emailPassword.php
forcePasswd.php
gameBox.php
gameSession.php
logout.php
myGameList.php
newUser.php
updateGame.php
updateUser.php
validateUser.php
Include Modules
An oveview discussion of these modules is available here.
auth.php
auth.php is included at the start of all password protected pages
and all password protected PHP programs called via AJAX.
It starts a php session and then checks to see that the player is
logged in and has been active sometime in the last 30 minutes.
configMail.php
configMail.php is included at the start of sendEmail.php which sends SMTP emails via PHPMailer. Modify MAIL_HOST, MAIL_PORT, MAIL_USER and MAIL_PASS to the values appropriate for your Email server.
define('MAIL_HOST', 'mail.server.org'); define('MAIL_PORT', '587'); // STARTTLS define('MAIL_USER', 'user@server.org'); define('MAIL_PASS', 'xxxxxxxxxx');
config.php
config.php is included at the start of all pages and php routines that access the board18 database. Modify DB_HOST and if necessary DB_DATABASE to contain the correct database host and name. You can also change the database user ID and password here.
define('DB_HOST', 'localhost'); define('DB_DATABASE', 'board18'); define('DB_USER', 'board18'); define('DB_PASSWORD', 'board18');
sendEmail.php
sendEmail.php uses SMTP to send plain text emails.
Use configMail.php to specify the server and server access
information.
You should use the SMTP server provided by your
ISP or your hosting service for these Emails.
makeTables.php
makeTables.php is included via "require_once()" into various board18 PHP pages. It supplies a number of functions for creating the HTML to display various tables on the page. These tables must be displayed on initial creation of these pages. They cannot be updated later by these functions without reloading the entire page. This file contains these functions:
showBoxes($conn) - create a table of all game boxes in database. showPlayers($conn) - create a table of all players in database. gamePlayers($gameid, $conn) - create a table of players in game.
makeTables.php initializes these variables:
$theLink - value returned by mysqli_connect function. $open - set to an empty string if the database connect succeeded. - set to 'fail' if the database connect failed.
This page is a stub. |
The BOARD18 Project will soon be expanding it. |