Difference between revisions of "Design Document PHP AJAX Coding Details Part 1"
m (→boxGetall.php) |
m |
||
Line 1: | Line 1: | ||
{{ReleaseNotice|2. | {{ReleaseNotice|2.6}}{{Design Document Index}} | ||
This page documents part 1 of the PHP AJAX called programs. | This page documents part 1 of the PHP AJAX called programs. | ||
Latest revision as of 13:36, 28 August 2020
This page has been updated to comply with Release 2.6.x of BOARD18. |
Design Document edit | |
This page documents part 1 of the PHP AJAX called programs.
An oveview discussion of all PHP programs is available here.
allGameList.php
This is the server side code for the AJAX allGameList call.
It produces the data needed to create a list of all games in the database. It can also select active or completed games based on gstat.
Input parameter:
gstat - can be Active, Completed or All
Output is the following stringified JSON data structure.
{ "stat":"success", "games": [ { "game_id":"nnnn", "gname":"gggg", "bname":"bbbb", "version":"vvvv", "start_date":"mm/dd/yyyy" "status":"ssss" }, . . . . more games . . . . . ] }
"stat" can be "success", "fail" or "none".
"games" will only be present if "stat" is "success".
boxGet.php
boxGet.php is the server side code for the AJAX boxGet call.
It returns most fields for a box from the box table. It also returns a list of the games associated with the box.
Input is: boxid.
Output is the following stringified JSON data structure.
{ "stat":"success||"fail"||"nogames", "boxid":"nnnn", "bname":"aaaaaa", "version":"bbbbbb", "cdate":"yyy-mm-dd hh:mm:ss", "adate":"yyy-mm-dd hh:mm:ss", "author":"llllllll", "status":"sssss", "games": [ { "gameid":"mmmmm", "gname":"ggggggg", "status":"ttttt", }, . . . . more games . . . . . ] }
boxGetAll.php
boxGetAll.php is the server side code for the AJAX boxGetAll call.
It returns an array of all active records in the box table.
No input parameters are used.
Output is the following stringified JSON data structure.
{ "stat":"success||"noboxes"||"fail", "boxes": [ { "boxid":"nnnn", "bname":"aaaaaa", "version":"vvvvvv", "cdate":"yyy-mm-dd hh:mm:ss", "author":"eeeeee", "status":"fffff" }, . . . . more boxes . . . . . ] }
boxShow.php
boxShow.php is the server side code for the AJAX boxShow call.
It returns an array of records from the box table.
Input is: blocksz and startrow.
Output is the following stringified JSON data structure.
{ "stat":"success||"noboxes"||"fail", "boxes": [ { "boxid":"nnnn", "bname":"aaaaaa", "version":"vvvvvv", "cdate":"yyy-mm-dd hh:mm:ss", "adate":"yyy-mm-dd hh:mm:ss", "author":"eeeeee", "status":"fffff", "gcount":"nnnnnn" }, . . . . more boxes . . . . . ] }
boxUpdate.php
boxUpdate.php is the server side code for the AJAX boxUpdate call.
It updates the name, the version, the author and/or the status fields in a row in the box table.
Input consists the following parameters:
boxid bname version author status
Output is the echo return status: "success", "fail" or "bname".
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".
checkForUpdate.php
checkForUpdate.php is the server side code for the AJAX checkForUpdate call. It checks the database to see if another player has made an update.
Input is the gameID.
Output will be "noupdate", "updatefound" or "failure".
The SESS_UPDATE_COUNTER session variable which is used by updateGame.php to support optimistic database locking is also used by checkForUpdate.php to detect updates made by another player.
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 #".
emailPlayer.php
emailPlayer.php is the server side code for the AJAX emailPlayer call. It creates a text email for a specific player. If the email creation 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 subject body
Output, if any, is the echo return status "fail".
emailPlayerAdd.php
emailPlayerAdd.php is the server side code for the AJAX emailPlayerAdd call. It creates a text email to notify a player that has been added to a game. If the email creation 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 is the server side code for the AJAX emailPlayerRem call. It creates a text email to notify a player that has been removed from a game. If the email creation 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".
emailPlayerID.php
emailPlayerID.php is the server side code for the AJAX emailPlayerID call.
It creates a text email to remind a player (that has forgotten) of his player ID. If the email creation is successful it then calls sendEmail.php and exits. This leaves it to sendEmail to return the final 'success" status.
Input consists the "email" parameter.
Output, if any, is the echo return status "fail" or "bademail".
emailPassword.php
emailPassword.php is the server side code for the AJAX emailPassword call.
It creates a text email to inform a player of his new temporary password. If the email creation 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:
name email
Output, if any, is the echo return status "fail" or "bademail".
forcePasswd.php
forcePasswd.php is the server side code for the AJAX forcePasswd call.
It will process a forced password change.
Input consists the following parameters:
player passwd
Output will be "success", "fail" or an edit failure code.