mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-11-30 04:04:03 -05:00
48 lines
2.1 KiB
PHP
48 lines
2.1 KiB
PHP
<?php
|
|
if (!canView('Events')) ajaxError('Insufficient permissions');
|
|
if (empty($_REQUEST['eid'])) ajaxError('Event Id Not Provided');
|
|
if (empty($_REQUEST['fid'])) ajaxError('Frame Id Not Provided');
|
|
|
|
$eid = $_REQUEST['eid'];
|
|
$fid = $_REQUEST['fid'];
|
|
$row = ( isset($_REQUEST['row']) ) ? $_REQUEST['row'] : '';
|
|
$raw = isset($_REQUEST['raw']);
|
|
$data = array();
|
|
|
|
if ($raw) {
|
|
$data['raw'] = array();
|
|
$sql = 'SELECT S.*,E.*,Z.Name AS ZoneName,Z.Units,Z.Area,M.Name AS MonitorName
|
|
FROM Stats AS S LEFT JOIN Events AS E ON S.EventId = E.Id LEFT JOIN Zones AS Z ON S.ZoneId = Z.Id LEFT JOIN Monitors AS M ON E.MonitorId = M.Id
|
|
WHERE S.EventId = ? AND S.FrameId = ? ORDER BY S.ZoneId';
|
|
$stats = dbFetchAll($sql, NULL, array($eid, $fid));
|
|
foreach ($stats as $stat) {
|
|
$stat['ZoneName'] = validHtmlStr($stat['ZoneName']);
|
|
$stat['PixelDiff'] = validHtmlStr($stat['PixelDiff']);
|
|
// Zone Area is in the 0-10000 percentage coordinate space, the pixel counts are not.
|
|
$area = floatval($stat['Area']) / 10000.0 * floatval($stat['Width']) * floatval($stat['Height']);
|
|
$px = function($n) use ($area) {
|
|
return $area > 0 ? sprintf('%d (%.1f%%)', $n, 100*$n/$area) : sprintf('%d', $n);
|
|
};
|
|
$stat['AlarmPixels'] = $px($stat['AlarmPixels']);
|
|
$stat['FilterPixels'] = $px($stat['FilterPixels']);
|
|
$stat['BlobPixels'] = $px($stat['BlobPixels']);
|
|
$stat['Blobs'] = validHtmlStr($stat['Blobs']);
|
|
if ($stat['Blobs'] > 1) {
|
|
$stat['BlobSizes'] = $area > 0
|
|
? sprintf('%d-%d (%.1f%%-%.1f%%)', $stat['MinBlobSize'], $stat['MaxBlobSize'], (100*$stat['MinBlobSize']/$area), (100*$stat['MaxBlobSize']/$area))
|
|
: sprintf('%d-%d', $stat['MinBlobSize'], $stat['MaxBlobSize']);
|
|
} else {
|
|
$stat['BlobSizes'] = $px($stat['MinBlobSize']);
|
|
}
|
|
$stat['AlarmLimits'] = validHtmlStr($stat['MinX'].','.$stat['MinY'].'-'.$stat['MaxX'].','.$stat['MaxY']);
|
|
$data['raw'][] = $stat;
|
|
} # end foreach stat/zone
|
|
} else {
|
|
$data['html'] = getStatsTableHTML($eid, $fid, $row);
|
|
$data['id'] = '#contentStatsTable' .$row;
|
|
}
|
|
|
|
ajaxResponse($data);
|
|
return;
|
|
?>
|