From 92690767a139f636138dc44c1742437bea2d6214 Mon Sep 17 00:00:00 2001 From: n1rwana Date: Fri, 4 Aug 2023 01:07:36 +0300 Subject: [PATCH] Update WallPresenter.php --- Web/Presenters/WallPresenter.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Web/Presenters/WallPresenter.php b/Web/Presenters/WallPresenter.php index 28badd08..0e54ed39 100644 --- a/Web/Presenters/WallPresenter.php +++ b/Web/Presenters/WallPresenter.php @@ -300,6 +300,12 @@ final class WallPresenter extends OpenVKPresenter if (!$geo["lat"] || !$geo["lng"] || !$geo["name"]) { $this->flashFail("err", tr("error"), tr("error_geolocation")); } + + $latitude = (float) $geo["lat"]; + $longitude = (float) $geo["lng"]; + if ($latitude > 90 || $latitude < -90 || $longitude > 180 || $longitude < -180) { + $this->flashFail("err", tr("error"), "Invalid latitude or longitude"); + } } if(empty($this->postParam("text")) && !$photo && !$video && !$poll && !$note && !$geo) @@ -316,8 +322,8 @@ final class WallPresenter extends OpenVKPresenter $post->setNsfw($this->postParam("nsfw") === "on"); if ($geo) { $post->setGeo(json_encode($geo)); - $post->setGeo_Lat($geo["lat"]); - $post->setGeo_Lon($geo["lng"]); + $post->setGeo_Lat($latitude); + $post->setGeo_Lon($longitude); } $post->save(); } catch (\LengthException $ex) {