From d64e54cd583e94859cedb6b63848fb3f575600c9 Mon Sep 17 00:00:00 2001 From: Maxim Leshchenko <50026114+maksalees@users.noreply.github.com> Date: Mon, 24 Jan 2022 16:58:42 +0200 Subject: [PATCH 01/23] Global: Fix code style in styles.css --- Web/static/css/style.css | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Web/static/css/style.css b/Web/static/css/style.css index 34745ba1..76225e14 100644 --- a/Web/static/css/style.css +++ b/Web/static/css/style.css @@ -214,7 +214,7 @@ a { } .page_yellowheader a { - color: #C8BF85; + color: #696029; } .page_content { @@ -1786,38 +1786,37 @@ body.scrolled .toTop:hover { .hover-box:hover { background-color: #C0CAD5; } + .summaryBar { border-bottom: 1px solid #DAE2E8; clear: both; - padding: 0 10px; - padding-top: 11px; - padding-top: 11px; + padding: 11px 10px; color: black; font-weight: normal; line-height: normal; margin-left: -12px; margin-right: -12px; } + .summaryBar .summary { color: #45688E; font-weight: bold; padding-top: 3px; padding-bottom: 4px; } + .note_header { background: #f7f7f7; border-bottom: solid 1px #DAE1E8; border-top: solid 1px #45688E; padding: 4px 6px 5px 6px; } + .note_header .note_title { color: #45688E; font-size: 13px; font-weight: bold; line-height: 15px; - margin: 0px; - padding: 0px 0px 1px 0px; + margin: 0; + padding: 0 0 1px 0; } -.page_yellowheader a { - color: #696029; -} \ No newline at end of file From e153c5c2f7a67a68bb9b6707e35d37fa5e5ea99b Mon Sep 17 00:00:00 2001 From: KosFurler Date: Mon, 24 Jan 2022 18:20:42 +0300 Subject: [PATCH 02/23] Albums: Upgrade style of album list --- Web/Presenters/templates/@listView.xml | 2 +- Web/Presenters/templates/Photos/AlbumList.xml | 6 ++---- Web/static/css/style.css | 10 +++++----- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Web/Presenters/templates/@listView.xml b/Web/Presenters/templates/@listView.xml index 35c9a2f0..3fd8f26f 100644 --- a/Web/Presenters/templates/@listView.xml +++ b/Web/Presenters/templates/@listView.xml @@ -11,7 +11,7 @@ {if sizeof($data) > 0}
- +
diff --git a/Web/Presenters/templates/Photos/AlbumList.xml b/Web/Presenters/templates/Photos/AlbumList.xml index 0c964e47..4c7510b2 100644 --- a/Web/Presenters/templates/Photos/AlbumList.xml +++ b/Web/Presenters/templates/Photos/AlbumList.xml @@ -28,11 +28,9 @@ {var cover = $x->getCoverPhoto()} {var preview = is_null($cover) ? "/assets/packages/static/openvk/img/camera_200.png" : $cover->getURL()} -
- {$x->getName()} + {$x->getName()} -
{/block} {block name} @@ -42,6 +40,6 @@ {block description} {$x->getDescription() ?? $x->getName()}
{$x->getPhotosCount()} фотографий
+ Обновлен {$x->getEditTime() ?? $x->getCreationTime()} Создан {$x->getCreationTime()}
- Изменён {$x->getEditTime() ?? $x->getCreationTime()} {/block} diff --git a/Web/static/css/style.css b/Web/static/css/style.css index 34745ba1..ca45261b 100644 --- a/Web/static/css/style.css +++ b/Web/static/css/style.css @@ -1581,11 +1581,10 @@ body.scrolled .toTop:hover { } .postFeedWrapper { - margin: -10px; - width: 611px; - padding: 4px 8px; - background-color: rgb(240, 240, 240); - border-bottom: 1px solid #ccc; + padding: 4px 8px; + background-color: rgb(240, 240, 240); + border-bottom: 1px solid #ccc; + border-top: 1px solid #ccc; } .user-alert { @@ -1803,6 +1802,7 @@ body.scrolled .toTop:hover { font-weight: bold; padding-top: 3px; padding-bottom: 4px; + display: inline-block; } .note_header { background: #f7f7f7; From 6e863134f27ae38afc8847baf01a2705fc11dde8 Mon Sep 17 00:00:00 2001 From: Maxim Leshchenko <50026114+maksalees@users.noreply.github.com> Date: Mon, 24 Jan 2022 17:55:43 +0200 Subject: [PATCH 03/23] Photos: Fix code style in AlbumList.xml --- Web/Presenters/templates/Photos/AlbumList.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Web/Presenters/templates/Photos/AlbumList.xml b/Web/Presenters/templates/Photos/AlbumList.xml index 4c7510b2..40e8b22d 100644 --- a/Web/Presenters/templates/Photos/AlbumList.xml +++ b/Web/Presenters/templates/Photos/AlbumList.xml @@ -38,8 +38,8 @@ {/block} {block description} - {$x->getDescription() ?? $x->getName()}
- {$x->getPhotosCount()} фотографий
- Обновлен {$x->getEditTime() ?? $x->getCreationTime()} - Создан {$x->getCreationTime()}
+ {$x->getDescription() ?? $x->getName()}
+ {$x->getPhotosCount()} фотографий
+ Обновлен {$x->getEditTime() ?? $x->getCreationTime()}
+ Создан {$x->getCreationTime()}
{/block} From 71186631f3cc80726e8f6e915657f3d0635607c3 Mon Sep 17 00:00:00 2001 From: Maxim Leshchenko Date: Tue, 25 Jan 2022 00:21:58 +0200 Subject: [PATCH 04/23] Global: Fix lists display and CSS formatting fixes --- Web/Presenters/templates/@listView.xml | 2 +- Web/Presenters/templates/Photos/AlbumList.xml | 6 +- Web/static/css/style.css | 60 +++++++++---------- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Web/Presenters/templates/@listView.xml b/Web/Presenters/templates/@listView.xml index 3fd8f26f..35c9a2f0 100644 --- a/Web/Presenters/templates/@listView.xml +++ b/Web/Presenters/templates/@listView.xml @@ -11,7 +11,7 @@ {if sizeof($data) > 0}
- +
diff --git a/Web/Presenters/templates/Photos/AlbumList.xml b/Web/Presenters/templates/Photos/AlbumList.xml index 40e8b22d..7db097d0 100644 --- a/Web/Presenters/templates/Photos/AlbumList.xml +++ b/Web/Presenters/templates/Photos/AlbumList.xml @@ -28,9 +28,9 @@ {var cover = $x->getCoverPhoto()} {var preview = is_null($cover) ? "/assets/packages/static/openvk/img/camera_200.png" : $cover->getURL()} - - {$x->getName()} - + + {$x->getName()} + {/block} {block name} diff --git a/Web/static/css/style.css b/Web/static/css/style.css index add49c26..ff04619b 100644 --- a/Web/static/css/style.css +++ b/Web/static/css/style.css @@ -794,9 +794,9 @@ table.User { } .tabs { - border-bottom: 1px solid #707070; - margin-right: -12px; - margin-left: -12px; + border-bottom: 1px solid #707070; + margin-right: -12px; + margin-left: -12px; } #activetabs { @@ -1581,10 +1581,10 @@ body.scrolled .toTop:hover { } .postFeedWrapper { - padding: 4px 8px; - background-color: rgb(240, 240, 240); - border-bottom: 1px solid #ccc; - border-top: 1px solid #ccc; + padding: 4px 8px; + background-color: rgb(240, 240, 240); + border-bottom: 1px solid #ccc; + border-top: 1px solid #ccc; } .user-alert { @@ -1787,36 +1787,36 @@ body.scrolled .toTop:hover { } .summaryBar { - border-bottom: 1px solid #DAE2E8; - clear: both; - padding: 11px 10px; - color: black; - font-weight: normal; - line-height: normal; - margin-left: -12px; - margin-right: -12px; + border-bottom: 1px solid #DAE2E8; + clear: both; + padding: 11px 10px; + color: black; + font-weight: normal; + line-height: normal; + margin-left: -12px; + margin-right: -12px; } .summaryBar .summary { - color: #45688E; - font-weight: bold; - padding-top: 3px; - padding-bottom: 4px; - display: inline-block; + color: #45688E; + font-weight: bold; + padding-top: 3px; + padding-bottom: 4px; + display: inline-block; } .note_header { - background: #f7f7f7; - border-bottom: solid 1px #DAE1E8; - border-top: solid 1px #45688E; - padding: 4px 6px 5px 6px; + background: #f7f7f7; + border-bottom: solid 1px #DAE1E8; + border-top: solid 1px #45688E; + padding: 4px 6px 5px 6px; } .note_header .note_title { - color: #45688E; - font-size: 13px; - font-weight: bold; - line-height: 15px; - margin: 0; - padding: 0 0 1px 0; + color: #45688E; + font-size: 13px; + font-weight: bold; + line-height: 15px; + margin: 0; + padding: 0 0 1px 0; } From eca0f057ca09179023eb4322a0704a5513ab89ff Mon Sep 17 00:00:00 2001 From: Maxim Leshchenko Date: Tue, 25 Jan 2022 14:22:33 +0200 Subject: [PATCH 05/23] About: Hide list of most popular groups if there are no groups --- Web/Presenters/AboutPresenter.php | 2 +- .../templates/About/AboutInstance.xml | 20 ++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Web/Presenters/AboutPresenter.php b/Web/Presenters/AboutPresenter.php index f7131772..bd84efbc 100644 --- a/Web/Presenters/AboutPresenter.php +++ b/Web/Presenters/AboutPresenter.php @@ -63,7 +63,7 @@ final class AboutPresenter extends OpenVKPresenter $this->template->usersStats = (new Users)->getStatistics(); $this->template->clubsCount = (new Clubs)->getCount(); $this->template->postsCount = (new Posts)->getCount(); - $this->template->popularClubs = (new Clubs)->getPopularClubs(); + $this->template->popularClubs = iterator_to_array((new Clubs)->getPopularClubs()); $this->template->admins = iterator_to_array((new Users)->getInstanceAdmins()); } diff --git a/Web/Presenters/templates/About/AboutInstance.xml b/Web/Presenters/templates/About/AboutInstance.xml index 61bd9d2f..af63d9ee 100644 --- a/Web/Presenters/templates/About/AboutInstance.xml +++ b/Web/Presenters/templates/About/AboutInstance.xml @@ -42,15 +42,17 @@
-

{_most_popular_groups}

-
    -
  1. - {$entry->club->getName()} -
    - {tr("participants", $entry->subscriptions)} -
    -
  2. -
+ {if sizeof($popularClubs) !== 0} +

{_most_popular_groups}

+
    +
  1. + {$entry->club->getName()} +
    + {tr("participants", $entry->subscriptions)} +
    +
  2. +
+ {/if}

{_rules}

From 11cd1234362132c8ad599162e097ba2899821444 Mon Sep 17 00:00:00 2001 From: Maxim Leshchenko <50026114+maksalees@users.noreply.github.com> Date: Tue, 25 Jan 2022 17:25:49 +0200 Subject: [PATCH 06/23] Discussions: Fix the checkbox "Everyone can create topics" This line was accidentally removed in one of the commits. I return it back. --- Web/Presenters/GroupPresenter.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Web/Presenters/GroupPresenter.php b/Web/Presenters/GroupPresenter.php index 4ad9f849..65d3640f 100644 --- a/Web/Presenters/GroupPresenter.php +++ b/Web/Presenters/GroupPresenter.php @@ -207,6 +207,7 @@ final class GroupPresenter extends OpenVKPresenter $club->setShortcode(empty($this->postParam("shortcode")) ? NULL : $this->postParam("shortcode")); $club->setWall(empty($this->postParam("wall")) ? 0 : 1); $club->setAdministrators_List_Display(empty($this->postParam("administrators_list_display")) ? 0 : $this->postParam("administrators_list_display")); + $club->setEveryone_Can_Create_Topics(empty($this->postParam("everyone_can_create_topics")) ? 0 : 1); $club->setDisplay_Topics_Above_Wall(empty($this->postParam("display_topics_above_wall")) ? 0 : 1); $club->setHide_From_Global_Feed(empty($this->postParam("hide_from_global_feed")) ? 0 : 1); From 954b9f350dd1051eb2ae990194c3f35b62e1477e Mon Sep 17 00:00:00 2001 From: KosFurler Date: Tue, 25 Jan 2022 22:26:19 +0300 Subject: [PATCH 07/23] Notes: Update layout (beta) --- Web/Presenters/templates/Notes/View.xml | 18 ++++++++++-------- Web/static/css/style.css | 9 +++++++++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Web/Presenters/templates/Notes/View.xml b/Web/Presenters/templates/Notes/View.xml index dd1e8348..e9858c64 100644 --- a/Web/Presenters/templates/Notes/View.xml +++ b/Web/Presenters/templates/Notes/View.xml @@ -35,7 +35,7 @@ } -
+ + +
@@ -60,11 +68,5 @@ model => "notes", parent => $note}
-
-

{_actions}

-
- {_delete} -
-
{/block} diff --git a/Web/static/css/style.css b/Web/static/css/style.css index add49c26..7fe91ff0 100644 --- a/Web/static/css/style.css +++ b/Web/static/css/style.css @@ -1820,3 +1820,12 @@ body.scrolled .toTop:hover { margin: 0; padding: 0 0 1px 0; } +.note_footer { + border-top: 1px solid #ddd; + clear: both; + margin-top: 10px; + padding: 0px 2px 0px 6px; +} +.comments_count { + padding: 5px 0px 0px 0px; +} \ No newline at end of file From 287b2a29aab9d19b0cc01de4f0ec6d2a22d57e14 Mon Sep 17 00:00:00 2001 From: KosFurler Date: Tue, 25 Jan 2022 23:52:23 +0300 Subject: [PATCH 08/23] Notes: Update layot --- Web/Presenters/templates/Notes/View.xml | 14 ++++++++------ Web/static/css/style.css | 12 +++++++----- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Web/Presenters/templates/Notes/View.xml b/Web/Presenters/templates/Notes/View.xml index e9858c64..5d1eb5ab 100644 --- a/Web/Presenters/templates/Notes/View.xml +++ b/Web/Presenters/templates/Notes/View.xml @@ -51,16 +51,19 @@
- diff --git a/Web/routes.yml b/Web/routes.yml index e22f938e..7bd01965 100644 --- a/Web/routes.yml +++ b/Web/routes.yml @@ -223,6 +223,8 @@ routes: handler: "Notes->view" - url: "/notes/create" handler: "Notes->create" + - url: "/note{num}_{num}/edit" + handler: "Notes->edit" - url: "/note{num}_{num}/delete" handler: "Notes->delete" - url: "/invite" diff --git a/locales/en.strings b/locales/en.strings index 0f4d8fc7..ee2e9081 100644 --- a/locales/en.strings +++ b/locales/en.strings @@ -295,8 +295,11 @@ "name_note" = "Title"; "text_note" = "Content"; "create_note" = "Create note"; +"edit_note" = "Edit note"; "actions" = "Actions"; +"edited" = "Edited"; + "notes_zero" = "No notes"; "notes_one" = "$1 note"; "notes_other" = "$1 notes"; diff --git a/locales/ru.strings b/locales/ru.strings index 64f66185..bee9b7cc 100644 --- a/locales/ru.strings +++ b/locales/ru.strings @@ -313,8 +313,11 @@ "name_note" = "Название"; "text_note" = "Содержание"; "create_note" = "Создать заметку"; +"edit_note" = "Редактировать заметку"; "actions" = "Действия"; +"edited" = "Отредактировано"; + "notes_zero" = "Ни одной заметки"; "notes_one" = "Одна заметка"; "notes_few" = "$1 заметки"; From 22157c7fa30d7a7779c536929d91affd864044e3 Mon Sep 17 00:00:00 2001 From: Ilya Prokopenko Date: Thu, 27 Jan 2022 14:01:27 +0300 Subject: [PATCH 14/23] [SECURITY] Deny login to a deleted account --- Web/Presenters/AuthPresenter.php | 7 +++++-- Web/Presenters/OpenVKPresenter.php | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Web/Presenters/AuthPresenter.php b/Web/Presenters/AuthPresenter.php index 0d43315b..9123f12a 100644 --- a/Web/Presenters/AuthPresenter.php +++ b/Web/Presenters/AuthPresenter.php @@ -126,6 +126,10 @@ final class AuthPresenter extends OpenVKPresenter if(!$this->authenticator->verifyCredentials($user->id, $this->postParam("password"))) $this->flashFail("err", tr("login_failed"), tr("invalid_username_or_password")); + $ovkUser = new User($user->related("profiles.user")->fetch()); + if($ovkUser->isDeleted()) + $this->flashFail("err", tr("login_failed"), tr("invalid_username_or_password")); + $secret = $user->related("profiles.user")->fetch()["2fa_secret"]; $code = $this->postParam("code"); if(!is_null($secret)) { @@ -136,7 +140,6 @@ final class AuthPresenter extends OpenVKPresenter if(is_null($code)) return; - $ovkUser = new User($user->related("profiles.user")->fetch()); if(!($code === (new Totp)->GenerateToken(Base32::decode($secret)) || $ovkUser->use2faBackupCode((int) $code))) { $this->flash("err", tr("login_failed"), tr("incorrect_2fa_code")); return; @@ -229,7 +232,7 @@ final class AuthPresenter extends OpenVKPresenter } $user = $this->users->getByChandlerUser(new ChandlerUser($uRow)); - if(!$user) + if(!$user || $user->isDeleted()) $this->flashFail("err", tr("error"), tr("password_reset_error")); $request = $this->restores->getLatestByUser($user); diff --git a/Web/Presenters/OpenVKPresenter.php b/Web/Presenters/OpenVKPresenter.php index c232cd91..1aee16d2 100755 --- a/Web/Presenters/OpenVKPresenter.php +++ b/Web/Presenters/OpenVKPresenter.php @@ -210,6 +210,13 @@ abstract class OpenVKPresenter extends SimplePresenter $this->user->id = $this->user->identity->getId(); $this->template->thisUser = $this->user->identity; $this->template->userTainted = $user->isTainted(); + + if($this->user->identity->isDeleted()) { + Authenticator::i()->logout(); + Session::i()->set("_su", NULL); + $this->flashFail("err", tr("error"), tr("profile_not_found")); + $this->redirect("/", static::REDIRECT_TEMPORARY); + } if($this->user->identity->isBanned() && !$this->banTolerant) { header("HTTP/1.1 403 Forbidden"); From 3796135c2f5a3a2812ef369620f1b7be08e0cfd4 Mon Sep 17 00:00:00 2001 From: Ilya Prokopenko Date: Thu, 27 Jan 2022 14:46:28 +0300 Subject: [PATCH 15/23] Search: Filter out deleted accounts --- Web/Models/Repositories/Users.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Web/Models/Repositories/Users.php b/Web/Models/Repositories/Users.php index e99611b2..e0893a6d 100644 --- a/Web/Models/Repositories/Users.php +++ b/Web/Models/Repositories/Users.php @@ -39,7 +39,7 @@ class Users function find(string $query): Util\EntityStream { $query = "%$query%"; - $result = $this->users->where("CONCAT_WS(' ', first_name, last_name) LIKE ?", $query); + $result = $this->users->where("CONCAT_WS(' ', first_name, last_name) LIKE ?", $query)->where("deleted", 0); return new Util\EntityStream("User", $result); } From 518a52971dadf9f855caa52ebbd68f8edb00e359 Mon Sep 17 00:00:00 2001 From: WerySkok <15957616+WerySkok@users.noreply.github.com> Date: Thu, 27 Jan 2022 21:18:45 +0300 Subject: [PATCH 16/23] Docs: Move docs away from the repo We now have docs.openvk.su for hosting documentation. --- docs/centos8_install.md | 357 ---------------------------------------- 1 file changed, 357 deletions(-) delete mode 100644 docs/centos8_install.md diff --git a/docs/centos8_install.md b/docs/centos8_install.md deleted file mode 100644 index f29ebc67..00000000 --- a/docs/centos8_install.md +++ /dev/null @@ -1,357 +0,0 @@ -# Installing OpenVK - -Based on [@rem-pai](https://github.com/rem-pai)'s way to install OpenVK modified using my experience. - -!!WARNING!! - -CentOS 8 is reaching it's end-of-life soon. There are other supported similar distributions like Rocky Linux or AlmaLinux. - -## SELinux - -🖥Run the command: - -```bash -sestatus -``` - -If it says `SELinux status: enabled` then SELinux will disturb us. Let's disable it. - -_ℹNote: I know that it's not most secured solution but I don't know any proper way that will work._ - -📝Edit file `/etc/sysconfig/selinux` and change the line `SELinux=enforcing` to `SELinux=disabled`, then 🔌reboot your machine. `sestatus` should tell `SELinux status: disabled` right now. - -## Dependencies - -🖥Let's install EPEL and Remi repos for PHP 7.4: - -```bash -dnf -y install epel-release -dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm -``` - -🖥Then enable modules that we need: - -```bash -dnf -y module enable php:remi-7.4 -dnf -y module enable nodejs:14 -``` - -🖥And install dependencies: - -```bash -dnf -y install php php-cli php-common unzip php-zip php-yaml php-gd php-pdo_mysql nodejs git -``` - -🖥Don't forget about Yarn and Composer: - -```bash -npm i -g yarn -php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" -php composer-setup.php --filename=composer2 --install-dir=/bin --snapshot -rm composer-setup.php -``` - -### Database - -🖥We will use Percona Server for DB: - -```bash -dnf -y install https://repo.percona.com/yum/percona-release-latest.noarch.rpm -percona-release setup -y ps80 -dnf -y install percona-server-server percona-toolkit -systemctl start mysql -``` - -🖥And then look up for temporary password: - -```bash -cat /var/log/mysqld.log | grep password -``` - -It should look like this: - - 2021-01-11T12:56:09.203991Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: >b?Q.fDXJ4fk - -🖥Then run `mysql_secure_installation`, set new password and answer like this: - - Change the password for root ? ((Press y|Y for Yes, any other key for No) : n - Remove anonymous users? (Press y|Y for Yes, any other key for No) : y - Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y - Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y - Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y - -### ffmpeg - -Additionally, you can install ffmpeg for processing videos. - -🖥You will need to use RPMFusion repo to install it: - -```bash -dnf -y localinstall --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-8.noarch.rpm -dnf -y install --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-8.noarch.rpm -``` - -🖥Then install SDL2 and ffmpeg: - -```bash -dnf -y install http://rpmfind.net/linux/epel/7/x86_64/Packages/s/SDL2-2.0.10-1.el7.x86_64.rpm -dnf -y install ffmpeg -``` - -## Chandler and OpenVK installation - -🖥Install Chandler in `/opt`: - -```bash -cd /opt -git clone https://github.com/openvk/chandler.git -cd chandler/ -composer2 install -``` - -🖥You will need a secret key. You can generate it using: - -```bash -cat /dev/random | tr -dc 'a-z0-9' | fold -w 128 | head -n 1 -``` - -📝Now edit config file `chandler-example.yml` like this: - -```yaml -chandler: - debug: true - websiteUrl: null - rootApp: "openvk" - - preferences: - appendExtension: "xhtml" - adminUrl: "/chandlerd" - exposeChandler: true - - database: - dsn: "mysql:unix_socket=/var/lib/mysql/mysql.sock;dbname=db" - user: "root" - password: "DATABASE_PASSWORD" - - security: - secret: "SECRET_KEY_HERE" - csrfProtection: "permissive" - sessionDuration: 14 -``` - -🖥And rename it to `chandler.yml`: - -```bash -mv chandler-example.yml chandler.yml -``` - -🖥Now let's install CommitCaptcha extension. It is mandatory for OpenVK. - -```bash -cd extensions/available/ -git clone https://github.com/openvk/commitcaptcha.git -cd commitcaptcha/ -composer2 install -``` - -🖥And now download OpenVK: - -```bash -cd .. -git clone https://github.com/openvk/openvk.git -cd openvk/ -composer2 install -cd Web/static/js -yarn install -``` - -📝Now edit config file `openvk-example.yml` like this: - -```yaml -openvk: - debug: true - appearance: - name: "OpenVK" - motd: "Yet another OpenVK instance" - preferences: - femaleGenderPriority: true - uploads: - disableLargeUploads: false - mode: "basic" - shortcodes: - forbiddenNames: - - "index.php" - security: - requireEmail: false - requirePhone: false - forcePhoneVerification: false - forceEmailVerification: false - enableSu: true - rateLimits: - actions: 5 - time: 20 - maxViolations: 50 - maxViolationsAge: 120 - autoban: true - support: - supportName: "Moderator" - adminAccount: 1 # Change this ok - messages: - strict: false - wall: - postSizes: - maxSize: 60000 - processingLimit: 3000 - emojiProcessingLimit: 1000 - menu: - links: - - adPoster: - enable: false - src: "https://example.org/ad_poster.jpeg" - caption: "Ad caption" - link: "https://example.org/product.aspx?id=10&from=ovk" - bellsAndWhistles: - fartscroll: false - testLabel: false - credentials: - smsc: - enable: false - client: "" - secret: "" - eventDB: - enable: true # Better enable this - database: - dsn: "mysql:unix_socket=/var/lib/mysql/mysql.sock;dbname=openvk_eventdb" - user: "root" - password: "DATABASE_PASSWORD" -``` - -Please note `eventDB` section because it's better to enable event database. - -🖥And rename it to `openvk.yml`: - -```bash -mv openvk-example.yml openvk.yml -``` - -🖥Then enable CommitCaptcha and OpenVK for Chandler: - -```bash -ln -s /opt/chandler/extensions/available/commitcaptcha/ /opt/chandler/extensions/enabled/commitcaptcha -ln -s /opt/chandler/extensions/available/openvk/ /opt/chandler/extensions/enabled/openvk -``` - -### DB configuration - -_ℹNote: it's better to create another user for SQL but I won't cover that._ - -🖥Enter MySQL shell: - -```bash -mysql -p -``` - -🖥And create main and event databases: - -```sql -CREATE DATABASE openvk; -CREATE DATABASE openvk_eventdb; -exit -``` - -🖥Go to `/opt/chandler`: - -```bash -cd /opt/chandler -``` - -📝We need to import Chandler database but for some reason it's not ready for use so we need to edit dump `install/init-db.sql`: -1\. Remove ` PAGE_CHECKSUM=1` everywhere. -2\. Replace `Aria` with `InnoDB` everywhere. - -🖥Now database dump can be imported: - -```bash -mysql -p'DATABASE_PASSWORD' openvk < install/init-db.sql -``` - -🖥Go to `extensions/available/openvk/`: - -```bash -cd extensions/available/openvk/ -``` - -📝We also need to import OpenVK database. Unless you use MariaDB (we are using Percona here) you should edit `install/init-static-db.sql`: -1\. Replace `utf8mb4_unicode_nopad_ci` with `utf8mb4_unicode_520_ci` everywhere. - -🖥Now database dump can be imported: - -```bash -mysql -p'DATABASE_PASSWORD' openvk < install/init-static-db.sql -``` - -🖥Also import event database: - -```bash -mysql -p'DATABASE_PASSWORD' openvk_eventdb < install/init-event-db.sql -``` - -### Webserver configuration - -Apache is already installed so we will use it. - -🖥Make the user `apache` owner of the `chandler` folder: - -```bash -cd /opt -chown -R apache: chandler/ -``` - -📝Now let's create config file `/etc/httpd/conf.d/10-openvk.conf`: - -```apache - - ServerName openvk.local - DocumentRoot /opt/chandler/htdocs - - - AllowOverride All - - Require all granted - - - ErrorLog /var/log/openvk/error.log - CustomLog /var/log/openvk/access.log combinedio - -``` - -📝Also enable rewrite_module by creating `/etc/httpd/conf.modules.d/02-rewrite.conf`: - -```apache -LoadModule rewrite_module modules/mod_rewrite.so -``` - -🖥Make directory for OpenVK logs and make the user `apache` owner of it: - -```bash -mkdir /var/log/openvk -chown apache: /var/log/openvk/ -``` - -🖥Make the firewall exception for port 80: - -```bash -firewall-cmd --permanent --add-port=80/tcp -firewall-cmd --reload -``` - -🖥And start Apache: - -```bash -systemctl start httpd -``` - -OpenVK should work right now! - -Also you can raise 2MB the file limit through editing `/etc/php.ini`. And it's also better to install PHPMyAdmin but I won't cover that. From 2c31a72774d9c2adafa62f5bd841d4300758ddaf Mon Sep 17 00:00:00 2001 From: WerySkok <15957616+WerySkok@users.noreply.github.com> Date: Thu, 27 Jan 2022 21:24:42 +0300 Subject: [PATCH 17/23] Locales: Fix README --- locales/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locales/README.md b/locales/README.md index 84bb344a..1d156ee7 100644 --- a/locales/README.md +++ b/locales/README.md @@ -1,5 +1,5 @@ # Locales for OpenVK -So, there is a locales contained here for [OpenVK](../../../openvk). +So, there is a locales contained here for [OpenVK](../../openvk). ## Contributing From e35b4dc70ee10f9338ee2ba6579c050ca4c7824a Mon Sep 17 00:00:00 2001 From: WerySkok <15957616+WerySkok@users.noreply.github.com> Date: Thu, 27 Jan 2022 21:28:23 +0300 Subject: [PATCH 18/23] Locales: hotfix previous commit --- locales/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locales/README.md b/locales/README.md index 1d156ee7..1a1c94e0 100644 --- a/locales/README.md +++ b/locales/README.md @@ -1,5 +1,5 @@ # Locales for OpenVK -So, there is a locales contained here for [OpenVK](../../openvk). +So, there is a locales contained here for [OpenVK](../../../). ## Contributing From 67c61bf7a18a99975d70c15eec5ae9873e321b45 Mon Sep 17 00:00:00 2001 From: Maxim Leshchenko Date: Fri, 28 Jan 2022 15:34:13 +0200 Subject: [PATCH 19/23] Support: Add ability to delete comments in a ticket There used to be a button for this, but it didn't work. It works now --- Web/Models/Entities/TicketComment.php | 5 ++++ Web/Models/Repositories/TicketComments.php | 3 +-- Web/Presenters/SupportPresenter.php | 23 +++++++++++++++++++ .../templates/Support/AnswerTicket.xml | 8 +++---- Web/Presenters/templates/Support/View.xml | 2 +- Web/routes.yml | 2 ++ 6 files changed, 35 insertions(+), 8 deletions(-) diff --git a/Web/Models/Entities/TicketComment.php b/Web/Models/Entities/TicketComment.php index 0801c39f..a9fb684a 100644 --- a/Web/Models/Entities/TicketComment.php +++ b/Web/Models/Entities/TicketComment.php @@ -127,5 +127,10 @@ class TicketComment extends RowModel return $mark === 1; } + function isDeleted(): bool + { + return (bool) $this->getRecord()->deleted; + } + use Traits\TRichText; } diff --git a/Web/Models/Repositories/TicketComments.php b/Web/Models/Repositories/TicketComments.php index 94360aec..4d3c5316 100644 --- a/Web/Models/Repositories/TicketComments.php +++ b/Web/Models/Repositories/TicketComments.php @@ -4,7 +4,6 @@ namespace openvk\Web\Models\Repositories; // use openvk\Web\Models\Entities\User; // use openvk\Web\Models\Repositories\Users; use openvk\Web\Models\Entities\TicketComment; -use Nette\Database\Table\ActiveRow; use Chandler\Database\DatabaseConnection; class TicketComments @@ -20,7 +19,7 @@ class TicketComments function getCommentsById(int $ticket_id): \Traversable { - foreach($this->comments->where(['ticket_id' => $ticket_id]) as $comment) yield new TicketComment($comment); + foreach($this->comments->where(['ticket_id' => $ticket_id, 'deleted' => 0]) as $comment) yield new TicketComment($comment); } // private function toTicket(?ActiveRow $ar): ?Ticket diff --git a/Web/Presenters/SupportPresenter.php b/Web/Presenters/SupportPresenter.php index 8a48a0db..a96ac465 100644 --- a/Web/Presenters/SupportPresenter.php +++ b/Web/Presenters/SupportPresenter.php @@ -226,6 +226,29 @@ final class SupportPresenter extends OpenVKPresenter $this->template->content = $parser->text($content); } + function renderDeleteComment(int $id): void + { + $this->assertUserLoggedIn(); + $this->assertNoCSRF(); + + $comment = $this->comments->get($id); + if(is_null($comment)) + $this->notFound(); + + $ticket = $comment->getTicket(); + + if($ticket->isDeleted()) + $this->notFound(); + + if(!($ticket->getUserId() === $this->user->id && $comment->getUType() === 0)) + $this->assertPermission("openvk\Web\Models\Entities\TicketReply", "write", 0); + + $this->willExecuteWriteAction(); + $comment->delete(); + + $this->flashFail("succ", tr("ticket_changed"), tr("ticket_changed_comment")); + } + function renderRateAnswer(int $id, int $mark): void { $this->willExecuteWriteAction(); diff --git a/Web/Presenters/templates/Support/AnswerTicket.xml b/Web/Presenters/templates/Support/AnswerTicket.xml index c8fea4d7..a35ad6a6 100644 --- a/Web/Presenters/templates/Support/AnswerTicket.xml +++ b/Web/Presenters/templates/Support/AnswerTicket.xml @@ -101,11 +101,9 @@ {/if}
- {if $comment->getUType() === 0} -
- {_delete} -
- {/if} +
+ {_delete} +
{if $comment->getUType() === 1 && !is_null($comment->isLikedByUser())}
diff --git a/Web/Presenters/templates/Support/View.xml b/Web/Presenters/templates/Support/View.xml index 8f502fc3..4ef1ce2b 100644 --- a/Web/Presenters/templates/Support/View.xml +++ b/Web/Presenters/templates/Support/View.xml @@ -103,7 +103,7 @@ {if $comment->getUType() === 0}
- {_delete} + {_delete}
{/if} diff --git a/Web/routes.yml b/Web/routes.yml index 7bd01965..9fc08750 100644 --- a/Web/routes.yml +++ b/Web/routes.yml @@ -25,6 +25,8 @@ routes: handler: "Support->makeComment" - url: "/al_comments/create/support/reply/{num}" handler: "Support->AnswerTicketReply" + - url: "/support/comment/{num}/delete" + handler: "Support->deleteComment" - url: "/al_comments/create/{text}/{num}" handler: "Comment->makeComment" - url: "/support/delete/{num}" From f53058d40bdf3622e13433b644beaf066bea8cfb Mon Sep 17 00:00:00 2001 From: Maxim Leshchenko Date: Fri, 28 Jan 2022 18:02:19 +0200 Subject: [PATCH 20/23] Support: Display number of tickets with a response in left menu to banned users --- Web/Presenters/templates/@layout.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Web/Presenters/templates/@layout.xml b/Web/Presenters/templates/@layout.xml index d410bc84..4834aed8 100644 --- a/Web/Presenters/templates/@layout.xml +++ b/Web/Presenters/templates/@layout.xml @@ -190,7 +190,11 @@ {php echo OPENVK_ROOT_CONF['openvk']['preferences']['adPoster']['caption']} {else} - {_menu_support} + {_menu_support} + {if $ticketAnsweredCount > 0} + ({$ticketAnsweredCount}) + {/if} + {_menu_logout} {/if} {else} From dcd18d266f17a118a5f512d654e0100df0ef935f Mon Sep 17 00:00:00 2001 From: Maxim Leshchenko Date: Fri, 28 Jan 2022 18:11:58 +0200 Subject: [PATCH 21/23] Users: Do not constantly reload the page about the user's ban Closes #440 --- Web/Presenters/OpenVKPresenter.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Web/Presenters/OpenVKPresenter.php b/Web/Presenters/OpenVKPresenter.php index 1aee16d2..51840c3d 100755 --- a/Web/Presenters/OpenVKPresenter.php +++ b/Web/Presenters/OpenVKPresenter.php @@ -223,6 +223,7 @@ abstract class OpenVKPresenter extends SimplePresenter $this->getTemplatingEngine()->render(__DIR__ . "/templates/@banned.xml", [ "thisUser" => $this->user->identity, "csrfToken" => $GLOBALS["csrfToken"], + "isTimezoned" => Session::i()->get("_timezoneOffset"), ]); exit; } From 9a47089736341ef00adf78ac1c05c17012ae5e5a Mon Sep 17 00:00:00 2001 From: Ilya Prokopenko Date: Sat, 29 Jan 2022 09:49:03 +0300 Subject: [PATCH 22/23] Note: Add an Cancel button for editing --- Web/Presenters/templates/Notes/Edit.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Web/Presenters/templates/Notes/Edit.xml b/Web/Presenters/templates/Notes/Edit.xml index 1544fbc1..b3b37ee2 100644 --- a/Web/Presenters/templates/Notes/Edit.xml +++ b/Web/Presenters/templates/Notes/Edit.xml @@ -22,6 +22,8 @@ +   + {_cancel} {script "js/node_modules/monaco-editor/min/vs/loader.js"} From e06884a946ca9a663c581d3239797076c0724dfc Mon Sep 17 00:00:00 2001 From: Ilya Prokopenko Date: Sat, 29 Jan 2022 10:15:00 +0300 Subject: [PATCH 23/23] README: Change the link for CentOS 8 installation This was done due to appearance of docs.openvk.su and the removal of docs from the OVK source code (518a52971dadf9f855caa52ebbd68f8edb00e359). --- README.md | 2 +- README_RU.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bfab5547..56211045 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Once you are done, you can login as a system administrator on the network itself * **Password**: `admin` * It is recommended to change the password before using the built-in account. -Full example installation instruction for CentOS 8 is also available [here](docs/centos8_install.md). +Full example installation instruction for CentOS 8 is also available [here](https://docs.openvk.su/openvk_engine/centos8_installation/). ### If my website uses OpenVK, should I publish it's sources? diff --git a/README_RU.md b/README_RU.md index f40b45ea..2ed13a7b 100644 --- a/README_RU.md +++ b/README_RU.md @@ -61,7 +61,7 @@ ln -s /path/to/chandler/extensions/available/openvk /path/to/chandler/extensions * **Пароль**: `admin` * Перед использованием встроенной учетной записи рекомендуется сменить пароль. -Полный пример инструкции по установке CentOS 8 также доступен [здесь](docs/centos8_install.md). +Полный пример инструкции по установке CentOS 8 также доступен [здесь](https://docs.openvk.su/openvk_engine/centos8_installation/). ### Если мой сайт использует OpenVK, должен ли я публиковать его исходные тексты?