Web UI for ARGUS server
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.

344 lines
12 KiB

6 years ago
​
6 years ago
5 years ago
​
​
​
​
​
5 years ago
5 years ago
​
​
​
​
5 years ago
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
5 years ago
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
5 years ago
5 years ago
5 years ago
​
5 years ago
​
​
​
​
​
​
​
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
​
6 years ago
5 years ago
6 years ago
​
  1. <?php
  2. require_once('../ajax_asm.php');
  3. $SAVE_AS_PICTURE = true;
  4. if( $CUser->Data['id'] > 1 ){
  5. header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
  6. header("Cache-Control: post-check=0, pre-check=0", false);
  7. header("Pragma: no-cache");
  8. header("Content-Type: image/png");
  9. if(isset( $_POST['NID'] )){
  10. $NID = intval($_POST['NID']);
  11. } else {
  12. $NID = intval($_GET['NID']);
  13. };
  14. if(isset( $_POST['AUX'] )){
  15. $AUX = intval($_POST['AUX']);
  16. } elseif( isset($_GET['AUX']) ) {
  17. $AUX = intval($_GET['AUX']);
  18. } else $AUX = 0;
  19. $QS = "SELECT * FROM lrf_draw WHERE node_id={$NID} ORDER BY ts DESC LIMIT 1";
  20. $Result = $DATABASE->Query( $QS, false );
  21. if( count( $Result ) ){
  22. if( $SAVE_AS_PICTURE ){
  23. if( $Result[0]['rendered'] == 'Y' ){
  24. if( $AUX ){
  25. $FN = "data/device_draws/{$Result[0]['md5']}_{$AUX}.png";
  26. } else {
  27. $FN = "data/device_draws/{$Result[0]['md5']}_100.png";
  28. };
  29. } else {
  30. $FF = "data/device_draws/{$Result[0]['md5']}.raw";
  31. $FN = "ddd";
  32. if( file_exists( $FF ) ) {
  33. $FD = fopen( $FF, "rb" );
  34. if( $FD ){
  35. if( $Result[0]['type'] == 1 ){
  36. //$IM = imagecreatefrompng("../../style/assets/3d_draw_empty_100.png");
  37. $IM = imagecreatefromjpeg("../../style/assets/3d_draw_empty_100.jpg");
  38. imagesavealpha( $IM, true );
  39. $bg = imagecolorallocate($IM, 0, 0, 0);
  40. $black = imagecolorallocate($IM, 255, 255, 0);
  41. //$green = imagecolorallocate($IM, 0, 255, 0);
  42. $green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 );
  43. imagefilledrectangle( $IM, 5, 5, 36, 18, $bg );
  44. imagestring( $IM, 2, 6, 5, "LIBERMANDA", $black );
  45. imagepng( $IM, "data/device_draws/{$Result[0]['md5']}_100.png" );
  46. imagedestroy( $IM );
  47. $QS = "UPDATE lrf_draw SET rendered='Y' WHERE id={$Result[0]['id']}";
  48. $DATABASE->Query( $QS );
  49. $FN = "data/device_draws/{$Result[0]['md5']}_100.png";
  50. } else {
  51. $CL = fread( $FD, 4 );
  52. $size = unpack( "V", $CL );
  53. $pts = array();
  54. $as = $size[1];
  55. for($i=0; $i< $as; $i++ ){
  56. $CL = fread( $FD, 4 );
  57. $T = unpack( "V", $CL );
  58. //print_r( $T );
  59. $pts[] = $T[1] >> 16;
  60. };
  61. fclose( $FD );
  62. $QS = "SELECT ls.base_shift, ls.max_range FROM nodes ns LEFT JOIN lrf_sensors ls ON ( ls.id=ns.aux_id ) WHERE ns.id={$NID}";
  63. $PP = $DATABASE->Query( $QS );
  64. $stp = 2.0 * ( M_PI / $as );
  65. $MR = intval( $PP[0]['max_range'] );
  66. $S = ( M_PI / 3000.0 ) * intval( $PP[0]['base_shift'] );
  67. $IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_100.png");
  68. imagesavealpha( $IM, true );
  69. $bg = imagecolorallocate($IM, 0, 0, 0);
  70. $black = imagecolorallocate($IM, 255, 255, 0);
  71. //$green = imagecolorallocate($IM, 0, 255, 0);
  72. $green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 );
  73. imagefilledrectangle( $IM, 5, 5, 36, 18, $bg );
  74. imagestring( $IM, 2, 6, 5, $MR . "m.", $black );
  75. $maxR = 98.0;
  76. $rst = $maxR / 1025.0;
  77. $x0 = 100;
  78. $y0 = 100;
  79. $ppA = array();
  80. $ppB = array();
  81. for( $i=0; $i< $as; $i++ ){
  82. if( $pts[$i] > 0 ){
  83. $cr = ($rst * $pts[$i]);
  84. $ca = 0.0 - ( $S + $i * $stp );
  85. $ppA[] = $x0 + $cr * cos( $ca );
  86. $ppA[] = $y0 + $cr * sin( $ca );
  87. $ppB[] = $x0 + $maxR * cos( $ca );
  88. $ppB[] = $y0 + $maxR * sin( $ca );
  89. } else {
  90. $ca = 0.0 - ( $S + $i * $stp );
  91. $ppA[] = $x0 + $maxR * cos( $ca );
  92. $ppA[] = $y0 + $maxR * sin( $ca );
  93. $ppB[] = $x0 + $maxR * cos( $ca );
  94. $ppB[] = $y0 + $maxR * sin( $ca );
  95. };
  96. };
  97. $ppB[] = $ppA[count($ppA)-2];
  98. $ppB[] = $ppA[count($ppA)-1];
  99. $popo = array_merge( $ppA, $ppB );
  100. imagefilledpolygon( $IM, $popo, count( $popo ) / 2, $green );
  101. imagepng( $IM, "data/device_draws/{$Result[0]['md5']}_100.png" );
  102. imagedestroy( $IM );
  103. $IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_50.png");
  104. imagesavealpha( $IM, true );
  105. $bg = imagecolorallocate($IM, 0, 0, 0);
  106. $black = imagecolorallocate($IM, 255, 255, 0);
  107. //$green = imagecolorallocate($IM, 0, 255, 0);
  108. $green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 );
  109. imagefilledrectangle( $IM, 5, 5, 36, 18, $bg );
  110. imagestring( $IM, 2, 6, 5, ( $MR / 2 ) . "m.", $black );
  111. $rst = $maxR / 513.0;
  112. $ppA = array();
  113. $ppB = array();
  114. for( $i=0; $i< $as; $i++ ){
  115. if( $pts[$i] > 0 && $pts[$i] < 513 ){
  116. $cr = ($rst * $pts[$i]);
  117. $ca = 0.0 - ( $S + $i * $stp );
  118. $ppA[] = $x0 + $cr * cos( $ca );
  119. $ppA[] = $y0 + $cr * sin( $ca );
  120. $ppB[] = $x0 + $maxR * cos( $ca );
  121. $ppB[] = $y0 + $maxR * sin( $ca );
  122. } else {
  123. $ca = 0.0 - ( $S + $i * $stp );
  124. $ppA[] = $x0 + $maxR * cos( $ca );
  125. $ppA[] = $y0 + $maxR * sin( $ca );
  126. $ppB[] = $x0 + $maxR * cos( $ca );
  127. $ppB[] = $y0 + $maxR * sin( $ca );
  128. };
  129. };
  130. $ppB[] = $ppA[count($ppA)-2];
  131. $ppB[] = $ppA[count($ppA)-1];
  132. $popo = array_merge( $ppA, $ppB );
  133. imagefilledpolygon( $IM, $popo, count( $popo ) / 2, $green );
  134. imagepng( $IM, "data/device_draws/{$Result[0]['md5']}_50.png" );
  135. imagedestroy( $IM );
  136. $IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_25.png");
  137. imagesavealpha( $IM, true );
  138. $bg = imagecolorallocate($IM, 0, 0, 0);
  139. $black = imagecolorallocate($IM, 255, 255, 0);
  140. //$green = imagecolorallocate($IM, 0, 255, 0);
  141. $green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 );
  142. imagefilledrectangle( $IM, 5, 5, 36, 18, $bg );
  143. imagestring( $IM, 2, 6, 5, ( $MR / 4 ) . "m.", $black );
  144. $rst = $maxR / 257.0;
  145. $ppA = array();
  146. $ppB = array();
  147. for( $i=0; $i< $as; $i++ ){
  148. if( $pts[$i] > 0 && $pts[$i] < 256 ){
  149. $cr = ($rst * $pts[$i]);
  150. $ca = 0.0 - ( $S + $i * $stp );
  151. $ppA[] = $x0 + $cr * cos( $ca );
  152. $ppA[] = $y0 + $cr * sin( $ca );
  153. $ppB[] = $x0 + $maxR * cos( $ca );
  154. $ppB[] = $y0 + $maxR * sin( $ca );
  155. } else {
  156. $ca = 0.0 - ( $S + $i * $stp );
  157. $ppA[] = $x0 + $maxR * cos( $ca );
  158. $ppA[] = $y0 + $maxR * sin( $ca );
  159. $ppB[] = $x0 + $maxR * cos( $ca );
  160. $ppB[] = $y0 + $maxR * sin( $ca );
  161. };
  162. };
  163. $ppB[] = $ppA[count($ppA)-2];
  164. $ppB[] = $ppA[count($ppA)-1];
  165. $popo = array_merge( $ppA, $ppB );
  166. imagefilledpolygon( $IM, $popo, count( $popo ) / 2, $green );
  167. imagepng( $IM, "data/device_draws/{$Result[0]['md5']}_25.png" );
  168. imagedestroy( $IM );
  169. $IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_12.png");
  170. imagesavealpha( $IM, true );
  171. $bg = imagecolorallocate($IM, 0, 0, 0);
  172. $black = imagecolorallocate($IM, 255, 255, 0);
  173. //$green = imagecolorallocate($IM, 0, 255, 0);
  174. $green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 );
  175. imagefilledrectangle( $IM, 5, 5, 36, 18, $bg );
  176. imagestring( $IM, 2, 6, 5, ( $MR / 8 ) . "m.", $black );
  177. $rst = $maxR / 129.0;
  178. $ppA = array();
  179. $ppB = array();
  180. for( $i=0; $i< $as; $i++ ){
  181. if( $pts[$i] > 0 && $pts[$i] < 128 ){
  182. $cr = ($rst * $pts[$i]);
  183. $ca = 0.0 - ( $S + $i * $stp );
  184. $ppA[] = $x0 + $cr * cos( $ca );
  185. $ppA[] = $y0 + $cr * sin( $ca );
  186. $ppB[] = $x0 + $maxR * cos( $ca );
  187. $ppB[] = $y0 + $maxR * sin( $ca );
  188. } else {
  189. $ca = 0.0 - ( $S + $i * $stp );
  190. $ppA[] = $x0 + $maxR * cos( $ca );
  191. $ppA[] = $y0 + $maxR * sin( $ca );
  192. $ppB[] = $x0 + $maxR * cos( $ca );
  193. $ppB[] = $y0 + $maxR * sin( $ca );
  194. };
  195. };
  196. $ppB[] = $ppA[count($ppA)-2];
  197. $ppB[] = $ppA[count($ppA)-1];
  198. $popo = array_merge( $ppA, $ppB );
  199. imagefilledpolygon( $IM, $popo, count( $popo ) / 2, $green );
  200. imagepng( $IM, "data/device_draws/{$Result[0]['md5']}_12.png" );
  201. imagedestroy( $IM );
  202. $QS = "UPDATE lrf_draw SET rendered='Y' WHERE id={$Result[0]['id']}";
  203. $DATABASE->Query( $QS );
  204. if( $AUX ){
  205. $FN = "data/device_draws/{$Result[0]['md5']}_{$AUX}.png";
  206. } else {
  207. $FN = "data/device_draws/{$Result[0]['md5']}_100.png";
  208. };
  209. };
  210. };
  211. } else {
  212. echo "No Res"; exit();
  213. if( $AUX ){
  214. $FN = "../../style/assets/lfs_draw_empty_{$AUX}.png";
  215. } else {
  216. $FN = "../../style/assets/lfs_draw_empty_100.png";
  217. };
  218. };
  219. };
  220. if( !file_exists( $FN ) ) $FN = "../../style/assets/lfs_draw_empty_100.png";
  221. readfile( $FN );
  222. } else {
  223. //! $SAVE_AS_PICTURE
  224. $FF = "data/device_draws/{$Result[0]['md5']}.raw";
  225. if( file_exists( $FF ) ) {
  226. $FD = fopen( $FF, "rb" );
  227. if( $FD ){
  228. $CL = fread( $FD, 4 );
  229. $size = unpack( "V", $CL );
  230. $pts = array();
  231. $as = $size[1];
  232. for($i=0; $i< $as; $i++ ){
  233. $CL = fread( $FD, 4 );
  234. $T = unpack( "V", $CL );
  235. $pts[] = $T[1] >> 16;
  236. };
  237. fclose( $FD );
  238. $QS = "SELECT ls.base_shift, ls.max_range FROM nodes ns LEFT JOIN lrf_sensors ls ON ( ls.id=ns.aux_id ) WHERE ns.id={$NID}";
  239. $PP = $DATABASE->Query( $QS );
  240. $stp = 2.0 * ( M_PI / $as );
  241. $MR = intval( $PP[0]['max_range'] );
  242. $S = ( M_PI / 3000.0 ) * intval( $PP[0]['base_shift'] );
  243. switch( $AUX ){
  244. case 12: {
  245. $IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_12.png");
  246. $RR = 129.0;
  247. $MR = $MR / 8;
  248. $MD = 128;
  249. break;
  250. };
  251. case 25: {
  252. $IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_25.png");
  253. $RR = 257.0;
  254. $MR = $MR / 4;
  255. $MD = 256;
  256. break;
  257. };
  258. case 50: {
  259. $IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_50.png");
  260. $RR = 513.0;
  261. $MR = $MR / 2;
  262. $MD = 512;
  263. break;
  264. };
  265. default:{
  266. $IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_100.png");
  267. $RR = 1025.0;
  268. $MD = 1025;
  269. break;
  270. };
  271. };
  272. imagesavealpha( $IM, true );
  273. $bg = imagecolorallocate($IM, 0, 0, 0);
  274. $black = imagecolorallocate($IM, 255, 255, 0);
  275. //$green = imagecolorallocate($IM, 0, 255, 0);
  276. $green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 );
  277. imagefilledrectangle( $IM, 5, 5, 36, 18, $bg );
  278. imagestring( $IM, 2, 6, 5, $MR . "m.", $black );
  279. $maxR = 98.0;
  280. $x0 = 100;
  281. $y0 = 100;
  282. $rst = $maxR / $RR;
  283. $ppA = array();
  284. $ppB = array();
  285. for( $i=0; $i< $as; $i++ ){
  286. if( $pts[$i] > 0 && $pts[$i] < $MD ){
  287. $cr = ($rst * $pts[$i]);
  288. $ca = 0.0 - ( $S + $i * $stp );
  289. $ppA[] = $x0 + $cr * cos( $ca );
  290. $ppA[] = $y0 + $cr * sin( $ca );
  291. $ppB[] = $x0 + $maxR * cos( $ca );
  292. $ppB[] = $y0 + $maxR * sin( $ca );
  293. } else {
  294. $ca = 0.0 - ( $S + $i * $stp );
  295. $ppA[] = $x0 + $maxR * cos( $ca );
  296. $ppA[] = $y0 + $maxR * sin( $ca );
  297. $ppB[] = $x0 + $maxR * cos( $ca );
  298. $ppB[] = $y0 + $maxR * sin( $ca );
  299. };
  300. };
  301. $ppB[] = $ppA[count($ppA)-2];
  302. $ppB[] = $ppA[count($ppA)-1];
  303. $popo = array_merge( $ppA, $ppB );
  304. imagefilledpolygon( $IM, $popo, count( $popo ) / 2, $green );
  305. imagepng( $IM );
  306. imagedestroy( $IM );
  307. } else {
  308. if( $AUX ){
  309. $FN = "../../style/assets/lfs_draw_empty_{$AUX}.png";
  310. } else {
  311. $FN = "../../style/assets/lfs_draw_empty_100.png";
  312. };
  313. if( !file_exists( $FN ) ) $FN = "../../style/assets/lfs_draw_empty_100.png";
  314. readfile( $FN );
  315. };
  316. } else {
  317. if( $AUX ){
  318. $FN = "../../style/assets/lfs_draw_empty_{$AUX}.png";
  319. } else {
  320. $FN = "../../style/assets/lfs_draw_empty_100.png";
  321. };
  322. if( !file_exists( $FN ) ) $FN = "../../style/assets/lfs_draw_empty_100.png";
  323. readfile( $FN );
  324. };
  325. };
  326. } else {
  327. if( $AUX ){
  328. $FN = "../../style/assets/lfs_draw_empty_{$AUX}.png";
  329. } else {
  330. $FN = "../../style/assets/lfs_draw_empty_100.png";
  331. };
  332. if( !file_exists( $FN ) ) $FN = "../../style/assets/lfs_draw_empty_100.png";
  333. readfile( $FN );
  334. };
  335. } else {
  336. header('location: /');
  337. };
  338. ?>