2018-04-11 04:06:01 +08:00
|
|
|
<?php
|
|
|
|
//
|
|
|
|
// ZoneMinder web console file, $Date$, $Revision$
|
|
|
|
// Copyright (C) 2001-2008 Philip Coombes
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
|
|
|
// as published by the Free Software Foundation; either version 2
|
|
|
|
// of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
//
|
|
|
|
|
|
|
|
$navbar = getNavBarHTML();
|
|
|
|
ob_start();
|
|
|
|
include('_monitor_filters.php');
|
|
|
|
$filterbar = ob_get_contents();
|
|
|
|
ob_end_clean();
|
|
|
|
|
|
|
|
noCacheHeaders();
|
2020-04-10 23:10:13 +08:00
|
|
|
xhtmlHeaders( __FILE__, translate('Console'));
|
2018-04-11 04:06:01 +08:00
|
|
|
|
2018-05-08 05:08:17 +08:00
|
|
|
if ( isset($_REQUEST['minTime']) ) {
|
2018-05-04 00:42:14 +08:00
|
|
|
$minTime = validHtmlStr($_REQUEST['minTime']);
|
2018-05-08 05:08:17 +08:00
|
|
|
} else {
|
2020-04-10 23:10:13 +08:00
|
|
|
$minTime = strftime('%FT%T', time() - (2*3600));
|
2018-05-08 05:08:17 +08:00
|
|
|
}
|
|
|
|
if ( isset($_REQUEST['maxTime']) ) {
|
2018-05-04 00:42:14 +08:00
|
|
|
$maxTime = validHtmlStr($_REQUEST['maxTime']);
|
2018-05-08 05:08:17 +08:00
|
|
|
} else {
|
|
|
|
$maxTime = strftime('%FT%T',time() - 3600);
|
2018-05-04 00:42:14 +08:00
|
|
|
}
|
2018-04-11 04:06:01 +08:00
|
|
|
|
2018-05-04 00:42:14 +08:00
|
|
|
$filter = array(
|
|
|
|
'Query' => array(
|
|
|
|
'terms' => array(
|
|
|
|
array('attr'=>'StartDateTime', 'op'=>'>=', 'val'=>$minTime, 'obr'=>'1'),
|
|
|
|
array('attr'=>'StartDateTime', 'op'=>'<=', 'val'=>$maxTime, 'cnj'=>'and', 'cbr'=>'1'),
|
|
|
|
)
|
|
|
|
),
|
|
|
|
);
|
|
|
|
if ( count($selected_monitor_ids) ) {
|
2020-04-10 23:10:13 +08:00
|
|
|
$filter['Query']['terms'][] = (array('attr'=>'MonitorId', 'op'=>'IN', 'val'=>implode(',', $selected_monitor_ids), 'cnj'=>'and'));
|
2018-05-04 00:42:14 +08:00
|
|
|
} else if ( ( $group_id != 0 || isset($_SESSION['ServerId']) || isset($_SESSION['StorageId']) || isset($_SESSION['Status']) ) ) {
|
2018-04-11 04:06:01 +08:00
|
|
|
# this should be redundant
|
2020-04-10 23:10:13 +08:00
|
|
|
for ( $i=0; $i < count($displayMonitors); $i++ ) {
|
|
|
|
if ( $i == 0 ) {
|
2018-05-04 00:42:14 +08:00
|
|
|
$filter['Query']['terms'][] = array('attr'=>'MonitorId', 'op'=>'=', 'val'=>$displayMonitors[$i]['Id'], 'cnj'=>'and', 'obr'=>'1');
|
2020-04-10 23:10:13 +08:00
|
|
|
} else if ( $i == count($displayMonitors)-1 ) {
|
2018-05-04 00:42:14 +08:00
|
|
|
$filter['Query']['terms'][] = array('attr'=>'MonitorId', 'op'=>'=', 'val'=>$displayMonitors[$i]['Id'], 'cnj'=>'or', 'cbr'=>'1');
|
|
|
|
} else {
|
|
|
|
$filter['Query']['terms'][] = array('attr'=>'MonitorId', 'op'=>'=', 'val'=>$displayMonitors[$i]['Id'], 'cnj'=>'or');
|
2018-04-11 04:06:01 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-05-04 00:42:14 +08:00
|
|
|
parseFilter($filter);
|
|
|
|
$filterQuery = $filter['query'];
|
2020-10-14 22:39:25 +08:00
|
|
|
ZM\Debug($filterQuery);
|
2018-04-11 04:06:01 +08:00
|
|
|
|
|
|
|
$eventsSql = 'SELECT *,
|
2020-11-05 02:56:37 +08:00
|
|
|
UNIX_TIMESTAMP(E.StartDateTime) AS StartTimeSecs,
|
|
|
|
UNIX_TIMESTAMP(EndDateTime) AS EndTimeSecs
|
2018-04-11 04:06:01 +08:00
|
|
|
FROM Events AS E
|
|
|
|
WHERE 1 > 0
|
|
|
|
';
|
2020-04-10 23:10:13 +08:00
|
|
|
if ( !empty($user['MonitorIds']) ) {
|
2018-04-11 04:06:01 +08:00
|
|
|
$eventsSql .= ' AND MonitorId IN ('.$user['MonitorIds'].')';
|
|
|
|
}
|
|
|
|
if ( count($selected_monitor_ids) ) {
|
2020-04-10 23:10:13 +08:00
|
|
|
$eventsSql .= ' AND MonitorId IN ('.implode(',', $selected_monitor_ids).')';
|
2018-04-11 04:06:01 +08:00
|
|
|
}
|
|
|
|
if ( isset($minTime) && isset($maxTime) ) {
|
2020-11-05 02:56:37 +08:00
|
|
|
$eventsSql .= " AND EndDateTime > '" . $minTime . "' AND StartDateTime < '" . $maxTime . "'";
|
2018-04-11 04:06:01 +08:00
|
|
|
}
|
|
|
|
$eventsSql .= ' ORDER BY Id ASC';
|
|
|
|
|
2018-05-04 00:42:14 +08:00
|
|
|
$result = dbQuery($eventsSql);
|
|
|
|
if ( !$result ) {
|
2019-02-22 22:19:07 +08:00
|
|
|
ZM\Fatal('SQL-ERR');
|
2018-04-11 04:06:01 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
$EventsByMonitor = array();
|
2020-04-10 23:10:13 +08:00
|
|
|
while ( $event = $result->fetch(PDO::FETCH_ASSOC) ) {
|
2019-02-22 22:19:07 +08:00
|
|
|
$Event = new ZM\Event($event);
|
2018-04-11 04:06:01 +08:00
|
|
|
if ( ! isset($EventsByMonitor[$event['MonitorId']]) )
|
2020-04-10 23:10:13 +08:00
|
|
|
$EventsByMonitor[$event['MonitorId']] = array('Events'=>array(), 'MinGap'=>0, 'MaxGap'=>0, 'FileMissing'=>array(), 'ZeroSize'=>array());
|
2018-04-11 04:06:01 +08:00
|
|
|
|
|
|
|
if ( count($EventsByMonitor[$event['MonitorId']]['Events']) ) {
|
|
|
|
$last_event = end($EventsByMonitor[$event['MonitorId']]['Events']);
|
2020-10-14 22:39:25 +08:00
|
|
|
#Debug(print_r($last_event,true));
|
2018-04-11 04:06:01 +08:00
|
|
|
$gap = $last_event->EndTimeSecs() - $event['StartTimeSecs'];
|
|
|
|
|
|
|
|
if ( $gap < $EventsByMonitor[$event['MonitorId']]['MinGap'] )
|
|
|
|
$EventsByMonitor[$event['MonitorId']]['MinGap'] = $gap;
|
|
|
|
if ( $gap > $EventsByMonitor[$event['MonitorId']]['MaxGap'] )
|
|
|
|
$EventsByMonitor[$event['MonitorId']]['MaxGap'] = $gap;
|
|
|
|
|
|
|
|
} # end if has previous events
|
2020-04-10 23:10:13 +08:00
|
|
|
if ( !$Event->file_exists() ) {
|
2018-05-08 05:08:17 +08:00
|
|
|
$EventsByMonitor[$event['MonitorId']]['FileMissing'][] = $Event;
|
2018-05-09 00:22:20 +08:00
|
|
|
} else if ( ! $Event->file_size() ) {
|
2018-05-04 00:42:14 +08:00
|
|
|
$EventsByMonitor[$event['MonitorId']]['ZeroSize'][] = $Event;
|
2018-04-11 04:06:01 +08:00
|
|
|
}
|
|
|
|
$EventsByMonitor[$event['MonitorId']]['Events'][] = $Event;
|
|
|
|
} # end foreach event
|
|
|
|
|
|
|
|
?>
|
|
|
|
<body>
|
2019-02-10 13:39:19 +08:00
|
|
|
<form name="monitorForm" method="get" action="?">
|
2018-04-11 04:06:01 +08:00
|
|
|
<input type="hidden" name="view" value="<?php echo $view ?>"/>
|
|
|
|
<input type="hidden" name="action" value=""/>
|
|
|
|
|
|
|
|
<?php echo $navbar ?>
|
|
|
|
<div class="filterBar">
|
|
|
|
<?php echo $filterbar ?>
|
|
|
|
<div id="DateTimeDiv">
|
|
|
|
<label>Event Start Time</label>
|
2020-04-10 23:10:13 +08:00
|
|
|
<input type="text" name="minTime" id="minTime" value="<?php echo preg_replace('/T/', ' ', $minTime) ?>" oninput="this.form.submit();"/> to
|
|
|
|
<input type="text" name="maxTime" id="maxTime" value="<?php echo preg_replace('/T/', ' ', $maxTime) ?>" oninput="this.form.submit();"/>
|
2018-04-11 04:06:01 +08:00
|
|
|
</div>
|
|
|
|
</div><!--FilterBar-->
|
|
|
|
|
|
|
|
<div class="container-fluid">
|
|
|
|
<table class="table table-striped table-hover table-condensed" id="consoleTable">
|
|
|
|
<thead class="thead-highlight">
|
|
|
|
<tr>
|
|
|
|
<th class="colId"><?php echo translate('Id') ?></th>
|
|
|
|
<th class="colName"><i class="material-icons md-18">videocam</i> <?php echo translate('Name') ?></th>
|
2018-04-30 22:09:23 +08:00
|
|
|
<th class="colServer"><?php echo translate('Server') ?></th>
|
2018-04-11 04:06:01 +08:00
|
|
|
<th class="colEvents"><?php echo translate('Events') ?></th>
|
2018-04-30 22:09:23 +08:00
|
|
|
<th class="colFirstEvent"><?php echo translate('FirstEvent') ?></th>
|
|
|
|
<th class="colLastEvent"><?php echo translate('LastEvent') ?></th>
|
2018-04-11 04:06:01 +08:00
|
|
|
<th class="colMinGap"><?php echo translate('MinGap') ?></th>
|
|
|
|
<th class="colMaxGap"><?php echo translate('MaxGap') ?></th>
|
|
|
|
<th class="colMissingFiles"><?php echo translate('MissingFiles') ?></th>
|
2018-04-19 04:48:20 +08:00
|
|
|
<th class="colZeroSize"><?php echo translate('ZeroSize') ?></th>
|
2018-04-11 04:06:01 +08:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<?php
|
2020-04-10 23:10:13 +08:00
|
|
|
for ( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) {
|
2018-04-11 04:06:01 +08:00
|
|
|
$monitor = $displayMonitors[$monitor_i];
|
2019-02-22 22:19:07 +08:00
|
|
|
$Monitor = new ZM\Monitor($monitor);
|
2020-04-10 23:10:13 +08:00
|
|
|
$montagereview_link = '?view=montagereview&live=0&MonitorId='.$monitor['Id'].'&minTime='.$minTime.'&maxTime='.$maxTime;
|
2018-04-30 22:09:23 +08:00
|
|
|
|
2018-05-04 00:42:14 +08:00
|
|
|
$monitor_filter = addFilterTerm(
|
|
|
|
$filter,
|
|
|
|
count($filter['Query']['terms']),
|
|
|
|
array('cnj'=>'and', 'attr'=>'MonitorId', 'op'=>'=', 'val'=>$monitor['Id'])
|
|
|
|
);
|
|
|
|
parseFilter($monitor_filter);
|
|
|
|
|
2018-04-30 22:09:23 +08:00
|
|
|
if ( isset($EventsByMonitor[$Monitor->Id()]) ) {
|
|
|
|
$EventCounts = $EventsByMonitor[$Monitor->Id()];
|
|
|
|
$MinGap = $EventCounts['MinGap'];
|
|
|
|
$MaxGap = $EventCounts['MaxGap'];
|
|
|
|
$FileMissing = $EventCounts['FileMissing'];
|
|
|
|
$ZeroSize = $EventCounts['ZeroSize'];
|
|
|
|
$FirstEvent = $EventCounts['Events'][0];
|
|
|
|
$LastEvent = end($EventCounts['Events']);
|
|
|
|
} else {
|
|
|
|
$MinGap = 0;
|
|
|
|
$MaxGap = 0;
|
2018-05-08 05:08:17 +08:00
|
|
|
$FileMissing = array();
|
|
|
|
$ZeroSize = array();
|
2018-04-30 22:09:23 +08:00
|
|
|
$FirstEvent = 0;
|
|
|
|
$LastEvent = 0;
|
|
|
|
}
|
|
|
|
|
2018-05-08 05:08:17 +08:00
|
|
|
if ( count($FileMissing) ) {
|
|
|
|
$FileMissing_filter = array(
|
|
|
|
'Query' => array(
|
|
|
|
'terms' => array(
|
2020-04-10 23:10:13 +08:00
|
|
|
array('attr'=>'Id', 'op'=>'IN', 'val'=>implode(',', array_map(function($Event){return $Event->Id();}, $FileMissing)))
|
2018-05-08 05:08:17 +08:00
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
parseFilter($FileMissing_filter);
|
|
|
|
}
|
|
|
|
if ( count($ZeroSize) ) {
|
|
|
|
$ZeroSize_filter = array(
|
|
|
|
'Query' => array(
|
|
|
|
'terms' => array(
|
2020-04-10 23:10:13 +08:00
|
|
|
array('attr'=>'Id', 'op'=>'IN', 'val'=>implode(',', array_map(function($Event){return $Event->Id();}, $ZeroSize)))
|
2018-05-08 05:08:17 +08:00
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2019-07-08 05:54:45 +08:00
|
|
|
parseFilter($ZeroSize_filter);
|
2018-05-08 05:08:17 +08:00
|
|
|
}
|
2018-04-11 04:06:01 +08:00
|
|
|
?>
|
|
|
|
<tr id="<?php echo 'monitor_id-'.$monitor['Id'] ?>" title="<?php echo $monitor['Id'] ?>">
|
2018-04-18 05:14:40 +08:00
|
|
|
<td class="colId"><a href="<?php echo $montagereview_link ?>"><?php echo $monitor['Id'] ?></a></td>
|
2018-04-11 04:06:01 +08:00
|
|
|
<td class="colName">
|
2020-04-10 23:10:13 +08:00
|
|
|
<a href="<?php echo $montagereview_link ?>"><?php echo validHtmlStr($monitor['Name']) ?></a><br/>
|
|
|
|
<div class="small text-nowrap text-muted">
|
2018-04-11 04:06:01 +08:00
|
|
|
<?php echo implode('<br/>',
|
|
|
|
array_map(function($group_id){
|
2019-02-22 22:19:07 +08:00
|
|
|
$Group = new ZM\Group($group_id);
|
2018-04-11 04:06:01 +08:00
|
|
|
$Groups = $Group->Parents();
|
2018-05-04 00:42:14 +08:00
|
|
|
array_push($Groups, $Group);
|
2019-02-10 13:39:19 +08:00
|
|
|
return implode(' > ', array_map(function($Group){ return '<a href="?view=montagereview&GroupId='.$Group->Id().'">'.$Group->Name().'</a>'; }, $Groups ));
|
2020-04-10 23:10:13 +08:00
|
|
|
}, $Monitor->GroupIds()));
|
2018-04-11 04:06:01 +08:00
|
|
|
?>
|
|
|
|
</div></td>
|
2020-04-10 23:10:13 +08:00
|
|
|
<td class="colServer"><?php echo validHtmlStr($Monitor->Server()->Name())?></td>
|
2018-05-04 00:42:14 +08:00
|
|
|
<td class="colEvents"><a href="?view=<?php echo ZM_WEB_EVENTS_VIEW ?>&page=1<?php echo $monitor_filter['query'] ?>"><?php echo isset($EventsByMonitor[$Monitor->Id()])?count($EventsByMonitor[$Monitor->Id()]['Events']):0 ?></a></td>
|
2020-11-05 02:56:37 +08:00
|
|
|
<td class="colFirstEvent"><?php echo $FirstEvent ? $FirstEvent->link_to($FirstEvent->Id().' at '.$FirstEvent->StartDateTime()) : 'none'?></td>
|
|
|
|
<td class="colLastEvent"><?php echo $LastEvent ? $LastEvent->link_to($LastEvent->Id().' at '.$LastEvent->StartDateTime()) : 'none'?></td>
|
2018-04-28 04:20:38 +08:00
|
|
|
<td class="colMinGap"><?php echo $MinGap ?></td>
|
|
|
|
<td class="colMaxGap"><?php echo $MaxGap ?></td>
|
2018-05-08 05:08:17 +08:00
|
|
|
<td class="colFileMissing<?php echo count($FileMissing) ? ' errorText' : ''?>">
|
2020-04-10 23:10:13 +08:00
|
|
|
<?php echo count($FileMissing) ? '<a href="?view='.ZM_WEB_EVENTS_VIEW.'&page=1'.$FileMissing_filter['query'].'">'.count($FileMissing).'</a>' : '0' ?>
|
2018-05-08 05:08:17 +08:00
|
|
|
</td>
|
|
|
|
<td class="colZeroSize<?php echo count($ZeroSize) ? ' errorText' : ''?>">
|
2020-04-10 23:10:13 +08:00
|
|
|
<?php echo count($ZeroSize) ? '<a href="?view='.ZM_WEB_EVENTS_VIEW.'&page=1'.$ZeroSize_filter['query'].'">'.count($ZeroSize).'</a>' : '0' ?>
|
2018-05-08 05:08:17 +08:00
|
|
|
</td>
|
2018-04-11 04:06:01 +08:00
|
|
|
</tr>
|
|
|
|
<?php
|
|
|
|
} # end for each monitor
|
|
|
|
?>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
<?php xhtmlFooter() ?>
|