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.

100 lines
3.5 KiB

​
​
4 years ago
3 years ago
3 years ago
​
​
​
3 years ago
​
​
​
​
3 years ago
​
​
​
​
​
​
​
​
3 years ago
3 years ago
​
​
​
​
3 years ago
​
​
​
​
​
​
​
​
​
​
​
3 years ago
​
3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
3 years ago
​
​
​
​
​
​
​
​
​
3 years ago
​
​
​
​
3 years ago
​
​
​
​
​
​
​
3 years ago
​
​
4 years ago
​
​
​
​
​
  1. <?php
  2. require_once('../ajax_asm.php');
  3. if( $CUser->Data['id'] > 1 ){
  4. $DTS = intval( $_POST['DTS'] );
  5. if( $DTS ){
  6. $TZ = new DateTimeZone( date_default_timezone_get() );
  7. $DT = new DateTime("now", $TZ );
  8. $DIDI = $TZ->getOffset( $DT );
  9. //$DTS += $DIDI;
  10. $Y = date("Y", $DTS );
  11. $M = date("m", $DTS );
  12. $D = date("d", $DTS );
  13. $DS = date("Y/m/d", $DTS );
  14. $NONO = '';
  15. $MUMU = new SQLite_DB( $SYSPath . '/lib/controller/data/reports/stat.db' );
  16. $QS = "SELECT * FROM `days` WHERE `year`={$Y} AND `month`={$M} AND `day`={$D}";
  17. $LOLO = $MUMU->Query( $QS );
  18. $S = 0;
  19. $V = 0;
  20. $E = 0;
  21. if( count( $LOLO ) ){
  22. $S = intval( $LOLO[0]['session_count'] );
  23. $V = intval( $LOLO[0]['videos_count'] );
  24. $E = intval( $LOLO[0]['evt_count'] );
  25. $ZIZI = new SQLite_DB( $SYSPath . '/lib/controller/data/reports/' . $DS . '/report.db' );
  26. $QS = "SELECT `id`, `ts`, `evt_type` FROM `events` WHERE ( `evt_type`=52 OR `evt_type`=53 OR `evt_type`=54 )";
  27. $NDD = $ZIZI->Query( $QS );
  28. if( count( $NDD ) ){
  29. $st_ignore = true;
  30. $DH = 0;
  31. $BID = 0;
  32. $EID = 0;
  33. $BTM = 0;
  34. $JIGA = array();
  35. foreach( $NDD as $N ){
  36. if( $st_ignore && $N['evt_type']!=52 ) continue;
  37. if( $st_ignore && $N['evt_type']==52 ) $st_ignore = false;
  38. if( $N['evt_type']==52 ) {
  39. $DH = 0;
  40. $BID = intval( $N['id'] );
  41. $BTM = date( "H:i:s", $N['ts'] );
  42. } else {
  43. $DH = 1;
  44. $EID = intval( $N['id'] );
  45. };
  46. if( $st_ignore == false && $DH == 1 ){
  47. $JIGA[] = "{ text: '{$BTM}', leaf: true, bid: {$BID}, eid: {$EID} }";
  48. };
  49. };
  50. if( $DH == 0 ){
  51. //Ongoing Event goes next day - must catch up
  52. $QS = "SELECT `id`, `ts`, `evt_type` FROM `events` WHERE `id` > {$BID} AND ( `evt_type`=53 OR `evt_type`=54 ) LIMIT 1";
  53. $NDD = $ZIZI->Query( $QS );
  54. if( count( $NDD ) ){
  55. $EID = intval( $NDD[0]['id'] );
  56. } else {
  57. $EID = 1000000000;//Infinity
  58. };
  59. $JIGA[] = "{ text: '{$BTM}', leaf: true, bid: {$BID}, eid: {$EID} }";
  60. };
  61. if( count( $JIGA ) ){
  62. $NONO = "{ text: 'Sessions', leaf: false, expanded: true, children:[". implode( ",", $JIGA ) . "]}";
  63. } else {
  64. $NONO = "{ text: 'No Sessions', leaf: true }";
  65. };
  66. };
  67. $QS = "SELECT DISTINCT `ts`/3600 AS JUJA FROM `events`";
  68. $NDD = $ZIZI->Query( $QS );
  69. if( count( $NDD ) ){
  70. $st_ignore = true;
  71. $DH = 0;
  72. $SIGA = array();
  73. foreach( $NDD as $N ){
  74. $BTS = intval($N['JUJA'])*3600;
  75. $DADA = date( "H:i", $BTS );
  76. $ETS = $BTS+3600;
  77. $BID = 0;
  78. $EID = 0;
  79. $QS="SELECT `id` FROM `events` WHERE `ts`>({$BTS}-1) LIMIT 1";
  80. $KK = $ZIZI->Query( $QS );
  81. if( count( $KK ) ) $BID = $KK[0]['id'];
  82. $QS="SELECT `id` FROM `events` WHERE `ts`<({$ETS}-1) ORDER BY `id` DESC LIMIT 1";
  83. $KK = $ZIZI->Query( $QS );
  84. if( count( $KK ) ) $EID = $KK[0]['id']; else $EID = $BID;
  85. if( $BID && $EID ){
  86. $SIGA[] = "{ text: '{$DADA}', leaf: true, bid: {$BID}, eid: {$EID} }";
  87. };
  88. };
  89. $EVEVE = "{ text: 'Events by Hours', leaf: false, expanded: true, children:[". implode( ",", $SIGA ) . "]}";
  90. };
  91. };
  92. if( $NONO=='' ) $NONO = "{ text: 'No Sessions', leaf: true }";
  93. if( $EVEVE=='' ) $EVEVE = "{ text: 'No Events', leaf: true }";
  94. echo "{expanded: true, children: [{$NONO},{$EVEVE}], sessions:{$S}, events:{$E}, videos:{$V} }";
  95. } else {
  96. echo "[]";
  97. };
  98. } else {
  99. header('location: /');
  100. };
  101. ?>