diff --git a/Web/Presenters/AboutPresenter.php b/Web/Presenters/AboutPresenter.php
index 6b21ca1a..8e493bc5 100644
--- a/Web/Presenters/AboutPresenter.php
+++ b/Web/Presenters/AboutPresenter.php
@@ -14,20 +14,14 @@ final class AboutPresenter extends OpenVKPresenter
function renderIndex(): void
{
if(!is_null($this->user)) {
- header("HTTP/1.1 302 Found");
-
if($this->user->identity->getMainPage())
- header("Location: /feed");
+ $this->redirect("/feed");
else
- header("Location: /id" . $this->user->id);
-
- exit;
+ $this->redirect($this->user->identity->getURL());
}
if($_SERVER['REQUEST_URI'] == "/id0") {
- header("HTTP/1.1 302 Found");
- header("Location: /");
- exit;
+ $this->redirect("/");
}
$this->template->stats = (new Users)->getStatistics();
@@ -127,16 +121,11 @@ final class AboutPresenter extends OpenVKPresenter
function renderHumansTxt(): void
{
# :D
-
- header("HTTP/1.1 302 Found");
- header("Location: https://github.com/openvk/openvk#readme");
- exit;
+ $this->redirect("https://github.com/openvk/openvk#readme");
}
function renderDev(): void
{
- header("HTTP/1.1 302 Found");
- header("Location: https://docs.openvk.su/");
- exit;
+ $this->redirect("https://docs.openvk.su/");
}
}
diff --git a/Web/Presenters/AdminPresenter.php b/Web/Presenters/AdminPresenter.php
index f35e1081..4a484a4d 100644
--- a/Web/Presenters/AdminPresenter.php
+++ b/Web/Presenters/AdminPresenter.php
@@ -170,8 +170,7 @@ final class AdminPresenter extends OpenVKPresenter
$voucher->save();
- $this->redirect("/admin/vouchers/id" . $voucher->getId(), static::REDIRECT_TEMPORARY);
- exit;
+ $this->redirect("/admin/vouchers/id" . $voucher->getId());
}
function renderGiftCategories(): void
@@ -193,7 +192,7 @@ final class AdminPresenter extends OpenVKPresenter
if(!$cat)
$this->notFound();
else if($cat->getSlug() !== $slug)
- $this->redirect("/admin/gifts/" . $cat->getSlug() . "." . $id . ".meta", static::REDIRECT_TEMPORARY);
+ $this->redirect("/admin/gifts/" . $cat->getSlug() . "." . $id . ".meta");
} else {
$gen = true;
$cat = new GiftCategory;
@@ -234,7 +233,7 @@ final class AdminPresenter extends OpenVKPresenter
$cat->setDescription($code, $this->postParam("description_$code"));
}
- $this->redirect("/admin/gifts/" . $cat->getSlug() . "." . $cat->getId() . ".meta", static::REDIRECT_TEMPORARY);
+ $this->redirect("/admin/gifts/" . $cat->getSlug() . "." . $cat->getId() . ".meta");
}
function renderGifts(string $catSlug, int $catId): void
@@ -245,7 +244,7 @@ final class AdminPresenter extends OpenVKPresenter
if(!$cat)
$this->notFound();
else if($cat->getSlug() !== $catSlug)
- $this->redirect("/admin/gifts/" . $cat->getSlug() . "." . $catId . "/", static::REDIRECT_TEMPORARY);
+ $this->redirect("/admin/gifts/" . $cat->getSlug() . "." . $catId . "/");
$this->template->cat = $cat;
$this->template->gifts = iterator_to_array($cat->getGifts((int) ($this->queryParam("p") ?? 1), NULL, $this->template->count));
@@ -284,7 +283,7 @@ final class AdminPresenter extends OpenVKPresenter
$name = $catTo->getName();
$this->flash("succ", "Gift moved successfully", "This gift will now be in $name.");
- $this->redirect("/admin/gifts/" . $catTo->getSlug() . "." . $catTo->getId() . "/", static::REDIRECT_TEMPORARY);
+ $this->redirect("/admin/gifts/" . $catTo->getSlug() . "." . $catTo->getId() . "/");
break;
default:
case "edit":
@@ -328,7 +327,7 @@ final class AdminPresenter extends OpenVKPresenter
$cat->addGift($gift);
}
- $this->redirect("/admin/gifts/id" . $gift->getId(), static::REDIRECT_TEMPORARY);
+ $this->redirect("/admin/gifts/id" . $gift->getId());
}
}
diff --git a/Web/Presenters/AuthPresenter.php b/Web/Presenters/AuthPresenter.php
index f3ed0d62..599efe8f 100644
--- a/Web/Presenters/AuthPresenter.php
+++ b/Web/Presenters/AuthPresenter.php
@@ -51,7 +51,7 @@ final class AuthPresenter extends OpenVKPresenter
function renderRegister(): void
{
if(!is_null($this->user))
- $this->redirect("/id" . $this->user->id, static::REDIRECT_TEMPORARY);
+ $this->redirect($this->user->identity->getURL());
if(!$this->hasPermission("user", "register", -1)) exit("Вас забанили");
@@ -129,7 +129,7 @@ final class AuthPresenter extends OpenVKPresenter
}
$this->authenticator->authenticate($chUser->getId());
- $this->redirect("/id" . $user->getId(), static::REDIRECT_TEMPORARY);
+ $this->redirect("/id" . $user->getId());
}
}
@@ -138,12 +138,11 @@ final class AuthPresenter extends OpenVKPresenter
$redirUrl = $this->requestParam("jReturnTo");
if(!is_null($this->user))
- $this->redirect($redirUrl ?? "/id" . $this->user->id, static::REDIRECT_TEMPORARY);
+ $this->redirect($redirUrl ?? $this->user->identity->getURL());
if(!$this->hasPermission("user", "login", -1)) exit("Вас забанили");
if($_SERVER["REQUEST_METHOD"] === "POST") {
-
$user = $this->db->table("ChandlerUsers")->where("login", $this->postParam("login"))->fetch();
if(!$user)
$this->flashFail("err", tr("login_failed"), tr("invalid_username_or_password"));
@@ -172,8 +171,7 @@ final class AuthPresenter extends OpenVKPresenter
}
$this->authenticator->authenticate($user->id);
- $this->redirect($redirUrl ?? "/id" . $user->related("profiles.user")->fetch()->id, static::REDIRECT_TEMPORARY);
- exit;
+ $this->redirect($redirUrl ?? $ovkUser->getURL());
}
}
@@ -184,7 +182,7 @@ final class AuthPresenter extends OpenVKPresenter
if($uuid === "unset") {
Session::i()->set("_su", NULL);
- $this->redirect("/", static::REDIRECT_TEMPORARY);
+ $this->redirect("/");
}
if(!$this->db->table("ChandlerUsers")->where("id", $uuid))
@@ -193,8 +191,7 @@ final class AuthPresenter extends OpenVKPresenter
$this->assertPermission('openvk\Web\Models\Entities\User', 'substitute', 0);
Session::i()->set("_su", $uuid);
$this->flash("succ", tr("profile_changed"), tr("profile_changed_comment"));
- $this->redirect("/", static::REDIRECT_TEMPORARY);
- exit;
+ $this->redirect("/");
}
function renderLogout(): void
@@ -204,7 +201,7 @@ final class AuthPresenter extends OpenVKPresenter
$this->authenticator->logout();
Session::i()->set("_su", NULL);
- $this->redirect("/", static::REDIRECT_TEMPORARY_PRESISTENT);
+ $this->redirect("/");
}
function renderFinishRestoringPassword(): void
@@ -244,7 +241,7 @@ final class AuthPresenter extends OpenVKPresenter
function renderRestore(): void
{
if(!is_null($this->user))
- $this->redirect("/id" . $this->user->id, static::REDIRECT_TEMPORARY);
+ $this->redirect($this->user->identity->getURL());
if(($this->queryParam("act") ?? "default") === "finish")
$this->pass("openvk!Auth->finishRestoringPassword");
@@ -274,7 +271,6 @@ final class AuthPresenter extends OpenVKPresenter
];
$this->sendmail($uRow->login, "password-reset", $params); #Vulnerability possible
-
$this->flashFail("succ", tr("information_-1"), tr("password_reset_email_sent"));
}
}
@@ -282,7 +278,7 @@ final class AuthPresenter extends OpenVKPresenter
function renderResendEmail(): void
{
if(!is_null($this->user) && $this->user->identity->isActivated())
- $this->redirect("/id" . $this->user->id, static::REDIRECT_TEMPORARY);
+ $this->redirect($this->user->identity->getURL());
if($_SERVER["REQUEST_METHOD"] === "POST") {
$user = $this->user->identity;
@@ -330,6 +326,6 @@ final class AuthPresenter extends OpenVKPresenter
$this->user->identity->reactivate();
- $this->redirect("/", 2);
+ $this->redirect("/");
}
}
diff --git a/Web/Presenters/CommentPresenter.php b/Web/Presenters/CommentPresenter.php
index 81783a2f..cbdac84e 100644
--- a/Web/Presenters/CommentPresenter.php
+++ b/Web/Presenters/CommentPresenter.php
@@ -24,7 +24,7 @@ final class CommentPresenter extends OpenVKPresenter
if(!is_null($this->user)) $comment->toggleLike($this->user->identity);
- $this->redirect($_SERVER["HTTP_REFERER"], static::REDIRECT_TEMPORARY);
+ $this->redirect($_SERVER["HTTP_REFERER"]);
}
function renderMakeComment(string $repo, int $eId): void
diff --git a/Web/Presenters/GiftsPresenter.php b/Web/Presenters/GiftsPresenter.php
index c4c7e9d8..b99e5ba9 100644
--- a/Web/Presenters/GiftsPresenter.php
+++ b/Web/Presenters/GiftsPresenter.php
@@ -91,7 +91,7 @@ final class GiftsPresenter extends OpenVKPresenter
$gift->used();
$this->flash("succ", "Подарок отправлен", "Вы отправили подарок " . $user->getFirstName() . " за " . $gift->getPrice() . " голосов.");
- $this->redirect($user->getURL(), static::REDIRECT_TEMPORARY);
+ $this->redirect($user->getURL());
}
function renderStub(): void
diff --git a/Web/Presenters/GroupPresenter.php b/Web/Presenters/GroupPresenter.php
index 7b551859..a83386db 100644
--- a/Web/Presenters/GroupPresenter.php
+++ b/Web/Presenters/GroupPresenter.php
@@ -54,8 +54,7 @@ final class GroupPresenter extends OpenVKPresenter
}
$club->toggleSubscription($this->user->identity);
- header("HTTP/1.1 302 Found");
- header("Location: /club" . $club->getId());
+ $this->redirect("/club" . $club->getId());
}else{
$this->flashFail("err", "Ошибка", "Вы не ввели название группы.");
}
@@ -74,9 +73,7 @@ final class GroupPresenter extends OpenVKPresenter
$club->toggleSubscription($this->user->identity);
- header("HTTP/1.1 302 Found");
- header("Location: /club" . $club->getId());
- exit;
+ $this->redirect($club->getURL());
}
function renderFollowers(int $id): void
diff --git a/Web/Presenters/OpenVKPresenter.php b/Web/Presenters/OpenVKPresenter.php
index 38f301f8..1cf1e86f 100755
--- a/Web/Presenters/OpenVKPresenter.php
+++ b/Web/Presenters/OpenVKPresenter.php
@@ -61,9 +61,7 @@ abstract class OpenVKPresenter extends SimplePresenter
$this->flash($type, $title, $message, $code);
$referer = $_SERVER["HTTP_REFERER"] ?? "/";
- header("HTTP/1.1 302 Found");
- header("Location: $referer");
- exit;
+ $this->redirect($referer);
}
}
@@ -99,9 +97,8 @@ abstract class OpenVKPresenter extends SimplePresenter
}
$this->flash("err", tr("login_required_error"), tr("login_required_error_comment"));
- header("HTTP/1.1 302 Found");
- header("Location: $loginUrl");
- exit;
+
+ $this->redirect($loginUrl);
}
}
@@ -111,9 +108,7 @@ abstract class OpenVKPresenter extends SimplePresenter
if($model !== "user") {
$this->flash("info", tr("login_required_error"), tr("login_required_error_comment"));
- header("HTTP/1.1 302 Found");
- header("Location: /login");
- exit;
+ $this->redirect("/login");
}
return ($action === "register" || $action === "login");
@@ -227,7 +222,7 @@ abstract class OpenVKPresenter extends SimplePresenter
Authenticator::i()->logout();
Session::i()->set("_su", NULL);
$this->flashFail("err", tr("error"), tr("profile_not_found"));
- $this->redirect("/", static::REDIRECT_TEMPORARY);
+ $this->redirect("/");
}
exit;
}
diff --git a/Web/Presenters/PhotosPresenter.php b/Web/Presenters/PhotosPresenter.php
index 3d4a136b..24b8bd7c 100644
--- a/Web/Presenters/PhotosPresenter.php
+++ b/Web/Presenters/PhotosPresenter.php
@@ -83,9 +83,9 @@ final class PhotosPresenter extends OpenVKPresenter
$album->save();
if(isset($club))
- $this->redirect("/album-" . $album->getOwner()->getId() . "_" . $album->getId(), static::REDIRECT_TEMPORARY);
+ $this->redirect("/album-" . $album->getOwner()->getId() . "_" . $album->getId());
else
- $this->redirect("/album" . $album->getOwner()->getId() . "_" . $album->getId(), static::REDIRECT_TEMPORARY);
+ $this->redirect("/album" . $album->getOwner()->getId() . "_" . $album->getId());
}
}
@@ -204,7 +204,7 @@ final class PhotosPresenter extends OpenVKPresenter
$photo->save();
$this->flash("succ", "Изменения сохранены", "Обновлённое описание появится на странице с фоткой.");
- $this->redirect("/photo" . $photo->getPrettyId(), static::REDIRECT_TEMPORARY);
+ $this->redirect("/photo" . $photo->getPrettyId());
}
$this->template->photo = $photo;
@@ -245,7 +245,7 @@ final class PhotosPresenter extends OpenVKPresenter
$album->setEdited(time());
$album->save();
- $this->redirect("/photo" . $photo->getPrettyId() . "?from=album" . $album->getId(), static::REDIRECT_TEMPORARY);
+ $this->redirect("/photo" . $photo->getPrettyId() . "?from=album" . $album->getId());
} else {
$this->template->album = $album;
}
@@ -270,7 +270,7 @@ final class PhotosPresenter extends OpenVKPresenter
$album->save();
$this->flash("succ", "Фотография удалена", "Эта фотография была успешно удалена.");
- $this->redirect("/album" . $album->getPrettyId(), static::REDIRECT_TEMPORARY);
+ $this->redirect("/album" . $album->getPrettyId());
}
}
@@ -289,6 +289,6 @@ final class PhotosPresenter extends OpenVKPresenter
$photo->delete();
$this->flash("succ", "Фотография удалена", "Эта фотография была успешно удалена.");
- $this->redirect("/id0", static::REDIRECT_TEMPORARY);
+ $this->redirect("/id0");
}
}
diff --git a/Web/Presenters/SupportPresenter.php b/Web/Presenters/SupportPresenter.php
index b9af87ac..105af4e6 100644
--- a/Web/Presenters/SupportPresenter.php
+++ b/Web/Presenters/SupportPresenter.php
@@ -100,8 +100,7 @@ final class SupportPresenter extends OpenVKPresenter
Telegram::send($helpdeskChat, $telegramText);
}
- header("HTTP/1.1 302 Found");
- header("Location: /support/view/" . $ticket->getId());
+ $this->redirect("/support/view/" . $ticket->getId());
} else {
$this->flashFail("err", tr("error"), tr("you_have_not_entered_name_or_text"));
}
@@ -192,8 +191,7 @@ final class SupportPresenter extends OpenVKPresenter
$comment->setCreated(time());
$comment->save();
- header("HTTP/1.1 302 Found");
- header("Location: /support/view/" . $id);
+ $this->redirect("/support/view/" . $id);
} else {
$this->flashFail("err", tr("error"), tr("you_have_not_entered_text"));
}
diff --git a/Web/Presenters/TopicsPresenter.php b/Web/Presenters/TopicsPresenter.php
index 16dd1795..6dd1ec6c 100644
--- a/Web/Presenters/TopicsPresenter.php
+++ b/Web/Presenters/TopicsPresenter.php
@@ -108,7 +108,7 @@ final class TopicsPresenter extends OpenVKPresenter
}
} catch(ISE $ex) {
$this->flash("err", "Не удалось опубликовать комментарий", "Файл медиаконтента повреждён или слишком велик.");
- $this->redirect("/topic" . $topic->getPrettyId(), static::REDIRECT_TEMPORARY);
+ $this->redirect("/topic" . $topic->getPrettyId());
}
if(!empty($this->postParam("text")) || $photo || $video) {
@@ -123,7 +123,7 @@ final class TopicsPresenter extends OpenVKPresenter
$comment->save();
} catch (\LengthException $ex) {
$this->flash("err", "Не удалось опубликовать комментарий", "Комментарий слишком большой.");
- $this->redirect("/topic" . $topic->getPrettyId(), static::REDIRECT_TEMPORARY);
+ $this->redirect("/topic" . $topic->getPrettyId());
}
if(!is_null($photo))
@@ -133,7 +133,7 @@ final class TopicsPresenter extends OpenVKPresenter
$comment->attach($video);
}
- $this->redirect("/topic" . $topic->getPrettyId(), static::REDIRECT_TEMPORARY);
+ $this->redirect("/topic" . $topic->getPrettyId());
}
$this->template->club = $club;
@@ -167,7 +167,7 @@ final class TopicsPresenter extends OpenVKPresenter
$topic->save();
$this->flash("succ", tr("changes_saved"), tr("topic_changes_saved_comment"));
- $this->redirect("/topic" . $topic->getPrettyId(), static::REDIRECT_TEMPORARY);
+ $this->redirect("/topic" . $topic->getPrettyId());
}
$this->template->topic = $topic;
@@ -189,6 +189,6 @@ final class TopicsPresenter extends OpenVKPresenter
$this->willExecuteWriteAction();
$topic->deleteTopic();
- $this->redirect("/board" . $topic->getClub()->getId(), static::REDIRECT_TEMPORARY);
+ $this->redirect("/board" . $topic->getClub()->getId());
}
}
diff --git a/Web/Presenters/UserPresenter.php b/Web/Presenters/UserPresenter.php
index 449763bb..186d5823 100644
--- a/Web/Presenters/UserPresenter.php
+++ b/Web/Presenters/UserPresenter.php
@@ -80,7 +80,7 @@ final class UserPresenter extends OpenVKPresenter
$name = $user->getFullName();
$this->flash("err", "Ошибка доступа", "Вы не можете просматривать полный список подписок $name.");
- $this->redirect("/id$id", static::REDIRECT_TEMPORARY_PRESISTENT);
+ $this->redirect($user->getURL());
}
}
}
@@ -281,7 +281,7 @@ final class UserPresenter extends OpenVKPresenter
$user->toggleSubscription($this->user->identity);
- $this->redirect("/id" . $user->getId());
+ $this->redirect($user->getURL());
}
function renderSetAvatar(): void
@@ -587,7 +587,7 @@ final class UserPresenter extends OpenVKPresenter
$this->user->identity->save();
}
- $this->redirect("/", static::REDIRECT_TEMPORARY_PRESISTENT);
+ $this->redirect("/");
}
function renderCoinsTransfer(): void
diff --git a/Web/Presenters/VideosPresenter.php b/Web/Presenters/VideosPresenter.php
index 0e20a91b..a0963f53 100644
--- a/Web/Presenters/VideosPresenter.php
+++ b/Web/Presenters/VideosPresenter.php
@@ -80,7 +80,7 @@ final class VideosPresenter extends OpenVKPresenter
$video->save();
- $this->redirect("/video" . $video->getPrettyId(), static::REDIRECT_TEMPORARY);
+ $this->redirect("/video" . $video->getPrettyId());
} else {
$this->flashFail("err", "Произошла ошибка", "Видео не может быть опубликовано без названия.");
}
@@ -104,7 +104,7 @@ final class VideosPresenter extends OpenVKPresenter
$video->save();
$this->flash("succ", "Изменения сохранены", "Обновлённое описание появится на странице с видосиком.");
- $this->redirect("/video" . $video->getPrettyId(), static::REDIRECT_TEMPORARY);
+ $this->redirect("/video" . $video->getPrettyId());
}
$this->template->video = $video;
@@ -128,7 +128,6 @@ final class VideosPresenter extends OpenVKPresenter
$this->flashFail("err", "Не удалось удалить пост", "Вы не вошли в аккаунт.");
}
- $this->redirect("/videos".$owner, static::REDIRECT_TEMPORARY);
- exit;
+ $this->redirect("/videos" . $owner);
}
}
diff --git a/Web/Presenters/WallPresenter.php b/Web/Presenters/WallPresenter.php
index 8d61f746..f8997cd7 100644
--- a/Web/Presenters/WallPresenter.php
+++ b/Web/Presenters/WallPresenter.php
@@ -294,11 +294,7 @@ final class WallPresenter extends OpenVKPresenter
if($wall > 0 && $wall !== $this->user->identity->getId())
(new WallPostNotification($wallOwner, $post, $this->user->identity))->emit();
- if($wall > 0)
- $this->redirect("/id$wall", 2); #Will exit
-
- $wall = $wall * -1;
- $this->redirect("/club$wall", 2);
+ $this->redirect($wallOwner->getURL());
}
function renderPost(int $wall, int $post_id): void
@@ -337,10 +333,7 @@ final class WallPresenter extends OpenVKPresenter
$post->toggleLike($this->user->identity);
}
- $this->redirect(
- "$_SERVER[HTTP_REFERER]#postGarter=" . $post->getId(),
- static::REDIRECT_TEMPORARY
- );
+ $this->redirect("$_SERVER[HTTP_REFERER]#postGarter=" . $post->getId());
}
function renderShare(int $wall, int $post_id): void
@@ -392,8 +385,7 @@ final class WallPresenter extends OpenVKPresenter
$this->flashFail("err", tr("failed_to_delete_post"), tr("login_required_error_comment"));
}
- $this->redirect($wall < 0 ? "/club".($wall*-1) : "/id".$wall, static::REDIRECT_TEMPORARY);
- exit;
+ $this->redirect($wall < 0 ? "/club" . ($wall*-1) : "/id" . $wall);
}
function renderPin(int $wall, int $post_id): void