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.

94 lines
3.3 KiB

​
​
4 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( '/srv/www/web/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( '/srv/www/web/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. $JIGA = array();
  32. foreach( $NDD as $N ){
  33. if( $st_ignore && $N['evt_type']!=52 ) continue;
  34. if( $st_ignore && $N['evt_type']==52 ) $st_ignore = false;
  35. if( $N['evt_type']==52 ) {
  36. $DH = 0;
  37. $BID = intval( $N['id'] );
  38. $BTM = date( "H:i:s", $N['ts'] );
  39. } else {
  40. $DH = 1;
  41. $EID = intval( $N['id'] );
  42. };
  43. if( $DH == 1 ){
  44. $JIGA[] = "{ text: '{$BTM}', leaf: true, bid: {$BID}, eid: {$EID} }";
  45. };
  46. };
  47. if( $DH == 0 ){
  48. //Ongoing Event goes next day - must catch up
  49. $QS = "SELECT `id`, `ts`, `evt_type` FROM `events` WHERE `id` > {$BID} AND ( `evt_type`=53 OR `evt_type`=54 ) LIMIT 1";
  50. $NDD = $ZIZI->Query( $QS );
  51. if( count( $NDD ) ){
  52. $EID = intval( $NDD[0]['id'] );
  53. } else {
  54. $EID = 1000000000;//Infinity
  55. };
  56. $JIGA[] = "{ text: '{$BTM}', leaf: true, bid: {$BID}, eid: {$EID} }";
  57. };
  58. $NONO = "{ text: 'Sessions', leaf: false, expanded: true, children:[". implode( ",", $JIGA ) . "]}";
  59. };
  60. $QS = "SELECT DISTINCT `ts`/3600 AS JUJA FROM `events`";
  61. $NDD = $ZIZI->Query( $QS );
  62. if( count( $NDD ) ){
  63. $st_ignore = true;
  64. $DH = 0;
  65. $SIGA = array();
  66. foreach( $NDD as $N ){
  67. $BTS = intval($N['JUJA'])*3600;
  68. $DADA = date( "H:i", $BTS );
  69. $ETS = $BTS+3599;
  70. $BID = 0;
  71. $EID = 0;
  72. $QS="SELECT `id` FROM `events` WHERE `ts`>({$BTS}-1) LIMIT 1";
  73. $KK = $ZIZI->Query( $QS );
  74. if( count( $KK ) ) $BID = $KK[0]['id'];
  75. $QS="SELECT `id` FROM `events` WHERE `ts`>({$ETS}-1) LIMIT 1";
  76. $KK = $ZIZI->Query( $QS );
  77. if( count( $KK ) ) $EID = $KK[0]['id']; else $EID = $BID;
  78. if( $BID && $EID ){
  79. $SIGA[] = "{ text: '{$DADA}', leaf: true, bid: {$BID}, eid: {$EID} }";
  80. };
  81. };
  82. $EVEVE = "{ text: 'Events by Hours', leaf: false, expanded: true, children:[". implode( ",", $SIGA ) . "]}";
  83. };
  84. };
  85. if( $NONO=='' ) $NONO = "{ text: 'No Sessions', leaf: true }";
  86. if( $EVEVE=='' ) $EVEVE = "{ text: 'No Events', leaf: true }";
  87. echo "{expanded: true, children: [{$NONO},{$EVEVE}], sessions:{$S}, events:{$E}, videos:{$V} }";
  88. } else {
  89. echo "[]";
  90. };
  91. } else {
  92. header('location: /');
  93. };
  94. ?>