diff --git a/README.textile b/README.textile index 8094d17f..40349daf 100644 --- a/README.textile +++ b/README.textile @@ -1,67 +1,72 @@ -h1. openvkOpenVK - -*OpenVK* is an attempt to create a simple CMS that -cosplays- imitates old VK. Code provided here is not stable yet. -VKontakte belongs to Pavel Durov and VK Group. -To be honest, we don't even know whether it even works. However, this version is maintained and we will be happy to accept your bugreports "in our bug-tracker":https://github.com/openvk/openvk/projects/1. You should also be able to submit them using "ticketing system":https://openvk.su/support?act=new (you will need an OVK account for this). - -h2. When's the release? - -Please use the master branch, as it has the most changes. - -Updating the source code is done with this command: @git pull --recurse-submodules@ - -h2. Instances - -* *"openvk.su":https://openvk.su/* -* "openvk.zavsc.pw":http://openvk.zavsc.pw/ - -h2. Can I create my own OpenVK instance? - -Yes! And you're very welcome to. -However, OVK makes use of Chandler Application Server. This software requires extensions, that may not be provided by your hosting provider (namely, sodium and yaml. this extensions are available on most of ISPManager hostings). -Simply put, we would recommend you to use latest CentOS (running on your own VDS/Dedicated) with latest PHP from EPEL. We used to have this configuration on our "main instance":https://openvk.su/ and thus will be able to provide quicker support for OVK running in this environment. -If you want, you can add your instance to the list above so that people can register there. - -h3. Installation procedure - -"samukhin":https://github.com/samukhin is working on a Docker container that contains a microblog version of OpenVK, see "#76":https://github.com/openvk/openvk/pull/76 for details. (Experimental) - -# Install PHP 7, web-server, Composer, Node.js, Yarn and "Chandler":https://github.com/openvk/chandler -PHP 8 has *not* yet been tested, so you should not expect it to work. -# Install "commitcaptcha":https://github.com/openvk/commitcaptcha and OpenVK as Chandler extensions like this: -@git clone --recursive https://github.com/openvk/openvk /path/to/chandler/extensions/available/openvk@ -@git clone https://github.com/openvk/commitcaptcha /path/to/chandler/extensions/available/commitcaptcha@ -# And enable them: -@ln -s /path/to/chandler/extensions/available/commitcaptcha /path/to/chandler/extensions/enabled/@ -@ln -s /path/to/chandler/extensions/available/openvk /path/to/chandler/extensions/enabled/@ -# Import @install/init-static-db.sql@ to *same database* you installed Chandler to -# Import @install/init-event-db.sql@ to *separate database* -# Copy @openvk-example.yml@ to @openvk.yml@ and change options -# Run @composer install@ in OpenVK directory -# Move to @Web/static/js@ and execute @yarn install@ -# Set @openvk@ as your root app in @chandler.yml@ - -*Note*: If OVK submodules were not downloaded beforehand (i.e. @--recursive@ was not used during cloning), this command *must be* executed in the @openvk@ folder: @git submodule update --init@ - -Once you are done, you can login as a system administrator on the network itself (no registration required): -* *Login*: admin@localhost.localdomain6 -* *Password*: admin -It is recommended to change the password before using the built-in account. - -h3. If my website uses OpenVK, should I publish it's sources? - -You are encouraged to do so. We don't enforce this though. You can keep your sources to yourself (unless you distribute your OpenVK distro to other people). -You also not required to publish source texts of your themepacks and plugins. - -h2. Where can I get assistance? - -You may reach out to us via: -* "Bug-tracker":https://github.com/openvk/openvk/projects/1 -* "Ticketing system":https://openvk.su/support?act=new -* Telegram chat: Go to "our channel":https://t.me/openvkch and open discussion in our channel menu. -* "Reddit":https://www.reddit.com/r/openvk/ -* "Discussions":https://github.com/openvk/openvk/discussions - -*Attention*: bug tracker and telegram chat are public places. And ticketing system is being served by volunteers. If you need to report something, that shouldn't be immediately disclosed to general public (for instance, vulnerability report), *please use contact us directly*: -* *Head of OpenVK Security Commitee*: stingray@jill.pl or "@id155":https://t.me/id155 -* *Backend developer*: "@saddyteirusu":https://t.me/saddyteirusu +h1. openvkOpenVK + +*OpenVK* is an attempt to create a simple CMS that -cosplays- imitates old VK. Code provided here is not stable yet. +VKontakte belongs to Pavel Durov and VK Group. +To be honest, we don't even know whether it even works. However, this version is maintained and we will be happy to accept your bugreports "in our bug-tracker":https://github.com/openvk/openvk/projects/1. You should also be able to submit them using "ticketing system":https://openvk.su/support?act=new (you will need an OVK account for this). + +h2. When's the release? + +Please use the master branch, as it has the most changes. + +Updating the source code is done with this command: @git pull --recurse-submodules@ + +h2. Instances + +* *"openvk.su":https://openvk.su/* +* "openvk.zavsc.pw":http://openvk.zavsc.pw/ + +h2. Can I create my own OpenVK instance? + +Yes! And you're very welcome to. +However, OVK makes use of Chandler Application Server. This software requires extensions, that may not be provided by your hosting provider (namely, sodium and yaml. this extensions are available on most of ISPManager hostings). +Simply put, we would recommend you to use latest CentOS (running on your own VDS/Dedicated) with latest PHP from EPEL. We used to have this configuration on our "main instance":https://openvk.su/ and thus will be able to provide quicker support for OVK running in this environment. +If you want, you can add your instance to the list above so that people can register there. + +h3. Installation procedure + +"samukhin":https://github.com/samukhin is working on a Docker container that contains a microblog version of OpenVK, see "#76":https://github.com/openvk/openvk/pull/76 for details. (Experimental) + +# Install PHP 7, web-server, Composer, Node.js, Yarn and "Chandler":https://github.com/openvk/chandler +PHP 8 has *not* yet been tested, so you should not expect it to work. +# Install "commitcaptcha":https://github.com/openvk/commitcaptcha and OpenVK as Chandler extensions like this: +@git clone --recursive https://github.com/openvk/openvk /path/to/chandler/extensions/available/openvk@ +@git clone https://github.com/openvk/commitcaptcha /path/to/chandler/extensions/available/commitcaptcha@ +# And enable them: +@ln -s /path/to/chandler/extensions/available/commitcaptcha /path/to/chandler/extensions/enabled/@ +@ln -s /path/to/chandler/extensions/available/openvk /path/to/chandler/extensions/enabled/@ +# Import @install/init-static-db.sql@ to *same database* you installed Chandler to +# Import @install/init-event-db.sql@ to *separate database* +# Copy @openvk-example.yml@ to @openvk.yml@ and change options +# Run @composer install@ in OpenVK directory +# Move to @Web/static/js@ and execute @yarn install@ +# Set @openvk@ as your root app in @chandler.yml@ + +*Note*: If OVK submodules were not downloaded beforehand (i.e. @--recursive@ was not used during cloning), this command *must be* executed in the @openvk@ folder: @git submodule update --init@ + +Once you are done, you can login as a system administrator on the network itself (no registration required): +* *Login*: admin@localhost.localdomain6 +* *Password*: admin +It is recommended to change the password before using the built-in account. + +h3. If my website uses OpenVK, should I publish it's sources? + +You are encouraged to do so. We don't enforce this though. You can keep your sources to yourself (unless you distribute your OpenVK distro to other people). +You also not required to publish source texts of your themepacks and plugins. + +h2. Where can I get assistance? + +You may reach out to us via: +* "Bug-tracker":https://github.com/openvk/openvk/projects/1 +* "Ticketing system":https://openvk.su/support?act=new +* Telegram chat: Go to "our channel":https://t.me/openvkch and open discussion in our channel menu. +* "Reddit":https://www.reddit.com/r/openvk/ +* "Discussions":https://github.com/openvk/openvk/discussions + +*Attention*: bug tracker and telegram chat are public places. And ticketing system is being served by volunteers. If you need to report something, that shouldn't be immediately disclosed to general public (for instance, vulnerability report), *please use contact us directly*: +* *Head of OpenVK Security Commitee*: stingray@jill.pl or "@id155":https://t.me/id155 +* *Backend developer*: "@saddyteirusu":https://t.me/saddyteirusu + +Codeberg repository clone: + + Get it on Codeberg + \ No newline at end of file diff --git a/Web/Models/Entities/User.php b/Web/Models/Entities/User.php index 6913855d..68585168 100644 --- a/Web/Models/Entities/User.php +++ b/Web/Models/Entities/User.php @@ -204,6 +204,11 @@ class User extends RowModel return $this->getRecord()->shortcode; } + function getAlert(): ?string + { + return $this->getRecord()->alert; + } + function getBanReason(): ?string { return $this->getRecord()->block_reason; @@ -214,10 +219,10 @@ class User extends RowModel return $this->getRecord()->type; } - function getCoins(): int + function getCoins(): float { if(!OPENVK_ROOT_CONF["openvk"]["preferences"]["commerce"]) - return 0; + return 0.0; return $this->getRecord()->coins; } @@ -563,6 +568,11 @@ class User extends RowModel return !is_null($this->getBanReason()); } + function isOnline(): bool + { + return time() - $this->getRecord()->online <= 300; + } + function prefersNotToSeeRating(): bool { return !((bool) $this->getRecord()->show_rating); diff --git a/Web/Presenters/UserPresenter.php b/Web/Presenters/UserPresenter.php index 01a2431d..8bbc3945 100644 --- a/Web/Presenters/UserPresenter.php +++ b/Web/Presenters/UserPresenter.php @@ -30,18 +30,14 @@ final class UserPresenter extends OpenVKPresenter if(parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH) !== "/" . $user->getShortCode()) $this->redirect("/" . $user->getShortCode(), static::REDIRECT_TEMPORARY_PRESISTENT); - $then = date_create("@" . $user->getOnline()->timestamp()); - $now = date_create(); - $diff = date_diff($now, $then); - $this->template->albums = (new Albums)->getUserAlbums($user); $this->template->albumsCount = (new Albums)->getUserAlbumsCount($user); $this->template->videos = (new Videos)->getByUser($user, 1, 2); $this->template->videosCount = (new Videos)->getUserVideosCount($user); $this->template->notes = (new Notes)->getUserNotes($user, 1, 4); $this->template->notesCount = (new Notes)->getUserNotesCount($user); + $this->template->user = $user; - $this->template->diff = $diff; } } diff --git a/Web/Presenters/WallPresenter.php b/Web/Presenters/WallPresenter.php index 600cfb83..b63bb648 100644 --- a/Web/Presenters/WallPresenter.php +++ b/Web/Presenters/WallPresenter.php @@ -48,7 +48,10 @@ final class WallPresenter extends OpenVKPresenter if(is_null($this->user)) $canPost = false; else if($user > 0) - $canPost = $owner->getPrivacyPermission("wall.write", $this->user->identity); + if(!$owner->isBanned()) + $canPost = $owner->getPrivacyPermission("wall.write", $this->user->identity); + else + $this->flashFail("err", tr("error"), "Ошибка доступа"); else if($user < 0) if($owner->canBeModifiedBy($this->user->identity)) $canPost = true; @@ -165,7 +168,10 @@ final class WallPresenter extends OpenVKPresenter $wallOwner = ($wall > 0 ? (new Users)->get($wall) : (new Clubs)->get($wall * -1)) ?? $this->flashFail("err", "Не удалось опубликовать пост", "Такого пользователя не существует."); if($wall > 0) - $canPost = $wallOwner->getPrivacyPermission("wall.write", $this->user->identity); + if(!$wallOwner->isBanned()) + $canPost = $wallOwner->getPrivacyPermission("wall.write", $this->user->identity); + else + $this->flashFail("err", "Ошибка доступа", "Вам нельзя писать на эту стену."); else if($wall < 0) if($wallOwner->canBeModifiedBy($this->user->identity)) $canPost = true; @@ -245,10 +251,11 @@ final class WallPresenter extends OpenVKPresenter $this->logPostView($post, $wall); $this->template->post = $post; - if ($post->getTargetWall() > 0) - { + if ($post->getTargetWall() > 0) { $this->template->wallOwner = (new Users)->get($post->getTargetWall()); $this->template->isWallOfGroup = false; + if($this->template->wallOwner->isBanned()) + $this->flashFail("err", tr("error"), "Ошибка доступа"); } else { $this->template->wallOwner = (new Clubs)->get(abs($post->getTargetWall())); $this->template->isWallOfGroup = true; diff --git a/Web/Presenters/templates/@layout.xml b/Web/Presenters/templates/@layout.xml index f66302d7..aecb4659 100644 --- a/Web/Presenters/templates/@layout.xml +++ b/Web/Presenters/templates/@layout.xml @@ -251,7 +251,7 @@ {_footer_choose_language} {_footer_privacy} -

