27 lines
911 B
PHP
27 lines
911 B
PHP
<?php
|
|
// include database and object files
|
|
include_once '../config/init.php'; // contains $db
|
|
include_once '../config/error.php';
|
|
include_once '../objects/db_session.php';
|
|
|
|
// prepare user object
|
|
$gameSession = new GameSession($db);
|
|
|
|
// read mandatory $_POST properties : ensure sessionType and sessionName are passed in $_POST parameters
|
|
if (isset($_POST['sessionId']))
|
|
$gameSession->id = $_POST['sessionId'];
|
|
else trigger_error( missing_parameter_error("sessionId") );
|
|
|
|
// read other $_POST properties for game session
|
|
$gameSession->timeToFinish = $_POST['duration'];
|
|
$gameSession->success = (strcasecmp( ($_POST['success'] ?? false), "true" ) == 0) ? 1 : 0;
|
|
$gameSession->score = $_POST['score'];
|
|
|
|
// close the game session
|
|
if ($gameSession->stop())
|
|
{
|
|
$session_arr = $gameSession->getResultArray(true, "Session_Stop_OK");
|
|
print_r(json_encode($session_arr)); // OK
|
|
}
|
|
else trigger_error("Error_Occured");
|
|
?>
|