Design Document PHP AJAX Coding Details Part 2

From BOARD18 Project WIKI
Revision as of 14:35, 28 August 2020 by Rich (talk | contribs) (→‎gameGet.php: added gamePlayers.php)
Jump to navigation Jump to search
This page has been updated to comply with Release 2.5.x of BOARD18.
Design Document edit


This page documents part 2 of the PHP AJAX called programs.

An oveview discussion of all PHP programs is available here.

gameBox.php

This is the server side code for the AJAX gameBox call.

It returns a game box in JSON format.

Input is the game box id.

Output is JSON game box data.

gameGet.php

This is the server side code for the AJAX gameGet call.

It returns most fields for a game from the game table. It also returns a list of the players who are playing the game.

Input is: gameid.

Output is the following stringified JSON data structure.

 {
   "stat":"success||"fail"||"noplayers",
   "gameid":"nnnn",
   "gname":"aaaaaa",
   "bname":"bbbbbb",
   "sdate":"yyy-mm-dd hh:mm:ss",
   "adate":"yyy-mm-dd hh:mm:ss",
   "lastupdater":"llllllll",
   "status":"sssss",
   "players":
   [
     {
       "playerid":"nnnn",
       "login":"pppppp",
       "fname":"fffffff",
       "lname":"ggggggg"
     },
     . . . . more players . . . . . 
   ]
 }

gamePlayers.php

gamePlayers.php is the server side code for the AJAX gamePlayers call.

It returns a list of the players who are playing the game.

Input is: gameid.

Output is the following stringified JSON data structure.

 {
   "stat":"success||"fail"||"noplayers",
   "players":
   [
     {
       "playerid":"nnnn",
       "login":"pppppp",
       "fname":"fffffff",
       "lname":"ggggggg"
     },
     . . . . more players . . . . . 
   ]
 }

gameSession.php

This is the server side code for the AJAX gameSession call.

It returns game activity information in JSON format.

Input is the game_id.

Output is JSON game session data.

The SESS_UPDATE_COUNTER is initialized here and used by updateGame.php to support optimistic database locking.
This should stop concurrent updates from messing up the database.

gameShow.php

This is the server side code for the AJAX gameShow call.

It returns an array of records from the game table.

Input is: blocksz and startrow.

Output is the following stringified JSON data structure.

 {
   "stat":"success||"nogames"||"fail",
   "games":
   [
     {
       "gameid":"nnnn",
       "gname":"gggggg",
       "bname":"aaaaaa", 
       "sdate":"yyy-mm-dd hh:mm:ss",
       "adate":"yyy-mm-dd hh:mm:ss",
       "boxid":"eeeeee",
       "status":"fffff",
       "pcount":"nnnnnn"
     },
     . . . . more games . . . . . 
   ]
 }

gameSnap.php

This is the server side code for the AJAX gameSnap call.

It returns a snapshot of game activity information in JSON format.

Input is the snapshot id.

Output is JSON game session data.

gameUpdate.php

This is the server side code for the AJAX gameUpdate call.

It updates the name and/or the status fields in a row in the game table.

Input consists the following parameters:

 gameid  
 gname
 status

Output is the echo return status:

 "success", "fail", "gname".

linkAdd.php

This is the server side code for the AJAX linkAdd call.

It adds a game_link record to the game_link table.

Input is: gameid, linkname and linkurl.

Output is the echo return status:

 "success", "fail" or "duplicate". 

linkDel.php

This is the server side code for the AJAX linkDel call.

It deletes a game_link record from the game_link table.

Input is: gameid and linkname.

Output is the echo return status:

 "success", "fail" or "missing". 

linkGet.php

This is the server side code for the AJAX linkGet call.

It returns an array of the game_link records for this game.

Input is: gameid.

Output is the following stringified JSON data structure.

 {
   "stat":"success||none||fail",
   "links":
   [
     {
       "link_name":"aaaaaa",
       "link_url":"bbbbbbb",
       "act_date":"mm/dd/yyyy"
     },
     . . . . more links . . . . . 
   ]
 }

logout.php

logout.php is the server side code for the AJAX logout call.

It will unset all of the session variables, delete the session cookie and, finally, destroy the session.

There are no input parameters.

Output will always be "success".

myGameList.php

This is the server side code for the AJAX myGameList call.

It produces the data needed to create a list of all active games that the signed in player is playing.

There are no input parameters.

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"
     },
     . . . . more games . . . . . 
   ]
 }

newUser.php

newUser.php is the server side code for the AJAX newUser call. It inserts a row in the players table to define a new player.

Input consists the following parameters:

 fname
 lname
 newuser
 passwrd
 email

Output is one of these the echo return statuses:

 "success"
 "fail"
 "bademail"
 "email login"
 "duplicate"