/** Returns the width and height of a monitor */ function getMonitorDims($monitor) { $query = "select Width,Height from Monitors where Id = " . $monitor; $res = dbFetchOne(escapeSql($query)); return $res; }
/* If pageOffset is greater than we actually have, * we need to adjust it */ $pageOffset = validInteger($_GET['pageOff' . $monitor['Id']]); if ($pageOffset >= ceil($monitor['EventCount0'] / $numEvents)) { $pageOffset = 0; } $offset = $pageOffset * $numEvents; } $eventsSql .= " offset " . $offset; } else { unset($eventsSql); } xml_tag_val("PAGEOFF", $pageOffset); xml_tag_sec("EVENTS", 1); if (canView('Events') && isset($eventsSql)) { foreach (dbFetchAll(escapeSql($eventsSql)) as $event) { xml_tag_sec("EVENT", 1); xml_tag_val("ID", $event['Id']); xml_tag_val("NAME", $event['Name']); xml_tag_val("TIME", strftime(STRF_FMT_DATETIME_SHORTER, strtotime($event['StartTime']))); xml_tag_val("DURATION", $event['Length']); xml_tag_val("FRAMES", $event['Frames']); xml_tag_val("FPS", $event['Length'] > 0 ? ceil($event['Frames'] / $event['Length']) : 0); xml_tag_val("TOTSCORE", $event['TotScore']); xml_tag_val("AVGSCORE", $event['AvgScore']); xml_tag_val("MAXSCORE", $event['MaxScore']); /* Grab the max frame-id from Frames table. If AlarmFrames = 0, don't try * to grab any frames, and just signal the max frame index as index 0 */ $fridx = 1; $alarmFrames = 1; if ($event['AlarmFrames']) {
$frame = validInteger($_GET['frame']); $eventsSql = "select E.Id, E.MonitorId, E.Name, E.StartTime, E.Length, E.Frames from Events as E where (E.Id = " . $eid . ")"; $event = dbFetchOne(escapeSql($eventsSql)); $qty = validInteger(getset('qty', 100)); if ($qty > 100) { $qty = 100; } $scale = validInteger(getset('scale', 100)); if (!$event) { logxmlErr("Requested event ID " . $eid . " does not exist"); exit; } /* Figure out the frame number. If 'alarm' is not set, this is just equal to the <frame> parameter. * If 'alarm' is set, need to query DB and grab the <frame>-th item */ if (isset($_GET['alarm'])) { $frameSql = escapeSql("select * from Frames as F where (F.EventId = " . $eid . ") "); $frameSql .= " and (F.Type = 'Alarm') order by F.FrameId"; $i = 0; foreach (dbFetchAll($frameSql) as $dbframe) { if ($i == $frame) { $frame = $dbframe['FrameId']; break; } $i++; } } if (isset($_GET['analyze']) && ZM_CREATE_ANALYSIS_IMAGES) { $suffix = "analyse"; } else { $suffix = "capture"; }