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.

54 lines
2.2 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <?php
  2. require_once('../ajax_asm.php');
  3. function verbose( $ok=1,$info=""){
  4. // failure to upload throws 400 error
  5. if( $ok==0 ){
  6. http_response_code(400);
  7. };
  8. die(json_encode(["success"=>true, "ok"=>$ok, "info"=>$info]));
  9. };
  10. header('content-type text/html;');
  11. if( $CUser->Data['id'] > 1 ){
  12. $MID = intval( $_POST['MID'] );
  13. if( $MID ){
  14. $QS = "SELECT * FROM `location_maps` WHERE `id`={$MID}";
  15. $DDD = $DATABASE->Query( $QS );
  16. if( count( $DDD ) ){
  17. $BM = intval( $_POST['bounds_mode'] );
  18. $MD = $DDD[0];
  19. list( $width, $height, $type, $attr ) = getimagesize( $SYSPath . 'lib/controller/data/assets/images/' . $MD['layer_url'] );
  20. $ENAME = $DATABASE->escape($_POST['map_name']);
  21. $EDESC = $DATABASE->escape($_POST['map_desc']);
  22. $EATTR = $DATABASE->escape($_POST['map_attr']);
  23. $IZOOM = intval( $_POST['map_maxz'] );
  24. $INZOOM = intval( $_POST['map_maxz'] );
  25. $MA_WI = floatval( $_POST['map_width'] );
  26. $MA_HE = floatval( $_POST['map_height'] );
  27. $TB = intval( $_POST['map_tpb'] );
  28. $LB = intval( $_POST['map_lpb'] );
  29. $RB = intval( $_POST['map_rpb'] );
  30. $BB = intval( $_POST['map_bpb'] );
  31. $K_X = $MA_WI / ( $width - $LB - $RB );
  32. $K_Y = $MA_HE / ( $height - $TB - $BB );
  33. if( $BM ){
  34. $THW = (($width + $RB + $LB) * $K_X ) / 2.0;
  35. $THH = (($height + $BB + $TB) * $K_Y ) / 2.0;
  36. $IBLX = -$THW;
  37. $IBLY = -$THH;
  38. $IBRX = $THW;
  39. $IBRY = $THH;
  40. } else {
  41. $IBLX = (-$LB)*$K_X;
  42. $IBLY = (-$TB)*$K_Y;
  43. $IBRX = ( $width + $RB ) * $K_X;
  44. $IBRY = ( $height + $BB ) * $K_Y;
  45. };
  46. $QS = "UPDATE `location_maps` SET `name`='{$ENAME}',`desc`='{$EDESC}', `maxNativeZoom`={$INZOOM},`maxZoom`={$IZOOM}, `attribution`='{$EATTR}',`bounds_lx`={$IBLX},`bounds_ly`={$IBLY}, `bounds_rx`={$IBRX},`bounds_ry`={$IBRY}, `img_w`={$width}, `img_h`={$height}, `img_lb`={$LB}, `img_rb`={$RB}, `img_tb`={$TB},`img_bb`={$BB}, `img_map_w`={$MA_WI}, `img_map_h`={$MA_HE}, `bounds_mode`={$BM} WHERE `id`={$MID}";
  47. $DATABASE->Query( $QS );
  48. verbose( 1, "ALL IS OK" );
  49. } else verbose( 0, "WRONG MAPID" );
  50. } else verbose( 0, "WRONG MAPID" );
  51. } else {
  52. verbose( 0, 'Access Denied!' );
  53. };
  54. ?>