OpenVK {php echo OPENVK_VERSION} | PHP: {phpversion()} | DB: {$dbVersion}

+

OpenVK {php echo OPENVK_VERSION} | PHP: {phpversion()} | DB: {$dbVersion}

{php echo OPENVK_ROOT_CONF["openvk"]["appearance"]["motd"]}

diff --git a/Web/Presenters/templates/About/Version.xml b/Web/Presenters/templates/About/Version.xml index 44102ae4..bd1e8f71 100644 --- a/Web/Presenters/templates/About/Version.xml +++ b/Web/Presenters/templates/About/Version.xml @@ -79,7 +79,7 @@ #ovkLogo { float: right; border: 0; - width: 30px; + height: 30px; padding-top: 6px; position: relative; } @@ -97,7 +97,7 @@

OpenVK {=OPENVK_VERSION}

- + diff --git a/Web/Presenters/templates/User/View.xml b/Web/Presenters/templates/User/View.xml index c2576ac6..0d18f59b 100644 --- a/Web/Presenters/templates/User/View.xml +++ b/Web/Presenters/templates/User/View.xml @@ -34,10 +34,10 @@
- {if $diff->i <= 5} - {_online} + {if $user->isOnline()} + {_online} {else} - {_was_online} {$user->getOnline()} + {_was_online} {$user->getOnline()} {/if}
@@ -76,6 +76,9 @@ {/if} {if $thisUser->getChandlerUser()->can("access")->model("admin")->whichBelongsTo(NULL)} + + {_manage_user_action} + {_ban_user_action} @@ -349,7 +352,7 @@
- +
{$alert}

{$user->getFullName()}

diff --git a/Web/Presenters/templates/components/post/microblogpost.xml b/Web/Presenters/templates/components/post/microblogpost.xml index fa0284d8..1c893512 100644 --- a/Web/Presenters/templates/components/post/microblogpost.xml +++ b/Web/Presenters/templates/components/post/microblogpost.xml @@ -7,12 +7,10 @@ - {if !$post->isPostedOnBehalfOfGroup() && !$compact} - - {if $diff->i <= 5} - {_online} - {/if} - + {if !$post->isPostedOnBehalfOfGroup() && !$compact} + + {_online} + {/if} diff --git a/Web/Presenters/templates/components/post/oldpost.xml b/Web/Presenters/templates/components/post/oldpost.xml index 4af95710..36f01936 100644 --- a/Web/Presenters/templates/components/post/oldpost.xml +++ b/Web/Presenters/templates/components/post/oldpost.xml @@ -7,13 +7,11 @@ - {if !$post->isPostedOnBehalfOfGroup() && !$compact} - - {if $diff->i <= 5} - {_online} + {if !$post->isPostedOnBehalfOfGroup() && !$compact} + + {_online} + {/if} - - {/if}