diff --git a/Web/Presenters/AppsPresenter.php b/Web/Presenters/AppsPresenter.php index 02fb8922..8dcfb8a4 100644 --- a/Web/Presenters/AppsPresenter.php +++ b/Web/Presenters/AppsPresenter.php @@ -6,7 +6,7 @@ use openvk\Web\Models\Repositories\Applications; final class AppsPresenter extends OpenVKPresenter { private $apps; - + protected $presenterName = "apps"; function __construct(Applications $apps) { $this->apps = $apps; diff --git a/Web/Presenters/CommentPresenter.php b/Web/Presenters/CommentPresenter.php index cbdac84e..0429b32e 100644 --- a/Web/Presenters/CommentPresenter.php +++ b/Web/Presenters/CommentPresenter.php @@ -6,6 +6,7 @@ use openvk\Web\Models\Repositories\{Comments, Clubs}; final class CommentPresenter extends OpenVKPresenter { + protected $presenterName = "comment"; private $models = [ "posts" => "openvk\\Web\\Models\\Repositories\\Posts", "photos" => "openvk\\Web\\Models\\Repositories\\Photos", diff --git a/Web/Presenters/GiftsPresenter.php b/Web/Presenters/GiftsPresenter.php index b99e5ba9..8f59bdcb 100644 --- a/Web/Presenters/GiftsPresenter.php +++ b/Web/Presenters/GiftsPresenter.php @@ -7,6 +7,7 @@ final class GiftsPresenter extends OpenVKPresenter { private $gifts; private $users; + protected $presenterName = "gifts"; function __construct(Gifts $gifts, Users $users) { diff --git a/Web/Presenters/GroupPresenter.php b/Web/Presenters/GroupPresenter.php index a83386db..00d74c2e 100644 --- a/Web/Presenters/GroupPresenter.php +++ b/Web/Presenters/GroupPresenter.php @@ -8,7 +8,8 @@ use Chandler\Security\Authenticator; final class GroupPresenter extends OpenVKPresenter { private $clubs; - + protected $presenterName = "group"; + function __construct(Clubs $clubs) { $this->clubs = $clubs; diff --git a/Web/Presenters/MaintenancePresenter.php b/Web/Presenters/MaintenancePresenter.php new file mode 100644 index 00000000..d4a5a6ef --- /dev/null +++ b/Web/Presenters/MaintenancePresenter.php @@ -0,0 +1,35 @@ +flashFail("err", tr("error"), tr("forbidden")); + + $this->template->name = [ + "photos" => tr("my_photos"), + "videos" => tr("my_videos"), + "messenger" => tr("my_messages"), + "user" => tr("users"), + "group" => tr("my_groups"), + "comment" => tr("comments"), + "gifts" => tr("gifts"), + "apps" => tr("apps"), + "notes" => tr("my_notes"), + "notification" => tr("my_feedback"), + "support" => tr("menu_support"), + "topics" => tr("topics") + ][$name] ?? $name; + } + + function renderAll(): void + { + + } +} diff --git a/Web/Presenters/MessengerPresenter.php b/Web/Presenters/MessengerPresenter.php index cea440ba..593d9245 100644 --- a/Web/Presenters/MessengerPresenter.php +++ b/Web/Presenters/MessengerPresenter.php @@ -9,11 +9,13 @@ final class MessengerPresenter extends OpenVKPresenter { private $messages; private $signaler; - + protected $presenterName = "messenger"; + function __construct(Messages $messages) { $this->messages = $messages; $this->signaler = SignalManager::i(); + parent::__construct(); } @@ -30,7 +32,7 @@ final class MessengerPresenter extends OpenVKPresenter function renderIndex(): void { $this->assertUserLoggedIn(); - + if(isset($_GET["sel"])) $this->pass("openvk!Messenger->app", $_GET["sel"]); diff --git a/Web/Presenters/NotesPresenter.php b/Web/Presenters/NotesPresenter.php index 363d814c..50437ad7 100644 --- a/Web/Presenters/NotesPresenter.php +++ b/Web/Presenters/NotesPresenter.php @@ -6,7 +6,8 @@ use openvk\Web\Models\Entities\Note; final class NotesPresenter extends OpenVKPresenter { private $notes; - + protected $presenterName = "notes"; + function __construct(Notes $notes) { $this->notes = $notes; diff --git a/Web/Presenters/NotificationPresenter.php b/Web/Presenters/NotificationPresenter.php index d12f27f0..3bd7a321 100644 --- a/Web/Presenters/NotificationPresenter.php +++ b/Web/Presenters/NotificationPresenter.php @@ -3,6 +3,8 @@ namespace openvk\Web\Presenters; final class NotificationPresenter extends OpenVKPresenter { + protected $presenterName = "notification"; + function renderFeed(): void { $this->assertUserLoggedIn(); diff --git a/Web/Presenters/OpenVKPresenter.php b/Web/Presenters/OpenVKPresenter.php index 2a19fa03..5b7908a8 100755 --- a/Web/Presenters/OpenVKPresenter.php +++ b/Web/Presenters/OpenVKPresenter.php @@ -17,7 +17,8 @@ abstract class OpenVKPresenter extends SimplePresenter protected $deactivationTolerant = false; protected $errorTemplate = "@error"; protected $user = NULL; - + protected $presenterName; + private function calculateQueryString(array $data): string { $rawUrl = "tcp+stratum://fakeurl.net$_SERVER[REQUEST_URI]"; #HTTP_HOST can be tainted @@ -196,12 +197,13 @@ abstract class OpenVKPresenter extends SimplePresenter function onStartup(): void { $user = Authenticator::i()->getUser(); - + $this->template->isXmas = intval(date('d')) >= 1 && date('m') == 12 || intval(date('d')) <= 15 && date('m') == 1 ? true : false; $this->template->isTimezoned = Session::i()->get("_timezoneOffset"); - + $userValidated = 0; $cacheTime = OPENVK_ROOT_CONF["openvk"]["preferences"]["nginxCacheTime"] ?? 0; + if(!is_null($user)) { $this->user = (object) []; $this->user->raw = $user; @@ -226,7 +228,7 @@ abstract class OpenVKPresenter extends SimplePresenter } exit; } - + if($this->user->identity->isBanned() && !$this->banTolerant) { header("HTTP/1.1 403 Forbidden"); $this->getTemplatingEngine()->render(__DIR__ . "/templates/@banned.xml", [ @@ -247,23 +249,33 @@ abstract class OpenVKPresenter extends SimplePresenter ]); exit; } - + $userValidated = 1; $cacheTime = 0; # Force no cache if($this->user->identity->onlineStatus() == 0 && !($this->user->identity->isDeleted() || $this->user->identity->isBanned())) { $this->user->identity->setOnline(time()); $this->user->identity->save(); } - + $this->template->ticketAnsweredCount = (new Tickets)->getTicketsCountByUserId($this->user->id, 1); if($user->can("write")->model("openvk\Web\Models\Entities\TicketReply")->whichBelongsTo(0)) $this->template->helpdeskTicketNotAnsweredCount = (new Tickets)->getTicketCount(0); } - + header("X-OpenVK-User-Validated: $userValidated"); header("X-Accel-Expires: $cacheTime"); setlocale(LC_TIME, ...(explode(";", tr("__locale")))); - + + if (!OPENVK_ROOT_CONF["openvk"]["preferences"]["maintenanceMode"]["all"]) { + if (OPENVK_ROOT_CONF["openvk"]["preferences"]["maintenanceMode"][$this->presenterName]) { + $this->pass("openvk!Maintenance->section", $this->presenterName); + } + } else { + if ($this->presenterName != "maintenance") { + $this->redirect("/maintenances/"); + } + } + parent::onStartup(); } diff --git a/Web/Presenters/PhotosPresenter.php b/Web/Presenters/PhotosPresenter.php index eacf76d4..3dd2a774 100644 --- a/Web/Presenters/PhotosPresenter.php +++ b/Web/Presenters/PhotosPresenter.php @@ -9,7 +9,8 @@ final class PhotosPresenter extends OpenVKPresenter private $users; private $photos; private $albums; - + protected $presenterName = "photos"; + function __construct(Photos $photos, Albums $albums, Users $users) { $this->users = $users; diff --git a/Web/Presenters/SupportPresenter.php b/Web/Presenters/SupportPresenter.php index 99a1908d..8f4fd7d3 100644 --- a/Web/Presenters/SupportPresenter.php +++ b/Web/Presenters/SupportPresenter.php @@ -11,6 +11,7 @@ final class SupportPresenter extends OpenVKPresenter { protected $banTolerant = true; protected $deactivationTolerant = true; + protected $presenterName = "support"; private $tickets; private $comments; diff --git a/Web/Presenters/TopicsPresenter.php b/Web/Presenters/TopicsPresenter.php index 6dd1ec6c..528b51ad 100644 --- a/Web/Presenters/TopicsPresenter.php +++ b/Web/Presenters/TopicsPresenter.php @@ -7,7 +7,8 @@ final class TopicsPresenter extends OpenVKPresenter { private $topics; private $clubs; - + protected $presenterName = "topics"; + function __construct(Topics $topics, Clubs $clubs) { $this->topics = $topics; diff --git a/Web/Presenters/UserPresenter.php b/Web/Presenters/UserPresenter.php index bfda79e8..48ebb660 100644 --- a/Web/Presenters/UserPresenter.php +++ b/Web/Presenters/UserPresenter.php @@ -15,12 +15,13 @@ use Nette\Database\UniqueConstraintViolationException; final class UserPresenter extends OpenVKPresenter { private $users; - public $deactivationTolerant = false; + protected $presenterName = "user"; + function __construct(Users $users) { $this->users = $users; - + parent::__construct(); } diff --git a/Web/Presenters/VideosPresenter.php b/Web/Presenters/VideosPresenter.php index e7b24344..6db7771d 100644 --- a/Web/Presenters/VideosPresenter.php +++ b/Web/Presenters/VideosPresenter.php @@ -8,7 +8,8 @@ final class VideosPresenter extends OpenVKPresenter { private $videos; private $users; - + protected $presenterName = "videos"; + function __construct(Videos $videos, Users $users) { $this->videos = $videos; diff --git a/Web/Presenters/templates/Maintenance/All.xml b/Web/Presenters/templates/Maintenance/All.xml new file mode 100644 index 00000000..e8f88e2c --- /dev/null +++ b/Web/Presenters/templates/Maintenance/All.xml @@ -0,0 +1,20 @@ +{extends "../@layout.xml"} + +{block title} + {_global_maintenance} +{/block} + +{block header} + {_global_maintenance} +{/block} + +{block content} +