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.

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