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.
 
 
 
 

66 lines
2.8 KiB

<?php
require_once('../ajax_asm.php');
function verbose( $ok=1,$info=""){
// failure to upload throws 400 error
if( $ok==0 ){
http_response_code(400);
};
die(json_encode(["ok"=>$ok, "info"=>$info]));
};
if( $CUser->Data['id'] > 1 ){
if( intval( $_POST['ctype'] ) == 1 ){
$EURL = $DATABASE->escape($_POST['map_url']);
$ENAME = $DATABASE->escape($_POST['map_name']);
$EDESC = $DATABASE->escape($_POST['map_desc']);
$EATTR = $DATABASE->escape($_POST['map_attr']);
$IZOOM = intval( $_POST['map_maxz'] );
$INZOOM = intval( $_POST['map_maxnz'] );
$QS = "INSERT INTO `location_maps`(`type`,`name`,`layer_url`,`desc`,`maxNativeZoom`,`maxZoom`,`attribution`) values(1,'{$ENAME}','{$EURL}','{$EDESC}',{$INZOOM},{$IZOOM},'{$EATTR}')";
$DATABASE->Query( $QS );
} else {
if( empty( $_FILES ) || $_FILES['map_image']['error'] ){
verbose( 0, "Failed to move uploaded file.[" . $_FILES['map_image']['error'] . "]" );
};
// upload destination
//$filePath = __DIR__ . DIRECTORY_SEPARATOR . "../../vault/working_dir/uploads";
$filePath = $SYSPath . 'lib/controller/data/assets/images';
if( !file_exists( $filePath ) ){
if (!mkdir($filePath, 0777, true)) {
verbose(0, "Failed to create $filePath" );
};
};
if( file_exists( $_FILES['map_image']['tmp_name'] ) ){
$MD5 = md5_file( $_FILES['map_image']['tmp_name'] );
$TArr = explode( '.', $_FILES['map_image']['name'] );
$EXT = $TArr[ count($TArr) - 1 ];
$FNAME = $MD5 . '.' . $EXT;
copy( $_FILES['map_image']['tmp_name'], $filePath . '/' . $FNAME );
@unlink( $_FILES['map_image']['tmp_name'] );
list( $width, $height, $type, $attr ) = getimagesize( $filePath . '/' . $FNAME );
$ENAME = $DATABASE->escape($_POST['map_name']);
$EDESC = $DATABASE->escape($_POST['map_desc']);
$EATTR = $DATABASE->escape($_POST['map_attr']);
$IZOOM = intval( $_POST['map_maxz'] );
$INZOOM = intval( $_POST['map_maxz'] );
$MA_WI = floatval( $_POST['map_width'] );
$MA_HE = floatval( $_POST['map_height'] );
$TB = intval( $_POST['map_tpb'] );
$LB = intval( $_POST['map_lpb'] );
$RB = intval( $_POST['map_rpb'] );
$BB = intval( $_POST['map_bpb'] );
$K_X = $MA_WI / ( $width - $LB - $RB );
$K_Y = $MA_HE / ( $height - $TB - $BB );
$IBLX = (-$LB)*$K_X;
$IBLY = (-$TB)*$K_Y;
$IBRX = ( $width + $RB ) * $K_X;
$IBRY = ( $height + $BB ) * $K_Y;
$QS = "INSERT INTO `location_maps`(`type`,`name`,`layer_url`,`desc`,`maxNativeZoom`,`maxZoom`,`attribution`,`bounds_lx`,`bounds_ly`,`bounds_rx`,`bounds_ry`) values(2,'{$ENAME}','{$FNAME}','{$EDESC}',{$INZOOM},{$IZOOM},'{$EATTR}',{$IBLX},{$IBLY},{$IBRX},{$IBRY})";
$DATABASE->Query( $QS );
verbose( 1, "ALL IS OK" );
};
};
} else {
verbose( 0, 'Access Denied!' );
};
?>