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.
63 lines
1.9 KiB
63 lines
1.9 KiB
<?php
|
|
require_once('../ajax_asm.php');
|
|
if( $CUser->Data['id'] > 1 ){
|
|
if( isset( $_GET['NID'] ) ) if( !isset( $_POST['NID'] ) ) $_POST['NID'] = $_GET['NID'];
|
|
if( isset( $_POST['NID'] ) ){
|
|
$NID = intval( $_POST['NID'] );
|
|
if( $NID ){
|
|
$QS="SELECT `type` FROM `nodes` WHERE `id`={$NID}";
|
|
$SS = $DATABASE->Query( $QS );
|
|
if( count( $SS ) ){
|
|
$IS_IMAGE = ( $SS[0]['type'] == 5 );
|
|
if( $IS_IMAGE ){
|
|
$QS="SELECT `data`, `type` FROM `lrf_draw` WHERE `node_id`={$NID} AND `type`=1 ORDER BY `ts` DESC LIMIT 1";
|
|
} else {
|
|
$QS="SELECT `data`, `type` FROM `lrf_draw` WHERE `node_id`={$NID} AND `type`=0 ORDER BY `ts` DESC LIMIT 1";
|
|
};
|
|
$SS = $DATABASE->Query( $QS );
|
|
if( count( $SS ) ){
|
|
if( $IS_IMAGE ){
|
|
$DUDU= $SS[0]['data'];
|
|
$FD = file_get_contents( 'data/device_draws/' . $DUDU.'_100.png' );
|
|
header('Content-Type: image/png');
|
|
echo $FD;
|
|
} else {
|
|
$DUDU= $SS[0]['data'];
|
|
$FD = fopen( 'data/device_draws/' . $DUDU.'.raw', "r" );
|
|
if( $FD ){
|
|
$C = fread( $FD, 4 );
|
|
if( $C !== false ){
|
|
$U = unpack("L", $C );
|
|
$Data['count'] = $U[1];
|
|
$C = fread( $FD, 4*$Data['count'] );
|
|
$U = unpack("S*", $C );
|
|
$idx = 1;
|
|
$C = array();
|
|
$Data['data']=array();
|
|
for( $i = 0; $i < $Data['count']; $i++ ){
|
|
$C['S'] = $U[$idx++];
|
|
$C['M'] = $U[$idx++];
|
|
$Data['data'][]=$C;
|
|
};
|
|
};
|
|
fclose( $FD );
|
|
};
|
|
echo json_encode( $Data );
|
|
};
|
|
} else {
|
|
if( $IS_IMAGE ){
|
|
$FD = file_get_contents( 'data/assets/images/empty_3d.png' );
|
|
header('Content-Type: image/png');
|
|
echo $FD;
|
|
} else {
|
|
$Data['count'] = 0;
|
|
echo json_encode( $Data );
|
|
};
|
|
};
|
|
exit();
|
|
};
|
|
};
|
|
};
|
|
};
|
|
header('location: /');
|
|
?>
|