Example #1
0
     }
     break;
     ////////////////////////////////////////////////////////////////////////////////////////////
     // FEN
     // Params: action, sid, gameid
     ////////////////////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////////////////////
 // FEN
 // Params: action, sid, gameid
 ////////////////////////////////////////////////////////////////////////////////////////////
 case "fen":
     if (isSessionIDValid($config, $xsid)) {
         if ($_GET['gameid'] != "") {
             //Instantiate the CR3DCQuery Class
             $oR3DCQuery = new CR3DCQuery($config);
             $fen = $oR3DCQuery->GetActualFEN($xsid, $_GET['gameid']);
             $oR3DCQuery->Close();
             unset($oR3DCQuery);
             echo "<RESPONSE>\n";
             echo "<FEN>" . $fen . "</FEN>\n";
             echo "</RESPONSE>\n";
         } else {
             echo "<RESPONSE>\n";
             echo "<FEN></FEN>\n";
             echo "</RESPONSE>\n";
         }
     } else {
         echo "<RESPONSE>\n";
         echo "<ERROR>ID_SESSION_ID_INVALID</ERROR>\n";
         echo "</RESPONSE>\n";
     }
}
$blackdiv = "\n\t<div id=\"blackclock\"></div>\n\t<div class=\"avatar\">{$image}</div>\n\t<div class=\"userid\">{$userid}</div>\n\t<div class=\"points\">{$points}</div>\n\t";
//check the current player's color. set the location of player information accordingly. i.e if the player is black, black player's information is diplayed at the bottom and vice versa
if ($oR3DCQuery->IsPlayerBlack($config, $gid, $_SESSION['id'])) {
    $player = 'black';
    $tdiv = $whitediv;
    $bdiv = $blackdiv;
    $imgc = 'b';
} else {
    $player = 'white';
    $bdiv = $whitediv;
    $tdiv = $blackdiv;
    $imgc = 'w';
}
//get the current FEN data
$fen = explode(" ", $oR3DCQuery->GetActualFEN($_SESSION['sid'], $gid));
//set the turn
if ($fen[1] == 'w') {
    $turn = 'white';
} else {
    $turn = 'black';
}
//explode the board info into rows
$board = explode("/", $fen[0]);
$initiator = "";
$w_player_id = "";
$b_player_id = "";
$status = "";
$completion_status = "";
$start_time = "";
$next_move = "";