change quotes, and limit the # of results to 2 when getting next and previous frames. 2 is because one of them could be the currently selected Event,

This commit is contained in:
Isaac Connor 2017-11-03 15:09:19 -04:00
parent 0ef5c16bcc
commit 8432ab5938
1 changed files with 158 additions and 158 deletions

View File

@ -1,170 +1,170 @@
<?php <?php
$statusData = array( $statusData = array(
"system" => array( 'system' => array(
"permission" => "System", 'permission' => 'System',
"table" => "Monitors", 'table' => 'Monitors',
"limit" => 1, 'limit' => 1,
"elements" => array( 'elements' => array(
"MonitorCount" => array( "sql" => "count(*)" ), 'MonitorCount' => array( 'sql' => "count(*)" ),
"ActiveMonitorCount" => array( "sql" => "count(if(Function != 'None',1,NULL))" ), 'ActiveMonitorCount' => array( 'sql' => "count(if(Function != 'None',1,NULL))" ),
"State" => array( "func" => "daemonCheck()?".translate('Running').":".translate('Stopped') ), 'State' => array( 'func' => "daemonCheck()?".translate('Running').":".translate('Stopped') ),
"Load" => array( "func" => "getLoad()" ), 'Load' => array( 'func' => "getLoad()" ),
"Disk" => array( "func" => "getDiskPercent()" ), 'Disk' => array( 'func' => "getDiskPercent()" ),
), ),
), ),
"monitor" => array( 'monitor' => array(
"permission" => "Monitors", 'permission' => 'Monitors',
"table" => "Monitors", 'table' => 'Monitors',
"limit" => 1, 'limit' => 1,
"selector" => "Monitors.Id", 'selector' => "Monitors.Id",
"elements" => array( 'elements' => array(
"Id" => array( "sql" => "Monitors.Id" ), 'Id' => array( 'sql' => "Monitors.Id" ),
"Name" => array( "sql" => "Monitors.Name" ), 'Name' => array( 'sql' => "Monitors.Name" ),
"Type" => true, 'Type' => true,
"Function" => true, 'Function' => true,
"Enabled" => true, 'Enabled' => true,
"LinkedMonitors" => true, 'LinkedMonitors' => true,
"Triggers" => true, 'Triggers' => true,
"Device" => true, 'Device' => true,
"Channel" => true, 'Channel' => true,
"Format" => true, 'Format' => true,
"Host" => true, 'Host' => true,
"Port" => true, 'Port' => true,
"Path" => true, 'Path' => true,
"Width" => array( "sql" => "Monitors.Width" ), 'Width' => array( 'sql' => "Monitors.Width" ),
"Height" => array( "sql" => "Monitors.Height" ), 'Height' => array( 'sql' => "Monitors.Height" ),
"Palette" => true, 'Palette' => true,
"Orientation" => true, 'Orientation' => true,
"Brightness" => true, 'Brightness' => true,
"Contrast" => true, 'Contrast' => true,
"Hue" => true, 'Hue' => true,
"Colour" => true, 'Colour' => true,
"EventPrefix" => true, 'EventPrefix' => true,
"LabelFormat" => true, 'LabelFormat' => true,
"LabelX" => true, 'LabelX' => true,
"LabelY" => true, 'LabelY' => true,
"LabelSize" => true, 'LabelSize' => true,
"ImageBufferCount" => true, 'ImageBufferCount' => true,
"WarmupCount" => true, 'WarmupCount' => true,
"PreEventCount" => true, 'PreEventCount' => true,
"PostEventCount" => true, 'PostEventCount' => true,
"AlarmFrameCount" => true, 'AlarmFrameCount' => true,
"SectionLength" => true, 'SectionLength' => true,
"FrameSkip" => true, 'FrameSkip' => true,
"MotionFrameSkip" => true, 'MotionFrameSkip' => true,
"MaxFPS" => true, 'MaxFPS' => true,
"AlarmMaxFPS" => true, 'AlarmMaxFPS' => true,
"FPSReportInterval" => true, 'FPSReportInterval' => true,
"RefBlendPerc" => true, 'RefBlendPerc' => true,
"Controllable" => true, 'Controllable' => true,
"ControlId" => true, 'ControlId' => true,
"ControlDevice" => true, 'ControlDevice' => true,
"ControlAddress" => true, 'ControlAddress' => true,
"AutoStopTimeout" => true, 'AutoStopTimeout' => true,
"TrackMotion" => true, 'TrackMotion' => true,
"TrackDelay" => true, 'TrackDelay' => true,
"ReturnLocation" => true, 'ReturnLocation' => true,
"ReturnDelay" => true, 'ReturnDelay' => true,
"DefaultView" => true, 'DefaultView' => true,
"DefaultRate" => true, 'DefaultRate' => true,
"DefaultScale" => true, 'DefaultScale' => true,
"WebColour" => true, 'WebColour' => true,
"Sequence" => true, 'Sequence' => true,
"MinEventId" => array( "sql" => "(SELECT min(Events.Id) FROM Events WHERE Events.MonitorId = Monitors.Id" ), 'MinEventId' => array( 'sql' => "(SELECT min(Events.Id) FROM Events WHERE Events.MonitorId = Monitors.Id" ),
"MaxEventId" => array( "sql" => "(SELECT max(Events.Id) FROM Events WHERE Events.MonitorId = Monitors.Id" ), 'MaxEventId' => array( 'sql' => "(SELECT max(Events.Id) FROM Events WHERE Events.MonitorId = Monitors.Id" ),
"TotalEvents" => array( "sql" => "(SELECT count(Events.Id) FROM Events WHERE Events.MonitorId = Monitors.Id" ), 'TotalEvents' => array( 'sql' => "(SELECT count(Events.Id) FROM Events WHERE Events.MonitorId = Monitors.Id" ),
"Status" => array( "zmu" => "-m ".escapeshellarg($_REQUEST['id'][0])." -s" ), 'Status' => array( 'zmu' => "-m ".escapeshellarg($_REQUEST['id'][0])." -s" ),
"FrameRate" => array( "zmu" => "-m ".escapeshellarg($_REQUEST['id'][0])." -f" ), 'FrameRate' => array( 'zmu' => "-m ".escapeshellarg($_REQUEST['id'][0])." -f" ),
), ),
), ),
"events" => array( 'events' => array(
"permission" => "Events", 'permission' => 'Events',
"table" => "Events", 'table' => 'Events',
"selector" => "Events.MonitorId", 'selector' => "Events.MonitorId",
"elements" => array( 'elements' => array(
"Id" => true, 'Id' => true,
"Name" => true, 'Name' => true,
"Cause" => true, 'Cause' => true,
"Notes" => true, 'Notes' => true,
"StartTime" => true, 'StartTime' => true,
"StartTimeShort" => array( "sql" => "date_format( StartTime, '".MYSQL_FMT_DATETIME_SHORT."' )" ), 'StartTimeShort' => array( 'sql' => "date_format( StartTime, '".MYSQL_FMT_DATETIME_SHORT."' )" ),
"EndTime" => true, 'EndTime' => true,
"Width" => true, 'Width' => true,
"Height" => true, 'Height' => true,
"Length" => true, 'Length' => true,
"Frames" => true, 'Frames' => true,
"AlarmFrames" => true, 'AlarmFrames' => true,
"TotScore" => true, 'TotScore' => true,
"AvgScore" => true, 'AvgScore' => true,
"MaxScore" => true, 'MaxScore' => true,
), ),
), ),
"event" => array( 'event' => array(
"permission" => "Events", 'permission' => 'Events',
"table" => "Events", 'table' => 'Events',
"limit" => 1, 'limit' => 1,
"selector" => "Events.Id", 'selector' => "Events.Id",
"elements" => array( 'elements' => array(
"Id" => array( "sql" => "Events.Id" ), 'Id' => array( 'sql' => "Events.Id" ),
"MonitorId" => true, 'MonitorId' => true,
"MonitorName" => array("sql" => "(SELECT Monitors.Name FROM Monitors WHERE Monitors.Id = Events.MonitorId)"), 'MonitorName' => array('sql' => "(SELECT Monitors.Name FROM Monitors WHERE Monitors.Id = Events.MonitorId)"),
"Name" => true, 'Name' => true,
"Cause" => true, 'Cause' => true,
"StartTime" => true, 'StartTime' => true,
"StartTimeShort" => array( "sql" => "date_format( StartTime, '".MYSQL_FMT_DATETIME_SHORT."' )" ), 'StartTimeShort' => array( 'sql' => "date_format( StartTime, '".MYSQL_FMT_DATETIME_SHORT."' )" ),
"EndTime" => true, 'EndTime' => true,
"Width" => true, 'Width' => true,
"Height" => true, 'Height' => true,
"Length" => true, 'Length' => true,
"Frames" => true, 'Frames' => true,
"DefaultVideo" => true, 'DefaultVideo' => true,
"AlarmFrames" => true, 'AlarmFrames' => true,
"TotScore" => true, 'TotScore' => true,
"AvgScore" => true, 'AvgScore' => true,
"MaxScore" => true, 'MaxScore' => true,
"Archived" => true, 'Archived' => true,
"Videoed" => true, 'Videoed' => true,
"Uploaded" => true, 'Uploaded' => true,
"Emailed" => true, 'Emailed' => true,
"Messaged" => true, 'Messaged' => true,
"Executed" => true, 'Executed' => true,
"Notes" => true, 'Notes' => true,
"MinFrameId" => array( "sql" => "(SELECT min(Frames.FrameId) FROM Frames WHERE EventId=Events.Id)" ), 'MinFrameId' => array( 'sql' => "(SELECT min(Frames.FrameId) FROM Frames WHERE EventId=Events.Id)" ),
"MaxFrameId" => array( "sql" => "(SELECT max(Frames.FrameId) FROM Frames WHERE Events.Id = Frames.EventId)" ), 'MaxFrameId' => array( 'sql' => "(SELECT max(Frames.FrameId) FROM Frames WHERE Events.Id = Frames.EventId)" ),
"MinFrameDelta" => array( "sql" => "(SELECT min(Frames.Delta) FROM Frames WHERE Events.Id = Frames.EventId)" ), 'MinFrameDelta' => array( 'sql' => "(SELECT min(Frames.Delta) FROM Frames WHERE Events.Id = Frames.EventId)" ),
"MaxFrameDelta" => array( "sql" => "(SELECT max(Frames.Delta) FROM Frames WHERE Events.Id = Frames.EventId)" ), 'MaxFrameDelta' => array( 'sql' => "(SELECT max(Frames.Delta) FROM Frames WHERE Events.Id = Frames.EventId)" ),
//"Path" => array( "postFunc" => "getEventPath" ), //'Path' => array( 'postFunc' => 'getEventPath' ),
), ),
), ),
"frame" => array( 'frame' => array(
"permission" => "Events", 'permission' => 'Events',
"table" => "Frames", 'table' => 'Frames',
"limit" => 1, 'limit' => 1,
"selector" => array( array( "table" => "Events", "join" => "Events.Id = Frames.EventId", "selector"=>"Events.Id" ), "Frames.FrameId" ), 'selector' => array( array( 'table' => 'Events', 'join' => "Events.Id = Frames.EventId", 'selector'=>"Events.Id" ), "Frames.FrameId" ),
"elements" => array( 'elements' => array(
//"Id" => array( "sql" => "Frames.FrameId" ), //'Id' => array( 'sql' => "Frames.FrameId" ),
"FrameId" => true, 'FrameId' => true,
"EventId" => true, 'EventId' => true,
"Type" => true, 'Type' => true,
"TimeStamp" => true, 'TimeStamp' => true,
"TimeStampShort" => array( "sql" => "date_format( StartTime, '".MYSQL_FMT_DATETIME_SHORT."' )" ), 'TimeStampShort' => array( 'sql' => "date_format( StartTime, '".MYSQL_FMT_DATETIME_SHORT."' )" ),
"Delta" => true, 'Delta' => true,
"Score" => true, 'Score' => true,
//"Image" => array( "postFunc" => "getFrameImage" ), //'Image' => array( 'postFunc' => 'getFrameImage' ),
), ),
), ),
"frameimage" => array( 'frameimage' => array(
"permission" => "Events", 'permission' => 'Events',
"func" => "getFrameImage()" 'func' => "getFrameImage()"
), ),
"nearframe" => array( 'nearframe' => array(
"permission" => "Events", 'permission' => 'Events',
"func" => "getNearFrame()" 'func' => "getNearFrame()"
), ),
"nearevents" => array( 'nearevents' => array(
"permission" => "Events", 'permission' => 'Events',
"func" => "getNearEvents()" 'func' => "getNearEvents()"
) )
); );
@ -290,7 +290,7 @@ function collectData() {
$data = collectData(); $data = collectData();
if ( !isset($_REQUEST['layout']) ) { if ( !isset($_REQUEST['layout']) ) {
$_REQUEST['layout'] = "json"; $_REQUEST['layout'] = 'json';
} }
switch( $_REQUEST['layout'] ) { switch( $_REQUEST['layout'] ) {
@ -331,7 +331,7 @@ function getFrameImage() {
$frame = array(); $frame = array();
$frame['EventId'] = $eventId; $frame['EventId'] = $eventId;
$frame['FrameId'] = $frameId; $frame['FrameId'] = $frameId;
$frame['Type'] = "Virtual"; $frame['Type'] = 'Virtual';
} }
$event = dbFetchOne( 'select * from Events where Id = ?', NULL, array( $frame['EventId'] ) ); $event = dbFetchOne( 'select * from Events where Id = ?', NULL, array( $frame['EventId'] ) );
$frame['Image'] = getImageSrc( $event, $frame, SCALE_BASE ); $frame['Image'] = getImageSrc( $event, $frame, SCALE_BASE );
@ -349,7 +349,7 @@ function getNearFrame() {
return( array() ); return( array() );
} }
} }
$_REQUEST['entity'] = "frame"; $_REQUEST['entity'] = 'frame';
$_REQUEST['id'][1] = $nearFrameId; $_REQUEST['id'][1] = $nearFrameId;
return( collectData() ); return( collectData() );
} }
@ -358,7 +358,7 @@ function getNearEvents() {
global $user, $sortColumn, $sortOrder; global $user, $sortColumn, $sortOrder;
$eventId = $_REQUEST['id']; $eventId = $_REQUEST['id'];
$event = dbFetchOne( 'select * from Events where Id = ?', NULL, array( $eventId ) ); $event = dbFetchOne( 'SELECT * FROM Events WHERE Id=?', NULL, array( $eventId ) );
parseFilter( $_REQUEST['filter'] ); parseFilter( $_REQUEST['filter'] );
parseSort(); parseSort();
@ -368,7 +368,7 @@ function getNearEvents() {
else else
$midSql = ''; $midSql = '';
$sql = "select E.Id as Id, E.StartTime as StartTime from Events as E inner join Monitors as M on E.MonitorId = M.Id where $sortColumn ".($sortOrder=='asc'?'<=':'>=')." '".$event[$_REQUEST['sort_field']]."'".$_REQUEST['filter']['sql'].$midSql." order by $sortColumn ".($sortOrder=='asc'?'desc':'asc'); $sql = "SELECT E.Id AS Id, E.StartTime AS StartTime FROM Events AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id WHERE $sortColumn ".($sortOrder=='asc'?'<=':'>=')." '".$event[$_REQUEST['sort_field']]."'".$_REQUEST['filter']['sql'].$midSql." ORDER BY $sortColumn ".($sortOrder=='asc'?'desc':'asc') . ' LIMIT 2';
$result = dbQuery( $sql ); $result = dbQuery( $sql );
while ( $id = dbFetchNext( $result, 'Id' ) ) { while ( $id = dbFetchNext( $result, 'Id' ) ) {
if ( $id == $eventId ) { if ( $id == $eventId ) {
@ -377,7 +377,7 @@ function getNearEvents() {
} }
} }
$sql = "select E.Id as Id, E.StartTime as StartTime from Events as E inner join Monitors as M on E.MonitorId = M.Id where $sortColumn ".($sortOrder=='asc'?'>=':'<=')." '".$event[$_REQUEST['sort_field']]."'".$_REQUEST['filter']['sql'].$midSql." order by $sortColumn $sortOrder"; $sql = "SELECT E.Id AS Id, E.StartTime AS StartTime FROM Events AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id WHERE $sortColumn ".($sortOrder=='asc'?'>=':'<=')." '".$event[$_REQUEST['sort_field']]."'".$_REQUEST['filter']['sql'].$midSql." ORDER BY $sortColumn $sortOrder LIMIT 2";
$result = dbQuery( $sql ); $result = dbQuery( $sql );
while ( $id = dbFetchNext( $result, 'Id' ) ) { while ( $id = dbFetchNext( $result, 'Id' ) ) {
if ( $id == $eventId ) { if ( $id == $eventId ) {