36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
<?php
|
|
// include database and object files
|
|
include_once '../config/init.php'; // contains $db
|
|
include_once '../config/error.php';
|
|
include_once '../objects/db_triggerevent.php';
|
|
|
|
// prepare user object
|
|
$event = new TriggerEvent($db);
|
|
|
|
// read mandatory $_POST properties
|
|
// ensure sessionId, userId and trigger index are passed in $_POST parameters
|
|
if (isset($_POST['session']) && $_POST['session'] > 0)
|
|
$event->sessionId = $_POST['session'];
|
|
else trigger_error( missing_parameter_error("session") );
|
|
|
|
if (isset($_POST['user']) && $_POST['user'] >= 0)
|
|
$event->srcUserId = $_POST['user'];
|
|
else trigger_error( missing_parameter_error("user") );
|
|
|
|
if (isset($_POST['index']) && $_POST['index'] >= 0)
|
|
$event->indexCount = $_POST['index'];
|
|
else trigger_error( missing_parameter_error("index") );
|
|
|
|
// read other $_POST properties
|
|
$event->type = $_POST['type'];
|
|
$event->timeStamp = $_POST['timestamp'];
|
|
$event->successful = $_POST['success'];
|
|
|
|
// create trigger event
|
|
if ($event->record())
|
|
{
|
|
$evt_arr = $event->getResultArray(true, "Event_Stored_OK");
|
|
print_r(json_encode($evt_arr)); // OK
|
|
}
|
|
else trigger_error("Error_Occured");
|
|
?>
|