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.

62 lines
1.9 KiB

3 years ago
3 years ago
​
​
3 years ago
​
3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 years ago
​
​
  1. <?php
  2. require_once('../ajax_asm.php');
  3. if( $CUser->Data['id'] > 1 ){
  4. if( isset( $_GET['NID'] ) ) if( !isset( $_POST['NID'] ) ) $_POST['NID'] = $_GET['NID'];
  5. if( isset( $_POST['NID'] ) ){
  6. $NID = intval( $_POST['NID'] );
  7. if( $NID ){
  8. $QS="SELECT `type` FROM `nodes` WHERE `id`={$NID}";
  9. $SS = $DATABASE->Query( $QS );
  10. if( count( $SS ) ){
  11. $IS_IMAGE = ( $SS[0]['type'] == 5 );
  12. if( $IS_IMAGE ){
  13. $QS="SELECT `data`, `type` FROM `lrf_draw` WHERE `node_id`={$NID} AND `type`=1 ORDER BY `ts` DESC LIMIT 1";
  14. } else {
  15. $QS="SELECT `data`, `type` FROM `lrf_draw` WHERE `node_id`={$NID} AND `type`=0 ORDER BY `ts` DESC LIMIT 1";
  16. };
  17. $SS = $DATABASE->Query( $QS );
  18. if( count( $SS ) ){
  19. if( $IS_IMAGE ){
  20. $DUDU= $SS[0]['data'];
  21. $FD = file_get_contents( 'data/device_draws/' . $DUDU.'_100.png' );
  22. header('Content-Type: image/png');
  23. echo $FD;
  24. } else {
  25. $DUDU= $SS[0]['data'];
  26. $FD = fopen( 'data/device_draws/' . $DUDU.'.raw', "r" );
  27. if( $FD ){
  28. $C = fread( $FD, 4 );
  29. if( $C !== false ){
  30. $U = unpack("L", $C );
  31. $Data['count'] = $U[1];
  32. $C = fread( $FD, 4*$Data['count'] );
  33. $U = unpack("S*", $C );
  34. $idx = 1;
  35. $C = array();
  36. $Data['data']=array();
  37. for( $i = 0; $i < $Data['count']; $i++ ){
  38. $C['S'] = $U[$idx++];
  39. $C['M'] = $U[$idx++];
  40. $Data['data'][]=$C;
  41. };
  42. };
  43. fclose( $FD );
  44. };
  45. echo json_encode( $Data );
  46. };
  47. } else {
  48. if( $IS_IMAGE ){
  49. $FD = file_get_contents( 'data/assets/images/empty_3d.png' );
  50. header('Content-Type: image/png');
  51. echo $FD;
  52. } else {
  53. $Data['count'] = 0;
  54. echo json_encode( $Data );
  55. };
  56. };
  57. exit();
  58. };
  59. };
  60. };
  61. };
  62. header('location: /');
  63. ?>