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

$sessionId = -1;

// read mandatory $_POST properties : ensure sessionId is passed in $_POST parameters
if (isset($_POST['sessionId']))
	$sessionId = $_POST['sessionId'];
else trigger_error( missing_parameter_error("sessionId") );

$userId = isset($_POST['userId']) ? $_POST['userId'] : -1;

// check sessionId is > 0
//if ($sessionId > 0)
//{
	// prepare user object
	$stats = new StatsObject($db);
	$stats->getStatsForSession($sessionId, $userId);
	
	$stats_arr = $stats->getResultArray(true, "Stats_Collected_OK");
	print_r(json_encode($stats_arr));	// OK
//}
//else trigger_error("Invalid session id");
?>