$zmSlangEvents, "filter" => array( "terms" => array( ) ), ), array( "title" => $zmSlangHour, "filter" => array( "terms" => array( array( "attr" => "Archived", "op" => "=", "val" => "0" ), array( "cnj" => "and", "attr" => "DateTime", "op" => ">=", "val" => "-1 hour" ), ) ), ), array( "title" => $zmSlangDay, "filter" => array( "terms" => array( array( "attr" => "Archived", "op" => "=", "val" => "0" ), array( "cnj" => "and", "attr" => "DateTime", "op" => ">=", "val" => "-1 day" ), ) ), ), array( "title" => $zmSlangWeek, "filter" => array( "terms" => array( array( "attr" => "Archived", "op" => "=", "val" => "0" ), array( "cnj" => "and", "attr" => "DateTime", "op" => ">=", "val" => "-7 day" ), ) ), ), array( "title" => $zmSlangMonth, "filter" => array( "terms" => array( array( "attr" => "Archived", "op" => "=", "val" => "0" ), array( "cnj" => "and", "attr" => "DateTime", "op" => ">=", "val" => "-1 month" ), ) ), ), array( "title" => $zmSlangArchive, "filter" => array( "terms" => array( array( "attr" => "Archived", "op" => "=", "val" => "1" ), ) ), ), ); $running = daemonCheck(); $status = $running?$zmSlangRunning:$zmSlangStopped; if ( !isset($cgroup) ) { $cgroup = 0; } if ( $group = dbFetchOne( "select * from Groups where Id = '$cgroup'" ) ) $group_ids = array_flip(split( ',', $group['MonitorIds'] )); if ( ZM_WEB_REFRESH_METHOD == "http" ) header("Refresh: ".ZM_WEB_REFRESH_MAIN."; URL=$PHP_SELF" ); noCacheHeaders(); $db_now = strftime( STRF_FMT_DATETIME_DB ); $monitors = array(); $max_width = 0; $max_height = 0; $cycle_count = 0; $min_sequence = 0; $max_sequence = 1; $seq_id_list = array(); $monitors = dbFetchAll( "select * from Monitors order by Sequence asc" ); for ( $i = 0; $i < count($monitors); $i++ ) { if ( !visibleMonitor( $monitors[$i]['Id'] ) ) { continue; } if ( $group && !empty($group_ids) && !array_key_exists( $monitors[$i]['Id'], $group_ids ) ) { continue; } $monitors[$i]['Show'] = true; if ( empty($min_sequence) || ($monitors[$i]['Sequence'] < $min_sequence) ) { $min_sequence = $monitors[$i]['Sequence']; } if ( $monitors[$i]['Sequence'] > $max_sequence ) { $max_sequence = $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($event_counts); $j++ ) { $filter = addFilterTerm( $event_counts[$j]['filter'], count($event_counts[$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]['event_counts'][$j]['filter'] = $filter; } $sql = "select ".join($counts,", ")." from Events as E where MonitorId = '".$monitors[$i]['Id']."'"; $counts = dbFetchOne( $sql ); if ( $monitors[$i]['Function'] != 'None' ) { $cycle_count++; $scale_width = reScale( $monitors[$i]['Width'], $monitors[$i]['DefaultScale'], ZM_WEB_DEFAULT_SCALE ); $scale_height = reScale( $monitors[$i]['Height'], $monitors[$i]['DefaultScale'], ZM_WEB_DEFAULT_SCALE ); if ( $max_width < $scale_width ) $max_width = $scale_width; if ( $max_height < $scale_height ) $max_height = $scale_height; } $monitors[$i] = array_merge( $monitors[$i], $counts ); $seq_id_list[] = $monitors[$i]['Id']; } $last_id = 0; $seq_id_u_list = array(); foreach ( $seq_id_list as $seq_id ) { if ( !empty($last_id) ) { $seq_id_u_list[$seq_id] = $last_id; } $last_id = $seq_id; } $last_id = 0; $seq_id_d_list = array(); foreach ( array_reverse($seq_id_list) as $seq_id ) { if ( !empty($last_id) ) { $seq_id_d_list[$seq_id] = $last_id; } $last_id = $seq_id; } if ( $cycle_count ) { $montage_rows = intval((($cycle_count-1)/ZM_WEB_MONTAGE_MAX_COLS)+1); $montage_cols = intval(ceil($cycle_count/$montage_rows)); } else { $montage_rows = 0; $montage_cols = 0; } $montage_width = ZM_WEB_MONTAGE_WIDTH?ZM_WEB_MONTAGE_WIDTH:$max_width; $montage_height = ZM_WEB_MONTAGE_HEIGHT?ZM_WEB_MONTAGE_HEIGHT:$max_height; ?>