Skip to content

Commit

Permalink
Update WallPresenter.php
Browse files Browse the repository at this point in the history
  • Loading branch information
n1rwana committed Aug 3, 2023
1 parent 22ab724 commit 9269076
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Web/Presenters/WallPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ function renderMakePost(int $wall): void
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)
Expand All @@ -316,8 +322,8 @@ function renderMakePost(int $wall): void
$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) {
Expand Down

0 comments on commit 9269076

Please sign in to comment.