Design Document Server Side Overview

From BOARD18 Project WIKI
Revision as of 15:56, 31 July 2017 by Rich (talk | contribs) (→‎AJAX Called Programs: update links)
Jump to navigation Jump to search
This page has been updated to comply with Release 1.5.x of BOARD18.

The server side of the BOARD18 application will use a minimalist approach. In other words, anything that can be done on the client side, will be done on the client side. This philosophy limits the server mostly to data base access and game logging tasks. The server side of the BOARD18 application will also provide conflict resolution for multi thread database accesses.

Design Document edit


Data Base

BOARD 18 uses MySQL for its data management. A single database, with a data base name of BOARD18, is used. The database consists of six tables:

  1. The Box Table
  2. The Game Table
  3. The Game Check Point Table
  4. The Game Link Table
  5. The Game Player Table
  6. The Players Table

The Box Table

Each row in the table named “box” contains a game box. The table layout is shown below. The json_text field contains a stringified JSON game box object as described in section 5.2.1.

Column Type Null Default
box_id Int (11) No
bname Varchar (25) No
version Varchar (25) Yes NULL
create_date Timestamp Yes NULL
activity_date Timestamp No CURRENT_TIMESTAMP
author Varchar (25) No
status Varchar (10) No 'Active'
json_text MediumText Yes NULL

The Game Table

The “game” table contains a row for each game that is being tracked by BOARD18. The table layout is shown below. The json_text field contains a stringified JSON game session object as described in section 5.2.2.

Column Type Null Default
game_id Int (11) No
gname Varchar (25) No
start_date Timestamp Yes NULL
activity_date Timestamp No CURRENT_TIMESTAMP
update_counter Int (11) No 0
last_updater Varchar (45) No
box_id Int (11) No
cp_count Int (11) No 0
status Varchar (10) No 'Active'
json_text MediumText Yes NULL

The Game Snapshot Table

The “game_snap” table contains a row for each snapshot taken for each game that is being tracked by BOARD18. The table layout is shown below. The json_text field contains a stringified JSON game session object as described in section 5.2.2.

Column Type Null Default
game_id Int (11) No
cp_id Int (11) No
cp_date Timestamp No CURRENT_TIMESTAMP
player Varchar (45) No
last_updater Varchar (45) No
game_round Varchar (32) No
json_text MediumText Yes NULL

The Game Link Table

The “game_link” table contains a row for each link that will be available to each game that is being tracked by BOARD18. The table layout is shown below.

Column Type Null Default
game_id Int (11) No
link_name Varchar (30) No
link_url Varchar (100) Yes NULL
activity_date Timestamp No CURRENT_TIMESTAMP

The Game Player Table

The “game_player” table contains a row for each player of each active game that is being tracked by BOARD18. The table layout is shown below. This table is the link between players and the game sessions that they are playing.

Column Type Null Default
game_id Int (11) No
player_id Int (11) No
status Varchar (10) No 'P'

The Players Table

The “players” table contains a row for each player that has a login ID in BOARD18. The table layout is shown below. This table is used to control player access to the application.

Column Type Null Default
player_id Int (11) No
firstname Varchar (25) No
lastname Varchar (25) Yes NULL
email Varchar (254) No
login Varchar (16) No
passwd Varchar (64) No
create_date Timestamp No CURRENT_TIMESTAMP
level Varchar (10) No player
changeit Tinyint (1) No 0

The Auth_tokens Table

The “auth_tokens” table contains a row for each unexpired LTPAlocal cookie created during login processing. These rows are deleted when the cookies are deleted, so this is a volatile table.
The table layout is shown below. This table is used to control player access to the application.

Column Type Null Default
token_id Int (11) No
selector Varchar (16) Yes NULL
hashedValidator Char (64) Yes NULL
player_id Int (11) No
expires Bigint (20) Yes NULL

Logic

AJAX Called Programs

