<?php
// include database and object files
include_once '../config/init.php';	// contains $db
include_once '../config/error.php';
include_once '../objects/stats_object.php';

$userId = isset($_POST['userId']) ? $_POST['userId'] : -1;
$sessionId = isset($_POST['sessionId']) ? $_POST['sessionId'] : -1;
$sessionType = isset($_POST['sessionType']) ? $_POST['sessionType'] : -1;   // useless because it is "re-calculated"
$fromUserId = isset($_POST['fromUserId']) ? $_POST['fromUserId'] : -1;

if ($sessionId > 0)// && $sessionType < 0) // "calculate" sessionType based on session
{
    $session = new GameSession($db);
    $session->id = $sessionId;
    $session->load();
    $sessionType = $session->sessionType;
}

$stats = new StatsObject($db);
$stats->get($sessionId, $userId, $sessionType, $fromUserId);
$stats_arr = $stats->getResultArray(true, "Stats_Collected_OK");
	
print_r(json_encode($stats_arr));	// OK
?>