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.
 
 
 
 

83 lines
2.2 KiB

<?php
require_once('../ajax_asm.php');
if( $CUser->Data['id'] > 1 ){
$Data = array();
$Data['success'] = false;
if( isset( $_POST['SNID'] ) ) {
$SNID = intval($_POST['SNID']);
} else $SNID = 0;
if( isset( $_POST['OPID'] ) ){
$CMD = intval( $_POST['OPID'] );
} else {
$CMD = 0;
};
if( $SNID > 0 && $CMD > 0 ){
$QS = "SELECT `id` FROM `nodes` WHERE `aux_id`={$SNID} AND `type` IN ( 1,2,3,4,5 )";
$RR = $DATABASE->Query( $QS );
if( count( $RR ) ){
$CN = $RR[0];
$QS = '';
switch( $CMD ){
case 1: {
$OPCODE = intval( $_POST['OPCODE'] );
$NID = $CN['id'];
$QS = "UPDATE `nodes` SET `enable`={$OPCODE} WHERE `id`={$NID}";
$Data['success'] = true;
break;
};
case 2:{
$OPCODE = intval( $_POST['OPCODE'] );
$RANGES = array( 15, 35, 45, 65, 75, 150, 200, 300 );
$VAL = $RANGES[$OPCODE];
if( $VAL ){
$QS = "UPDATE `lrf_sensors` SET `max_range`={$VAL} WHERE `id`={$SNID}";
$Data['success'] = true;
};
break;
};
case 3:{
$OPCODE = intval( $_POST['OPCODE'] );
if( $OPCODE < 256 ){
$QS = "UPDATE `lrf_sensors` SET `device_id`={$OPCODE} WHERE `id`={$SNID}";
$Data['success'] = true;
};
break;
};
case 4:{
$OPCODE = intval( $_POST['OPCODE'] );
if( $OPCODE ){
$QS = "UPDATE `lrf_sensors` SET `uart_id`={$OPCODE} WHERE `id`={$SNID}";
$Data['success'] = true;
};
break;
};
case 5:{
$OPCODE = intval( $_POST['OPCODE'] );
$TIMES = array( 0, 10, 20, 30, 40, 50, 100, 200 );
$VAL = $TIMES[$OPCODE] / 1;
$QS = "UPDATE `lrf_sensors` SET `auto_draw`={$VAL} WHERE `id`={$SNID}";
$Data['success'] = true;
break;
};
case 6:{
$OPCODE = intval( $_POST['OPCODE'] );
if( $OPCODE < 6001 ){
$QS = "UPDATE `lrf_sensors` SET `base_shift`={$OPCODE} WHERE `id`={$SNID}";
$Data['success'] = true;
};
break;
};
};
if( $QS != '' ) $DATABASE->Query( $QS, false );
$Data['query'] = $QS;
} else {
$Data['msg']='Node Not Found!';
};
} else {
$Data['msg']='Wrong Parameters!';
};
echo json_encode( $Data );
exit();
};
header('location: /');
?>