|
|
@@ -146,13 +146,18 @@ class Route_GeoreferencesManager extends RouteBase {
|
|
|
if (!is_numeric($maxDistance)) throw new Exception("Błąd formularza #1");
|
|
|
if (!isset($_FILES['file'])) throw new Exception("Błąd formularza #2");
|
|
|
if (!file_exists($_FILES['file']['tmp_name'])) throw new Exception("Wystąpił problem z przesłaniem pliku");
|
|
|
- if ($_FILES['file']['type'] != 'text/csv') throw new Exception("Błędny typ pliku - {$_FILES['file']['type']}");
|
|
|
+ $fileTypes = [
|
|
|
+ 'text/csv',
|
|
|
+ 'application/vnd.ms-excel',
|
|
|
+ ];
|
|
|
+ if (!in_array($_FILES['file']['type'], $fileTypes)) throw new Exception("Błędny typ pliku - {$_FILES['file']['type']}");
|
|
|
$file = file($_FILES['file']['tmp_name']);
|
|
|
|
|
|
$points = [];
|
|
|
foreach ($file as $line) {
|
|
|
+ if (!preg_match('/^[[:alnum:]]+,([[:digit:]\.]+,){3}[[:alnum:] ]+$/', trim($line))) throw new Exception("Plik zawiera niepoprawne dane #1 - {$line}");
|
|
|
list($lp, $y, $x, $z, $type) = explode(',', $line);
|
|
|
- if (!($lp && $x && $y && $z && $type)) throw new Exception("Plik zawiera niepoprawne dane");
|
|
|
+ if (!($lp && $x && $y && $z && $type)) throw new Exception("Plik zawiera niepoprawne dane #2");
|
|
|
if (trim($type) == "Pikieta") {
|
|
|
foreach ($points as $key => $point) {
|
|
|
if (sqrt((pow($point['x'] - $x, 2) + pow($point['y'] - $y, 2)) <= $maxDistance)) {
|