????JFIF??x?x????'
| Server IP : 79.136.114.73 / Your IP : 216.73.217.84 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/www.supervision-online.se/login/scripts/ |
Upload File : |
<?php
function grid_to_geodetic($x, $y, $central_meridian) {
$lat_lon[] = 2;
$axis = 6378137.0; // GRS 80.
$flattening = 1.0 / 298.257222101; // GRS 80.
$lat_of_origin = 0.0;
$scale = 1.0;
$false_northing = 0.0;
$false_easting = 150000.0;
// Prepare ellipsoid-based stuff.
$e2 = $flattening * (2.0 - $flattening);
$n = $flattening / (2.0 - $flattening);
$a_roof = $axis / (1.0 + $n) * (1.0 + $n*$n/4.0 + $n*$n*$n*$n/64.0);
$delta1 = $n/2.0 - 2.0*$n*$n/3.0 + 37.0*$n*$n*$n/96.0 - $n*$n*$n*$n/360.0;
$delta2 = $n*$n/48.0 + $n*$n*$n/15.0 - 437.0*$n*$n*$n*$n/1440.0;
$delta3 = 17.0*$n*$n*$n/480.0 - 37*$n*$n*$n*$n/840.0;
$delta4 = 4397.0*$n*$n*$n*$n/161280.0;
$Astar = $e2 + $e2*$e2 + $e2*$e2*$e2 + $e2*$e2*$e2*$e2;
$Bstar = -(7.0*$e2*$e2 + 17.0*$e2*$e2*$e2 + 30.0*$e2*$e2*$e2*$e2) / 6.0;
$Cstar = (224.0*$e2*$e2*$e2 + 889.0*$e2*$e2*$e2*$e2) / 120.0;
$Dstar = -(4279.0*$e2*$e2*$e2*$e2) / 1260.0;
// Convert.
$deg_to_rad = M_PI / 180;
$lambda_zero = $central_meridian * $deg_to_rad;
$xi = ($x - $false_northing) / ($scale * $a_roof);
$eta = ($y - $false_easting) / ($scale * $a_roof);
$xi_prim = $xi -
$delta1*sin(2.0*$xi) * cosh(2.0*$eta) -
$delta2*sin(4.0*$xi) * cosh(4.0*$eta) -
$delta3*sin(6.0*$xi) * cosh(6.0*$eta) -
$delta4*sin(8.0*$xi) * cosh(8.0*$eta);
$eta_prim = $eta -
$delta1*cos(2.0*$xi) * sinh(2.0*$eta) -
$delta2*cos(4.0*$xi) * sinh(4.0*$eta) -
$delta3*cos(6.0*$xi) * sinh(6.0*$eta) -
$delta4*cos(8.0*$xi) * sinh(8.0*$eta);
$phi_star = asin(sin($xi_prim) / cosh($eta_prim));
$delta_lambda = atan(sinh($eta_prim) / cos($xi_prim));
$lon_radian = $lambda_zero + $delta_lambda;
$lat_radian = $phi_star + sin($phi_star) * cos($phi_star) *
($Astar +
$Bstar*pow(sin($phi_star), 2) +
$Cstar*pow(sin($phi_star), 4) +
$Dstar*pow(sin($phi_star), 6));
$lat_lon[0] = $lat_radian * 180.0 / M_PI;
$lat_lon[1] = $lon_radian * 180.0 / M_PI;
//echo($lat_lon[0].",". $lat_lon[1]);
return $lat_lon;
}
session_start();
$link = mysql_connect ("localhost", "root", "root123");
mysql_select_db ("supervision");
$source_encoding = "ISO-8859-1";
ini_set("auto_detect_line_endings", true);
$uploaded_file = md5($_FILES["file"]["name"].date("Y-m-d-hh-ss")).".csv";
move_uploaded_file($_FILES["file"]["tmp_name"],"/var/www/www.supervision-online.se/login/data/" . $uploaded_file);
$nbr_pos = 0;
if(file_exists("/var/www/www.supervision-online.se/login/data/".$uploaded_file)){
$file = fopen("/var/www/www.supervision-online.se/login/data/".$uploaded_file, "r");
$line_nbr = 0;
while(true){
$line = fgets($file);
if($line_nbr > 0){
$array = explode("\t", trim($line));
$x = 0;
$PArray[] = sizeof($array)+1;
foreach ($array as $v) {
$PArray[$x] = $v;
$x++;
}
//echo($PArray[0]." - ".$PArray[1]."<br>");
$UpdateDate = gmdate("Y-m-d H:i:s");
$PositionId = $PArray[0];
if($PositionId == ""){
$PositionId = "0";
}
$TempPositionId = 0;
$Title = $PArray[1];
if($_POST['system'] == "wgs"){
$Lat = str_replace(",",".", iconv("UTF-8","ISO-8859-1",$PArray[2]));
$Long =str_replace(",",".",$PArray[3]);
}else{
$Lat = str_replace(",",".",$PArray[2]);
$Long =str_replace(",",".",$PArray[3]);
$arr = grid_to_geodetic($Lat,$Long,$_POST['system']);
$Lat = $arr[0];
$Long = $arr[1];
}
//$Description = iconv("UTF-16","ISO-8859-1", $PArray[4]);
$Description = $PArray[4];
$Status = $_POST['status'];
$SymbolSetId = $_POST['symbolset'];
$UserId = $_SESSION['SUPERVISION_SSO_INFO'][0];
$sql = "Select * from tblPositions where SymbolSetId = $SymbolSetId and posid = '$PositionId';";
$result = mysql_query($sql);
$id = 0;
while ($row = mysql_fetch_assoc($result)){
$id = $row['id'];
}
if($posid != 0){
$sql = "UPDATE tblPositions SET posid = '$PositionId', tempposid = '$TempPositionId', label = '$Title', description = '$Description', status = '$Status', updatedate = '$UpdateDate', userid = '$UserId' WHERE id = $id";
}else{
$sql = "INSERT into tblPositions Values(NULL , '$PositionId', '$TempPositionId', '$Title', '$Lat', '$Long', '$Description', '', '', '', '', '$Status', '$SymbolSetId', '$UpdateDate', '$UserId');";
}
//echo($sql);
mysql_query($sql);
$nbr_pos++;
}
if(feof($file)){
break;
}
$line_nbr++;
}
}
header("Location: ../data.php?message=Dina ".$nbr_pos." positioner har importerats!");
?>