From 095b7960ca912551901b5316a3621a17fe7bd2ce Mon Sep 17 00:00:00 2001 From: Jill Stingray Date: Thu, 11 Jun 2020 12:54:20 +0300 Subject: [PATCH] Fix short addr collision --- Web/Models/Entities/Club.php | 6 ++++++ Web/Presenters/GroupPresenter.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Web/Models/Entities/Club.php b/Web/Models/Entities/Club.php index 7b5dbdfd..cad4eafb 100644 --- a/Web/Models/Entities/Club.php +++ b/Web/Models/Entities/Club.php @@ -137,6 +137,12 @@ class Club extends RowModel return false; if(in_array($code, OPENVK_ROOT_CONF["openvk"]["preferences"]["shortcodes"]["forbiddenNames"])) return false; + if(\Chandler\MVC\Routing\Router::i()->getMatchingRoute("/$code")[0]->presenter !== "UnknownTextRouteStrategy") + return false; + + $pUser = DB::i()->getContext()->table("profiles")->where("shortcode", $code)->fetch(); + if(!is_null($pUser)) + return false; } $this->stateChanges("shortcode", $code); diff --git a/Web/Presenters/GroupPresenter.php b/Web/Presenters/GroupPresenter.php index 6f2c0a43..d0d08c96 100644 --- a/Web/Presenters/GroupPresenter.php +++ b/Web/Presenters/GroupPresenter.php @@ -146,7 +146,7 @@ final class GroupPresenter extends OpenVKPresenter $club->setName(empty($this->postParam("name")) ? $club->getName() : $this->postParam("name")); $club->setAbout(empty($this->postParam("about")) ? NULL : $this->postParam("about")); $club->setShortcode(empty($this->postParam("shortcode")) ? NULL : $this->postParam("shortcode")); - $club->setWall(empty($this->postParam("wall")) ? 0 : 1); + $club->setWall(empty($this->postParam("wall")) ? 0 : 1); if($_FILES["ava"]["error"] === UPLOAD_ERR_OK) { $photo = new Photo;