PHP files that are called by Javascript files
File Name Called Via Called By[1] Return Type[2] MySQL?
allGameList.php post board18View.php JSON file Yes
boxGet.php post board18Boxes.php JSON file Yes
boxShow.php post board18Boxes.php JSON file Yes
boxUpdate.php post board18Boxes.php echo status Yes
changePlayers.php post board18Misc.js echo status Yes
checkForUpdate.php post board18Map3.js echo status Yes
createGame.php post board18New.js echo status Yes
emailPassword.php post board18index.js echo status Yes
emailPlayer.php post board18Players2.js echo status Yes
emailPlayerAdd.php post board18New.js echo status Yes
emailPlayerID.php post board18index.js echo status Yes
emailPlayerRem.php post board18Misc.js echo status Yes
forcePasswd.php post board18Admin.js echo status Yes
gameBox.php getJSON board18Map2.js JSON file Yes
gameGet.php post board18Games.js JSON file Yes
gameSession.php getJSON board18Map.php JSON file Yes
gameShow.php post board18Games.php JSON file Yes
gameSnap.php getJSON board18SnapMap.php JSON file Yes
gameUpdate.php post board18Games.php echo status Yes
linkAdd.php post board18Misc.js echo status Yes
linkDel.php post board18Misc.js echo status Yes
linkGet.php post board18Misc.js JSON file Yes
logout.php post board18Main.php echo status No
myGameList.php post board18Main.php JSON file Yes
newUser.php post board18index.js echo status Yes
playerGet.php post board18Players1.js JSON file Yes
playerShow.php post board18Players1.js JSON file Yes
playerUpdate.php post board18Players1.js echo status Yes
snapShot.php post board18Map6.js echo status Yes
snapShow.php post board18Map7.js JSON file Yes
statSwap.php post board18SnapList.js echo status Yes
tokenCheck.php post index.html echo status Yes
tokenInsert.php post board18index.js echo status Yes
tokenRemove.php post board18index.js echo status Yes
updateGame.php post board18Map3.js echo status Yes
updateUser.php post board18Admin.js echo status Yes
validateUser.php post board18index.js JSON file Yes

Most of the server side processing for BOARD18 is done in stand alone PHP programs that are executed from the web pages via AJAX calls. These programs are listed here with brief descriptions. They are also listed in the table to the right.

  • allGameList.php Returns a list of all the games that are in the database.
  • boxGet.php returns most fields for a box from the box table. It also returns a list of the games associated with the box.
  • boxShow.php returns an array of records from the box table.
  • boxUpdate.php updates the name, the version, the author and/or the status fields in a row in the box table.
  • changePlayers.php Adds and/or removes players from existing game sessions.
  • checkForUpdate.php Checks the database to see if another player has made an update.
  • createGame.php Creates a new row in the game table and adds a row in the game_player table for each player in the game.
  • emailPassword.php Sends an Email containing a temporary password to the player's Email address.
  • emailPlayer.php Sends an Email a specific player.
  • emailPlayerAdd.php Sends an Email a player who has been added to a game.
  • emailPlayerID.php Sends an Email containing the player ID to the player's Email address.
  • emailPlayerRem.php Sends an Email a player who has been removed from a game.
  • forcePasswd.php Processes a forced password change.
  • gameBox.php Returns a game box in JSON format.
  • gameGet.php Returns most fields for a game from the game table and a list of the players who are playing the game.
  • gameSession.php Returns game activity information in JSON format.
  • gameShow.php Returns an array of records from the game table.
  • gameSnap.php Returns a snapshot of game activity information in JSON format.
  • gameUpdate.php Updates the name and/or the status fields in a row in the game table.
  • linkAdd.php adds a game_link record to the game_link table.
  • linkDel.php deletes a game_link record from the game_link table.
  • linkGet.php returns an array of the game_link records for this game.
  • logout.php Logs the current user out of BOARD18.
  • myGameList.php Returns a list of the games that a player is playing.
  • newUser.php Creates a new row in the players table.
  • playerGet.php Returns player data and a list of the player's games.
  • playerShow.php Returns an array of records from the players table.
  • playerUpdate.php Updates a row in the players table.
  • snapShot.php Loads game status updates into the database.
  • snapShow.php Returns an array of the game_snap records for the current game.
  • statSwap.php Toggles game status in the database.
  • tokenCheck.php Checks each auth_token row for a match.
  • tokenInsert.php Inserts a new row in the auth_tokens table.
  • tokenRemove.php Deletes from auth_tokens table any rows for the logged in player.
  • updateGame.php Loads game updates into the database.
  • updateUser.php Updates a row in the players table.
  • validateUser.php Logs the current user in to BOARD18.

Notes for Table to Right

  1. Lists only first calling program.
  2. This standards document describes return types.

Include Modules

There are also a number of php modules that are included (using require once) by some of the above programs to reduce redundant code.

  • auth.php is included at the front of every php program that is listed above [except logout.php, emailPlayerID.php and emailPassword.php] and of every php enabled page. This module checks that the session is signed on and redirects control to access-denied.html if it is not.
  • configMail.php is included at the front of the sendEmail.php module. It contains information used to locate and access a SMTP server.
  • config.php is included at the front of every php program and php enabled page that accesses the board18 database. It contains information used to locate and access the BOARD18 database.
  • loadGameBox.php is a required module for board18BoxLoad.php. It is also a required module for the utility massLoadBoxes.php. It contains three functions: loadBox(), nextBox() and doLoad().
  • rm_r.php is a required module for board18BoxLoad.php. It contains the rm_r() function.
  • sendEmail.php is included at the front of every php program or module that sends Email. It accesses a SMTP server to actually send the email. This module includes some modules obtained from the PHPMailer application.
  • makeTables.php is included into various board18 PHP pages. It supplies a number of functions for creating the HTML to display various tables on those pages.