$SLANG['Events'], "filter" => array( "terms" => array( ) ), ), array( "title" => $SLANG['Hour'], "filter" => array( "terms" => array( array( "attr" => "Archived", "op" => "=", "val" => "0" ), array( "cnj" => "and", "attr" => "DateTime", "op" => ">=", "val" => "-1 hour" ), ) ), ), array( "title" => $SLANG['Day'], "filter" => array( "terms" => array( array( "attr" => "Archived", "op" => "=", "val" => "0" ), array( "cnj" => "and", "attr" => "DateTime", "op" => ">=", "val" => "-1 day" ), ) ), ), array( "title" => $SLANG['Week'], "filter" => array( "terms" => array( array( "attr" => "Archived", "op" => "=", "val" => "0" ), array( "cnj" => "and", "attr" => "DateTime", "op" => ">=", "val" => "-7 day" ), ) ), ), array( "title" => $SLANG['Month'], "filter" => array( "terms" => array( array( "attr" => "Archived", "op" => "=", "val" => "0" ), array( "cnj" => "and", "attr" => "DateTime", "op" => ">=", "val" => "-1 month" ), ) ), ), array( "title" => $SLANG['Archived'], "filter" => array( "terms" => array( array( "attr" => "Archived", "op" => "=", "val" => "1" ), ) ), ), ); $running = daemonCheck(); $status = $running?$SLANG['Running']:$SLANG['Stopped']; if ( $group = dbFetchOne( "select * from Groups where Id = '".(empty($_COOKIE['zmGroup'])?0:dbEscape($_COOKIE['zmGroup']))."'" ) ) $groupIds = array_flip(split( ',', $group['MonitorIds'] )); $maxWidth = 0; $maxHeight = 0; $cycleCount = 0; $minSequence = 0; $maxSequence = 1; $seqIdList = array(); $monitors = dbFetchAll( "select * from Monitors order by Sequence asc" ); $displayMonitors = array(); for ( $i = 0; $i < count($monitors); $i++ ) { if ( !visibleMonitor( $monitors[$i]['Id'] ) ) { continue; } if ( $group && !empty($groupIds) && !array_key_exists( $monitors[$i]['Id'], $groupIds ) ) { continue; } $monitors[$i]['Show'] = true; if ( empty($minSequence) || ($monitors[$i]['Sequence'] < $minSequence) ) { $minSequence = $monitors[$i]['Sequence']; } if ( $monitors[$i]['Sequence'] > $maxSequence ) { $maxSequence = $monitors[$i]['Sequence']; } $monitors[$i]['zmc'] = zmcStatus( $monitors[$i] ); $monitors[$i]['zma'] = zmaStatus( $monitors[$i] ); $monitors[$i]['ZoneCount'] = dbFetchOne( "select count(Id) as ZoneCount from Zones where MonitorId = '".$monitors[$i]['Id']."'", "ZoneCount" ); $counts = array(); for ( $j = 0; $j < count($eventCounts); $j++ ) { $filter = addFilterTerm( $eventCounts[$j]['filter'], count($eventCounts[$j]['filter']['terms']), array( "cnj" => "and", "attr" => "MonitorId", "op" => "=", "val" => $monitors[$i]['Id'] ) ); parseFilter( $filter ); $counts[] = "count(if(1".$filter['sql'].",1,NULL)) as EventCount$j"; $monitors[$i]['eventCounts'][$j]['filter'] = $filter; } $sql = "select ".join($counts,", ")." from Events as E where MonitorId = '".$monitors[$i]['Id']."'"; $counts = dbFetchOne( $sql ); if ( $monitors[$i]['Function'] != 'None' ) { $cycleCount++; $scaleWidth = reScale( $monitors[$i]['Width'], $monitors[$i]['DefaultScale'], ZM_WEB_DEFAULT_SCALE ); $scaleHeight = reScale( $monitors[$i]['Height'], $monitors[$i]['DefaultScale'], ZM_WEB_DEFAULT_SCALE ); if ( $maxWidth < $scaleWidth ) $maxWidth = $scaleWidth; if ( $maxHeight < $scaleHeight ) $maxHeight = $scaleHeight; } $monitors[$i] = array_merge( $monitors[$i], $counts ); $seqIdList[] = $monitors[$i]['Id']; $displayMonitors[] = $monitors[$i]; } /* Parse any specific actions here */ if (isset($_GET['action']) && (strcmp($_GET['action'],"login") != 0)) { $action = $_GET['action']; if (strcmp($action, "devent") == 0) { if (!canEdit('Events')) { error_log("User ".$user['Username']. " doesn't have edit Events perms"); exit; } $eid = validInt($_REQUEST['eid']); $url = "./index.php?view=request&request=event&id=".$eid."&action=delete"; header("Location: ".$url); exit; } else if (strcmp($action, "feed") == 0) { if (!canView('Stream')) { error_log("User ".$user['Username']. " doesn't have view Stream perms"); exit; } $monitor = validInt($_REQUEST['monitor']); if (isset($_GET['fps'])) $fps = $_GET['fps']; else $fps = ZM_WEB_VIDEO_MAXFPS; if (isset($_GET['scale'])) $scale = $_GET['scale']; else $scale = 100; $streamSrc = getStreamSrc( array( "mode=jpeg", "monitor=".$monitor, "scale=".$scale, "maxfps=".$fps, "buffer=1000" ) ); noCacheHeaders(); xhtmlHeaders( __FILE__, "Stream" ); echo "
\n"; echo "