Web Interface For Lite Argus Control modules
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

65 lines
2.1 KiB

<?php
require_once('../ajax_asm.php');
if( $CUser->Data['id'] > 1 ){
$DTS = intval( $_POST['DTS'] );
if( $DTS ){
$Y = date("Y", $DTS );
$M = date("m", $DTS );
$D = date("d", $DTS );
$DS = date("Y/m/d", $DTS );
$NONO = '';
$MUMU = new SQLite_DB( '/srv/www/web/lib/controller/data/reports/stat.db' );
$QS = "SELECT * FROM `days` WHERE `year`={$Y} AND `month`={$M} AND `day`={$D}";
$LOLO = $MUMU->Query( $QS );
$S = 0;
$V = 0;
$E = 0;
if( count( $LOLO ) ){
$S = intval( $LOLO[0]['session_count'] );
$V = intval( $LOLO[0]['videos_count'] );
$E = intval( $LOLO[0]['evt_count'] );
$ZIZI = new SQLite_DB( '/srv/www/web/lib/controller/data/reports/' . $DS . '/report.db' );
$QS = "SELECT `id`, `ts`, `evt_type` FROM `events` WHERE ( `evt_type`=52 OR `evt_type`=53 OR `evt_type`=54 )";
$NDD = $ZIZI->Query( $QS );
if( count( $NDD ) ){
$st_ignore = true;
$DH = 0;
$JIGA = array();
foreach( $NDD as $N ){
if( $st_ignore && $N['evt_type']!=52 ) continue;
if( $st_ignore && $N['evt_type']==52 ) $st_ignore = false;
if( $N['evt_type']==52 ) {
$DH = 0;
$BID = intval( $N['id'] );
$BTM = date( "H:i:s", $N['ts'] );
} else {
$DH = 1;
$EID = intval( $N['id'] );
};
if( $DH == 1 ){
$JIGA[] = "{ text: '{$BTM}', leaf: true, bid: {$BID}, eid: {$EID} }";
};
};
if( $DH == 0 ){
//Ongoing Event goes next day - must catch up
$QS = "SELECT `id`, `ts`, `evt_type` FROM `events` WHERE `id` > {$BID} AND ( `evt_type`=53 OR `evt_type`=54 ) LIMIT 1";
$NDD = $ZIZI->Query( $QS );
if( count( $NDD ) ){
$EID = intval( $NDD[0]['id'] );
} else {
$EID = 1000000000;//Infinity
};
$JIGA[] = "{ text: '{$BTM}', leaf: true, bid: {$BID}, eid: {$EID} }";
};
$NONO = "{ text: 'Events', leaf: false, expanded: true, children:[". implode( ",", $JIGA ) . "]}";
};
};
echo "{expanded: true, children: [". $NONO ."], sessions:{$S}, events:{$E}, videos:{$V} }";
} else {
echo "[]";
};
} else {
header('location: /');
};
?>