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.

82 lines
2.2 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <?php
  2. require_once('../ajax_asm.php');
  3. if( $CUser->Data['id'] > 1 ){
  4. $Data = array();
  5. $Data['success'] = false;
  6. if( isset( $_POST['SNID'] ) ) {
  7. $SNID = intval($_POST['SNID']);
  8. } else $SNID = 0;
  9. if( isset( $_POST['OPID'] ) ){
  10. $CMD = intval( $_POST['OPID'] );
  11. } else {
  12. $CMD = 0;
  13. };
  14. if( $SNID > 0 && $CMD > 0 ){
  15. $QS = "SELECT `id` FROM `nodes` WHERE `aux_id`={$SNID} AND `type` IN ( 1,2,3,4,5 )";
  16. $RR = $DATABASE->Query( $QS );
  17. if( count( $RR ) ){
  18. $CN = $RR[0];
  19. $QS = '';
  20. switch( $CMD ){
  21. case 1: {
  22. $OPCODE = intval( $_POST['OPCODE'] );
  23. $NID = $CN['id'];
  24. $QS = "UPDATE `nodes` SET `enable`={$OPCODE} WHERE `id`={$NID}";
  25. $Data['success'] = true;
  26. break;
  27. };
  28. case 2:{
  29. $OPCODE = intval( $_POST['OPCODE'] );
  30. $RANGES = array( 15, 35, 45, 65, 75, 150, 200, 300 );
  31. $VAL = $RANGES[$OPCODE];
  32. if( $VAL ){
  33. $QS = "UPDATE `lrf_sensors` SET `max_range`={$VAL} WHERE `id`={$SNID}";
  34. $Data['success'] = true;
  35. };
  36. break;
  37. };
  38. case 3:{
  39. $OPCODE = intval( $_POST['OPCODE'] );
  40. if( $OPCODE < 256 ){
  41. $QS = "UPDATE `lrf_sensors` SET `device_id`={$OPCODE} WHERE `id`={$SNID}";
  42. $Data['success'] = true;
  43. };
  44. break;
  45. };
  46. case 4:{
  47. $OPCODE = intval( $_POST['OPCODE'] );
  48. if( $OPCODE ){
  49. $QS = "UPDATE `lrf_sensors` SET `uart_id`={$OPCODE} WHERE `id`={$SNID}";
  50. $Data['success'] = true;
  51. };
  52. break;
  53. };
  54. case 5:{
  55. $OPCODE = intval( $_POST['OPCODE'] );
  56. $TIMES = array( 0, 10, 20, 30, 40, 50, 100, 200 );
  57. $VAL = $TIMES[$OPCODE] / 1;
  58. $QS = "UPDATE `lrf_sensors` SET `auto_draw`={$VAL} WHERE `id`={$SNID}";
  59. $Data['success'] = true;
  60. break;
  61. };
  62. case 6:{
  63. $OPCODE = intval( $_POST['OPCODE'] );
  64. if( $OPCODE < 6001 ){
  65. $QS = "UPDATE `lrf_sensors` SET `base_shift`={$OPCODE} WHERE `id`={$SNID}";
  66. $Data['success'] = true;
  67. };
  68. break;
  69. };
  70. };
  71. if( $QS != '' ) $DATABASE->Query( $QS, false );
  72. $Data['query'] = $QS;
  73. } else {
  74. $Data['msg']='Node Not Found!';
  75. };
  76. } else {
  77. $Data['msg']='Wrong Parameters!';
  78. };
  79. echo json_encode( $Data );
  80. exit();
  81. };
  82. header('location: /');
  83. ?>